genderize-io 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.fasterer.yml +12 -12
- data/.gitignore +3 -1
- data/.rubocop.yml +28 -16
- data/.travis.yml +23 -11
- data/CHANGELOG.md +30 -0
- data/CODE_OF_CONDUCT.md +68 -7
- data/Gemfile +1 -1
- data/Gemfile.lock +96 -0
- data/README.md +36 -22
- data/Rakefile +3 -0
- data/_config.yml +1 -1
- data/bin/console +2 -2
- data/bin/setup +2 -1
- data/genderize-io.gemspec +25 -6
- data/lib/genderize/io/base.rb +6 -4
- 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 +43 -17
- 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: eefc153806c261ec8b1ae00ce0d5e9b1de409b60028d056a3969a2d907196e19
|
4
|
+
data.tar.gz: 5f425c3e959a0c4f34da36b3800d143faeac7733d95f158058f276b5152ea9c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf147f0c26294e4c0f8174ba4dbfc54e43fa646f4abffa9b35b2ef8b337f424eed8424efb63414c2d9c78ea27dfb607961c1d8f01bbef33ac4131d1b52e50d49
|
7
|
+
data.tar.gz: 2b2cb0b51fec3187f4fd821b3259901eda546872aed663ff0d68c4de4650ba9dbd5bfbb5178f5312da8870afa0c8c991195774c149cdab91da08398a74edbb52
|
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,42 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rake
|
4
|
+
- rubocop-rspec
|
1
5
|
AllCops:
|
6
|
+
TargetRubyVersion: 3.0
|
7
|
+
NewCops: enable
|
2
8
|
DisplayCopNames: true
|
3
9
|
DisplayStyleGuide: true
|
4
|
-
|
10
|
+
Gemspec/RequiredRubyVersion:
|
11
|
+
Enabled: false
|
12
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
13
|
+
Enabled: true
|
14
|
+
Layout/EmptyLinesAroundBlockBody:
|
5
15
|
Exclude:
|
6
16
|
- 'spec/**/**/*'
|
7
|
-
Gemspec/OrderedDependencies:
|
8
|
-
Enabled: false
|
9
17
|
Layout/EmptyLinesAroundClassBody:
|
10
|
-
|
18
|
+
EnforcedStyle: empty_lines_except_namespace
|
11
19
|
Layout/EmptyLinesAroundModuleBody:
|
12
|
-
|
13
|
-
LineLength:
|
20
|
+
EnforcedStyle: empty_lines_except_namespace
|
21
|
+
Layout/LineLength:
|
14
22
|
Max: 100
|
15
|
-
|
23
|
+
Layout/SpaceAroundMethodCallOperator:
|
24
|
+
Enabled: true
|
25
|
+
Lint/RaiseException:
|
26
|
+
Enabled: true
|
27
|
+
Lint/StructNewOverride:
|
28
|
+
Enabled: true
|
29
|
+
Metrics/BlockLength:
|
30
|
+
Exclude:
|
31
|
+
- 'spec/**/**/*'
|
32
|
+
- '*.gemspec'
|
33
|
+
RSpec/ExampleLength:
|
16
34
|
Enabled: false
|
17
|
-
|
35
|
+
RSpec/MultipleExpectations:
|
36
|
+
Enabled: false
|
37
|
+
Style/ArgumentsForwarding:
|
18
38
|
Enabled: false
|
19
39
|
Style/Documentation:
|
20
40
|
Enabled: false
|
21
41
|
Style/ExpandPathArguments:
|
22
42
|
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,25 @@
|
|
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
|
+
- 2.7
|
8
|
+
- ruby-head
|
9
|
+
matrix:
|
10
|
+
fast_finish: true
|
11
|
+
allow_failures:
|
12
|
+
- rvm: ruby-head
|
13
|
+
before_install:
|
14
|
+
- gem update --system
|
15
|
+
- gem install bundler
|
16
|
+
install:
|
17
|
+
- bundle install --jobs=3 --retry=3
|
18
|
+
script:
|
19
|
+
- bundle exec rspec
|
20
|
+
- bundle exec rubocop
|
21
|
+
- bundle exec fasterer
|
22
|
+
notifications:
|
23
|
+
email: false
|
24
|
+
slack:
|
25
|
+
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,30 @@
|
|
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.3.0] - 2021-07-19
|
10
|
+
### Added
|
11
|
+
- Added Ruby 3.0 support
|
12
|
+
|
13
|
+
## [1.2.2] - 2021-07-05
|
14
|
+
### Changed
|
15
|
+
- Linter fixes
|
16
|
+
|
17
|
+
## [1.2.1] - 2020-07-03
|
18
|
+
### Added
|
19
|
+
- Added Ruby 2.7 support
|
20
|
+
|
21
|
+
## [1.2.0] - 2019-11-17
|
22
|
+
### Added
|
23
|
+
- Added CHANGELOG.md
|
24
|
+
### Changed
|
25
|
+
- Swap `user_agent_db` for `agents` gem
|
26
|
+
- Refactor code to clean up lint errors
|
27
|
+
|
28
|
+
## [1.1.0] - 2019-11-17
|
29
|
+
### NOTE
|
30
|
+
- 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,96 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
genderize-io (1.3.0)
|
5
|
+
agents
|
6
|
+
typhoeus
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.8.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
agents (0.1.4)
|
14
|
+
ast (2.4.2)
|
15
|
+
colorize (0.8.1)
|
16
|
+
crack (0.4.5)
|
17
|
+
rexml
|
18
|
+
diff-lcs (1.4.4)
|
19
|
+
ethon (0.14.0)
|
20
|
+
ffi (>= 1.15.0)
|
21
|
+
fasterer (0.9.0)
|
22
|
+
colorize (~> 0.7)
|
23
|
+
ruby_parser (>= 3.14.1)
|
24
|
+
ffi (1.15.3)
|
25
|
+
hashdiff (1.0.1)
|
26
|
+
parallel (1.20.1)
|
27
|
+
parser (3.0.2.0)
|
28
|
+
ast (~> 2.4.1)
|
29
|
+
public_suffix (4.0.6)
|
30
|
+
rainbow (3.0.0)
|
31
|
+
rake (13.0.6)
|
32
|
+
regexp_parser (2.1.1)
|
33
|
+
rexml (3.2.5)
|
34
|
+
rspec (3.10.0)
|
35
|
+
rspec-core (~> 3.10.0)
|
36
|
+
rspec-expectations (~> 3.10.0)
|
37
|
+
rspec-mocks (~> 3.10.0)
|
38
|
+
rspec-core (3.10.1)
|
39
|
+
rspec-support (~> 3.10.0)
|
40
|
+
rspec-expectations (3.10.1)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.10.0)
|
43
|
+
rspec-mocks (3.10.2)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.10.0)
|
46
|
+
rspec-support (3.10.2)
|
47
|
+
rubocop (1.18.3)
|
48
|
+
parallel (~> 1.10)
|
49
|
+
parser (>= 3.0.0.0)
|
50
|
+
rainbow (>= 2.2.2, < 4.0)
|
51
|
+
regexp_parser (>= 1.8, < 3.0)
|
52
|
+
rexml
|
53
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
54
|
+
ruby-progressbar (~> 1.7)
|
55
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
56
|
+
rubocop-ast (1.8.0)
|
57
|
+
parser (>= 3.0.1.1)
|
58
|
+
rubocop-performance (1.11.4)
|
59
|
+
rubocop (>= 1.7.0, < 2.0)
|
60
|
+
rubocop-ast (>= 0.4.0)
|
61
|
+
rubocop-rake (0.6.0)
|
62
|
+
rubocop (~> 1.0)
|
63
|
+
rubocop-rspec (2.4.0)
|
64
|
+
rubocop (~> 1.0)
|
65
|
+
rubocop-ast (>= 1.1.0)
|
66
|
+
ruby-progressbar (1.11.0)
|
67
|
+
ruby_parser (3.16.0)
|
68
|
+
sexp_processor (~> 4.15, >= 4.15.1)
|
69
|
+
sexp_processor (4.15.3)
|
70
|
+
typhoeus (1.4.0)
|
71
|
+
ethon (>= 0.9.0)
|
72
|
+
unicode-display_width (2.0.0)
|
73
|
+
vcr (6.0.0)
|
74
|
+
webmock (3.13.0)
|
75
|
+
addressable (>= 2.3.6)
|
76
|
+
crack (>= 0.3.2)
|
77
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
bundler
|
84
|
+
fasterer
|
85
|
+
genderize-io!
|
86
|
+
rake
|
87
|
+
rspec
|
88
|
+
rubocop
|
89
|
+
rubocop-performance
|
90
|
+
rubocop-rake
|
91
|
+
rubocop-rspec
|
92
|
+
vcr
|
93
|
+
webmock
|
94
|
+
|
95
|
+
BUNDLED WITH
|
96
|
+
2.2.24
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
### Lookup
|
27
|
+
### Simple Lookup
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
# Basic Lookup
|
@@ -32,12 +32,15 @@ lookup = Genderize::Io::Lookup.new('kim').determine
|
|
32
32
|
lookup = Genderize::Io::Lookup.determine('kim')
|
33
33
|
|
34
34
|
# Custom Options
|
35
|
-
lookup = Genderize::Io::Lookup.determine(
|
36
|
-
|
37
|
-
|
35
|
+
lookup = Genderize::Io::Lookup.determine(
|
36
|
+
'kim',
|
37
|
+
host: 'https://api.genderize.io?api_key=xxx',
|
38
|
+
country_id: 'dk',
|
39
|
+
language_id: 'en'
|
40
|
+
)
|
38
41
|
```
|
39
42
|
|
40
|
-
###
|
43
|
+
### Simple Response
|
41
44
|
|
42
45
|
```ruby
|
43
46
|
lookup.url => 'https://api.genderize.io?name=kim'
|
@@ -56,7 +59,7 @@ lookup.x_rate_reset => 13829
|
|
56
59
|
lookup.error => 'sorry, my bad!'
|
57
60
|
```
|
58
61
|
|
59
|
-
### Batch Lookup
|
62
|
+
### Batch Lookup
|
60
63
|
|
61
64
|
```ruby
|
62
65
|
# Basic Lookup
|
@@ -64,30 +67,41 @@ lookup = Genderize::Io::Batch::Lookup.new(['kim', 'jim']).determine
|
|
64
67
|
lookup = Genderize::Io::Batch::Lookup.determine(['kim', 'jim'])
|
65
68
|
|
66
69
|
# Custom Options
|
67
|
-
lookup = Genderize::Io::Batch::Lookup.determine(
|
68
|
-
|
69
|
-
|
70
|
+
lookup = Genderize::Io::Batch::Lookup.determine(
|
71
|
+
['kim', 'jim'],
|
72
|
+
host: 'https://api.genderize.io?api_key=xxx',
|
73
|
+
country_id: 'dk',
|
74
|
+
language_id: 'en'
|
75
|
+
)
|
70
76
|
```
|
71
77
|
|
72
|
-
### Batch
|
78
|
+
### Batch Response
|
73
79
|
|
74
80
|
```ruby
|
75
81
|
lookup.url => 'https://api.genderize.io?name[0]=kim&name[1]=jim'
|
76
82
|
lookup.data => {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
+
'rate_limits' => { 'x_rate_limit_limit' => 1069, ... },
|
84
|
+
'responses' => [
|
85
|
+
{ 'name' => 'kim', 'gender' => 'female', ... },
|
86
|
+
{ 'name' => 'jim', 'gender' => 'male', ... }
|
87
|
+
]
|
88
|
+
}
|
83
89
|
```
|
84
90
|
|
91
|
+
## Development
|
92
|
+
|
93
|
+
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.
|
94
|
+
|
95
|
+
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).
|
96
|
+
|
85
97
|
## Contributing
|
86
98
|
|
87
|
-
|
99
|
+
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.
|
100
|
+
|
101
|
+
## License
|
102
|
+
|
103
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
104
|
+
|
105
|
+
## Code of Conduct
|
88
106
|
|
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
|
107
|
+
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,44 @@ 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-rake'
|
50
|
+
spec.add_development_dependency 'rubocop-rspec'
|
32
51
|
spec.add_development_dependency 'vcr'
|
33
52
|
spec.add_development_dependency 'webmock'
|
34
53
|
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
|
-
DEFAULT_HOST
|
11
|
-
HEADER_KEYS
|
10
|
+
DEFAULT_HOST = 'https://api.genderize.io'
|
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
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-20 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,35 @@ 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-rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-rspec
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
114
142
|
requirements:
|
115
143
|
- - ">="
|
@@ -150,7 +178,7 @@ dependencies:
|
|
150
178
|
- - ">="
|
151
179
|
- !ruby/object:Gem::Version
|
152
180
|
version: '0'
|
153
|
-
description:
|
181
|
+
description:
|
154
182
|
email:
|
155
183
|
- j.gomez@drexed.com
|
156
184
|
executables: []
|
@@ -159,17 +187,17 @@ extra_rdoc_files: []
|
|
159
187
|
files:
|
160
188
|
- ".fasterer.yml"
|
161
189
|
- ".gitignore"
|
162
|
-
- ".reek.yml"
|
163
190
|
- ".rspec"
|
164
191
|
- ".rubocop.yml"
|
165
192
|
- ".travis.yml"
|
193
|
+
- CHANGELOG.md
|
166
194
|
- CODE_OF_CONDUCT.md
|
167
195
|
- Gemfile
|
196
|
+
- Gemfile.lock
|
168
197
|
- README.md
|
169
198
|
- Rakefile
|
170
199
|
- _config.yml
|
171
200
|
- bin/console
|
172
|
-
- bin/rake
|
173
201
|
- bin/setup
|
174
202
|
- genderize-io.gemspec
|
175
203
|
- lib/genderize/io.rb
|
@@ -183,11 +211,10 @@ homepage: http://drexed.github.io/genderize-io
|
|
183
211
|
licenses:
|
184
212
|
- MIT
|
185
213
|
metadata: {}
|
186
|
-
post_install_message:
|
214
|
+
post_install_message:
|
187
215
|
rdoc_options: []
|
188
216
|
require_paths:
|
189
217
|
- lib
|
190
|
-
- support
|
191
218
|
required_ruby_version: !ruby/object:Gem::Requirement
|
192
219
|
requirements:
|
193
220
|
- - ">="
|
@@ -199,9 +226,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
226
|
- !ruby/object:Gem::Version
|
200
227
|
version: '0'
|
201
228
|
requirements: []
|
202
|
-
|
203
|
-
|
204
|
-
signing_key:
|
229
|
+
rubygems_version: 3.2.24
|
230
|
+
signing_key:
|
205
231
|
specification_version: 4
|
206
|
-
summary: Genderize.io Ruby SDK.
|
232
|
+
summary: Genderize.io Ruby SDK for interacting with the Genderize.io API.
|
207
233
|
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')
|