genderize-io 1.0.0 → 1.2.2

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
  SHA256:
3
- metadata.gz: ebc6e06738af6ebd88bea0db2a23de063cf8105bf7496bb438853bf643cdbba4
4
- data.tar.gz: 9bd34f44ae411ac7c66c6d9f5b8b7844697cda77409d064cf334effd76210568
3
+ metadata.gz: d97f694cd9d6f26d8263dc23af8766af0b11af488455a680c147d08dc86dc7f0
4
+ data.tar.gz: e01d99a26df53237e73cc7f606103d3e90277743c994af2e9d5598450babbc86
5
5
  SHA512:
6
- metadata.gz: 4fb103eaa24e8e7d1e9ebacc4b91aa02ab09c4c68a8a23a43e49a2d3b6c69fcc6250765feb7292f89cc43c47446f58fe218292854539a9ae7d80abbb7d685be2
7
- data.tar.gz: e912b7613bde5cdbb9055345cf989b60462f86329f8b4ed608194276569c6276ee7c81e2416737bedbb560060f5aa9826ac37dbc0feb420db04e250770c4744c
6
+ metadata.gz: 8909ce34c5924cd23df28c586da27ee31af03893bceeca81b37c72ed3aefe691cfcb949b8cf6cdc847a416f5c43a45f26b24e0b968663efc53b796f3fae13dac
7
+ data.tar.gz: 7264b5770065ca8676c7ddb21321048bbfd161d6622d75337e878120748f9690655a266332337f480e6fbd60d4e48bd8ef0d5d6d4fc2aee6b7abce0f802ab617
data/.fasterer.yml CHANGED
@@ -1,19 +1,19 @@
1
1
  speedups:
2
- rescue_vs_respond_to: true
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
- keys_each_vs_each_key: true
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
- block_vs_symbol_to_proc: true
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
- gsub_vs_tr: true
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
@@ -1,9 +1,11 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rubocop.yml CHANGED
@@ -1,24 +1,39 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
1
4
  AllCops:
5
+ TargetRubyVersion: 2.7
6
+ NewCops: enable
2
7
  DisplayCopNames: true
3
8
  DisplayStyleGuide: true
4
- TargetRubyVersion: 2.4
9
+ Gemspec/RequiredRubyVersion:
10
+ Enabled: false
11
+ Layout/EmptyLinesAroundAttributeAccessor:
12
+ Enabled: true
13
+ Layout/EmptyLinesAroundBlockBody:
5
14
  Exclude:
6
15
  - 'spec/**/**/*'
7
- Gemspec/OrderedDependencies:
8
- Enabled: false
9
16
  Layout/EmptyLinesAroundClassBody:
10
- Enabled: false
17
+ EnforcedStyle: empty_lines_except_namespace
11
18
  Layout/EmptyLinesAroundModuleBody:
12
- Enabled: false
13
- LineLength:
19
+ EnforcedStyle: empty_lines_except_namespace
20
+ Layout/LineLength:
14
21
  Max: 100
15
- Lint/ScriptPermission:
16
- Enabled: false
17
- Style/Documentation:
22
+ Layout/SpaceAroundMethodCallOperator:
23
+ Enabled: true
24
+ Lint/RaiseException:
25
+ Enabled: true
26
+ Lint/StructNewOverride:
27
+ Enabled: true
28
+ Metrics/BlockLength:
29
+ Exclude:
30
+ - 'spec/**/**/*'
31
+ - '*.gemspec'
32
+ RSpec/ExampleLength:
18
33
  Enabled: false
19
- Style/MethodMissing:
34
+ RSpec/MultipleExpectations:
20
35
  Enabled: false
21
- Style/PerlBackrefs:
36
+ Style/Documentation:
22
37
  Enabled: false
23
- Style/RegexpLiteral:
38
+ Style/ExpandPathArguments:
24
39
  Enabled: false
