source("./AppData/README/helpers.R")
pkgs <- c("desc", "devtools", "usethis", "webshot")
try(remotes::install_cran(pkgs), silent = TRUE)
try(webshot::install_phantomjs(), silent = TRUE)
knitr::opts_chunk$set(
  echo = FALSE, 
  message = FALSE,
  warning = FALSE,
  results = 'hide',
  fig.align = "center", 
  out.width = "100%"
)
#######################
## 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_href <- paste0("https://travis-ci.org/", package_repo)
travis_src <- paste0(travis_href, ".svg?branch=master")

covr_href <- paste0("https://codecov.io/github/", package_repo, "/", "?branch=master")
covr_src <- paste0("https://codecov.io/gh/", package_repo, "/branch/master/graph/badge.svg")

pkgdown_href <- desc_obj$get_urls()[[1]]
pkgdown_src <- generate_shield_src(label = "Package Website", message = "Click-Here", color = "9cf")

r package_name

usethis::use_badge("Package Website", pkgdown_href, pkgdown_src)
usethis::use_badge("Travis Status", travis_href, travis_src)
usethis::use_badge("Code Coverage Status", covr_href, covr_src)

Package Website Travis 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/template.package documentation built on Feb. 27, 2020, 1:47 a.m.