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 +4 -4
- data/README.md +2 -2
- data/lib/gendered/guesser.rb +12 -12
- data/lib/gendered/version.rb +1 -1
- data/spec/lib/gendered/guesser_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 213cf78b4e398d842b731504c37c8eca47a9c7f6
|
4
|
+
data.tar.gz: 7e98e2fdc2ab330f58da7938250d3a54aa6b0192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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"])
|
data/lib/gendered/guesser.rb
CHANGED
@@ -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
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
|
data/lib/gendered/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|