Browse Source

cleanup & travis

boB Rudis 7 months ago
parent
commit
34023fc086
No known key found for this signature in database
8 changed files with 100 additions and 11 deletions
  1. 2
    8
      .travis.yml
  2. 6
    0
      NAMESPACE
  3. 4
    0
      NEWS.md
  4. 27
    1
      R/splashr.r
  5. 20
    0
      R/user-agents.R
  6. 20
    0
      man/print.splashr.Rd
  7. 6
    2
      man/splash.Rd
  8. 15
    0
      man/splash_user_agent.Rd

+ 2
- 8
.travis.yml View File

@@ -9,17 +9,11 @@ services:
9 9
 env:
10 10
   global:
11 11
     - NOT_CRAN=true
12
-  matrix:
13
-    - PIP="pip" RETICULATE_PYTHON="/usr/bin/python"
14
-    - PYTHON=3 PIP="pip3" RETICULATE_PYTHON="/usr/bin/python3"
15 12
 
16 13
 before_install:
17
-  - docker pull scrapinghub/splash:3.0
18
-  - docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 -d scrapinghub/splash:3.0
14
+  - docker pull scrapinghub/splash:3.2
15
+  - docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 -d scrapinghub/splash:3.2
19 16
   - docker ps -a
20
-  - sudo apt-get -y install python${PYTHON}-pip python-dev python${PYTHON}-numpy
21
-  - sudo $PIP install -U setuptools
22
-  - sudo $PIP install -U docker
23 17
 
24 18
 r:
25 19
  - oldrel

+ 6
- 0
NAMESPACE View File

@@ -5,6 +5,7 @@ S3method(as.data.frame,harentries)
5 5
 S3method(as.data.frame,harentry)
6 6
 S3method(print,splash_debug)
7 7
 S3method(print,splash_json)
8
+S3method(print,splashr)
8 9
 export("%>%")
9 10
 export(HARviewer)
10 11
 export(HARviewerOutput)
@@ -77,11 +78,16 @@ export(splash_version)
77 78
 export(splash_wait)
78 79
 export(start_splash)
79 80
 export(stop_splash)
81
+export(ua_android_samsung)
82
+export(ua_apple_tv)
83
+export(ua_chromecast)
80 84
 export(ua_ios_safari)
85
+export(ua_kindle)
81 86
 export(ua_linux_chrome)
82 87
 export(ua_linux_firefox)
83 88
 export(ua_macos_chrome)
84 89
 export(ua_macos_safari)
90
+export(ua_ps4)
85 91
 export(ua_splashr)
86 92
 export(ua_win10_chrome)
87 93
 export(ua_win10_firefox)

+ 4
- 0
NEWS.md View File

@@ -2,6 +2,10 @@
2 2
 
3 3
 * Switch Docker orchestration to the `stevedore` package
4 4
 * Fixed minor check on as.data.frame functions
5
+* Cleaned up splashr object printing
6
+* Added Android, Kindle, Apple TV & Chromecast user agents and updated 
7
+  other user agents
8
+* Updated Travis config to not use old docker pkg components
5 9
 
6 10
 0.5.0
7 11
 

+ 27
- 1
R/splashr.r View File