data/.travis.yml CHANGED
@@ -1,13 +1,25 @@
1
- before_install:
2
- - sudo apt-get install libxml2-dev
3
- cache: bundler
1
+ sudo: false
4
2
  language: ruby
5
- notifications:
6
- email:
7
- recipients:
8
- - j.gomez@drexed.com
9
- on_failure: change
10
- on_success: never
3
+ cache: bundler
11
4
  rvm:
12
- - ruby-head
13
- script: 'bundle exec rake'
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,26 @@
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.2] - 2020-07-05
10
+ ### Changed
11
+ - Linter fixes
12
+
13
+ ## [1.2.1] - 2020-07-03
14
+ ### Added
15
+ - Added Ruby 2.7 support
16
+
17
+ ## [1.2.0] - 2019-11-17
18
+ ### Added
19
+ - Added CHANGELOG.md
20
+ ### Changed
21
+ - Swap `user_agent_db` for `agents` gem
22
+ - Refactor code to clean up lint errors
23
+
24
+ ## [1.1.0] - 2019-11-17
25
+ ### NOTE
26
+ - 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
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
3
+ ## Our Pledge
4
4
 
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
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
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
12
+ ## Our Standards
8
13
 
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
10
16
 
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
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
- This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- # Specify your gem's dependencies in trumail.gemspec
5
+ # Specify your gem's dependencies in genderize-io.gemspec
6
6
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,93 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ genderize-io (1.2.2)
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.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.0)
25
+ hashdiff (1.0.1)
26
+ parallel (1.20.1)
27
+ parser (3.0.1.1)
28
+ ast (~> 2.4.1)
29
+ public_suffix (4.0.6)
30
+ rainbow (3.0.0)
31
+ rake (13.0.3)
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.14.0)
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.5.0, < 2.0)
54
+ ruby-progressbar (~> 1.7)
55
+ unicode-display_width (>= 1.4.0, < 3.0)
56
+ rubocop-ast (1.5.0)
57
+ parser (>= 3.0.1.1)
58
+ rubocop-performance (1.11.3)
59
+ rubocop (>= 1.7.0, < 2.0)
60
+ rubocop-ast (>= 0.4.0)
61
+ rubocop-rspec (2.3.0)
62
+ rubocop (~> 1.0)
63
+ rubocop-ast (>= 1.1.0)
64
+ ruby-progressbar (1.11.0)
65
+ ruby_parser (3.15.1)
66
+ sexp_processor (~> 4.9)
67
+ sexp_processor (4.15.2)
68
+ typhoeus (1.4.0)
69
+ ethon (>= 0.9.0)
70
+ unicode-display_width (2.0.0)
71
+ vcr (6.0.0)
72
+ webmock (3.12.2)
73
+ addressable (>= 2.3.6)
74
+ crack (>= 0.3.2)
75
+ hashdiff (>= 0.4.0, < 2.0.0)
76
+
77
+ PLATFORMS
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ bundler
82
+ fasterer
83
+ genderize-io!
84
+ rake
85
+ rspec
86
+ rubocop
87
+ rubocop-performance
88
+ rubocop-rspec
89
+ vcr
90
+ webmock
91
+
92
+ BUNDLED WITH
93
+ 2.2.17
data/README.md CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- ### Lookup Determination
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('kim', host: 'https://api.genderize.io?api_key=xxx',
36
- country_id: 'dk',
37
- language_id: 'en')
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
- ### Lookup Methods
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 Determination
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(['kim', 'jim'], host: 'https://api.genderize.io?api_key=xxx',
68
- country_id: 'dk',
69
- language_id: 'en')
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 Lookup Methods
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
- 'rate_limits' => { 'x_rate_limit_limit' => 1069, ... },
78
- 'responses' => [
79
- { 'name' => 'kim', 'gender' => 'female', ... },
80
- { 'name' => 'jim', 'gender' => 'male', ... }
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
- Your contribution is welcome.
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
- 1. Fork it
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
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
4
7
 
5
8
  task default: :spec
data/_config.yml CHANGED
@@ -1 +1 @@
1
- theme: jekyll-theme-cayman
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 'pry'
11
+ # require "pry"
12
12
  # Pry.start
13
13
 
14
14
  require 'irb'
15
- IRB.start
15
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -1,6 +1,7 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
+ set -vx
4
5
 
5
6
  bundle install
6
7
 
data/genderize-io.gemspec CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # coding: utf-8
4
-
5
3
  lib = File.expand_path('../lib', __FILE__)
6
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
5
  require 'genderize/io/version'
@@ -12,23 +10,43 @@ Gem::Specification.new do |spec|
12
10
  spec.authors = ['Juan Gomez']
13
11
  spec.email = ['j.gomez@drexed.com']
14
12
 
15
- spec.summary = 'Genderize.io Ruby SDK.'
16
- 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.'
17
14
  spec.homepage = 'http://drexed.github.io/genderize-io'
18
15
  spec.license = 'MIT'
19
16
 
20
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
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
21
36
  spec.bindir = 'exe'
22
37
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = %w[lib support]
38
+ spec.require_paths = %w[lib]
24
39
 
40
+ spec.add_runtime_dependency 'agents'
25
41
  spec.add_runtime_dependency 'typhoeus'
26
- spec.add_runtime_dependency 'user_agent_db'
27
42
 
28
43
  spec.add_development_dependency 'bundler'
44
+ spec.add_development_dependency 'fasterer'
29
45
  spec.add_development_dependency 'rake'
30
46
  spec.add_development_dependency 'rspec'
31
- spec.add_development_dependency 'fasterer'
32
- spec.add_development_dependency 'reek'
33
47
  spec.add_development_dependency 'rubocop'
48
+ spec.add_development_dependency 'rubocop-performance'
49
+ spec.add_development_dependency 'rubocop-rspec'
50
+ spec.add_development_dependency 'vcr'
51
+ spec.add_development_dependency 'webmock'
34
52
  end
@@ -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 ||= 'https://api.genderize.io'
11
- HEADER_KEYS ||= %w[x_rate_limit_limit x_rate_limit_remaining x_rate_reset].freeze
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
 
@@ -35,23 +37,27 @@ module Genderize
35
37
 
36
38
  def generate_data
37
39
  return if @request.nil?
40
+
38
41
  Genderize::Io::Parser::Json.parse(@request.response_body)
39
42
  end
40
43
 
41
44
  def generate_headers
42
45
  return if @request.nil?
46
+
43
47
  Genderize::Io::Parser::Header.parse(@request.response_headers)
44
48
  end
45
49
 
46
50
  def generate_rate_limits
47
51
  headers = generate_headers
48
52
  return if headers.nil?
53
+
49
54
  HEADER_KEYS.each_with_object({}) { |key, hash| hash[key] = headers.send(key).to_i }
50
55
  end
51
56
 
52
57
  def generate_request
53
58
  return @request unless @request.nil?
54
- Typhoeus::Config.user_agent = UserAgentDB.random
59
+
60
+ Typhoeus::Config.user_agent = Agents.random_user_agent(:desktop)
55
61
  Typhoeus.get(url, accept_encoding: 'gzip,deflate')
56
62
  end
57
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(name, host: host, country_id: country_id, language_id: language_id)
10
- @data = {
11
- 'rate_limits' => {},
12
- 'responses' => []
13
- }
9
+ super
10
+
11
+ @data = { 'rate_limits' => {}, 'responses' => [] }
14
12
  end
15
13
 
16
14
  def determine
@@ -4,10 +4,13 @@ module Genderize
4
4
  module Io
5
5
  class Lookup < Genderize::Io::Base
6
6
 
7
- RESPONSE_KEYS ||= %w[count country_id error language_id gender probability].freeze
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(name, host: host, country_id: country_id, language_id: language_id)
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, *_args)
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(/HTTP\/\d\.\d (\d{3}.*)/)[1]
35
+ @headers[0].match(%r{HTTP/\d\.\d (\d{3}.*)})[1]
32
36
  end
