word_up 0.0.1 → 0.0.2

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.
@@ -1,3 +1,3 @@
1
1
  module WordUp
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/word_up.rb CHANGED
@@ -10,8 +10,11 @@ class String
10
10
 
11
11
  def word_after(w)
12
12
  sentence = self.gsub(/[^0-9a-z ]/i, '').split
13
- param_index = sentence.index(w)
14
- sentence[param_index + 1]
13
+ downcased = sentence.map(&:downcase)
14
+ param_index = downcased.index(w.downcase)
15
+ unless param_index.nil?
16
+ sentence[param_index + 1]
17
+ end
15
18
  end
16
19
 
17
20
  def capitalized?
data/spec/word_up_spec.rb CHANGED
@@ -14,16 +14,27 @@ describe WordUp do
14
14
  end
15
15
 
16
16
  describe "#word_after" do
17
- context "when a word follows"
18
- it "should return the word" do
19
- @sentence1.word_after("is").should == "a"
17
+ context "when a word follows" do
18
+ it "should return the word" do
19
+ @sentence1.word_after("is").should == "a"
20
+ end
21
+
22
+ it "should be case insensitive" do
23
+ @sentence2.word_after("Long").should == "sentence"
24
+ end
20
25
  end
21
26
 
22
- context "when no word follows" do
27
+ context "when no word follows the parameter" do
23
28
  it "should return nil" do
24
29
  @sentence2.word_after("yet").should == nil
25
30
  end
26
31
  end
32
+
33
+ context "when the parameter is not found" do
34
+ it "should return nil" do
35
+ @sentence1.word_after("missing").should == nil
36
+ end
37
+ end
27
38
  end
28
39
 
29
40
  describe "#capitalized?" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: word_up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-02 00:00:00.000000000Z
12
+ date: 2012-09-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70122958275900 !ruby/object:Gem::Requirement
16
+ requirement: &70255972703380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70122958275900
24
+ version_requirements: *70255972703380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70122958275000 !ruby/object:Gem::Requirement
27
+ requirement: &70255972699580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70122958275000
35
+ version_requirements: *70255972699580
36
36
  description: Language analysis tool
37
37
  email:
38
38
  - drurly@gmail.com