remotes::install_cran(c("desc", "devtools", "webshot"))
webshot::install_phantomjs()
knitr::opts_chunk$set(
  echo = TRUE, 
  message = FALSE,
  warning = FALSE,
  fig.align = "center", 
  out.width = "100%"
)
badge_custom <- function(x, y, color, url = "about::blank"){
    alt <- paste(x)
    x <- gsub(" ", "%20", x)
    y <- gsub(" ", "%20", y)
    x <- gsub("-", "--", x)
    y <- gsub("-", "--", y)
    badge <- paste0("![", alt, "](https://img.shields.io/badge/", x, "-",
                    y, "-", color, ".svg)")
    if (is.null(url)) return(badge) else paste0("[", badge, "](", url, ")")
}
#######################
## Get Project Paths ##
#######################
path_project <- getwd()
while (length(grep("test", path_project))>0) path_project <- dirname(path_project)
devtools::load_all(path_project)

############################# 
## Get Package DESCRIPTION ##
#############################
library(desc)
target <- file.path(path_project, "DESCRIPTION")
desc_obj <- description$new(target)

##########################
## Set System Variables ##
##########################
package_url <- desc_obj$get_field("BugReports") %>% stringr::str_remove("/issues$")
package_name <- desc_obj$get_field("Package")
package_repo <- stringr::str_extract_all(package_url, "[^/]+(?://[^/]*)*")[[1]][2:3] %>% paste0(collapse ="/")
Sys.setenv(CI_PROJECT_NAME = package_name)
Sys.setenv(CI_PROJECT_URL = package_url)

####################
## Construct URLs ##
####################
travis_url <- paste0("https://travis-ci.org/", package_repo)
pipeline_url <- paste0(travis_url, ".svg?branch=master")
mybinder_url <- "http://mybinder.org/badge.svg"

codecov_url <- paste0("https://codecov.io/github/", package_repo, "/", "?branch=master")
covr_url <- paste0("https://codecov.io/gh/", package_repo, "/branch/master/graph/badge.svg")
binder_url <- paste0("https://mybinder.org/v2/gh/", package_repo, "/master?urlpath=rstudio")

r package_name

r badge_custom("Package Website", "Click-Here", "9cf", desc_obj$get_urls()[[1]]) Travis build status Code coverage status

r desc_obj$get_field("Title")

knitr::include_graphics("https://i.imgur.com/RLEQkhe.png")

Overview

r desc_obj$get_field("Description")

See the package website for more information.

Installation

You can install r package_name by using:

install.packages("devtools")
devtools::install_github("`r package_repo`")


tidylab/tidy.preparation documentation built on Jan. 6, 2020, 12:45 a.m.