[med-svn] [r-cran-praise] 03/05: New upstream version 1.0.0

Andreas Tille tille at debian.org
Fri Sep 29 07:45:46 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository r-cran-praise.

commit 2e11822cb58bc31d71a9aeb9436f5e6601ceaabb
Author: Andreas Tille <tille at debian.org>
Date:   Fri Sep 29 09:41:27 2017 +0200

    New upstream version 1.0.0
---
 DESCRIPTION                |  19 +++++
 LICENSE                    |   2 +
 MD5                        |  17 +++++
 NAMESPACE                  |   4 ++
 R/adjective.R              | 110 +++++++++++++++++++++++++++++
 R/adverb.R                 |  64 +++++++++++++++++
 R/exclamation.R            |  43 ++++++++++++
 R/package.R                | 113 ++++++++++++++++++++++++++++++
 R/rpackage.R               |  10 +++
 R/verb.R                   |  40 +++++++++++
 debian/README.test         |   8 ---
 debian/changelog           |   5 --
 debian/compat              |   1 -
 debian/control             |  20 ------
 debian/copyright           |  35 ----------
 debian/docs                |   3 -
 debian/rules               |   6 --
 debian/source/format       |   1 -
 debian/tests/control       |   3 -
 debian/tests/run-unit-test |  13 ----
 debian/watch               |   2 -
 inst/NEWS.md               |   4 ++
 inst/README.Rmd            |  58 ++++++++++++++++
 inst/README.md             |  73 +++++++++++++++++++
 man/praise.Rd              |  34 +++++++++
 man/praise_parts.Rd        |  25 +++++++
 tests/testthat.R           |   4 ++
 tests/testthat/helper.R    |  57 +++++++++++++++
 tests/testthat/test.R      | 170 +++++++++++++++++++++++++++++++++++++++++++++
 29 files changed, 847 insertions(+), 97 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
