ソースを参照

execute examples and splash_local

master
boB Rudis 7年前
コミット
1ed092a77b
  1. 3
      DESCRIPTION
  2. 1
      NAMESPACE
  3. 1
      NEWS.md
  4. 16
      R/execute.r
  5. 4
      R/splashr.r
  6. 18
      man/execute_lua.Rd
  7. 6
      man/splash.Rd

3
DESCRIPTION

@ -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
NAMESPACE

@ -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
NEWS.md

@ -2,6 +2,7 @@
* added `execute`()
* modified `splash_active`()
* added `splash_local` global variable to avoid typing `splash("localhost")`
0.1.0

16
R/execute.r

@ -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
R/splashr.r

@ -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
man/execute_lua.Rd

@ -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
man/splash.Rd

@ -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}

読み込み中…
キャンセル
保存