Browse Source

Fixes #2

master
boB Rudis 5 years ago
parent
commit
d585fa2b73
No known key found for this signature in database GPG Key ID: 2A514A4997464560
  1. 1
      DESCRIPTION
  2. 4
      NAMESPACE
  3. 53
      R/bismer.r
  4. 21
      README.Rmd
  5. 83
      README.md
  6. 25
      man/insult.Rd

1
DESCRIPTION

@ -8,6 +8,7 @@ Maintainer: Bob Rudis <bob@rud.is>
Description: Shakespearean insult generator
URL: https://github.com/hrbrmstr/bismer
BugReports: https://github.com/hrbrmstr/bismer/issues
Encodig: UTF-8
License: AGPL
Suggests:
testthat, covr

4
NAMESPACE

@ -1,4 +1,8 @@
# Generated by roxygen2: do not edit by hand
export(gehornian)
export(híenan)
export(insult)
export(misgrétan)
export(scendan)
import(tibble)

53
R/bismer.r

@ -33,13 +33,52 @@ structure(list(c1 = c("artless", "bawdy", "beslubbering", "bootless",
#' Generate a random Shakespearean insult
#'
#' With this function thee can gen'rate a plain three-element æfþanc, one prefix'd with
#' "thou", and completeth fracoþ sentences with varying punctuation.
#'
#' @md
#' @param thou if `TRUE` then the insults are prefixed with "thou"
#' @param sentence if `TRUE` then the insults are prefixed with "Thou art a" and end with
#' punctuation. See `exclaim` for how to specify which punctuation. The value of
#' `sentence` overrides `thou`.
#' @param exclaim if `TRUE` and `sentence` == `TRUE` then the generated sentence will be
#' ended with a "!" else it shall be ended with a ".". This parameter is ignored
#' if `sentence` is `FALSE`.
#' @export
insult <- function(thou=TRUE, sentence=FALSE, exclaim=TRUE) {
prefix <- ""
beration <- sprintf("%s %s %s",
insults$c1[sample(length(insults$c1), 1)],
insults$c2[sample(length(insults$c2), 1)],
insults$c3[sample(length(insults$c3), 1)])
if (thou || sentence) prefix <- if (sentence) "Thou art a " else "thou "
if (sentence) {
is_vowel <- substr(beration, 1, 1) %in% c("a", "e", "i", "o", "u")
if (is_vowel) prefix <- gsub("a $", "an ", prefix)
beration <- sprintf("%s%s", beration, if (exclaim) "!" else ".")
}
sprintf("%s%s", prefix, beration)
}
#' @rdname insult
#' @export
gehornian <- insult
#' @rdname insult
#' @export
híenan <- insult
#' @rdname insult
#' @export
misgrétan <- insult
#' @rdname insult
#' @export
insult <- function(thou=TRUE) {
sprintf("%s%s %s %s",
if (thou) "thou " else "",
insults$c1[sample(length(insults$c1), 1)],
insults$c2[sample(length(insults$c2), 1)],
insults$c3[sample(length(insults$c3), 1)])
}
scendan <- insult

21
README.Rmd

@ -10,6 +10,15 @@ The following functions are implemented:
- `insult`: Generate a Shakespearean insult
The `insult()` function is aliased to
- `gehornian`
- `híenan`
- `misgrétan`
- `scendan`
for those who want to go "all-in" on the Shakespeare thing.
### Installation
```{r eval=FALSE}
@ -31,16 +40,8 @@ packageVersion("bismer")
purrr::walk(1:10, ~print(insult()))
purrr::walk(1:10, ~print(insult(thou=FALSE)))
```
### Test Results
purrr::walk(1:10, ~print(insult(sentence=TRUE)))
```{r message=FALSE, warning=FALSE, error=FALSE}
library(bismer)
library(testthat)
date()
test_dir("tests/")
purrr::walk(1:10, ~print(insult(sentence=TRUE, exclaim=FALSE)))
```

83
README.md

@ -7,6 +7,15 @@ The following functions are implemented:
- `insult`: Generate a Shakespearean insult
The `insult()` function is aliased to
- `gehornian`
- `híenan`
- `misgrétan`
- `scendan`
for those who want to go "all-in" on the Shakespeare thing.
### Installation
``` r
@ -28,48 +37,58 @@ packageVersion("bismer")
purrr::walk(1:10, ~print(insult()))
```
## [1] "thou puny beetle-headed death-token"
## [1] "thou errant tickle-brained flap-dragon"
## [1] "thou rank ill-breeding whey-face"
## [1] "thou spleeny crook-pared pumpion"
## [1] "thou errant milk-livered hugger-mugger"
## [1] "thou tottering clay-brained haggard"
## [1] "thou mewling fat-kidneyed bladder"
## [1] "thou impertinent toad-spotted harpy"
## [1] "thou droning dread-bolted baggage"
## [1] "thou wayward unchin-snouted pumpion"
## [1] "thou errant rude-growing ooxoomb"
## [1] "thou qualling fly-bitten miscreant"
## [1] "thou saucy flap-mouthed bum-bailey"
## [1] "thou reeky rude-growing puttock"
## [1] "thou lumpish common-kissing clotpole"
## [1] "thou paunchy weather-bitten strumpet"
## [1] "thou weedy common-kissing puttock"
## [1] "thou weedy full-gorged hedge-pig"
## [1] "thou puking pottle-deep joithead"
## [1] "thou gorbellied clapper-clawed dewberry"
``` r
purrr::walk(1:10, ~print(insult(thou=FALSE)))
```
## [1] "warped knotty-pated giglet"
## [1] "warped tickle-brained flap-dragon"
## [1] "dissembling beetle-headed giglet"
## [1] "surly tardy-gaited miscreant"
## [1] "surly dread-bolted pignut"
## [1] "puking spur-galled boar-pig"
## [1] "fobbing clay-brained mumble-news"
## [1] "goatish dismal-dreaning codpiece"
## [1] "beslubbering base-court death-token"
## [1] "roguish boil-brained maggot-pie"
### Test Results
## [1] "bawdy dismal-dreaning pignut"
## [1] "reeky unchin-snouted pumpion"
## [1] "currish doghearted lewdster"
## [1] "clouted bat-fouling minnow"
## [1] "lumpish hasty-witted gudgeon"
## [1] "qualling full-gorged harpy"
## [1] "surly common-kissing foot-licker"
## [1] "loggerheaded pottle-deep fustilarian"
## [1] "spongy hedge-born scut"
## [1] "spleeny beef-witted bum-bailey"
``` r
library(bismer)
library(testthat)
date()
purrr::walk(1:10, ~print(insult(sentence=TRUE)))
```
## [1] "Sun Mar 26 12:55:05 2017"
## [1] "Thou art a cockered flap-mouthed varlot!"
## [1] "Thou art a roguish common-kissing wagtail!"
## [1] "Thou art a venomed dizzy-eyed ooxoomb!"
## [1] "Thou art a currish ill-breeding skainsmate!"
## [1] "Thou art a vain unchin-snouted hugger-mugger!"
## [1] "Thou art a vain milk-livered gudgeon!"
## [1] "Thou art a jarring ill-nurtured harpy!"
## [1] "Thou art a craven ill-breeding harpy!"
## [1] "Thou art a bawdy spur-galled haggard!"
## [1] "Thou art a frothy bat-fouling flax-wench!"
``` r
test_dir("tests/")
purrr::walk(1:10, ~print(insult(sentence=TRUE, exclaim=FALSE)))
```
## testthat results ========================================================================================================
## OK: 0 SKIPPED: 0 FAILED: 0
##
## DONE ===================================================================================================================
## [1] "Thou art a venomed milk-livered flap-dragon."
## [1] "Thou art a bootless plume-plucked flirt-gill."
## [1] "Thou art a roguish hasty-witted canker-blossom."
## [1] "Thou art a vain folly-fallen bladder."
## [1] "Thou art a roguish bat-fouling death-token."
## [1] "Thou art a currish rude-growing pignut."
## [1] "Thou art an artless shard-borne giglet."
## [1] "Thou art a roguish ill-nurtured ratsbane."
## [1] "Thou art a dissembling tardy-gaited flax-wench."
## [1] "Thou art a dissembling idle-headed mammet."

25
man/insult.Rd

@ -2,13 +2,34 @@
% Please edit documentation in R/bismer.r
\name{insult}
\alias{insult}
\alias{gehornian}
\alias{híenan}
\alias{misgrétan}
\alias{scendan}
\title{Generate a random Shakespearean insult}
\usage{
insult(thou = TRUE)
insult(thou = TRUE, sentence = FALSE, exclaim = TRUE)
gehornian(thou = TRUE, sentence = FALSE, exclaim = TRUE)
híenan(thou = TRUE, sentence = FALSE, exclaim = TRUE)
misgrétan(thou = TRUE, sentence = FALSE, exclaim = TRUE)
scendan(thou = TRUE, sentence = FALSE, exclaim = TRUE)
}
\arguments{
\item{thou}{if \code{TRUE} then the insults are prefixed with "thou"}
\item{sentence}{if \code{TRUE} then the insults are prefixed with "Thou art a" and end with
punctuation. See \code{exclaim} for how to specify which punctuation. The value of
\code{sentence} overrides \code{thou}.}
\item{exclaim}{if \code{TRUE} and \code{sentence} == \code{TRUE} then the generated sentence will be
ended with a "!" else it shall be ended with a ".". This parameter is ignored
if \code{sentence} is \code{FALSE}.}
}
\description{
Generate a random Shakespearean insult
With this function thee can gen'rate a plain three-element æfþanc, one prefix'd with
"thou", and completeth fracoþ sentences with varying punctuation.
}

Loading…
Cancel
Save