Skip to content

Commit

Permalink
Pirate punctuation (#770)
Browse files Browse the repository at this point in the history
* Fixed Docker Compose env var Slack example

* Fixed pirate suffixing for final punctuation followed by white-space
  • Loading branch information
jcorrado authored and devth committed Oct 26, 2018
1 parent 1e5f55a commit af46d36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/yetibot/commands/pirate.clj
Expand Up @@ -73,8 +73,9 @@
[s]
(let [flavor (rand-nth flavor)]
(str/replace-first s
#"[.!?]*$"
#(format ", %s%s" flavor %))))
#"([.!?]*)\s*$"
(fn [[_ punc]]
(format ", %s%s" flavor punc)))))

(def slur-re #"[alr](?![alr])")

Expand Down
6 changes: 4 additions & 2 deletions test/yetibot/test/commands/pirate.clj
Expand Up @@ -24,8 +24,10 @@
(to-pirate "hello world admin") => "ahoy world helm")

(fact "suffix-flavor suffixes something"
(suffix-flavor "foo") => #"^foo,\s+[^\s]+"
(suffix-flavor "foo.") => #"^foo,\s+.+\.$")
(suffix-flavor "foo bar") => #"^foo bar,\s+[^\s]+"
(suffix-flavor "foo bar.") => #"^foo bar,\s+.+\.$"
(suffix-flavor "foo bar. ") => #"^foo bar,\s+.+\.$"
(suffix-flavor "foo bar.. ") => #"^foo bar,\s+.+\.\.$")

(def test-str "the quick brown fox jumps over the lazy dog")

Expand Down

0 comments on commit af46d36

Please sign in to comment.