genderizr 0.0.8 → 0.1.0

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 +1 @@
1
- module Genderizr; VERSION = '0.0.8'; end
1
+ module Genderizr; VERSION = '0.1.0'; end
data/lib/genderizr.rb CHANGED
@@ -21,7 +21,21 @@ module Genderizr
21
21
  s = StringScanner.new(string)
22
22
  until s.eos? do
23
23
  word = s.scan(/\w+|\W+/)
24
- result << (lookup[word].nil? ? word : lookup[word])
24
+
25
+ if word =~ /^\W+$/
26
+ result << word
27
+ next
28
+ end
29
+
30
+ capitalized = (word == word.capitalize)
31
+ upcased = (word == word.upcase)
32
+
33
+ genderized = (lookup[word.downcase].nil? ? word : lookup[word.downcase])
34
+
35
+ genderized = genderized.capitalize if capitalized
36
+ genderized = genderized.upcase if upcased
37
+
38
+ result << genderized
25
39
  end
26
40
  result
27
41
  end
@@ -54,6 +54,14 @@ shared_examples 'a genderized module' do
54
54
  subject.feminize("\t#{MASCULINE}").should eq " #{FEMININE}"
55
55
  end
56
56
 
57
+ it "preserves capitalization" do
58
+ subject.feminize(MASCULINE.capitalize).should eq FEMININE.capitalize
59
+ end
60
+
61
+ it "preserves upcase" do
62
+ subject.feminize(MASCULINE.upcase).should eq FEMININE.upcase
63
+ end
64
+
57
65
  it "deals with multi-word strings" do
58
66
  subject.feminize("#{MASCULINE} #{MASCULINE} #{FEMININE}").should eq "#{FEMININE} #{FEMININE} #{FEMININE}"
59
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genderizr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: