urmum 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/urmum/insulter.rb +4 -3
- data/lib/urmum/version.rb +1 -1
- data/spec/urmum/insulter_spec.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79c709746855bddedda2edad419e886e22a4fc1d
|
4
|
+
data.tar.gz: ab8c75bca238bde7ecabc927d657f42be8a37ccb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00ba2f1f146ab11e3d3607df9d1bb5793c6bbee970edd74473d234112da6226499c02982a7a75eafffb2b455179d6e929b5d298dcfb7155afc054282ce0cfadf
|
7
|
+
data.tar.gz: c4b5e7b8a9e73691e4ecf5d8c921cabd1df4b4b2030ae1ad8d06c5cd316289098860955b53d60059f6f653d585d8a3d86031c500ce0ee271e6bbf9e9740a8026
|
data/lib/urmum/insulter.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'engtagger'
|
2
|
-
require 'pry'
|
3
2
|
|
4
3
|
class Insulter
|
5
4
|
INSULT_BEGINNINGS = [
|
@@ -9,12 +8,15 @@ class Insulter
|
|
9
8
|
"Your mum's face is"
|
10
9
|
]
|
11
10
|
FALLBACK = "That's what she said"
|
11
|
+
EMPTY_RESPONSE = "Bring it on!"
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
@tagger = EngTagger.new
|
15
15
|
end
|
16
16
|
|
17
17
|
def insult_with(string)
|
18
|
+
return EMPTY_RESPONSE if string.nil? || string.empty? || string =~ /^\s*$/ #just whitespace
|
19
|
+
|
18
20
|
# Try and match against the beginning of the string. If so, get the next beginning from the array
|
19
21
|
regexp = Regexp.new(%{^(?<start>#{INSULT_BEGINNINGS.join("|")}) (?<article>an|a) (?<thing>.*)})
|
20
22
|
if matches = string.capitalize.match(regexp)
|
@@ -35,6 +37,5 @@ class Insulter
|
|
35
37
|
"You're a #{thing}"
|
36
38
|
end
|
37
39
|
|
38
|
-
# binding.pry
|
39
40
|
end
|
40
|
-
end
|
41
|
+
end
|
data/lib/urmum/version.rb
CHANGED
data/spec/urmum/insulter_spec.rb
CHANGED
@@ -44,6 +44,19 @@ describe "Insulter" do
|
|
44
44
|
it "should treat 'ur' the same as 'you're' and your"
|
45
45
|
it "should handle mum's the same as mum is"
|
46
46
|
|
47
|
+
context "when passed empty input" do
|
48
|
+
subject { insulter.insult_with("") }
|
49
|
+
it { should == "Bring it on!" }
|
50
|
+
end
|
51
|
+
context "when passed blank input" do
|
52
|
+
subject { insulter.insult_with("\t ") }
|
53
|
+
it { should == "Bring it on!" }
|
54
|
+
end
|
55
|
+
context "when passed nil input" do
|
56
|
+
subject { insulter.insult_with nil }
|
57
|
+
it { should == "Bring it on!" }
|
58
|
+
end
|
59
|
+
|
47
60
|
context "when passed a single word" do
|
48
61
|
context "which is a noun" do
|
49
62
|
subject { insulter.insult_with("thing") }
|