Sfoglia il codice sorgente

execute examples and splash_local

master
boB Rudis 3 anni fa
parent
commit
1ed092a77b
7 ha cambiato i file con 48 aggiunte e 1 eliminazioni
  1. +2
    -1
      DESCRIPTION
  2. +1
    -0
      NAMESPACE
  3. +1
    -0
      NEWS.md
  4. +16
    -0
      R/execute.r
  5. +4
    -0
      R/splashr.r
  6. +18
    -0
      man/execute_lua.Rd
  7. +6
    -0
      man/splash.Rd

+ 2
- 1
DESCRIPTION Vedi File

@@ -19,7 +19,8 @@ URL: http://github.com/hrbrmstr/splashr
BugReports: https://github.com/hrbrmstr/splashr/issues
License: AGPL
Suggests:
testthat
testthat,
tibble
Depends:
R (>= 3.2.0)
Imports:


+ 1
- 0
NAMESPACE Vedi File

@@ -17,6 +17,7 @@ export(render_png)
export(splash)
export(splash_active)
export(splash_debug)
export(splash_local)
export(start_splash)
export(stop_splash)
export(writeHAR)


+ 1
- 0
NEWS.md Vedi File

@@ -2,6 +2,7 @@

* added `execute`()
* modified `splash_active`()
* added `splash_local` global variable to avoid typing `splash("localhost")`

0.1.0



+ 16
- 0
R/execute.r Vedi File

@@ -11,6 +11,22 @@
#' @param load_args Parameter values to load from cache
#' @return `raw` content from the `httr` call. Given the vast diversity of possible return values, it's up to the caller to handle the return value.
#' @export
#' @examples \dontrun{
#' splash_local %>%
#' execute_lua('
#' function main(splash)
#' splash:go("https://projects.fivethirtyeight.com/congress-trump-score/")
#' splash:wait(0.5)
#' return splash:evaljs("memberScores")
#' end
#' ') -> res
#'
#' rawToChar(res) %>%
#' jsonlite::fromJSON(flatten=TRUE) %>%
#' purrr::map(tibble::as_tibble) -> member_scores
#'
#' member_scores
#' }
execute_lua <- function(splash_obj, lua_source, timeout=30, allowed_domains,
proxy, filters, save_args, load_args) {



+ 4
- 0
R/splashr.r Vedi File

@@ -9,6 +9,10 @@ splash <- function(host, port=8050L) {
list(host=host, port=port)
}

#' @rdname splash
#' @export
splash_local <- splash("localhost")

s_GET <- purrr::safely(GET)

#' Test if a Splash server is up


+ 18
- 0
man/execute_lua.Rd Vedi File

@@ -30,3 +30,21 @@ execute_lua(splash_obj, lua_source, timeout = 30, allowed_domains, proxy,
\description{
Execute a custom rendering script and return a result.
}
\examples{
\dontrun{
splash_local \%>\%
execute_lua('
function main(splash)
splash:go("https://projects.fivethirtyeight.com/congress-trump-score/")
splash:wait(0.5)
return splash:evaljs("memberScores")
end
') -> res

rawToChar(res) \%>\%
jsonlite::fromJSON(flatten=TRUE) \%>\%
purrr::map(tibble::as_tibble) -> member_scores

member_scores
}
}

+ 6
- 0
man/splash.Rd Vedi File

@@ -1,10 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/splashr.r
\docType{data}
\name{splash}
\alias{splash}
\alias{splash_local}
\title{Configure parameters for connecting to a Splash server}
\format{An object of class \code{list} of length 2.}
\usage{
splash(host, port = 8050L)

splash_local
}
\arguments{
\item{host}{host or IP address}
@@ -14,3 +19,4 @@ splash(host, port = 8050L)
\description{
Configure parameters for connecting to a Splash server
}
\keyword{datasets}

Loading…
Annulla
Salva