33
37
 
34
38
  def version
35
- @headers[0].match(/HTTP\/\d\.\d/)[0]
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 =~ /^\"(.*)\"$/ ? $1 : val
57
+ val =~ /^"(.*)"$/ ? Regexp.last_match(1) : val
54
58
  end
55
59
 
56
60
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Genderize
4
4
  module Io
5
- VERSION ||= '1.0.0'
5
+
6
+ VERSION = '1.2.2'
7
+
6
8
  end
7
9
  end
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.0.0
4
+ version: 1.2.2
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: 2017-11-29 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: typhoeus
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: user_agent_db
28
+ name: typhoeus
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fasterer
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +95,7 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: fasterer
98
+ name: rubocop
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -95,7 +109,7 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: reek
112
+ name: rubocop-performance
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -109,7 +123,35 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: rubocop
126
+ name: rubocop-rspec
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: vcr
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
113
155
  requirement: !ruby/object:Gem::Requirement
114
156
  requirements:
115
157
  - - ">="
@@ -122,7 +164,7 @@ dependencies:
122
164
  - - ">="
123
165
  - !ruby/object:Gem::Version
124
166
  version: '0'
125
- description: Genderize.io Ruby SDK for interacting with the Genderize.io API.
167
+ description:
126
168
  email:
127
169
  - j.gomez@drexed.com
