Browse Source

readr::type_convert

master
boB Rudis 7 years ago
parent
commit
a16ab243e8
No known key found for this signature in database GPG Key ID: 2A514A4997464560
  1. 5
      DESCRIPTION
  2. 1
      NAMESPACE
  3. 4
      R/hgr-package.R
  4. 4
      R/mercury.r
  5. 2
      README.Rmd
  6. 6
      README.md
  7. 2
      man/hgr.Rd

5
DESCRIPTION

@ -5,7 +5,7 @@ Version: 0.1.0
Date: 2017-04-19
Author: Bob Rudis (bob@rud.is)
Maintainer: Bob Rudis <bob@rud.is>
Description: PTools to Work with the 'Postlight' 'Mercury' 'API'.
Description: PTools to Work with the 'Postlight' 'Mercury' 'API' <https://mercury.postlight.com>.
URL: https://github.com/hrbrmstr/hgr
BugReports: https://github.com/hrbrmstr/hgr/issues
License: AGPL
@ -16,5 +16,6 @@ Depends:
R (>= 3.2.0)
Imports:
purrr,
httr
httr,
readr
RoxygenNote: 6.0.1

1
NAMESPACE

@ -3,3 +3,4 @@
export(just_the_facts)
import(httr)
import(purrr)
importFrom(readr,type_convert)

4
R/hgr-package.R

@ -1,10 +1,12 @@
#' Tools to Work with the 'Postlight' 'Mercury' 'API'
#'
#' Mercury takes any web article and returns only the relevant content — headline, author,
#' [Mercury](https://mercury.postlight.com) takes any web article and returns only the relevant content — headline, author,
#' body text, relevant images and more — free from any clutter.
#'
#' @md
#' @name hgr
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @import purrr httr
#' @importFrom readr type_convert
NULL

4
R/mercury.r

@ -19,7 +19,9 @@ just_the_facts <- function(url, mercury_api_key=Sys.getenv("MERCURY_API_KEY")) {
res <- httr::content(res, as="text", encoding="UTF-8")
res <- jsonlite::fromJSON(res, flatten=TRUE)
res <- purrr::flatten_df(res)
res <- readr::type_convert(res)
purrr::flatten_df(res)
res
}

2
README.Rmd

@ -4,7 +4,7 @@ output: rmarkdown::github_document
`hgr` : Tools to Work with the 'Postlight' 'Mercury' 'API'
Mercury takes any web article and returns only the relevant content — headline, author, body text, relevant images and more — free from any clutter.
Mercury takes any web article and returns only the relevant content — headline, author, body text, relevant images and more — free from any clutter. You need an API key which you can get from [here](https://mercury.postlight.com).
The following functions are implemented:

6
README.md

@ -1,7 +1,7 @@
`hgr` : Tools to Work with the 'Postlight' 'Mercury' 'API'
Mercury takes any web article and returns only the relevant content — headline, author, body text, relevant images and more — free from any clutter.
Mercury takes any web article and returns only the relevant content — headline, author, body text, relevant images and more — free from any clutter. You need an API key which you can get from [here](https://mercury.postlight.com).
The following functions are implemented:
@ -35,7 +35,7 @@ dplyr::glimpse(just_the_facts(story))
## $ title <chr> "Aircraft Carrier Wasn’t Sailing to Deter North Korea, as U.S. Suggested"
## $ content <chr> "<div><article id=\"story\" class=\"story theme-main \">\n\n \n\n ...
## $ author <chr> "Mark Landler and Eric Schmitt"
## $ date_published <chr> "2017-04-18T17:57:41.000Z"
## $ date_published <dttm> 2017-04-18 17:57:41
## $ lead_image_url <chr> "https://static01.nyt.com/images/2017/04/19/world/19carrier-sub/19carrier-sub-facebookJumbo....
## $ url <chr> "https://www.nytimes.com/2017/04/18/world/asia/aircraft-carrier-north-korea-carl-vinson.html"
## $ domain <chr> "www.nytimes.com"
@ -54,7 +54,7 @@ library(testthat)
date()
```
## [1] "Wed Apr 19 10:16:35 2017"
## [1] "Wed Apr 19 10:26:14 2017"
``` r
test_dir("tests/")

2
man/hgr.Rd

@ -6,7 +6,7 @@
\alias{hgr-package}
\title{Tools to Work with the 'Postlight' 'Mercury' 'API'}
\description{
Mercury takes any web article and returns only the relevant content — headline, author,
\href{https://mercury.postlight.com}{Mercury} takes any web article and returns only the relevant content — headline, author,
body text, relevant images and more — free from any clutter.
}
\author{

Loading…
Cancel
Save