gendered 0.0.3 → 0.0.4

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: 068779934b3427d6384b168d8245413af6049192
4
- data.tar.gz: dbec58cf7001b7f72dcd51b769d8eb4cb1647cfc
3
+ metadata.gz: 213cf78b4e398d842b731504c37c8eca47a9c7f6
4
+ data.tar.gz: 7e98e2fdc2ab330f58da7938250d3a54aa6b0192
5
5
  SHA512:
6
- metadata.gz: 83588c1c1bd0196cbf28cbe4c4ad6c8a3521e2be5b8a43f425b6b806f49bbb874d707fa8cc7d8c082ed6d1526c8770289fd93b8b09d49295bef714d5d2350dfe
7
- data.tar.gz: 6003d7bed6f5d4d8f93188af3e62333d911fd4d1579f7629e3a21ec049929ce134f59598f8e4a3de1e48aa368c1150612176b12e25eb85d2b52106c202fe8bb0
6
+ metadata.gz: 74eb2b0daeb45432a588304c21b30be3338a434828e6876501b142a37b159bf5960ab3afcc7c475da87ccf09366b7e410976d5da5fdff19691f86ba1253dbc2a
7
+ data.tar.gz: 42d7e26ea68a38ef090e5a230a3dea8b7b6d07a948ea8213249029601f6ba3314808d5edfda2ece6cd52f19831fc782649aa69daa6e3b0e989123f299c34e81e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **THIS LIBRARY IS STILL IN DEVELOPMENT.**
4
4
 
5
- Guess the gender of a name with the help of the [genderize.io](http://genderize.io).
5
+ Guess the gender of names with the help of the [genderize.io](http://genderize.io).
6
6
 
7
7
  ```bash
8
8
  gem install gendered
@@ -26,7 +26,7 @@ You can guess one name at a time...
26
26
  => 967
27
27
  ```
28
28
 
29
- Or batch up a list of names (which sends only one request to the API)...
29
+ Or batch up a list of names (which sends only one request per hundred names to the API)...
30
30
  ```ruby
31
31
  > require 'gendered'
32
32
  > name_list = Gendered::NameList.new(["Sean","Theresa"])
@@ -13,22 +13,22 @@ module Gendered
13
13
  response = HTTP.get(url)
14
14
  case response.code
15
15
  when 200
16
- @names = JSON.parse(response.body).collect do |guess|
17
- name = names.find { |n| n.to_s == guess["name"] }
18
16
 
19
- if name.is_a?(String)
20
- name = Name.new(guess["name"])
21
- end
17
+ guesses = JSON.parse(response.body)
18
+
19
+ names.collect do |name|
20
+ name = Name.new(name) if name.is_a?(String)
22
21
 
23
- name.tap do |n|
24
- if guess["gender"]
25
- n.gender = guess["gender"].to_sym
26
- n.probability = guess["probability"]
27
- n.sample_size = guess["count"]
28
- end
22
+ guess = guesses.find { |g| g["name"] == name.value }
23
+
24
+ if guess["gender"]
25
+ name.gender = guess["gender"].to_sym
26
+ name.probability = guess["probability"]
27
+ name.sample_size = guess["count"]
29
28
  end
29
+
30
+ name
30
31
  end
31
- self.names
32
32
  end
33
33
  end
34
34
 
@@ -1,3 +1,3 @@
1
1
  module Gendered
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -39,5 +39,15 @@ module Gendered
39
39
  end
40
40
  end
41
41
 
42
+ context "with multiple names that are the same" do
43
+ let :names do
44
+ ["Sean","Sean"]
45
+ end
46
+ it "guesses them both" do
47
+ guesses = subject.guess!
48
+ expect(guesses.collect(&:gender).uniq.size).to eq 1
49
+ end
50
+ end
51
+
42
52
  end
43
53
  end
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Devine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-05 00:00:00.000000000 Z
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http