urmum 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 566135a23494d1c681ca731511c6719398b9caf7
4
- data.tar.gz: 139b589eecf1dcc259c2cf24a831fbc001071e60
3
+ metadata.gz: 79c709746855bddedda2edad419e886e22a4fc1d
4
+ data.tar.gz: ab8c75bca238bde7ecabc927d657f42be8a37ccb
5
5
  SHA512:
6
- metadata.gz: 54895bc52cfcda4232fcc02d7e2425681b6124c1b5965e478c56075f0ff1e63db2f5bf85d9fa0f312ffe978116653dcdf4a8fd698387299d676f5d9902cffcf0
7
- data.tar.gz: d9a033a6c72aaae8d1d5ceacd76f0e983e794430faac817e0adf9e3577a5247d7c45cd69ac61ea042aef6ac8990dcd56e805b48676f40be5efb93f64c1c38a1e
6
+ metadata.gz: 00ba2f1f146ab11e3d3607df9d1bb5793c6bbee970edd74473d234112da6226499c02982a7a75eafffb2b455179d6e929b5d298dcfb7155afc054282ce0cfadf
7
+ data.tar.gz: c4b5e7b8a9e73691e4ecf5d8c921cabd1df4b4b2030ae1ad8d06c5cd316289098860955b53d60059f6f653d585d8a3d86031c500ce0ee271e6bbf9e9740a8026
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Urmum
2
- VERSION = "0.0.0"
2
+ VERSION = "0.0.1"
3
3
  end
@@ -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") }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urmum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duncan Stuart