gendered 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gendered/guesser.rb +5 -3
- data/lib/gendered/name.rb +2 -2
- data/lib/gendered/name_list.rb +2 -2
- data/lib/gendered/version.rb +1 -1
- data/spec/lib/gendered/guesser_spec.rb +5 -0
- data/spec/lib/gendered/name_list_spec.rb +7 -0
- data/spec/lib/gendered/name_spec.rb +6 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f86b31842ddc95c2113669e6f66a5d99aac816a3
|
4
|
+
data.tar.gz: c94175107eea8f35359a3e3ce610c59572847f5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d69366b21df292f59b479a5eba8c16d3055b7de8b457acc968bbf0aa52c7b40057f5e40659d6f5c1334203f2dfb9394226652183cfe41b8240b3ad250ee57582
|
7
|
+
data.tar.gz: dc544551f8658804b434b29269d374f6aa5cbd31df8b1dd4027c063bef8667d2d2a099df7eecab15b5070da432f80acd663fa749f1903b18dd242ae22ef78ae8
|
data/lib/gendered/guesser.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module Gendered
|
2
2
|
class Guesser
|
3
3
|
|
4
|
-
attr_accessor :names
|
4
|
+
attr_accessor :names, :country_id
|
5
5
|
|
6
|
-
def initialize(values)
|
6
|
+
def initialize(values, country_id = nil)
|
7
7
|
raise ArgumentError, "cannot be empty" if Array(values).empty?
|
8
8
|
|
9
9
|
@names = Array(values)
|
10
|
+
@country_id = country_id
|
10
11
|
end
|
11
12
|
|
12
13
|
def guess!
|
@@ -34,11 +35,12 @@ module Gendered
|
|
34
35
|
|
35
36
|
def url
|
36
37
|
url = "http://api.genderize.io/?"
|
38
|
+
url += "country_id=#{country_id}&" if country_id
|
39
|
+
|
37
40
|
name_queries = names.collect.with_index do |name, index|
|
38
41
|
"name[#{index}]=#{CGI.escape(name.to_s)}"
|
39
42
|
end
|
40
43
|
url + name_queries.join("&")
|
41
44
|
end
|
42
|
-
|
43
45
|
end
|
44
46
|
end
|
data/lib/gendered/name.rb
CHANGED
data/lib/gendered/name_list.rb
CHANGED
data/lib/gendered/version.rb
CHANGED
@@ -13,6 +13,11 @@ module Gendered
|
|
13
13
|
expect(subject.names).to eq names
|
14
14
|
end
|
15
15
|
|
16
|
+
it "is initialized with country id" do
|
17
|
+
guesser = Guesser.new(names, 'us')
|
18
|
+
expect(guesser.country_id).to eq 'us'
|
19
|
+
end
|
20
|
+
|
16
21
|
it "creates the correct url" do
|
17
22
|
expect(subject.url).to eq "http://api.genderize.io/?name[0]=Sean&name[1]=Theresa"
|
18
23
|
end
|
@@ -13,6 +13,13 @@ module Gendered
|
|
13
13
|
expect(Guesser).to receive(:new).with(subject.names).and_return(guesser)
|
14
14
|
subject.guess!
|
15
15
|
end
|
16
|
+
|
17
|
+
it 'guesses correctly with country id' do
|
18
|
+
guesser = double(Guesser)
|
19
|
+
expect(guesser).to receive(:guess!).with('us')
|
20
|
+
expect(Guesser).to receive(:new).with(subject.names).and_return(guesser)
|
21
|
+
subject.guess!('us')
|
22
|
+
end
|
16
23
|
end
|
17
24
|
context "when the values are strings" do
|
18
25
|
it "sets the names" do
|
@@ -23,6 +23,12 @@ module Gendered
|
|
23
23
|
it "returns the gender" do
|
24
24
|
expect(subject.guess!).to eq :male
|
25
25
|
end
|
26
|
+
|
27
|
+
it 'returns gender by country id' do
|
28
|
+
name = Gendered::Name.new('kim')
|
29
|
+
expect(name.guess!).to eq :female
|
30
|
+
expect(name.guess!('dk')).to eq :male
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
34
|
describe "#gender=" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gendered
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Devine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.4.5
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Guess the gender of a name.
|
@@ -124,4 +124,3 @@ test_files:
|
|
124
124
|
- spec/lib/gendered/name_list_spec.rb
|
125
125
|
- spec/lib/gendered/name_spec.rb
|
126
126
|
- spec/spec_helper.rb
|
127
|
-
has_rdoc:
|