128
170
  executables: []
@@ -131,17 +173,17 @@ extra_rdoc_files: []
131
173
  files:
132
174
  - ".fasterer.yml"
133
175
  - ".gitignore"
134
- - ".reek"
135
176
  - ".rspec"
136
177
  - ".rubocop.yml"
137
178
  - ".travis.yml"
179
+ - CHANGELOG.md
138
180
  - CODE_OF_CONDUCT.md
139
181
  - Gemfile
182
+ - Gemfile.lock
140
183
  - README.md
141
184
  - Rakefile
142
185
  - _config.yml
143
186
  - bin/console
144
- - bin/rake
145
187
  - bin/setup
146
188
  - genderize-io.gemspec
147
189
  - lib/genderize/io.rb
@@ -155,11 +197,10 @@ homepage: http://drexed.github.io/genderize-io
155
197
  licenses:
156
198
  - MIT
157
199
  metadata: {}
158
- post_install_message:
200
+ post_install_message:
159
201
  rdoc_options: []
160
202
  require_paths:
161
203
  - lib
162
- - support
163
204
  required_ruby_version: !ruby/object:Gem::Requirement
164
205
  requirements:
165
206
  - - ">="
@@ -171,9 +212,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
212
  - !ruby/object:Gem::Version
172
213
  version: '0'
173
214
  requirements: []
174
- rubyforge_project:
175
- rubygems_version: 2.7.2
176
- signing_key:
215
+ rubygems_version: 3.2.17
216
+ signing_key:
177
217
  specification_version: 4
178
- summary: Genderize.io Ruby SDK.
218
+ summary: Genderize.io Ruby SDK for interacting with the Genderize.io API.
179
219
  test_files: []
data/.reek DELETED
@@ -1,27 +0,0 @@
1
- ---
2
- BooleanParameter:
3
- enabled: false
4
- DuplicateMethodCall:
5
- enabled: false
6
- FeatureEnvy:
7
- enabled: false
8
- InstanceVariableAssumption:
9
- enabled: false
10
- IrresponsibleModule:
11
- enabled: false
12
- LongParameterList:
13
- enabled: false
14
- NilCheck:
15
- enabled: false
16
- RepeatedConditional:
17
- enabled: false
18
- TooManyInstanceVariables:
19
- enabled: false
20
- TooManyStatements:
21
- enabled: false
22
- UnusedParameters:
23
- enabled: false
24
- UncommunicativeVariableName:
25
- enabled: false
26
- UtilityFunction:
27
- 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')