gender_detector 1.0.0 → 2.0.0

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: fdee5d9e457b4a5c4c9e6dd8f52e64cd86fe1bff
4
- data.tar.gz: 41b06696c8af71759cfffc69c9268471a8cb578d
3
+ metadata.gz: 7c5163b78567fcc01065054f923931d101f83015
4
+ data.tar.gz: 28bd20c35b5946ac08c33c413a462e4dfd70e86e
5
5
  SHA512:
6
- metadata.gz: c799a9cb5b317826b83f3ed794ca4cdf9e501956fcd111cd8f9762ccc49bfcad68a4b49a42fdc888968b7e4edef49df3824d9335fc4989aa7d2fa69cf8e0cf3d
7
- data.tar.gz: 609ff37bf50849e52ee38922101f81b4fe8db973765b5f7f4b638c63adc6406f59423c29f2f3ce60cf5bed7caa4e09de323d0b35ef3a58d788e7e5d757c5da7a
6
+ metadata.gz: 613a60d4e62eac81e1e2465e103798ea853f5ba4f490161cf79502390d2f13dff7ac6eb06f4adcebff3cbb9d007c9bdba8850561dd6a603fe95d4ba70b3b37de
7
+ data.tar.gz: 4a4418adabcffdb57f8f09d3f10112747e40c0546a0ca542fcefb5f9b755f1f56e5c11fd4f5ee0260301013a0d9a8da6c2e81a58611d06634491f46eb0740df5
@@ -1,17 +1,21 @@
1
1
  require 'gender_detector/version'
2
2
 
3
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4.0')
4
+ require 'active_support/core_ext/string/multibyte'
5
+ end
6
+
3
7
  # Main class for interacting with the data file
4
8
  class GenderDetector
5
- COUNTRIES = [:great_britain, :ireland, :usa, :italy, :malta, :portugal,
6
- :spain, :france, :belgium, :luxembourg, :the_netherlands,
7
- :east_frisia, :germany, :austria, :swiss, :iceland, :denmark,
8
- :norway, :sweden, :finland, :estonia, :latvia, :lithuania,
9
- :poland, :czech_republic, :slovakia, :hungary, :romania,
10
- :bulgaria, :bosniaand, :croatia, :kosovo, :macedonia,
11
- :montenegro, :serbia, :slovenia, :albania, :greece, :russia,
12
- :belarus, :moldova, :ukraine, :armenia, :azerbaijan, :georgia,
13
- :the_stans, :turkey, :arabia, :israel, :china, :india, :japan,
14
- :korea, :vietnam, :other_countries].freeze
9
+ COUNTRIES = %i[great_britain ireland usa italy malta portugal
10
+ spain france belgium luxembourg the_netherlands
11
+ east_frisia germany austria swiss iceland denmark
12
+ norway sweden finland estonia latvia lithuania
13
+ poland czech_republic slovakia hungary romania
14
+ bulgaria bosniaand croatia kosovo macedonia
15
+ montenegro serbia slovenia albania greece russia
16
+ belarus moldova ukraine armenia azerbaijan georgia
17
+ the_stans turkey arabia israel china india japan
18
+ korea vietnam other_countries].freeze
15
19
 
16
20
  ISO_3166_MAPPING = {
17
21
  'AE' => :arabia, 'AL' => :albania, 'AM' => :armenia, 'AT' => :austria,
@@ -70,7 +74,7 @@ class GenderDetector
70
74
  @unknown_value
71
75
  elsif country.nil?
72
76
  most_popular_gender(name) do |country_values|
73
- country_values.split('').select { |l| l.strip != '' }.length
77
+ country_values.split('').reject { |l| l.strip == '' }.length
74
78
  end
75
79
  elsif COUNTRIES.include?(country)
76
80
  most_popular_gender_in_country(name, country)
@@ -98,7 +102,7 @@ class GenderDetector
98
102
  def eat_name_line(line)
99
103
  return if line.start_with?('#', '=')
100
104
 
101
- parts = line.split(' ').select { |p| p.strip != '' }
105
+ parts = line.split(' ').reject { |p| p.strip == '' }
102
106
  country_values = line.slice(30, line.length)
103
107
  name = @case_sensitive ? parts[1] : downcase(parts[1])
104
108
 
@@ -139,9 +143,7 @@ class GenderDetector
139
143
  end
140
144
 
141
145
  def downcase(name)
142
- if defined?(UnicodeUtils)
143
- UnicodeUtils.downcase(name)
144
- elsif defined?(ActiveSupport::Multibyte::Chars)
146
+ if defined?(ActiveSupport::Multibyte::Chars)
145
147
  name.mb_chars.downcase.to_s
146
148
  else
147
149
  name.downcase
@@ -1,3 +1,3 @@
1
1
  class GenderDetector
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gender_detector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Muller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-25 00:00:00.000000000 Z
11
+ date: 2017-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,84 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.42'
19
+ version: '0.50'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.42'
26
+ version: '0.50'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.9'
33
+ version: '5.10'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '5.9'
40
+ version: '5.10'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '12.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '12.1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest-stub-const
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.5'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.5'
69
- - !ruby/object:Gem::Dependency
70
- name: unicode_utils
56
+ name: activesupport
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '1.3'
61
+ version: '5.1'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '1.3'
68
+ version: '5.1'
83
69
  - !ruby/object:Gem::Dependency
84
- name: activesupport
70
+ name: minitest-stub-const
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '5.0'
75
+ version: '0.6'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '5.0'
82
+ version: '0.6'
97
83
  description: Guess gender from first name, with multilingual support.
98
84
  email:
99
85
  - bamuller@gmail.com
@@ -125,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
111
  version: '0'
126
112
  requirements: []
127
113
  rubyforge_project:
128
- rubygems_version: 2.5.1
114
+ rubygems_version: 2.6.13
129
115
  signing_key:
130
116
  specification_version: 4
131
117
  summary: Get gender from first name.