Browse Source

README/tinytest

master
boB Rudis 4 years ago
parent
commit
e348f8ef26
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 10
      DESCRIPTION
  2. 4
      NEWS.md
  3. 103
      README.Rmd
  4. 141
      README.md
  5. 17
      cran-comments.md
  6. 14
      inst/tinytest/test_longurl.R
  7. 4
      tests/testthat.R
  8. 13
      tests/testthat/test-longurl.R
  9. 5
      tests/tinytest.R

10
DESCRIPTION

@ -1,6 +1,6 @@
Package: longurl
Title: Expand Short 'URLs'
Version: 0.3.2
Version: 0.3.3
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640")),
@ -14,12 +14,12 @@ Description: Tools are provided to expand vectors of short URLs into long 'URLs'
larger dependencies, such as 'Redis', to gain a longer-term performance boost
at the expense of added complexity.
Maintainer: Bob Rudis <bob@rud.is>
Depends: R (>= 3.2.0)
Depends: R (>= 3.6.0)
Encoding: UTF-8
License: MIT + file LICENSE
LazyData: true
Suggests:
testthat
Imports:
Suggests:
tinytest
Imports:
httr
RoxygenNote: 6.0.1.9000

4
NEWS.md

@ -1,3 +1,7 @@
# longurl 0.3.3
* Switch to {tinytest}
# longurl 0.3.2
* Ensure input is character before processing. (@JohnCoene, #4)

103
README.Rmd

@ -1,97 +1,64 @@
---
output: rmarkdown::github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r options, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```
![](longurl.png)
[![Build Status](https://travis-ci.org/hrbrmstr/longurl.svg)](https://travis-ci.org/hrbrmstr/longurl)
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/longurl)](http://cran.r-project.org/web/packages/longurl)
![downloads](http://cranlogs.r-pkg.org/badges/grand-total/longurl)
# longurl
Tools expand vectors of short URLs into long URLs.
## Description
This does a bit more than [decode_short_url](https://github.com/geoffjentry/twitteR/blob/master/R/utils.R#L22-L31) from the [twitteR](https://github.com/geoffjentry/twitteR) package since it:
- doesn't rely on a URL expansion API (anymore)
- has options for progress bars & display of warnings during URL checks
- works with a vector of URLs
- returns `tbl_df`s that include HTTP status code for final (expanded) URL
Tools are provided to expand vectors of short URLs into long 'URLs'.
No 'API' services are used, which may mean that this operates more slowly than
'API' services do (since they usually cache results of expansions that every
user of the service requests). You can setup your own caching layer with the
'memoise' package if you wish to have a speedup during single sessions or add
larger dependencies, such as 'Redis', to gain a longer-term performance boost
at the expense of added complexity.
```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```
## What's inside the tin?
```{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```
## What's Inside The Tin
The following functions are implemented:
- `expand_urls`: Expand a vector of (short) URLs
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```
## Installation
```{r install, eval=FALSE, message=FALSE, warning=FALSE}
devtools::install_github("hrbrmstr/longurl")
# OR
install.packages("longurl")
```
```{r options_2, echo=FALSE, message=FALSE, warning=FALSE, error=FALSE}
options(width=200)
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```
## Usage
```{r usage, message=FALSE, warning=FALSE}
```{r vers, message=FALSE, warning=FALSE, error=FALSE, cache=FALSE}
library(longurl)
library(dplyr)
library(magrittr)
# current verison
# current version
packageVersion("longurl")
```
test_urls <- c("http://t.co/D4C7aWYIiA",
"1.usa.gov/1J6GNoW",
"ift.tt/1L2Llfr",
"bit.ly/1GPr5w5",
"http://l.dds.ec/1da152x",
"http://l.rud.is/seven",
"qrp://not a valid url/")
```{r ex1}
c(
"http://t.co/D4C7aWYIiA",
"1.usa.gov/1J6GNoW",
"ift.tt/1L2Llfr",
"bit.ly/1GPr5w5",
"http://l.dds.ec/1da152x",
"http://l.rud.is/seven",
"qrp://not a valid url/"
) -> test_urls
expand_urls(test_urls) %>%
select(orig_url, status_code, expanded_url) %>%
dplyr::select(orig_url, status_code, expanded_url) %>%
knitr::kable()
```
### Test Results
## longurl Metrics
```{r test, message=FALSE, warning=FALSE}
library(longurl)
library(testthat)
date()
test_dir("tests/")
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```
### Code of Conduct
## Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).
By participating in this project you agree to abide by its terms.

141
README.md

@ -1,114 +1,99 @@
<!-- README.md is generated from README.Rmd. Please edit that file -->
![](longurl.png)
[![Build
Status](https://travis-ci.org/hrbrmstr/longurl.svg)](https://travis-ci.org/hrbrmstr/longurl)
[![Project Status: Active - The project has reached a stable, usable
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/longurl)](http://cran.r-project.org/web/packages/longurl)
![downloads](http://cranlogs.r-pkg.org/badges/grand-total/longurl)
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-17%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/longurl.svg?branch=master)](https://travis-ci.org/hrbrmstr/longurl)
[![Coverage
Status](https://codecov.io/gh/hrbrmstr/longurl/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/longurl)
[![cran
checks](https://cranchecks.info/badges/worst/longurl)](https://cranchecks.info/pkgs/longurl)
[![CRAN
status](https://www.r-pkg.org/badges/version/longurl)](https://www.r-pkg.org/pkg/longurl)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.6.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
# longurl
Tools expand vectors of short URLs into long URLs.
Expand Short ‘URLs’
## Description
This does a bit more than
[decode\_short\_url](https://github.com/geoffjentry/twitteR/blob/master/R/utils.R#L22-L31)
from the [twitteR](https://github.com/geoffjentry/twitteR) package since
it:
- doesn’t rely on a URL expansion API (anymore)
- has options for progress bars & display of warnings during URL
checks
- works with a vector of URLs
- returns `tbl_df`s that include HTTP status code for final (expanded)
URL
Tools are provided to expand vectors of short URLs into long ‘URLs’. No
‘API’ services are used, which may mean that this operates more slowly
than ‘API’ services do (since they usually cache results of expansions
that every user of the service requests). You can setup your own caching
layer with the ‘memoise’ package if you wish to have a speedup during
single sessions or add larger dependencies, such as ‘Redis’, to gain a
longer-term performance boost at the expense of added complexity.
## What’s inside the tin?
longer-term performance boost at the expense of added complexity. \#\#
What’s Inside The Tin
The following functions are implemented:
- `expand_urls`: Expand a vector of (short) URLs
- `expand_urls`: Expand a vector of (short) URLs using
## Installation
``` r
devtools::install_github("hrbrmstr/longurl")
# OR
install.packages("longurl")
remotes::install_gitlab("hrbrmstr/longurl")
# or
remotes::install_github("hrbrmstr/longurl")
```
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
## Usage
``` r
library(longurl)
library(dplyr)
library(magrittr)
# current verison
# current version
packageVersion("longurl")
#> [1] '0.3.2'
## [1] '0.3.2'
```
test_urls <- c("http://t.co/D4C7aWYIiA",
"1.usa.gov/1J6GNoW",
"ift.tt/1L2Llfr",
"bit.ly/1GPr5w5",
"http://l.dds.ec/1da152x",
"http://l.rud.is/seven",
"qrp://not a valid url/")
``` r
c(
"http://t.co/D4C7aWYIiA",
"1.usa.gov/1J6GNoW",
"ift.tt/1L2Llfr",
"bit.ly/1GPr5w5",
"http://l.dds.ec/1da152x",
"http://l.rud.is/seven",
"qrp://not a valid url/"
) -> test_urls
expand_urls(test_urls) %>%
select(orig_url, status_code, expanded_url) %>%
dplyr::select(orig_url, status_code, expanded_url) %>%
knitr::kable()
```
| orig\_url | status\_code | expanded\_url |
| :------------------------ | -----------: | :--------------------------------------------------------------------------------------------------------- |
| <http://t.co/D4C7aWYIiA> | NA | NA |
| 1.usa.gov/1J6GNoW | 410 | <https://www.democrats.senate.gov/2015/06/22/schedule-for-monday-june-22-2015/> |
| ift.tt/1L2Llfr | 200 | <https://ifttt.com/applet_embeds/299814p/image?width=660&height=340> |
| bit.ly/1GPr5w5 | 200 | <https://s3.amazonaws.com/features.ifttt.com/blog_images/Channels/Weebly+final+banner+with+IFTTT+logo.png> |
| <http://l.dds.ec/1da152x> | NA | NA |
| <http://l.rud.is/seven> | 404 | <http://l.rud.is/seven> |
| qrp://not a valid url/ | NA | NA |
### Test Results
``` r
library(longurl)
library(testthat)
date()
#> [1] "Mon Mar 26 16:30:03 2018"
test_dir("tests/")
#> ✔ | OK F W S | Context
#> ══ testthat results ═══════════════════════════════════════════════════════════════
#> OK: 4 SKIPPED: 0 FAILED: 0
#>
#> ══ Results ═════════════════════════════════════════════════════════════════════════
#> Duration: 5.4 s
#>
#> OK: 0
#> Failed: 0
#> Warnings: 0
#> Skipped: 0
```
### Code of Conduct
Please note that this project is released with a [Contributor Code of
Conduct](CONDUCT.md). By participating in this project you agree to
abide by its terms.
| :------------------------ | :----------- | :--------------------------------------------------------------------------------------------------------- |
| <http://t.co/D4C7aWYIiA> | 200 | <https://www.wired.com/2015/06/airlines-security-hole-grounded-polish-planes/> |
| 1.usa.gov/1J6GNoW | 404 | <https://1.usa.gov/1J6GNoW> |
| ift.tt/1L2Llfr | 200 | <https://ifttt.com/applet_embeds/299814p/image?width=660&height=340> |
| bit.ly/1GPr5w5 | 200 | <https://s3.amazonaws.com/features.ifttt.com/blog_images/Channels/Weebly+final+banner+with+IFTTT+logo.png> |
| <http://l.dds.ec/1da152x> | 200 | <http://l.dds.ec/1da152x> |
| <http://l.rud.is/seven> | 404 | <http://l.rud.is/seven> |
| qrp://not a valid url/ | NA | NA |
## longurl Metrics
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | --: | --: | ---: | ----------: | ---: | -------: | ---: |
| R | 4 | 0.8 | 110 | 0.84 | 20 | 0.56 | 44 | 0.62 |
| Rmd | 1 | 0.2 | 21 | 0.16 | 16 | 0.44 | 27 | 0.38 |
## Code of Conduct
Please note that this project is released with a Contributor Code of
Conduct. By participating in this project you agree to abide by its
terms.

17
cran-comments.md

@ -1,17 +1,10 @@
## Test environments
* local OS X install, R 3.3.2
* ubuntu (on travis-ci), R 3.3.2
* win-builder (devel and release)
* local R installation, R 4.0.2
* ubuntu 16.04 (on travis-ci), R 4.0.2
* win-builder (devel)
## R CMD check results
0 errors | 0 warnings | 0 notes
* This is a "bug fix" release with a complete re-thinking
of the packge. It no longer relies on third-party services
to do the heavy lifting. All work is done within R.
## Reverse dependencies
* None
0 errors | 0 warnings | 1 note
* This is an update to add support for non-200 status codes.

14
inst/tinytest/test_longurl.R

@ -0,0 +1,14 @@
library(longurl)
c(
"http://t.co/D4C7aWYIiA",
"1.usa.gov/1J6GNoW",
"ift.tt/1L2Llfr",
"bit.ly/1GPr5w5",
"http://l.dds.ec/1da152x",
"http://l.rud.is/seven"
) -> test_urls
res <- expand_urls(test_urls)
expect_true(inherits(res, "data.frame"))

4
tests/testthat.R

@ -1,4 +0,0 @@
library(testthat)
library(longurl)
test_check("longurl")

13
tests/testthat/test-longurl.R

@ -1,13 +0,0 @@
context("basic functionality")
test_that("the API works", {
test_urls <- c("http://t.co/D4C7aWYIiA",
"1.usa.gov/1J6GNoW",
"ift.tt/1L2Llfr",
"bit.ly/1GPr5w5",
"http://l.dds.ec/1da152x",
"http://l.rud.is/seven")
expect_that(expand_urls(test_urls), is_a("data.frame"))
})

5
tests/tinytest.R

@ -0,0 +1,5 @@
if ( requireNamespace("tinytest", quietly=TRUE) ){
tinytest::test_package("longurl")
}
Loading…
Cancel
Save