From 5609474b3bcfc1392c62af0349e2d68fd445876b Mon Sep 17 00:00:00 2001 From: hrbrmstr Date: Thu, 29 Oct 2015 09:20:52 -0400 Subject: [PATCH] initial commit --- .Rbuildignore | 5 ++++ .travis.yml | 5 ++++ CONDUCT.md | 25 +++++++++++++++++++ DESCRIPTION | 10 +++++--- NAMESPACE | 6 ++++- R/berate-package.r | 8 ++++++ R/berate.R | 17 +++++++++++++ README.Rmd | 59 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 42 +++++++++++++++++++++++++++++++ berate.Rproj | 10 ++++++++ man/berate.Rd | 14 +++++++++++ tests/testthat.R | 4 +++ tests/testthat/test-berate.R | 6 +++++ 13 files changed, 207 insertions(+), 4 deletions(-) create mode 100644 .travis.yml create mode 100644 CONDUCT.md create mode 100644 R/berate-package.r create mode 100644 R/berate.R create mode 100644 README.Rmd create mode 100644 README.md create mode 100644 man/berate.Rd create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-berate.R diff --git a/.Rbuildignore b/.Rbuildignore index 91114bf..e7ccc30 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,2 +1,7 @@ ^.*\.Rproj$ ^\.Rproj\.user$ +^README\.Rmd$ +^README-.*\.png$ +^\.travis\.yml$ +^CONDUCT\.md$ +^README\.md$ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bfdac82 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +# Sample .travis.yml for R projects + +language: r +warnings_are_errors: true +sudo: required diff --git a/CONDUCT.md b/CONDUCT.md new file mode 100644 index 0000000..52a673e --- /dev/null +++ b/CONDUCT.md @@ -0,0 +1,25 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, we pledge to respect all people who +contribute through reporting issues, posting feature requests, updating documentation, +submitting pull requests or patches, and other activities. + +We are committed to making participation in this project a harassment-free experience for +everyone, regardless of level of experience, gender, gender identity and expression, +sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. + +Examples of unacceptable behavior by participants include the use of sexual language or +imagery, derogatory comments or personal attacks, trolling, public or private harassment, +insults, or other unprofessional conduct. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, +commits, code, wiki edits, issues, and other contributions that are not aligned to this +Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed +from the project team. + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by +opening an issue or contacting one or more of the project maintainers. + +This Code of Conduct is adapted from the Contributor Covenant +(http:contributor-covenant.org), version 1.0.0, available at +http://contributor-covenant.org/version/1/0/0/ diff --git a/DESCRIPTION b/DESCRIPTION index 03c0ca6..dafd1aa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,12 @@ Package: berate -Title: What the Package Does (one line, title case) +Title: Provide Insightful Motivation During Interactive Sessions Version: 0.0.0.9000 Authors@R: c(person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre"))) -Description: What the package does (one paragraph). -Depends: R (>= 3.2.2) +Description: We've all been there. We do our best to crank out an analysis but those + pesky errors still remain. Why not add some helpful motivational information to + encourage you to be a bit more careful about what you type. +Depends: R (>= 3.0.0) License: AGPL + file LICENSE LazyData: true +Suggests: testthat +Imports: xml2, rvest diff --git a/NAMESPACE b/NAMESPACE index 9c9f9ac..6d43e8b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1 +1,5 @@ -exportPattern("^[^\\.]") +# Generated by roxygen2 (4.1.1): do not edit by hand + +importFrom(rvest,html_nodes) +importFrom(rvest,html_text) +importFrom(xml2,read_html) diff --git a/R/berate-package.r b/R/berate-package.r new file mode 100644 index 0000000..3ce083b --- /dev/null +++ b/R/berate-package.r @@ -0,0 +1,8 @@ +#' Provide Insightful Motivation During Interactive Sessions +#' +#' @name berate +#' @docType package +#' @author Bob Rudis (@@hrbrmstr) +#' @importFrom xml2 read_html +#' @importFrom rvest html_nodes html_text +NULL diff --git a/R/berate.R b/R/berate.R new file mode 100644 index 0000000..77d22ba --- /dev/null +++ b/R/berate.R @@ -0,0 +1,17 @@ +berate <- function(err) { + + if (stats::runif(1) < 0.1) { return(invisible()) } + + msg <- tryCatch(html_text(html_nodes(read_html("http://www.programmerinsults.com/"), "h1")), + error=function(err) { return("\\_(o_O)_/") }) + cat(msg) + +} + +.onAttach <- function(libname, pkgname) { + options(error=berate) +} + +.onLoad <- function(libname, pkgname) { + options(error=berate) +} diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..f099e25 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,59 @@ +--- +output: + md_document: + variant: markdown_github +--- + + + +```{r, echo = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "README-" +) +``` + +berate : Provide Insightful Motivation During Interactive Sessions + +No user exposed functions. Just add `library(berate)` to your `.Rprofile` or any interactive session to receive "helpful" motivations to code or type better. + +### News + +- Version 0.0.0.9999 released + +### Installation + +```{r eval=FALSE} +devtools::install_github("hrbrmstr/berate") +``` + +```{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE} +options(width=120) +``` + +### Usage + +```{r} +library(berate) + +# current verison +packageVersion("berate") + +``` + +### Test Results + +```{r} +library(berate) +library(testthat) + +date() + +test_dir("tests/") +``` + +### 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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..884cd98 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ + +berate : Provide Insightful Motivation During Interactive Sessions + +No user exposed functions. Just add `library(berate)` to your `.Rprofile` or any interactive session to receive "helpful" motivations to code or type better. + +### News + +- Version 0.0.0.9999 released + +### Installation + +``` r +devtools::install_github("hrbrmstr/berate") +``` + +### Usage + +``` r +library(berate) + +# current verison +packageVersion("berate") +#> [1] '0.0.0.9000' +``` + +### Test Results + +``` r +library(berate) +library(testthat) + +date() +#> [1] "Thu Oct 29 09:19:13 2015" + +test_dir("tests/") +#> testthat results ======================================================================================================== +#> OK: 0 SKIPPED: 0 FAILED: 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. diff --git a/berate.Rproj b/berate.Rproj index d848a9f..ed62028 100644 --- a/berate.Rproj +++ b/berate.Rproj @@ -14,3 +14,13 @@ BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source PackageRoxygenize: rd,collate,namespace +Version: 1.0 + +UseSpacesForTab: Yes +NumSpacesForTab: 2 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +PackageBuildArgs: --resave-data +PackageCheckArgs: --as-cran diff --git a/man/berate.Rd b/man/berate.Rd new file mode 100644 index 0000000..8fee287 --- /dev/null +++ b/man/berate.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/berate-package.r +\docType{package} +\name{berate} +\alias{berate} +\alias{berate-package} +\title{Provide Insightful Motivation During Interactive Sessions} +\description{ +Provide Insightful Motivation During Interactive Sessions +} +\author{ +Bob Rudis (@hrbrmstr) +} + diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..3f9543a --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(berate) + +test_check("berate") diff --git a/tests/testthat/test-berate.R b/tests/testthat/test-berate.R new file mode 100644 index 0000000..ab6f62f --- /dev/null +++ b/tests/testthat/test-berate.R @@ -0,0 +1,6 @@ +context("basic functionality") +test_that("we can do something", { + + #expect_that(some_function(), is_a("data.frame")) + +})