genderize-io 1.1.0 → 1.2.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.
- checksums.yaml +4 -4
- data/.fasterer.yml +12 -12
- data/.gitignore +3 -1
- data/.rubocop.yml +14 -16
- data/.travis.yml +22 -11
- data/CHANGELOG.md +18 -0
- data/CODE_OF_CONDUCT.md +68 -7
- data/Gemfile +1 -1
- data/Gemfile.lock +87 -0
- data/README.md +43 -22
- data/Rakefile +3 -0
- data/_config.yml +1 -1
- data/bin/console +2 -2
- data/bin/setup +2 -1
- data/genderize-io.gemspec +24 -6
- data/lib/genderize/io/base.rb +5 -3
- data/lib/genderize/io/batch/lookup.rb +3 -5
- data/lib/genderize/io/lookup.rb +5 -2
- data/lib/genderize/io/parser/header.rb +9 -5
- data/lib/genderize/io/version.rb +3 -1
- metadata +26 -14
- data/.reek.yml +0 -28
- data/bin/rake +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c70aa532119519cef8bccf2bef58bbdb9afdcba8abd4f88fe0b6a8621eaef4c
|
|
4
|
+
data.tar.gz: 466736b3a9127dd5260914a80a46ddf91e670603105fbb79077fc16f2d07eed2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3dd1223fd6f72fac667d2c1a5d1cbb33655bf7831b6b6dbb0c0fa3e702fcda45efbe872f50144467b55b1b7618934ab5c20e35df0686019b8486735423fefe88
|
|
7
|
+
data.tar.gz: 55a29a8e3ddb9044de27ec9dfe1e4b23bea78f96f0fa08bcae0159332a9324cc7e2cb529cdad01cd8a09735f6855c7960ec726c6de3f3f636a6ab8052db7dcd7
|
data/.fasterer.yml
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
speedups:
|
|
2
|
-
|
|
3
|
-
module_eval: true
|
|
4
|
-
shuffle_first_vs_sample: true
|
|
5
|
-
for_loop_vs_each: true
|
|
2
|
+
block_vs_symbol_to_proc: true
|
|
6
3
|
each_with_index_vs_while: false
|
|
7
|
-
map_flatten_vs_flat_map: true
|
|
8
|
-
reverse_each_vs_reverse_each: true
|
|
9
|
-
select_first_vs_detect: true
|
|
10
|
-
sort_vs_sort_by: true
|
|
11
4
|
fetch_with_argument_vs_block: true
|
|
12
|
-
|
|
5
|
+
for_loop_vs_each: true
|
|
6
|
+
getter_vs_attr_reader: true
|
|
7
|
+
gsub_vs_tr: true
|
|
13
8
|
hash_merge_bang_vs_hash_brackets: true
|
|
14
|
-
|
|
9
|
+
keys_each_vs_each_key: true
|
|
10
|
+
map_flatten_vs_flat_map: true
|
|
11
|
+
module_eval: true
|
|
15
12
|
proc_call_vs_yield: true
|
|
16
|
-
|
|
13
|
+
rescue_vs_respond_to: true
|
|
14
|
+
reverse_each_vs_reverse_each: true
|
|
15
|
+
select_first_vs_detect: true
|
|
17
16
|
select_last_vs_reverse_detect: true
|
|
18
|
-
getter_vs_attr_reader: true
|
|
19
17
|
setter_vs_attr_writer: true
|
|
18
|
+
shuffle_first_vs_sample: true
|
|
19
|
+
sort_vs_sort_by: true
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-performance
|
|
3
|
+
- rubocop-rspec
|
|
1
4
|
AllCops:
|
|
5
|
+
TargetRubyVersion: 2.6
|
|
2
6
|
DisplayCopNames: true
|
|
3
7
|
DisplayStyleGuide: true
|
|
4
|
-
|
|
8
|
+
Layout/EmptyLinesAroundBlockBody:
|
|
5
9
|
Exclude:
|
|
6
10
|
- 'spec/**/**/*'
|
|
7
|
-
Gemspec/OrderedDependencies:
|
|
8
|
-
Enabled: false
|
|
9
11
|
Layout/EmptyLinesAroundClassBody:
|
|
10
|
-
|
|
12
|
+
EnforcedStyle: empty_lines_except_namespace
|
|
11
13
|
Layout/EmptyLinesAroundModuleBody:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
EnforcedStyle: empty_lines_except_namespace
|
|
15
|
+
Metrics/BlockLength:
|
|
16
|
+
Exclude:
|
|
17
|
+
- 'spec/**/**/*'
|
|
18
|
+
- '*.gemspec'
|
|
19
|
+
Metrics/LineLength:
|
|
14
20
|
Max: 100
|
|
15
|
-
|
|
21
|
+
RSpec/ExampleLength:
|
|
16
22
|
Enabled: false
|
|
17
|
-
|
|
23
|
+
RSpec/MultipleExpectations:
|
|
18
24
|
Enabled: false
|
|
19
25
|
Style/Documentation:
|
|
20
26
|
Enabled: false
|
|
21
27
|
Style/ExpandPathArguments:
|
|
22
28
|
Enabled: false
|
|
23
|
-
Style/MethodMissingSuper:
|
|
24
|
-
Enabled: false
|
|
25
|
-
Style/MissingRespondToMissing:
|
|
26
|
-
Enabled: false
|
|
27
|
-
Style/PerlBackrefs:
|
|
28
|
-
Enabled: false
|
|
29
|
-
Style/RegexpLiteral:
|
|
30
|
-
Enabled: false
|
data/.travis.yml
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
- sudo apt-get install libxml2-dev
|
|
3
|
-
cache: bundler
|
|
1
|
+
sudo: false
|
|
4
2
|
language: ruby
|
|
5
|
-
|
|
6
|
-
email:
|
|
7
|
-
recipients:
|
|
8
|
-
- j.gomez@drexed.com
|
|
9
|
-
on_failure: change
|
|
10
|
-
on_success: never
|
|
3
|
+
cache: bundler
|
|
11
4
|
rvm:
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
- 2.5
|
|
6
|
+
- 2.6
|
|
7
|
+
- ruby-head
|
|
8
|
+
matrix:
|
|
9
|
+
fast_finish: true
|
|
10
|
+
allow_failures:
|
|
11
|
+
- rvm: ruby-head
|
|
12
|
+
before_install:
|
|
13
|
+
- gem update --system
|
|
14
|
+
- gem install bundler
|
|
15
|
+
install:
|
|
16
|
+
- bundle install --jobs=3 --retry=3
|
|
17
|
+
script:
|
|
18
|
+
- bundle exec rspec
|
|
19
|
+
- bundle exec rubocop
|
|
20
|
+
- bundle exec fasterer
|
|
21
|
+
notifications:
|
|
22
|
+
email: false
|
|
23
|
+
slack:
|
|
24
|
+
secure: bhsBY6XgILtpi5jt/WI4c95BuBTcXindABygXhmPGWNxn/pmbM/kzssvA+P9p29PWW3sgOSPDh8Ofkxv//8Fft4prM2duh8WLxHzroBDeEgl6I9ZTOmE2cx8gjcoyHk0UpBO90xhoqaKFLQNJ5q0Ajd4UIE+tPQlArXlNIrMbNRNfBTc1UYBX9C644RXPWLXmdyHgpc7gAvVakH+tKUA1PH8Xi1+PBSKHL4DGiGLj0kjuH/ik7HP5U4XnKfxnmmwSMDf04yLMHp5C9EpAvvRAsaH53DDQuU6LUdcZnGhhqYOebWY1QhAWCwSf52dZpySCysYwGk8dvhsD/2TFVc/8QwPiBueO+i9/J55OUR9z+BPLZ1VJYQK49kJUretM9H2h21YmbyjeiDtPF8mULXKEelWIrARFKa6ywYzSSxXu2Td3afGVigh5dd1X9B5aF2o2Z9ZbMynAyuzUa5YcwyuHM2YDb//RnV2hZPSOi0KpehG497o8oRcECADAu9HYgYPQGv/kujYsSZtH6VScDFL27vXH/F5P3cs2XirNM4pTF/1eOs3lhRGxn42e2vpYt0ODw+KyztfsGi/cN00TZgsL2b/d9BWZK3FUgFBkoqTBaSs2xtjSZ2MzElQBzg/HCVFL8LAdqWL5MFhZ7s4R0E71onOCZEcojmlEKF1e5zCIrI=
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [1.2.0] - 2019-11-17
|
|
10
|
+
### Added
|
|
11
|
+
- Added CHANGELOG.md
|
|
12
|
+
### Changed
|
|
13
|
+
- Swap `user_agent_db` for `agents` gem
|
|
14
|
+
- Refactor code to clean up lint errors
|
|
15
|
+
|
|
16
|
+
## [1.1.0] - 2019-11-17
|
|
17
|
+
### NOTE
|
|
18
|
+
- Previous version without CHANGELOG.md
|
data/CODE_OF_CONDUCT.md
CHANGED
|
@@ -1,13 +1,74 @@
|
|
|
1
|
-
# Contributor Code of Conduct
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Our Pledge
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
## Our Standards
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
12
22
|
|
|
13
|
-
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at j.gomez@drexed.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
genderize-io (1.2.0)
|
|
5
|
+
agents
|
|
6
|
+
typhoeus
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
addressable (2.7.0)
|
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
13
|
+
agents (0.1.4)
|
|
14
|
+
ast (2.4.0)
|
|
15
|
+
colorize (0.8.1)
|
|
16
|
+
crack (0.4.3)
|
|
17
|
+
safe_yaml (~> 1.0.0)
|
|
18
|
+
diff-lcs (1.3)
|
|
19
|
+
ethon (0.12.0)
|
|
20
|
+
ffi (>= 1.3.0)
|
|
21
|
+
fasterer (0.8.0)
|
|
22
|
+
colorize (~> 0.7)
|
|
23
|
+
ruby_parser (>= 3.14.1)
|
|
24
|
+
ffi (1.11.2)
|
|
25
|
+
hashdiff (1.0.0)
|
|
26
|
+
jaro_winkler (1.5.4)
|
|
27
|
+
parallel (1.19.0)
|
|
28
|
+
parser (2.6.5.0)
|
|
29
|
+
ast (~> 2.4.0)
|
|
30
|
+
public_suffix (4.0.1)
|
|
31
|
+
rainbow (3.0.0)
|
|
32
|
+
rake (13.0.1)
|
|
33
|
+
rspec (3.9.0)
|
|
34
|
+
rspec-core (~> 3.9.0)
|
|
35
|
+
rspec-expectations (~> 3.9.0)
|
|
36
|
+
rspec-mocks (~> 3.9.0)
|
|
37
|
+
rspec-core (3.9.0)
|
|
38
|
+
rspec-support (~> 3.9.0)
|
|
39
|
+
rspec-expectations (3.9.0)
|
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
41
|
+
rspec-support (~> 3.9.0)
|
|
42
|
+
rspec-mocks (3.9.0)
|
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
44
|
+
rspec-support (~> 3.9.0)
|
|
45
|
+
rspec-support (3.9.0)
|
|
46
|
+
rubocop (0.76.0)
|
|
47
|
+
jaro_winkler (~> 1.5.1)
|
|
48
|
+
parallel (~> 1.10)
|
|
49
|
+
parser (>= 2.6)
|
|
50
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
51
|
+
ruby-progressbar (~> 1.7)
|
|
52
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
|
53
|
+
rubocop-performance (1.5.1)
|
|
54
|
+
rubocop (>= 0.71.0)
|
|
55
|
+
rubocop-rspec (1.36.0)
|
|
56
|
+
rubocop (>= 0.68.1)
|
|
57
|
+
ruby-progressbar (1.10.1)
|
|
58
|
+
ruby_parser (3.14.1)
|
|
59
|
+
sexp_processor (~> 4.9)
|
|
60
|
+
safe_yaml (1.0.5)
|
|
61
|
+
sexp_processor (4.13.0)
|
|
62
|
+
typhoeus (1.3.1)
|
|
63
|
+
ethon (>= 0.9.0)
|
|
64
|
+
unicode-display_width (1.6.0)
|
|
65
|
+
vcr (5.0.0)
|
|
66
|
+
webmock (3.7.6)
|
|
67
|
+
addressable (>= 2.3.6)
|
|
68
|
+
crack (>= 0.3.2)
|
|
69
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
70
|
+
|
|
71
|
+
PLATFORMS
|
|
72
|
+
ruby
|
|
73
|
+
|
|
74
|
+
DEPENDENCIES
|
|
75
|
+
bundler
|
|
76
|
+
fasterer
|
|
77
|
+
genderize-io!
|
|
78
|
+
rake
|
|
79
|
+
rspec
|
|
80
|
+
rubocop
|
|
81
|
+
rubocop-performance
|
|
82
|
+
rubocop-rspec
|
|
83
|
+
vcr
|
|
84
|
+
webmock
|
|
85
|
+
|
|
86
|
+
BUNDLED WITH
|
|
87
|
+
1.17.3
|
data/README.md
CHANGED
|
@@ -22,9 +22,16 @@ Or install it yourself as:
|
|
|
22
22
|
|
|
23
23
|
$ gem install genderize-io
|
|
24
24
|
|
|
25
|
+
## Table of Contents
|
|
26
|
+
|
|
27
|
+
* [Simple Lookup](#simple-lookup)
|
|
28
|
+
* [Simple Response](#simple-response)
|
|
29
|
+
* [Batch Lookup](#batch-lookup)
|
|
30
|
+
* [Batch Response](#batch-response)
|
|
31
|
+
|
|
25
32
|
## Usage
|
|
26
33
|
|
|
27
|
-
### Lookup
|
|
34
|
+
### Simple Lookup
|
|
28
35
|
|
|
29
36
|
```ruby
|
|
30
37
|
# Basic Lookup
|
|
@@ -32,12 +39,15 @@ lookup = Genderize::Io::Lookup.new('kim').determine
|
|
|
32
39
|
lookup = Genderize::Io::Lookup.determine('kim')
|
|
33
40
|
|
|
34
41
|
# Custom Options
|
|
35
|
-
lookup = Genderize::Io::Lookup.determine(
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
lookup = Genderize::Io::Lookup.determine(
|
|
43
|
+
'kim',
|
|
44
|
+
host: 'https://api.genderize.io?api_key=xxx',
|
|
45
|
+
country_id: 'dk',
|
|
46
|
+
language_id: 'en'
|
|
47
|
+
)
|
|
38
48
|
```
|
|
39
49
|
|
|
40
|
-
###
|
|
50
|
+
### Simple Response
|
|
41
51
|
|
|
42
52
|
```ruby
|
|
43
53
|
lookup.url => 'https://api.genderize.io?name=kim'
|
|
@@ -56,7 +66,7 @@ lookup.x_rate_reset => 13829
|
|
|
56
66
|
lookup.error => 'sorry, my bad!'
|
|
57
67
|
```
|
|
58
68
|
|
|
59
|
-
### Batch Lookup
|
|
69
|
+
### Batch Lookup
|
|
60
70
|
|
|
61
71
|
```ruby
|
|
62
72
|
# Basic Lookup
|
|
@@ -64,30 +74,41 @@ lookup = Genderize::Io::Batch::Lookup.new(['kim', 'jim']).determine
|
|
|
64
74
|
lookup = Genderize::Io::Batch::Lookup.determine(['kim', 'jim'])
|
|
65
75
|
|
|
66
76
|
# Custom Options
|
|
67
|
-
lookup = Genderize::Io::Batch::Lookup.determine(
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
lookup = Genderize::Io::Batch::Lookup.determine(
|
|
78
|
+
['kim', 'jim'],
|
|
79
|
+
host: 'https://api.genderize.io?api_key=xxx',
|
|
80
|
+
country_id: 'dk',
|
|
81
|
+
language_id: 'en'
|
|
82
|
+
)
|
|
70
83
|
```
|
|
71
84
|
|
|
72
|
-
### Batch
|
|
85
|
+
### Batch Response
|
|
73
86
|
|
|
74
87
|
```ruby
|
|
75
88
|
lookup.url => 'https://api.genderize.io?name[0]=kim&name[1]=jim'
|
|
76
89
|
lookup.data => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
'rate_limits' => { 'x_rate_limit_limit' => 1069, ... },
|
|
91
|
+
'responses' => [
|
|
92
|
+
{ 'name' => 'kim', 'gender' => 'female', ... },
|
|
93
|
+
{ 'name' => 'jim', 'gender' => 'male', ... }
|
|
94
|
+
]
|
|
95
|
+
}
|
|
83
96
|
```
|
|
84
97
|
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
101
|
+
|
|
102
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
103
|
+
|
|
85
104
|
## Contributing
|
|
86
105
|
|
|
87
|
-
|
|
106
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/genderize-io. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
111
|
+
|
|
112
|
+
## Code of Conduct
|
|
88
113
|
|
|
89
|
-
|
|
90
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
91
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
92
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
93
|
-
5. Create new Pull Request
|
|
114
|
+
Everyone interacting in the Genderize::Io project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/genderize-io/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/_config.yml
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
theme: jekyll-theme-
|
|
1
|
+
theme: jekyll-theme-leap-day
|
data/bin/console
CHANGED
|
@@ -8,8 +8,8 @@ require 'genderize/io'
|
|
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
|
9
9
|
|
|
10
10
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
-
# require
|
|
11
|
+
# require "pry"
|
|
12
12
|
# Pry.start
|
|
13
13
|
|
|
14
14
|
require 'irb'
|
|
15
|
-
IRB.start
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
data/genderize-io.gemspec
CHANGED
|
@@ -10,25 +10,43 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.authors = ['Juan Gomez']
|
|
11
11
|
spec.email = ['j.gomez@drexed.com']
|
|
12
12
|
|
|
13
|
-
spec.summary = 'Genderize.io Ruby SDK.'
|
|
14
|
-
spec.description = 'Genderize.io Ruby SDK for interacting with the Genderize.io API.'
|
|
13
|
+
spec.summary = 'Genderize.io Ruby SDK for interacting with the Genderize.io API.'
|
|
15
14
|
spec.homepage = 'http://drexed.github.io/genderize-io'
|
|
16
15
|
spec.license = 'MIT'
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata.merge(
|
|
21
|
+
'allowed_push_host' => 'https://rubygems.org',
|
|
22
|
+
'changelog_uri' => 'https://github.com/drexed/genderize-io/blob/master/CHANGELOG.md',
|
|
23
|
+
'homepage_uri' => spec.homepage,
|
|
24
|
+
'source_code_uri' => 'https://github.com/drexed/genderize-io'
|
|
25
|
+
)
|
|
26
|
+
else
|
|
27
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
|
28
|
+
'public gem pushes.'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Specify which files should be added to the gem when it is released.
|
|
32
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
33
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
34
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
35
|
+
end
|
|
19
36
|
spec.bindir = 'exe'
|
|
20
37
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
21
|
-
spec.require_paths = %w[lib
|
|
38
|
+
spec.require_paths = %w[lib]
|
|
22
39
|
|
|
40
|
+
spec.add_runtime_dependency 'agents'
|
|
23
41
|
spec.add_runtime_dependency 'typhoeus'
|
|
24
|
-
spec.add_runtime_dependency 'user_agent_db'
|
|
25
42
|
|
|
26
43
|
spec.add_development_dependency 'bundler'
|
|
27
44
|
spec.add_development_dependency 'fasterer'
|
|
28
45
|
spec.add_development_dependency 'rake'
|
|
29
|
-
spec.add_development_dependency 'reek'
|
|
30
46
|
spec.add_development_dependency 'rspec'
|
|
31
47
|
spec.add_development_dependency 'rubocop'
|
|
48
|
+
spec.add_development_dependency 'rubocop-performance'
|
|
49
|
+
spec.add_development_dependency 'rubocop-rspec'
|
|
32
50
|
spec.add_development_dependency 'vcr'
|
|
33
51
|
spec.add_development_dependency 'webmock'
|
|
34
52
|
end
|
data/lib/genderize/io/base.rb
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'agents'
|
|
3
4
|
require 'typhoeus'
|
|
4
|
-
require 'user_agent_db'
|
|
5
5
|
|
|
6
6
|
module Genderize
|
|
7
7
|
module Io
|
|
8
8
|
class Base
|
|
9
9
|
|
|
10
10
|
DEFAULT_HOST ||= 'https://api.genderize.io'
|
|
11
|
-
HEADER_KEYS ||= %w[
|
|
11
|
+
HEADER_KEYS ||= %w[
|
|
12
|
+
x_rate_limit_limit x_rate_limit_remaining x_rate_reset
|
|
13
|
+
].freeze
|
|
12
14
|
|
|
13
15
|
attr_reader :country_id, :data, :host, :language_id, :name, :request
|
|
14
16
|
|
|
@@ -55,7 +57,7 @@ module Genderize
|
|
|
55
57
|
def generate_request
|
|
56
58
|
return @request unless @request.nil?
|
|
57
59
|
|
|
58
|
-
Typhoeus::Config.user_agent =
|
|
60
|
+
Typhoeus::Config.user_agent = Agents.random_user_agent(:desktop)
|
|
59
61
|
Typhoeus.get(url, accept_encoding: 'gzip,deflate')
|
|
60
62
|
end
|
|
61
63
|
|
|
@@ -6,11 +6,9 @@ module Genderize
|
|
|
6
6
|
class Lookup < Genderize::Io::Base
|
|
7
7
|
|
|
8
8
|
def initialize(name, host: DEFAULT_HOST, country_id: nil, language_id: nil)
|
|
9
|
-
super
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'responses' => []
|
|
13
|
-
}
|
|
9
|
+
super
|
|
10
|
+
|
|
11
|
+
@data = { 'rate_limits' => {}, 'responses' => [] }
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
def determine
|
data/lib/genderize/io/lookup.rb
CHANGED
|
@@ -4,10 +4,13 @@ module Genderize
|
|
|
4
4
|
module Io
|
|
5
5
|
class Lookup < Genderize::Io::Base
|
|
6
6
|
|
|
7
|
-
RESPONSE_KEYS ||= %w[
|
|
7
|
+
RESPONSE_KEYS ||= %w[
|
|
8
|
+
count country_id error language_id gender probability
|
|
9
|
+
].freeze
|
|
8
10
|
|
|
9
11
|
def initialize(name, host: DEFAULT_HOST, country_id: nil, language_id: nil)
|
|
10
|
-
super
|
|
12
|
+
super
|
|
13
|
+
|
|
11
14
|
@data = {}
|
|
12
15
|
end
|
|
13
16
|
|
|
@@ -23,16 +23,20 @@ module Genderize
|
|
|
23
23
|
@headers = @response.split(/\\r\\n|\n|\r/)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def method_missing(sym, *
|
|
27
|
-
detect_multi_value_keys(sym)
|
|
26
|
+
def method_missing(sym, *)
|
|
27
|
+
detect_multi_value_keys(sym) || super
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def respond_to_missing?(sym, *)
|
|
31
|
+
detect_multi_value_keys(sym) || super
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def response_code
|
|
31
|
-
@headers[0].match(
|
|
35
|
+
@headers[0].match(%r{HTTP/\d\.\d (\d{3}.*)})[1]
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
def version
|
|
35
|
-
@headers[0].match(
|
|
39
|
+
@headers[0].match(%r{HTTP/\d\.\d})[0]
|
|
36
40
|
end
|
|
37
41
|
|
|
38
42
|
private
|
|
@@ -50,7 +54,7 @@ module Genderize
|
|
|
50
54
|
|
|
51
55
|
def value_from(tag)
|
|
52
56
|
val = tag.split(/:\s+/)[1]
|
|
53
|
-
val =~ /^\"(.*)\"$/ ?
|
|
57
|
+
val =~ /^\"(.*)\"$/ ? Regexp.last_match(1) : val
|
|
54
58
|
end
|
|
55
59
|
|
|
56
60
|
end
|
data/lib/genderize/io/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: genderize-io
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juan Gomez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-11-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: agents
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: typhoeus
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
@@ -81,7 +81,7 @@ dependencies:
|
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
84
|
+
name: rspec
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - ">="
|
|
@@ -95,7 +95,7 @@ dependencies:
|
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
98
|
+
name: rubocop
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - ">="
|
|
@@ -109,7 +109,21 @@ dependencies:
|
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: rubocop
|
|
112
|
+
name: rubocop-performance
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: rubocop-rspec
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
114
128
|
requirements:
|
|
115
129
|
- - ">="
|
|
@@ -150,7 +164,7 @@ dependencies:
|
|
|
150
164
|
- - ">="
|
|
151
165
|
- !ruby/object:Gem::Version
|
|
152
166
|
version: '0'
|
|
153
|
-
description:
|
|
167
|
+
description:
|
|
154
168
|
email:
|
|
155
169
|
- j.gomez@drexed.com
|
|
156
170
|
executables: []
|
|
@@ -159,17 +173,17 @@ extra_rdoc_files: []
|
|
|
159
173
|
files:
|
|
160
174
|
- ".fasterer.yml"
|
|
161
175
|
- ".gitignore"
|
|
162
|
-
- ".reek.yml"
|
|
163
176
|
- ".rspec"
|
|
164
177
|
- ".rubocop.yml"
|
|
165
178
|
- ".travis.yml"
|
|
179
|
+
- CHANGELOG.md
|
|
166
180
|
- CODE_OF_CONDUCT.md
|
|
167
181
|
- Gemfile
|
|
182
|
+
- Gemfile.lock
|
|
168
183
|
- README.md
|
|
169
184
|
- Rakefile
|
|
170
185
|
- _config.yml
|
|
171
186
|
- bin/console
|
|
172
|
-
- bin/rake
|
|
173
187
|
- bin/setup
|
|
174
188
|
- genderize-io.gemspec
|
|
175
189
|
- lib/genderize/io.rb
|
|
@@ -187,7 +201,6 @@ post_install_message:
|
|
|
187
201
|
rdoc_options: []
|
|
188
202
|
require_paths:
|
|
189
203
|
- lib
|
|
190
|
-
- support
|
|
191
204
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
205
|
requirements:
|
|
193
206
|
- - ">="
|
|
@@ -199,9 +212,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
199
212
|
- !ruby/object:Gem::Version
|
|
200
213
|
version: '0'
|
|
201
214
|
requirements: []
|
|
202
|
-
|
|
203
|
-
rubygems_version: 2.7.7
|
|
215
|
+
rubygems_version: 3.0.6
|
|
204
216
|
signing_key:
|
|
205
217
|
specification_version: 4
|
|
206
|
-
summary: Genderize.io Ruby SDK.
|
|
218
|
+
summary: Genderize.io Ruby SDK for interacting with the Genderize.io API.
|
|
207
219
|
test_files: []
|
data/.reek.yml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
detectors:
|
|
3
|
-
BooleanParameter:
|
|
4
|
-
enabled: false
|
|
5
|
-
DuplicateMethodCall:
|
|
6
|
-
enabled: false
|
|
7
|
-
FeatureEnvy:
|
|
8
|
-
enabled: false
|
|
9
|
-
InstanceVariableAssumption:
|
|
10
|
-
enabled: false
|
|
11
|
-
IrresponsibleModule:
|
|
12
|
-
enabled: false
|
|
13
|
-
LongParameterList:
|
|
14
|
-
enabled: false
|
|
15
|
-
NilCheck:
|
|
16
|
-
enabled: false
|
|
17
|
-
RepeatedConditional:
|
|
18
|
-
enabled: false
|
|
19
|
-
TooManyInstanceVariables:
|
|
20
|
-
enabled: false
|
|
21
|
-
TooManyStatements:
|
|
22
|
-
enabled: false
|
|
23
|
-
UnusedParameters:
|
|
24
|
-
enabled: false
|
|
25
|
-
UncommunicativeVariableName:
|
|
26
|
-
enabled: false
|
|
27
|
-
UtilityFunction:
|
|
28
|
-
enabled: false
|
data/bin/rake
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
# This file was generated by Bundler.
|
|
5
|
-
#
|
|
6
|
-
# The application 'rake' is installed as part of a gem, and
|
|
7
|
-
# this file is here to facilitate running it.
|
|
8
|
-
|
|
9
|
-
require 'pathname'
|
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
|
|
11
|
-
|
|
12
|
-
require 'rubygems'
|
|
13
|
-
require 'bundler/setup'
|
|
14
|
-
|
|
15
|
-
load Gem.bin_path('rake', 'rake')
|