Skip to content

Commit

Permalink
Merge pull request #2 from IronistM/dev-readme-001
Browse files Browse the repository at this point in the history
Dev readme 001
  • Loading branch information
IronistM authored Nov 9, 2017
2 parents e8c2c90 + 0c2ac19 commit 376cb82
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 74 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
sudo: false
cache: packages
global:
- R_CHECK_ARGS="--no-build-vignettes --no-manual --timings --no-tests"
- _R_CHECK_TIMINGS_="0"
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Suggests:
testthat
License: GPL-3
LazyData: true
RoxygenNote: 5.0.1
RoxygenNote: 6.0.1
VignetteBuilder: knitr
10 changes: 9 additions & 1 deletion R/speed-insights-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#' are either the string "mobile" or the string "desktop".
#' @param key A unique key obtainable from Google by registering for free as a Google developer.
#' @examples
#' \dontrun{
#' speedfinder("https://www.cars.com","mobile",key)
#' }

#' @export
speedfinder <- function(url,strategy,key) {
Expand All @@ -20,6 +22,10 @@ speedfinder <- function(url,strategy,key) {
#'
#' Speedfinder2 is a function utilized by speedlist to allow a list of URLs to be submitted to the Google Page Speed
#' Insights API.
#' @param url A list of URLs on which to run the Google Page Speed Insights test.
#' @param strategy Whether the list of URLs should be evaluated in a mobile or desktop context. Accordingly, acceptable values
#' are either the string "mobile" or the string "desktop".
#' @param key A unique key obtainable from Google by registering for free as a Google developer.

#' @export
speedfinder2 <- function(url,strategy,key) {
Expand All @@ -32,12 +38,14 @@ speedfinder2 <- function(url,strategy,key) {
#' The speedlist function submits a list of URLs to the Google Page Speed Insights API, and returns a dataframe in which
#' each row contains the results from the API for a unique URL in the list.
#'
#' @param url A list of URLs on which to run the Google Page Speed Insights test.
#' @param pagelist A list of URLs on which to run the Google Page Speed Insights test.
#' @param strategy Whether the list of URLs should be evaluated in a mobile or desktop context. Accordingly, acceptable values
#' are either the string "mobile" or the string "desktop".
#' @param key A unique key obtainable from Google by registering for free as a Google developer.
#' @examples
#' \dontrun{
#' speedlist(listofURLs,"mobile",key)
#' }

#' @export
speedlist <- function(pagelist,strategy,key) {
Expand Down
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
#gpagespeed
[![Travis-CI Build Status](https://travis-ci.org/IronistM/gpagespeed.svg?branch=master)](https://travis-ci.org/IronistM/gpagespeed)

# gpagespeed

gpagespeed is a package designed to facilitate utilization of the Google PageSpeed Insights API. The PageSpeed Insights API provides insight into how Google's bots evaluate a given page, and the factors that web developers may wish to consider in building pages that will render faster. See Google's documentation on the PageSpeed Insights API to learn more about what the API offers as well as practical examples of its usage.

The PageSpeed Insights API returns a numeric summary of the results of each page, as well as recommendations in text format. Currently, this package is designed to support only retrieving the numeric summary, which includes the overall speed score as well as metrics pertaining to the number of file requests and sizes in kilobytes of images, HTML, CSS, and JavaScript. The package offers two functions: speedfinder and speedlist. These functions are documented below.

#Functions in gpagespeed

<strong>1.speedfinder.</strong> The speedfinder function returns a dataframe with a single observation and columsn of numeric data as its response. It accepts three arguments:

*_url_: The url argument refers to the url of the document on which the PageSpeed Insights API should be run and the corresponding summary metrics returned.<br />
*_strategy_: This argument should have one of two potential text string inputs: "desktop" or "mobile" to denote the device context that the PageSpeed Insights API should use in its evaluation.<br />
*_key_: This is the key that is required to use the API. [Visit Google's Developer Console](https://developers.google.com/console/help/using-keys) to obtain your free key.
# Functions in gpagespeed

<strong>2.speedlist.</strong> The speedlist function is like the speedfinder function, but allows processing of many URLs and returns a dataframe in which each observation corresponds to a unique URL. Like speedfinder, it accepts three arguments:
`speedfinder`
The `speedfinder` function returns a dataframe with a single observation and columns of numeric data as its response. It accepts three arguments:

*_pagelist_: A list object in which each item in the list is a URL listed as a character string. <br />
*_strategy_: This argument should have one of two potential text string inputs: "desktop" or "mobile" to denote the device context that the PageSpeed Insights API should use in its evaluation.<br />
*_key_: This is the key that is required to use the API. [Visit Google's Developer Console](https://developers.google.com/console/help/using-keys) to obtain your free key.
* _url_: The url argument refers to the URL of the document on which the PageSpeed Insights API should be run and the corresponding summary metrics returned.
* _strategy_: This argument should have one of two potential text string inputs: "`desktop`" or "`mobile`" to denote the device context that the PageSpeed Insights API should use in its evaluation.
* _key_: This is the key that is required to use the API. [Visit Google's Developer Console](https://developers.google.com/console/help/using-keys) to obtain your free key.

#Example Usage
`speedlist`
The `speedlist` function is like the `speedfinder` function, but allows processing of many URLs and returns a dataframe in which each observation corresponds to a unique URL. Like `speedfinder`, it accepts three arguments:

Below are examples of how the speedfinder and speedlist functions could be called in an R script.
* _pagelist_: A list object in which each item in the list is a URL listed as a character string.
* _strategy_: This argument should have one of two potential text string inputs: "`desktop`" or "`mobile`" to denote the device context that the PageSpeed Insights API should use in its evaluation.
* _key_: This is the key that is required to use the API. [Visit Google's Developer Console](https://developers.google.com/console/help/using-keys) to obtain your free key.

``` #get speed metrics for a single URL and assign it to a variable ```
# Example Usage

``` df1 <- speedfinder("https://www.cars.com","mobile","atextkeyigotfromgoogle111") ```
Below are examples of how the `speedfinder` and `speedlist` functions could be called in an R script.

``` #get speed metrics for a list of URLs and have it all returned in a single dataframe ```
```
# Get speed metrics for a single URL and assign it to a data frame
df1 <- speedfinder("https://www.cars.com", "mobile", "atextkeyigotfromgoogle111")
``` df2 <- speedlist(c("https://www.cars.com","http://www.yahoo.com","http://www.techmeme.com"), ```
``` "mobile","atextkeyigotfromgoogle111") ```
# Get speed metrics for a list of URLs and have it all returned in a single data frame
df2 <- speedlist(c("https://www.cars.com", "http://www.yahoo.com", "http://www.techmeme.com"),
"mobile",
"atextkeyigotfromgoogle111")
```
3 changes: 2 additions & 1 deletion man/speedfinder.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion man/speedfinder2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions man/speedlist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 0 additions & 48 deletions vignettes/my-vignette.Rmd

This file was deleted.

0 comments on commit 376cb82

Please sign in to comment.