@@ -2,6 +2,10 @@ splash_url <- function(splash_obj) { sprintf("http://%s:%s", splash_obj$host, sp
2 2
 
3 3
 #' Configure parameters for connecting to a Splash server
4 4
 #'
5
+#'
6
+#' @md
7
+#' @note There is a quick "helper" object named `splash_local` which is preconfigured
8
+#'       with `localhost` as the host name.
5 9
 #' @param host host or IP address
6 10
 #' @param port port the server is running on (default is 8050)
7 11
 #' @param user,pass leave `NULL` if basic auth is not configured. Otherwise,
@@ -11,7 +15,29 @@ splash_url <- function(splash_obj) { sprintf("http://%s:%s", splash_obj$host, sp
11 15
 #' sp <- splash()
12 16
 #' }
13 17
 splash <- function(host, port=8050L, user=NULL, pass=NULL) {
14
-  list(host=host, port=port, user=user, pass=pass)
18
+  obj <- list(host=host, port=port, user=user, pass=pass)
19
+  class(obj) <- c("splashr", "list")
20
+  obj
21
+}
22
+
23
+#' Print for splashr
24
+#'
25
+#' @md
26
+#' @param x a splashr object
27
+#' @param ... unused
28
+#' @keywords internal
29
+#' @return x
30
+#' @export
31
+print.splashr <- function(x, ...) {
32
+
33
+  cat(
34
+    "<splashr instance connection; ",
35
+    if (length(x$user)) sprintf("%s@", x$user) else "",
36
+    x$host, ":", x$port, ">\n", sep=""
37
+  )
38
+
39
+  invisible(x)
40
+
15 41
 }
16 42
 
17 43
 #' @rdname splash

+ 20
- 0
R/user-agents.R View File

@@ -46,3 +46,23 @@ ua_linux_firefox <- "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/2010
46 46
 #' @rdname splash_user_agent
47 47
 #' @export
48 48
 ua_ios_safari <- "Mozilla/5.0 (iPad; CPU OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0 Mobile/14C92 Safari/602.1"
49
+
50
+#' @rdname splash_user_agent
51
+#' @export
52
+ua_android_samsung <- "Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36"
53
+
54
+#' @rdname splash_user_agent
55
+#' @export
56
+ua_kindle <- "Mozilla/5.0 (X11; U; Linux armv7l like Android; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/533.2+ Kindle/3.0+"
57
+
58
+#' @rdname splash_user_agent
59
+#' @export
60
+ua_ps4 <- "Mozilla/5.0 (PlayStation 4 3.11) AppleWebKit/537.73 (KHTML, like Gecko)"
61
+
62
+#' @rdname splash_user_agent
63
+#' @export
64
+ua_apple_tv <- "AppleTV6,2/11.1"
65
+
66
+#' @rdname splash_user_agent
67
+#' @export
68
+ua_chromecast <- "Mozilla/5.0 (CrKey armv7l 1.5.16041) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.0 Safari/537.36"

+ 20
- 0
man/print.splashr.Rd View File

@@ -0,0 +1,20 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/splashr.R
3
+\name{print.splashr}
4
+\alias{print.splashr}
5
+\title{Print for splashr}
6
+\usage{
7
+\method{print}{splashr}(x, ...)
8
+}
9
+\arguments{
10
+\item{x}{a splashr object}
11
+
12
+\item{...}{unused}
13
+}
14
+\value{
15
+x
16
+}
17
+\description{
18
+Print for splashr
19
+}
20
+\keyword{internal}

+ 6
- 2
man/splash.Rd View File

@@ -5,7 +5,7 @@
5 5
 \alias{splash}
6 6
 \alias{splash_local}
7 7
 \title{Configure parameters for connecting to a Splash server}
8
-\format{An object of class \code{list} of length 4.}
8
+\format{An object of class \code{splashr} (inherits from \code{list}) of length 4.}
9 9
 \usage{
10 10
 splash(host, port = 8050L, user = NULL, pass = NULL)
11 11
 
@@ -16,12 +16,16 @@ splash_local
16 16
 
17 17
 \item{port}{port the server is running on (default is 8050)}
18 18
 
19
-\item{user, pass}{leave `NULL` if basic auth is not configured. Otherwise,
19
+\item{user, pass}{leave \code{NULL} if basic auth is not configured. Otherwise,
20 20
 fill in what you need for basic authentication.}
21 21
 }
22 22
 \description{
23 23
 Configure parameters for connecting to a Splash server
24 24
 }
25
+\note{
26
+There is a quick "helper" object named \code{splash_local} which is preconfigured
27
+with \code{localhost} as the host name.
28
+}
25 29
 \examples{
26 30
 \dontrun{
27 31
 sp <- splash()

+ 15
- 0
man/splash_user_agent.Rd View File

@@ -15,6 +15,11 @@
15 15
 \alias{ua_linux_chrome}
16 16
 \alias{ua_linux_firefox}
17 17
 \alias{ua_ios_safari}
18
+\alias{ua_android_samsung}
19
+\alias{ua_kindle}
20
+\alias{ua_ps4}
21
+\alias{ua_apple_tv}
22
+\alias{ua_chromecast}
18 23
 \title{Overwrite the User-Agent header for all further requests.}
19 24
 \format{An object of class \code{character} of length 1.}
20 25
 \usage{
@@ -43,6 +48,16 @@ ua_linux_chrome
43 48
 ua_linux_firefox
44 49
 
45 50
 ua_ios_safari
51
+
52
+ua_android_samsung
53
+
54
+ua_kindle
55
+
56
+ua_ps4
57
+
58
+ua_apple_tv
59
+
60
+ua_chromecast
46 61
 }
47 62
 \arguments{
48 63
 \item{splash_obj}{splashr object}

Loading…
Cancel
Save