praise/0000755000175100001440000000000012562312244011554 5ustar hornikuserspraise/inst/0000755000175100001440000000000012556730660012542 5ustar hornikuserspraise/inst/README.Rmd0000644000175100001440000000265712556730660014155 0ustar hornikusers ```{r, setup, echo = FALSE, message = FALSE} knitr::opts_chunk$set( comment = "#>", tidy = FALSE, error = FALSE, fig.width = 8, fig.height = 8) ``` # praise > Praise Users [![Linux Build Status](https://travis-ci.org/gaborcsardi/praise.svg?branch=master)](https://travis-ci.org/gaborcsardi/praise) [![Windows Build status](https://ci.appveyor.com/api/projects/status/github/gaborcsardi/praise?svg=true)](https://ci.appveyor.com/project/gaborcsardi/praise) [![](http://www.r-pkg.org/badges/version/praise)](http://www.r-pkg.org/pkg/praise) [![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/praise)](http://www.r-pkg.org/pkg/praise) Build friendly R packages that praise their users if they have done something good, or they just need it to feel better. ## Installation ```{r eval = FALSE} devtools::install_github("gaborcsardi/praise") ``` ## Usage ```{r} library(praise) praise() ``` You can supply a template, and `praise()` fills in random words of the specified part of speech: ```{r} praise("${EXCLAMATION}! You have done this ${adverb_manner}!") ``` Note that capitalization in the inserted words will be the same as in the template: ```{r} praise("${Exclamation}! ${EXCLAMATION}!-${EXCLAMATION}! This is just ${adjective}!") ``` Currently supported parts of speech: ```{r} names(praise_parts) ``` ## License MIT © [Gabor Csardi](https://github.com/gaborcsardi), [Sindre Sorhus](http://sindresorhus.com) praise/inst/NEWS.md0000644000175100001440000000004012556303115013621 0ustar hornikusers # 1.0.0 First public release. praise/inst/README.md0000644000175100001440000000304412556730664014026 0ustar hornikusers # praise > Praise Users [![Linux Build Status](https://travis-ci.org/gaborcsardi/praise.svg?branch=master)](https://travis-ci.org/gaborcsardi/praise) [![Windows Build status](https://ci.appveyor.com/api/projects/status/github/gaborcsardi/praise?svg=true)](https://ci.appveyor.com/project/gaborcsardi/praise) [![](http://www.r-pkg.org/badges/version/praise)](http://www.r-pkg.org/pkg/praise) [![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/praise)](http://www.r-pkg.org/pkg/praise) Build friendly R packages that praise their users if they have done something good, or they just need it to feel better. ## Installation ```r devtools::install_github("gaborcsardi/praise") ``` ## Usage ```r library(praise) praise() ``` ``` #> [1] "You are super-excellent!" ``` You can supply a template, and `praise()` fills in random words of the specified part of speech: ```r praise("${EXCLAMATION}! You have done this ${adverb_manner}!") ``` ``` #> [1] "AYE! You have done this enormously!" ``` Note that capitalization in the inserted words will be the same as in the template: ```r praise("${Exclamation}! ${EXCLAMATION}!-${EXCLAMATION}! This is just ${adjective}!") ``` ``` #> [1] "Yowza! MMHM!-YAHOO! This is just praiseworthy!" ``` Currently supported parts of speech: ```r names(praise_parts) ``` ``` #> [1] "adjective" "adverb" "adverb_manner" "created" #> [5] "creating" "exclamation" "rpackage" ``` ## License MIT © [Gabor Csardi](https://github.com/gaborcsardi), [Sindre Sorhus](http://sindresorhus.com) praise/tests/0000755000175100001440000000000012556303115012716 5ustar hornikuserspraise/tests/testthat.R0000644000175100001440000000007012556303115014676 0ustar hornikuserslibrary(testthat) library(praise) test_check("praise") praise/tests/testthat/0000755000175100001440000000000012562312244014556 5ustar hornikuserspraise/tests/testthat/test.R0000644000175100001440000000735112557712067015701 0ustar hornikusers context("parts") test_that("all parts are lowercase (except some)", { for (p in names(praise_parts)) { pp <- setdiff(praise_parts[[p]], "R package") expect_true( all(is_all_lowercase(pp)), info = p ) } }) context("templating") test_that("template without praise word", { str <- "This is just a random string" expect_equal(praise(str), str) expect_equal(praise(""), "") }) test_that("corner cases are OK", { praise_check("", "") praise_check("x", "x") praise_check("${adjective}", "^(?.*)$") }) test_that("template with a single part", { praise_check( "This is ${adjective}.", "^This is (?.*)\\.$" ) praise_check( "This is ${adverb}.", "^This is (?.*)\\.$" ) praise_check( "This is ${adverb_manner}.", "This is (?.*)\\.$" ) praise_check( "This was ${created}.", "^This was (?.*)\\.$" ) praise_check( "This was ${creating}.", "^This was (?.*)\\.$" ) praise_check( "This was ${exclamation}.", "^This was (?.*)\\.$" ) praise_check( "This is a nice ${rpackage}!", "^This is a nice (?.*)!$" ) }) test_that("templates with multiple parts of the same type", { praise_check("This is ${adjective} and ${adjective}.", "^This is (?.*) and (?.*)\\.$") }) test_that("different part types in the same template", { praise_check( "You did this ${adverb_manner} and it got ${adjective}!", "^You did this (?.*) and it got (?.*)!$" ) }) context("Capilatization") test_that("templates are case insensitive", { praise_check("${AdjeCtiVe}", "^(?.*)$") praise_check( "This is ${adjeCtive}.", "^This is (?.*)\\.$" ) praise_check( "This is ${Adverb}.", "^This is (?.*)\\.$" ) praise_check( "This is ${Adverb_Manner}.", "This is (?.*)\\.$" ) praise_check( "This was ${CREATED}.", "^This was (?.*)\\.$" ) praise_check( "This was ${creatING}.", "^This was (?.*)\\.$" ) praise_check( "This was ${EXClamation}.", "^This was (?.*)\\.$" ) praise_check( "This is a nice ${rpACKage}!", "^This is a nice (?.*)!$" ) praise_check("This is ${Adjective} and ${Adjective}.", "^This is (?.*) and (?.*)\\.$") praise_check( "You did this ${adVERB_manner} and it got ${Adjective}!", "^You did this (?.*) and it got (?.*)!$" ) }) test_that("first letter is capitalized", { for (i in 1:10) { pra <- praise("${Adjective}") expect_true(is_capitalized(pra)) pra <- praise("${Adverb}") expect_true(is_capitalized(pra)) pra <- praise("${Adverb_manner}") expect_true(is_capitalized(pra)) pra <- praise("${Created}") expect_true(is_capitalized(pra)) pra <- praise("${Creating}") expect_true(is_capitalized(pra)) pra <- praise("${Exclamation}") expect_true(is_capitalized(pra)) pra <- praise("${Rpackage}") expect_true(is_capitalized(pra)) } }) test_that("whole word is upper case", { for (i in 1:10) { pra <- praise("${ADJECTIVE}") expect_true(is_all_uppercase(pra), info = pra) pra <- praise("${ADVERB}") expect_true(is_all_uppercase(pra)) pra <- praise("${ADVERB_MANNER}") expect_true(is_all_uppercase(pra)) pra <- praise("${CREATED}") expect_true(is_all_uppercase(pra)) pra <- praise("${CREATING}") expect_true(is_all_uppercase(pra)) pra <- praise("${EXCLAMATION}") expect_true(is_all_uppercase(pra)) pra <- praise("${RPACKAGE}") expect_true(is_all_uppercase(pra)) } }) praise/tests/testthat/helper.R0000644000175100001440000000230212557712102016156 0ustar hornikusers re_match <- function(pattern, x) { stopifnot(length(x) == 1) mat <- regexpr(pattern, x, perl = TRUE) if (mat != -1L) { res <- substring(x, mat, mat + attr(mat, "match.length") - 1L) if (length(attr(mat, "capture.start"))) { res <- c( res, substring( x, attr(mat, "capture.start"), attr(mat, "capture.start") + attr(mat, "capture.length") - 1 ) ) } if (any(attr(mat, "capture.names") != "")) { names(res) <- c("", attr(mat, "capture.names")) } res } else { NULL } } praise_check <- function(template, regexp, num = 10) { for (i in 1:num) { pra <- praise(template) match <- re_match(regexp, pra) expect_true( !is.null(match), info = template ) parts <- sub("[0-9]*$", "", names(match[-1])) for (p in seq_along(parts)) { expect_true(tolower(match[p + 1]) %in% tolower(praise_parts[[ parts[p] ]])) } } } is_capitalized <- function(x) { toupper(substring(x, 1, 1)) == substring(x, 1, 1) & tolower(substring(x, 2)) == substring(x, 2) } is_all_uppercase <- function(x) { toupper(x) == x } is_all_lowercase <- function(x) { tolower(x) == x } praise/NAMESPACE0000644000175100001440000000013212562253543012775 0ustar hornikusers# Generated by roxygen2 (4.1.1): do not edit by hand export(praise) export(praise_parts) praise/R/0000755000175100001440000000000012556730252011763 5ustar hornikuserspraise/R/adverb.R0000644000175100001440000000157612556556033013365 0ustar hornikusers adverb_manner <- c( "beautifully", "bravely", "brightly", "calmly", "carefully", "cautiously", "cheerfully", "clearly", "correctly", "courageously", "daringly", "deliberately", "doubtfully", "eagerly", "easily", "elegantly", "enormously", "enthusiastically", "faithfully", "fast", "fondly", "fortunately", "frankly", "frantically", "generously", "gently", "gladly", "gracefully", "happily", "healthily", "honestly", "joyously", "justly", "kindly", "neatly", "openly", "patiently", "perfectly", "politely", "powerfully", "quickly", "quietly", "rapidly", "really", "regularly", "repeatedly", "rightfully", "seriously", "sharply", "smoothly", "speedily", "successfully", "swiftly", "tenderly", "thoughtfully", "truthfully", "warmly", "well", "wisely" ) adverb <- adverb_manner praise/R/rpackage.R0000644000175100001440000000017212556561443013667 0ustar hornikusers rpackage <- c( "code", "library (or package?)", "package", "program", "project", "software", "R package" ) praise/R/adjective.R0000644000175100001440000000300412556565640014050 0ustar hornikusers adjective <- c( "ace", "amazing", "astonishing", "astounding", "awe-inspiring", "awesome", "badass", "beautiful", "bedazzling", "bee's knees", "best", "breathtaking", "brilliant", "cat's meow", "cat's pajamas", "classy", "cool", "dandy", "dazzling", "delightful", "divine", "doozie", "epic", "excellent", "exceptional", "exquisite", "extraordinary", "fabulous", "fantastic", "fantabulous", "fine", "finest", "first-class", "first-rate", "flawless", "funkadelic", "geometric", "glorious", "gnarly", "good", "grand", "great", "groovy", "groundbreaking", "hunky-dory", "impeccable", "impressive", "incredible", "kickass", "kryptonian", "laudable", "legendary", "lovely", "luminous", "magnificent", "majestic", "marvelous", "mathematical", "mind-blowing", "neat", "outstanding", "peachy", "perfect", "phenomenal", "pioneering", "polished", "posh", "praiseworthy", "premium", "priceless", "prime", "primo", "rad", "remarkable", "riveting", "sensational", "shining", "slick", "smashing", "solid", "spectacular", "splendid", "stellar", "striking", "stunning", "stupendous", "stylish", "sublime", "super", "super-duper", "super-excellent", "superb", "superior", "supreme", "swell", "terrific", "tiptop", "top-notch", "transcendent", "tremendous", "ultimate", "unreal", "well-made", "wicked", "wonderful", "wondrous", "world-class" ) praise/R/package.R0000644000175100001440000000516212556570460013510 0ustar hornikusers #' @title Praise Users #' @name praise #' @description Build friendly R packages that #' praise their users if they have done something #' good, or they just need it to feel better. #' #' @docType package #' @aliases praise praise-package NULL #' Parts of speech for praising #' #' @format #' Named list of character vertors. List entries: \describe{ #' \item{adjective}{Words and phrases to be used as positive adjectives. #' Most of them are from \url{https://github.com/sindresorhus/superb}.} #' \item{adverb}{Adverbs.} #' \item{adverb_manner}{Adverbs of manner, with positive meanings.} #' \item{created}{Synonyms of \sQuote{create} in paste tense.} #' \item{creating}{Synonyms of \sQuote{create}, in present participle #' form.} #' \item{exclamation}{Positive exclamations.} #' \item{rpackage}{Synonyms for the term \sQuote{R package}.} #' } #' #' @include adjective.R adverb.R exclamation.R rpackage.R verb.R #' @export praise_parts <- list( adjective = adjective, adverb = adverb, adverb_manner = adverb_manner, created = created, creating = creating, exclamation = exclamation, rpackage = rpackage ) #' Randomized praise based on a template #' #' @details #' Replace parts of the template with random words from the praise #' word lists. See examples below. #' #' @param template Character scalar, the template string. #' @export #' @examples #' praise() #' #' ## Capitalization #' praise("${Exclamation}! This ${rpackage} is ${adjective}!") #' #' ## All upper case #' praise("${EXCLAMATION}! You have done this ${adverb_manner}!") praise <- function(template = "You are ${adjective}!") { while (is_template(template)) { template <- replace_one_template(template) } template } template_pattern <- "\\$\\{([^\\}]+)\\}" is_template <- function(x) grepl(template_pattern, x) replace_one_template <- function(template) { match <- regexpr(template_pattern, template, perl = TRUE) template1 <- substring( template, match, match + attr(match, "match.length") - 1L ) part <- substring( template, attr(match, "capture.start"), attr(match, "capture.start") + attr(match, "capture.length") - 1L ) match_case_sub( template1, part, sample(praise_parts[[tolower(part)]], 1), template ) } match_case_sub <- function(pattern, part, replacement, text) { if (toupper(part) == part) { replacement <- toupper(replacement) } else if (capitalize(part) == part) { replacement <- capitalize(replacement) } sub(pattern, replacement, text, fixed = TRUE) } capitalize <- function(x) { paste0( toupper(substring(x, 1, 1)), substring(x, 2) ) } praise/R/exclamation.R0000644000175100001440000000063412556561506014421 0ustar hornikusers exclamation <- c( "ah", "aha", "ahh", "ahhh", "aw", "aww", "awww", "aye", "gee", "ha", "hah", "hmm", "ho-ho", "huh", "heh", "hooray", "hurrah", "hurray", "huzzah", "mhm", "mm", "mmh", "mmhm", "mmm", "oh", "ole", "uh-hu", "wee", "whee", "whoa", "wow", "wowie", "yahoo", "yay", "yeah", "yee-haw", "yikes", "yippie", "yow", "yowza" ) praise/R/verb.R0000644000175100001440000000077312556561721013056 0ustar hornikusers created <- c( "assembled", "brewed", "built", "created", "composed", "constructed", "designed", "devised", "forged", "formed", "initiated", "invented", "made", "organized", "planned", "prepared", "set up" ) creating <- c( "assembling", "brewing", "building", "creating", "composing", "constructing", "designing", "devising", "forging", "forming", "initiating", "inventing", "making", "organizing", "planning", "preparin", "setting up" ) praise/MD50000644000175100001440000000147012562312244012066 0ustar hornikusers5efb80cff0fbeb96646c52b60c0f5697 *DESCRIPTION 8cff75b73749151ff48afea63ed20f50 *LICENSE 2b68a15753515e12bb444a8784e7b7e6 *NAMESPACE 1fc3816ff80eeb0d2766069782b2d5d4 *R/adjective.R b7caf9f026b204337d23d4fb1ad5b7f3 *R/adverb.R 7e92705c0df6066d621d02e4c5b07008 *R/exclamation.R ef7e5b33817c1765e7818b08cbe878b9 *R/package.R 86706bdfe21f28cda666bc0f318b5192 *R/rpackage.R bf71014fe84832e955871c40d892841e *R/verb.R 104b43a7414eeb73afc5f408f76d9163 *inst/NEWS.md 53bbc41b4e7063dbcee23b6a9b422a18 *inst/README.Rmd b49a6ea823437620cbadaef9f6e7cad8 *inst/README.md 1f84d50a76b97cdc28160e0747b9d848 *man/praise.Rd 7e0fb2829957438f66cb847a10c20a27 *man/praise_parts.Rd 0820649b37143bc02ed23383d159de9f *tests/testthat.R 8b37808072a6f1e363ad0d5b4f79eee8 *tests/testthat/helper.R 84d37154d3ac296e6b6e2d7a4a6e957b *tests/testthat/test.R praise/DESCRIPTION0000644000175100001440000000122012562312244013255 0ustar hornikusersPackage: praise Title: Praise Users Version: 1.0.0 Author: Gabor Csardi, Sindre Sorhus Maintainer: Gabor Csardi Description: Build friendly R packages that praise their users if they have done something good, or they just need it to feel better. License: MIT + file LICENSE LazyData: true URL: https://github.com/gaborcsardi/praise BugReports: https://github.com/gaborcsardi/praise/issues Suggests: testthat Collate: 'adjective.R' 'adverb.R' 'exclamation.R' 'verb.R' 'rpackage.R' 'package.R' NeedsCompilation: no Packaged: 2015-08-11 02:01:43 UTC; gaborcsardi Repository: CRAN Date/Publication: 2015-08-11 08:22:28 praise/man/0000755000175100001440000000000012562253543012335 5ustar hornikuserspraise/man/praise_parts.Rd0000644000175100001440000000150012562253543015314 0ustar hornikusers% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/package.R \docType{data} \name{praise_parts} \alias{praise_parts} \title{Parts of speech for praising} \format{Named list of character vertors. List entries: \describe{ \item{adjective}{Words and phrases to be used as positive adjectives. Most of them are from \url{https://github.com/sindresorhus/superb}.} \item{adverb}{Adverbs.} \item{adverb_manner}{Adverbs of manner, with positive meanings.} \item{created}{Synonyms of \sQuote{create} in paste tense.} \item{creating}{Synonyms of \sQuote{create}, in present participle form.} \item{exclamation}{Positive exclamations.} \item{rpackage}{Synonyms for the term \sQuote{R package}.} }} \usage{ praise_parts } \description{ Parts of speech for praising } \keyword{datasets} praise/man/praise.Rd0000644000175100001440000000141212562253543014105 0ustar hornikusers% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/package.R \docType{package} \name{praise} \alias{praise} \alias{praise-package} \title{Praise Users} \usage{ praise(template = "You are ${adjective}!") } \arguments{ \item{template}{Character scalar, the template string.} } \description{ Build friendly R packages that praise their users if they have done something good, or they just need it to feel better. Randomized praise based on a template } \details{ Replace parts of the template with random words from the praise word lists. See examples below. } \examples{ praise() ## Capitalization praise("${Exclamation}! This ${rpackage} is ${adjective}!") ## All upper case praise("${EXCLAMATION}! You have done this ${adverb_manner}!") } praise/LICENSE0000644000175100001440000000007112556306200012555 0ustar hornikusersYEAR: 2015 COPYRIGHT HOLDER: Gabor Csardi, Sindre Sorhus