new file mode 100644
index 0000000..b7b3ddb
--- /dev/null
+++ b/DESCRIPTION
@@ -0,0 +1,19 @@
+Package: praise
+Title: Praise Users
+Version: 1.0.0
+Author: Gabor Csardi, Sindre Sorhus
+Maintainer: Gabor Csardi <csardi.gabor at gmail.com>
+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
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..942ca18
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,2 @@
+YEAR: 2015
+COPYRIGHT HOLDER: Gabor Csardi, Sindre Sorhus
diff --git a/MD5 b/MD5
new file mode 100644
index 0000000..e4698b9
--- /dev/null
+++ b/MD5
@@ -0,0 +1,17 @@
+5efb80cff0fbeb96646c52b60c0f5697 *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
diff --git a/NAMESPACE b/NAMESPACE
new file mode 100644
index 0000000..0a5ff7c
--- /dev/null
+++ b/NAMESPACE
@@ -0,0 +1,4 @@
+# Generated by roxygen2 (4.1.1): do not edit by hand
+
+export(praise)
+export(praise_parts)
diff --git a/R/adjective.R b/R/adjective.R
new file mode 100644
index 0000000..488137d
--- /dev/null
+++ b/R/adjective.R
@@ -0,0 +1,110 @@
+
+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"
+)
diff --git a/R/adverb.R b/R/adverb.R
new file mode 100644
index 0000000..01027c1
--- /dev/null
+++ b/R/adverb.R
@@ -0,0 +1,64 @@
+
+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
diff --git a/R/exclamation.R b/R/exclamation.R
new file mode 100644
index 0000000..b36795f
--- /dev/null
+++ b/R/exclamation.R
@@ -0,0 +1,43 @@
+
+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"
+)
diff --git a/R/package.R b/R/package.R
new file mode 100644
index 0000000..553e23f
--- /dev/null
+++ b/R/package.R
@@ -0,0 +1,113 @@
+
+#' @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)
+  )
+}
diff --git a/R/rpackage.R b/R/rpackage.R
new file mode 100644
index 0000000..ea188b6
--- /dev/null
+++ b/R/rpackage.R
@@ -0,0 +1,10 @@
+
+rpackage <- c(
+  "code",
+  "library (or package?)",
+  "package",
+  "program",
+  "project",
+  "software",
+  "R package"
+)
diff --git a/R/verb.R b/R/verb.R
new file mode 100644
index 0000000..9d6c782
--- /dev/null
+++ b/R/verb.R
@@ -0,0 +1,40 @@
+
+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"
+)
diff --git a/debian/README.test b/debian/README.test
deleted file mode 100644
index 53fb4d7..0000000
--- a/debian/README.test
+++ /dev/null
@@ -1,8 +0,0 @@
-Notes on how this package can be tested.
-────────────────────────────────────────
-
-This package can be tested by running the provided test:
-
-   sh ./run-unit-test
-
-in order to confirm its integrity.
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index eb653d0..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-r-cran-praise (1.0.0-1) unstable; urgency=medium
-
-  * Initial upload (Closes: #803543)
-
- -- Andreas Tille <tille at debian.org>  Sat, 31 Oct 2015 09:06:59 +0100
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index ec63514..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-9
diff --git a/debian/control b/debian/control
deleted file mode 100644
index ff0d6d2..0000000
--- a/debian/control
+++ /dev/null
@@ -1,20 +0,0 @@
-Source: r-cran-praise
-Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
-Uploaders: Andreas Tille <tille at debian.org>
-Section: gnu-r
-Priority: optional
-Build-Depends: debhelper (>= 9),
-               cdbs,
-               r-base-dev
-Standards-Version: 3.9.6
-Vcs-Browser: http://anonscm.debian.org/viewvc/debian-med/trunk/packages/R/r-cran-praise/
-Vcs-Svn: svn://anonscm.debian.org/debian-med/trunk/packages/R/r-cran-praise/
-Homepage: http://cran.r-project.org/web/packages/praise
-
-Package: r-cran-praise
-Architecture: all
-Depends: ${misc:Depends},
-         ${R:Depends}
-Description: GNU R praise users
- Build friendly R packages that praise their users if they have done
- something good, or they just need it to feel better.
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 59b7533..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,35 +0,0 @@
-Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Contact: Gabor Csardi <csardi.gabor at gmail.com>
-Upstream-Name: praise
-Source: http://cran.r-project.org/web/packages/praise/
-Comment: The license is mentioned on the source download page as
-         link to the license text http://cran.r-project.org/web/licenses/MIT
-
-Files: *
-Copyright: 2014-2015 Gabor Csardi <csardi.gabor at gmail.com>, Sindre Sorhus
-License: MIT
-
-Files: debian/*
-Copyright: 2015 Andreas Tille <tille at debian.org>
-License: MIT
-
-License: MIT
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
- .
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- .
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
diff --git a/debian/docs b/debian/docs
deleted file mode 100644
index 960011c..0000000
--- a/debian/docs
+++ /dev/null
@@ -1,3 +0,0 @@
-tests
-debian/README.test
-debian/tests/run-unit-test
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 5000db0..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/make -f
-
-include /usr/share/R/debian/r-cran.mk
-
-install/$(package)::
-	rm -rf debian/$(package)/usr/lib/R/site-library/$(cranName)/LICENSE
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/debian/tests/control b/debian/tests/control
deleted file mode 100644
index b044b0c..0000000
--- a/debian/tests/control
+++ /dev/null
@@ -1,3 +0,0 @@
-Tests: run-unit-test
-Depends: @, r-cran-testthat
-Restrictions: allow-stderr
diff --git a/debian/tests/run-unit-test b/debian/tests/run-unit-test
deleted file mode 100644
index f3d1af1..0000000
--- a/debian/tests/run-unit-test
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh -e
-
-pkg=r-cran-crayon
-
-if [ "$ADTTMP" = "" ] ; then
-  ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
-fi
-cd $ADTTMP
-cp -a /usr/share/doc/${pkg}/tests/* $ADTTMP
-find . -name "*.gz" -exec gunzip \{\} \;
-# Make sure we are using C locale to pass all tests
-LC_ALL=C R --no-save < testthat.R
-rm -rf $ADTTMP/*
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index 527e116..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,2 +0,0 @@
-version=3
-http://cran.r-project.org/src/contrib/praise_([\d.-]*)\.tar.gz
diff --git a/inst/NEWS.md b/inst/NEWS.md
new file mode 100644
index 0000000..73ceffb
--- /dev/null
+++ b/inst/NEWS.md
@@ -0,0 +1,4 @@
+
+# 1.0.0
+
+First public release.
diff --git a/inst/README.Rmd b/inst/README.Rmd
new file mode 100644
index 0000000..331e0eb
--- /dev/null
+++ b/inst/README.Rmd
@@ -0,0 +1,58 @@
+
+```{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)
diff --git a/inst/README.md b/inst/README.md
new file mode 100644
index 0000000..8ed5489
--- /dev/null
+++ b/inst/README.md
@@ -0,0 +1,73 @@
+
+
+
+# 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)
diff --git a/man/praise.Rd b/man/praise.Rd
new file mode 100644
index 0000000..1e0ea01
--- /dev/null
+++ b/man/praise.Rd
@@ -0,0 +1,34 @@
+% 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}!")
+}
+
diff --git a/man/praise_parts.Rd b/man/praise_parts.Rd
new file mode 100644
index 0000000..438b8a8
--- /dev/null
+++ b/man/praise_parts.Rd
@@ -0,0 +1,25 @@
+% 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}
+
diff --git a/tests/testthat.R b/tests/testthat.R
new file mode 100644
index 0000000..d5ac969
--- /dev/null
+++ b/tests/testthat.R
@@ -0,0 +1,4 @@
+library(testthat)
+library(praise)
+
+test_check("praise")
diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R
new file mode 100644
index 0000000..3ee72c1
--- /dev/null
+++ b/tests/testthat/helper.R
@@ -0,0 +1,57 @@
+
+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
+}
diff --git a/tests/testthat/test.R b/tests/testthat/test.R
new file mode 100644
index 0000000..21cfd91
--- /dev/null
+++ b/tests/testthat/test.R
@@ -0,0 +1,170 @@
+
+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}", "^(?<adjective>.*)$")
+})
+
+test_that("template with a single part", {
+
+  praise_check(
+    "This is ${adjective}.",
+    "^This is (?<adjective1>.*)\\.$"
+  )
+
+  praise_check(
+    "This is ${adverb}.",
+    "^This is (?<adverb1>.*)\\.$"
+  )
+
+  praise_check(
+    "This is ${adverb_manner}.",
+    "This is (?<adverb_manner1>.*)\\.$"
+  )
+
+  praise_check(
+    "This was ${created}.",
+    "^This was (?<created1>.*)\\.$"
+  )
+
+  praise_check(
+    "This was ${creating}.",
+    "^This was (?<creating1>.*)\\.$"
+  )
+
+  praise_check(
+    "This was ${exclamation}.",
+    "^This was (?<exclamation1>.*)\\.$"
+  )
+
+  praise_check(
+    "This is a nice ${rpackage}!",
+    "^This is a nice (?<rpackage1>.*)!$"
+  )
+
+})
+
+test_that("templates with multiple parts of the same type", {
+
+  praise_check("This is ${adjective} and ${adjective}.",
+               "^This is (?<adjective1>.*) and (?<adjective2>.*)\\.$")
+
+})
+
+test_that("different part types in the same template", {
+
+  praise_check(
+    "You did this ${adverb_manner} and it got ${adjective}!",
+    "^You did this (?<adverb_manner>.*) and it got (?<adjective>.*)!$"
+  )
+
+})
+
+context("Capilatization")
+
+test_that("templates are case insensitive", {
+
+  praise_check("${AdjeCtiVe}", "^(?<adjective>.*)$")
+
+  praise_check(
+    "This is ${adjeCtive}.",
+    "^This is (?<adjective1>.*)\\.$"
+  )
+
+  praise_check(
+    "This is ${Adverb}.",
+    "^This is (?<adverb1>.*)\\.$"
+  )
+
+  praise_check(
+    "This is ${Adverb_Manner}.",
+    "This is (?<adverb_manner1>.*)\\.$"
+  )
+
+  praise_check(
+    "This was ${CREATED}.",
+    "^This was (?<created1>.*)\\.$"
+  )
+
+  praise_check(
+    "This was ${creatING}.",
+    "^This was (?<creating1>.*)\\.$"
+  )
+
+  praise_check(
+    "This was ${EXClamation}.",
+    "^This was (?<exclamation1>.*)\\.$"
+  )
+
+  praise_check(
+    "This is a nice ${rpACKage}!",
+    "^This is a nice (?<rpackage1>.*)!$"
+  )
+
+  praise_check("This is ${Adjective} and ${Adjective}.",
+               "^This is (?<adjective1>.*) and (?<adjective2>.*)\\.$")
+
+  praise_check(
+    "You did this ${adVERB_manner} and it got ${Adjective}!",
+    "^You did this (?<adverb_manner>.*) and it got (?<adjective>.*)!$"
+  )
+
+})
+
+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))
+  }
+})

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-praise.git



More information about the debian-med-commit mailing list