faker 2.13.0 → 2.14.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +49 -0
  3. data/README.md +4 -0
  4. data/lib/faker/default/barcode.rb +154 -0
  5. data/lib/faker/default/code.rb +96 -15
  6. data/lib/faker/default/driving_licence.rb +23 -0
  7. data/lib/faker/default/drone.rb +332 -0
  8. data/lib/faker/games/dnd.rb +89 -14
  9. data/lib/faker/games/street_fighter.rb +61 -0
  10. data/lib/faker/version.rb +1 -1
  11. data/lib/helpers/base58.rb +1 -1
  12. data/lib/helpers/unique_generator.rb +0 -2
  13. data/lib/locales/de-AT.yml +4 -2
  14. data/lib/locales/de-CH.yml +3 -1
  15. data/lib/locales/de.yml +4 -2
  16. data/lib/locales/en-AU.yml +8 -2
  17. data/lib/locales/en-GB.yml +1 -1
  18. data/lib/locales/en-IND.yml +2 -1
  19. data/lib/locales/en-MS.yml +2 -1
  20. data/lib/locales/en-NEP.yml +4 -1
  21. data/lib/locales/en-NZ.yml +3 -1
  22. data/lib/locales/en-PAK.yml +2 -1
  23. data/lib/locales/en-SG.yml +2 -1
  24. data/lib/locales/en-US.yml +10 -10
  25. data/lib/locales/en-au-ocker.yml +2 -1
  26. data/lib/locales/en.yml +0 -3
  27. data/lib/locales/en/animal.yml +1 -1
  28. data/lib/locales/en/barcode.yml +24 -0
  29. data/lib/locales/en/dnd.yml +430 -33
  30. data/lib/locales/en/driving_license.yml +178 -0
  31. data/lib/locales/en/drone.yml +95 -0
  32. data/lib/locales/en/name.yml +2 -2
  33. data/lib/locales/en/street_fighter.yml +1524 -0
  34. data/lib/locales/fi-FI.yml +1 -1
  35. data/lib/locales/fr-CA.yml +19 -5
  36. data/lib/locales/fr-CH.yml +2 -2
  37. data/lib/locales/fr.yml +8 -2
  38. data/lib/locales/id.yml +2 -1
  39. data/lib/locales/it.yml +2 -1
  40. data/lib/locales/ko.yml +34 -24
  41. data/lib/locales/nb-NO.yml +4 -2
  42. data/lib/locales/pt.yml +3 -1
  43. data/lib/locales/ru.yml +3 -1
  44. data/lib/locales/sk.yml +4 -2
  45. metadata +13 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 419bb77c9f0a8bc8f7c1b7ea5d93ba7d407bf7c437598eb91413f062f67494ce
4
- data.tar.gz: 6566078b00ceb18763960551f913a341393858c2458cec01fcb4b0f0163d2e4b
3
+ metadata.gz: c20404a4d9474978940db437ddac9984deddd352fdf7cf9313d038a7e9c0ce54
4
+ data.tar.gz: d52491d45e9dbc7525cf078789e84c10219d2c8e428de4541a1e73dfa6246569
5
5
  SHA512:
6
- metadata.gz: 694b65a586f50b801f47a456954dd6f2fba39a82b9a643153bb140f9bd3467b7e3080c49a63f0a8562db10c6442bc7c5c578928ddde129054cb070d2a81658e3
7
- data.tar.gz: eb6812f2f21c5a1930ad987ad8023efeb9168a6f6ec909fcd86d3deeb5e8720d82f457be58fc08f907d502571656ee6768bc21cbb6395a5366c2410d65e358cf
6
+ metadata.gz: ee17e0c0333a8e5456d167ed3f7ccc26be29c5f95efdcf6aa866cc2b80789afb95a910922af3405f9d3484b0c266c5217fa40fb593c08eefcc8aab0159b83f91
7
+ data.tar.gz: 66fa28264c8fbe299c025e6bd566a55870fd9059bda1863dfbe3d03c7fe56a176f04432c784f3d1a079429bb375cc18c56da6d38341b2167edce1f3abbae9074
@@ -1,5 +1,54 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.14.0](https://github.com/faker-ruby/faker/tree/v2.14.0) (2020-09-15)
4
+
5
+ ## Bug/Fixes
6
+
7
+ - [PR #2119](https://github.com/faker-ruby/faker/pull/2119) Fixed failing spec for phone number
8
+
9
+ ## Chores
10
+
11
+ - [PR #2088](https://github.com/faker-ruby/faker/pull/2088) Remove the space in the word "turtle" in the Creature::Animals faker
12
+ - [PR #2081](https://github.com/faker-ruby/faker/pull/2081) Remove redundant condition branch for Ruby 2.4
13
+ - [PR #2077](https://github.com/faker-ruby/faker/pull/2077) Rename tests according to the `test*.rb` pattern so that they run
14
+
15
+ ## Documentation
16
+
17
+ - [PR #2095](https://github.com/faker-ruby/faker/pull/2095) Fix a typo for `Games::DnD.species`
18
+ - [PR #2094](https://github.com/faker-ruby/faker/pull/2094) Correct method name from race to species in DnD doc
19
+ - [PR #2079](https://github.com/faker-ruby/faker/pull/2079) Add `Music::PearlJam` to Readme
20
+ - [PR #2058](https://github.com/faker-ruby/faker/pull/2058) Add YARD doc for `Faker::Code`
21
+
22
+ ## Feature Request
23
+
24
+ - [PR #2117](https://github.com/faker-ruby/faker/pull/2117) Add Truffleruby head to CI
25
+ - [PR #2104](https://github.com/faker-ruby/faker/pull/2104) 2097 Added barcodes
26
+ - [PR #2090](https://github.com/faker-ruby/faker/pull/2090) 1693 USA driving license
27
+ - [PR #2098](https://github.com/faker-ruby/faker/pull/2098) Update DnD generator
28
+ - [PR #2096](https://github.com/faker-ruby/faker/pull/2096) 2091 faker drones
29
+ - [PR #2092](https://github.com/faker-ruby/faker/pull/2092) Add a street fighter generator
30
+ - [PR #2082](https://github.com/faker-ruby/faker/pull/2082) Enable `Lint/UnifiedInteger` cop
31
+
32
+ ## Update locales
33
+
34
+ - [PR #2100](https://github.com/faker-ruby/faker/pull/2100) Remove Gaylord
35
+ - [PR #2087](https://github.com/faker-ruby/faker/pull/2087) Fix/remove country code from phone numbers
36
+ - [PR #2086](https://github.com/faker-ruby/faker/pull/2086) removing country code from phone numbers to `fr-CH`
37
+ - [PR #2084](https://github.com/faker-ruby/faker/pull/2084) removed extra + sign from country codes
38
+ - [PR #2078](https://github.com/faker-ruby/faker/pull/2078) Removed 07624 from UK mobile numbers
39
+ - [PR #2073](https://github.com/faker-ruby/faker/pull/2073) Add missing azimuth field for fr locale
40
+ - [PR #2072](https://github.com/faker-ruby/faker/pull/2072) Remove time formats from file
41
+
42
+ Update local dependencies
43
+
44
+ - Update rubocop requirement from = 0.87.1 to = 0.88.0 (#2080)
45
+ - Update rubocop requirement from = 0.87.0 to = 0.87.1 (#2075)
46
+ - Update rubocop requirement from = 0.86.0 to = 0.87.0 (#2074)
47
+ - Bumps i18n from 1.8.4 to 1.8.5 (#2089)
48
+ - Bumps i18n from 1.8.3 to 1.8.4 (#2083)
49
+
50
+ ------------------------------------------------------------------------------
51
+
3
52
  ## [v2.13.0](https://github.com/faker-ruby/faker/tree/v2.13.0) (2020-06-24)
4
53
 
5
54
  This version:
data/README.md CHANGED
@@ -130,6 +130,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
130
130
  - [Faker::Artist](doc/default/artist.md)
131
131
  - [Faker::Avatar](doc/default/avatar.md)
132
132
  - [Faker::Bank](doc/default/bank.md)
133
+ - [Faker::Barcode](doc/default/barcode.md)
133
134
  - [Faker::Beer](doc/default/beer.md)
134
135
  - [Faker::Blood](doc/default/blood.md)
135
136
  - [Faker::Boolean](doc/default/boolean.md)
@@ -157,6 +158,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
157
158
  - [Faker::Dessert](doc/default/dessert.md)
158
159
  - [Faker::Device](doc/default/device.md)
159
160
  - [Faker::DrivingLicence](doc/default/driving_licence.md)
161
+ - [Faker::Drone](doc/drone/drone.md)
160
162
  - [Faker::Educator](doc/default/educator.md)
161
163
  - [Faker::ElectricalComponents](doc/default/electrical_components.md)
162
164
  - [Faker::Esport](doc/default/esport.md)
@@ -245,6 +247,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
245
247
  - [Faker::Games::Overwatch](doc/games/overwatch.md)
246
248
  - [Faker::Games::Pokemon](doc/games/pokemon.md)
247
249
  - [Faker::Games::SonicTheHedgehog](doc/games/sonic_the_hedgehog.md)
250
+ - [Faker::Games::StreetFighter](doc/games/street_fighter.md)
248
251
  - [Faker::Games::SuperSmashBros](doc/games/super_smash_bros.md)
249
252
  - [Faker::Games::WarhammerFantasy](doc/games/warhammer_fantasy.md)
250
253
  - [Faker::Games::Witcher](doc/games/witcher.md)
@@ -274,6 +277,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
274
277
  - [Faker::Music](doc/music/music.md)
275
278
  - [Faker::Music::GratefulDead](doc/music/grateful_dead.md)
276
279
  - [Faker::Music::Opera](doc/music/opera.md)
280
+ - [Faker::Music::PearlJam](doc/music/pearl_jam.md)
277
281
  - [Faker::Music::Phish](doc/music/phish.md)
278
282
  - [Faker::Music::Prince](doc/music/prince.md)
279
283
  - [Faker::Music::RockBand](doc/music/rock_band.md)
@@ -0,0 +1,154 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class Barcode < Base
5
+ class << self
6
+ ## Returns a EAN 8 or 13 digit format barcode number with check digit
7
+ # @returns [String]
8
+ #
9
+ # @example
10
+ # Faker::Barcode.ean => "85657526"
11
+ # Faker::Barcode.ean(8) => "30152700"
12
+ # Faker::Barcode.ean(13) => "2115190480285"
13
+ #
14
+ # @faker.version next
15
+ def ean(length = 8)
16
+ generate_barcode("barcode.ean_#{Integer(length)}")
17
+ end
18
+
19
+ ## Returns a EAN 8 or 13 digit format barcode number with composite string attached with check digit
20
+ # @returns [String]
21
+ #
22
+ # @example
23
+ # Faker::Barcode.ean_with_composite_sumbology => "41007624|JHOC6649"
24
+ # Faker::Barcode.ean_with_composite_sumbology(8) => "38357961|XUYJ3266"
25
+ # Faker::Barcode.ean_with_composite_sumbology(13) => "9530722443911|CKHWQHID"
26
+ #
27
+ # @faker.version next
28
+ def ean_with_composite_symbology(length = 8)
29
+ "#{ean(length)}|#{bothify(parse('barcode.composite_symbol'))}"
30
+ end
31
+
32
+ ## Returns a UPC_A format barcode number with check digit
33
+ # @returns [String]
34
+ #
35
+ # @example
36
+ # Faker::Barcode.upc_a => "766807541831"
37
+ #
38
+ # @faker.version next
39
+ def upc_a
40
+ generate_barcode('barcode.upc_a')
41
+ end
42
+
43
+ ## Returns a UPC_E format barcode number with check digit
44
+ # @returns [String]
45
+ #
46
+ # @example
47
+ # Faker::Barcode.upc_e => "03746820"
48
+ #
49
+ # @faker.version next
50
+ def upc_e
51
+ generate_barcode('barcode.upc_e')
52
+ end
53
+
54
+ ## Returns a UPC_A format barcode number with composite string attached with check digit
55
+ # @returns [String]
56
+ #
57
+ # @example
58
+ # Faker::Barcode.upc_a_with_composite_symbology => "790670155765|JOVG6208"
59
+ #
60
+ # @faker.version next
61
+ def upc_a_with_composite_symbology
62
+ "#{upc_a}|#{bothify(parse('barcode.composite_symbol'))}"
63
+ end
64
+
65
+ ## Returns a UPC_E format barcode number with composite string attached with check digit
66
+ # @returns [String]
67
+ #
68
+ # @example
69
+ # Faker::Barcode.upc_e_with_composite_symbology => "05149247|BKZX9722"
70
+ #
71
+ # @faker.version next
72
+ def upc_e_with_composite_symbology
73
+ "#{upc_e}|#{bothify(parse('barcode.composite_symbol'))}"
74
+ end
75
+
76
+ ## Returns a ISBN format barcode number with check digit
77
+ # @returns [String]
78
+ #
79
+ # @example
80
+ # Faker::Barcode.isbn => "9798363807732"
81
+ #
82
+ # @faker.version next
83
+ def isbn
84
+ generate_barcode('barcode.isbn')
85
+ end
86
+
87
+ ## Returns a ISMN format barcode number with check digit
88
+ # @returns [String]
89
+ #
90
+ # @example
91
+ # Faker::Barcode.ismn => "9790527672897"
92
+ #
93
+ # @faker.version next
94
+ def ismn
95
+ generate_barcode('barcode.ismn')
96
+ end
97
+
98
+ ## Returns a ISSN format barcode number with check digit
99
+ # @returns [String]
100
+ #
101
+ # @example
102
+ # Faker::Barcode.issn => "9775541703338"
103
+ #
104
+ # @faker.version next
105
+ def issn
106
+ generate_barcode('barcode.issn')
107
+ end
108
+
109
+ private
110
+
111
+ def generate_barcode(key)
112
+ barcode = parse(key)
113
+ check_digit = generate_check_digit(*sum_even_odd(barcode))
114
+ "#{barcode}#{check_digit}"
115
+ end
116
+
117
+ ## Returns the sum of even and odd numbers from value passed
118
+ #
119
+ # @returns [Array]
120
+ #
121
+ # @example
122
+ # Faker::Barcode.send(:sum_even_odd, 12345) => [9, 5]
123
+ # Faker::Barcode.send(:sum_even_odd, 87465) => [17, 13]
124
+ #
125
+ # @faker.version next
126
+ def sum_even_odd(fake_num)
127
+ number = fake_num.to_i
128
+ sum_even, sum_odd = 0, 0, index = 1
129
+
130
+ while number != 0
131
+ index.even? ? sum_even += number % 10 : sum_odd += number % 10
132
+
133
+ number /= 10
134
+ index += 1
135
+ end
136
+
137
+ [sum_odd, sum_even]
138
+ end
139
+
140
+ ## Generates the check digits from sum passed
141
+ #
142
+ # @returns [Integer]
143
+ #
144
+ # @example
145
+ # Faker::Barcode.send(:generate_check_digit, 12, 4) => 0
146
+ # Faker::Barcode.send(:generate_check_digit, 23, 5) => 6
147
+ #
148
+ # @faker.version next
149
+ def generate_check_digit(odd_sum, even_sum)
150
+ (10 - (odd_sum * 3 + even_sum) % 10) % 10
151
+ end
152
+ end
153
+ end
154
+ end
@@ -4,32 +4,76 @@ module Faker
4
4
  class Code < Base
5
5
  flexible :code
6
6
  class << self
7
- # Generates a 10 digit NPI (National Provider Identifier
8
- # issued to health care providers in the United States)
7
+ ##
8
+ # Produces a random NPI (National Provider Identifer) code.
9
+ #
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # Faker::Code.npi #=> "9804062802"
14
+ #
15
+ # @faker.version 1.9.4
9
16
  def npi
10
17
  rand(10**10).to_s.rjust(10, '0')
11
18
  end
12
19
 
13
- # By default generates 10 sign isbn code in format 123456789-X
14
- # You can pass 13 to generate new 13 sign code
20
+ ##
21
+ # Produces a random ISBN (International Standard Book Number) code.
22
+ #
23
+ # @param base [Integer] the length of the code to generate (either 10 or 13)
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Code.isbn(base: 13) #=> "896579606969-8"
28
+ # @example
29
+ # Faker::Code.isbn #=> "170366802-2"
30
+ #
31
+ # @faker.version 2.2.0
15
32
  def isbn(legacy_base = NOT_GIVEN, base: 10)
16
33
  warn_for_deprecated_arguments do |keywords|
17
34
  keywords << :base if legacy_base != NOT_GIVEN
18
35
  end
19
36
 
20
- base == 13 ? generate_base13_isbn : generate_base10_isbn
37
+ case base
38
+ when 10 then generate_base10_isbn
39
+ when 13 then generate_base13_isbn
40
+ else raise ArgumentError, 'base must be 10 or 13'
41
+ end
21
42
  end
22
43
 
23
- # By default generates 13 sign ean code in format 1234567890123
24
- # You can pass 8 to generate ean8 code
44
+ ##
45
+ # Produces a random EAN (European Article Number) code.
46
+ #
47
+ # @param base [Integer] the length of the code to generate (either 8 or 13)
48
+ # @return [String]
49
+ #
50
+ # @example
51
+ # Faker::Code.ean(base: 8) #=> "36941070"
52
+ # @example
53
+ # Faker::Code.ean #=> "9941880131907"
54
+ #
55
+ # @faker.version 2.2.0
25
56
  def ean(legacy_base = NOT_GIVEN, base: 13)
26
57
  warn_for_deprecated_arguments do |keywords|
27
58
  keywords << :base if legacy_base != NOT_GIVEN
28
59
  end
29
60
 
30
- base == 8 ? generate_base8_ean : generate_base13_ean
61
+ case base
62
+ when 8 then generate_base8_ean
63
+ when 13 then generate_base13_ean
64
+ else raise ArgumentError, 'base must be 3 or 13'
65
+ end
31
66
  end
32
67
 
68
+ ##
69
+ # Produces a random RUT (Rol Unico Nacional) code.
70
+ #
71
+ # @return [String]
72
+ #
73
+ # @example
74
+ # Faker::Code.rut #=> "91611842-2"
75
+ #
76
+ # @faker.version 1.9.4
33
77
  def rut
34
78
  value = Number.number(digits: 8).to_s
35
79
  vd = rut_verificator_digit(value)
@@ -38,6 +82,23 @@ module Faker
38
82
 
39
83
  # By default generates a Singaporean NRIC ID for someone
40
84
  # who is born between the age of 18 and 65.
85
+ #
86
+ # Produces a random NRIC (National Registry Identity Card) code.
87
+ #
88
+ # @param min_age [Integer] the min age of the person in years
89
+ # @param max_age [Integer] the max age of the person in years
90
+ # @return [String]
91
+ #
92
+ # @example
93
+ # Faker::Code.nric(min_age: 25, max_age: 50) #=> "S9347283G"
94
+ # @example
95
+ # Faker::Code.nric(max_age: 55) #=> "S7876903C"
96
+ # @example
97
+ # Faker::Code.nric(min_age: 25) #=> "S6281697Z"
98
+ # @example
99
+ # Faker::Code.nric #=> "S6372958B"
100
+ #
101
+ # @faker.version 2.2.0
41
102
  def nric(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65)
42
103
  warn_for_deprecated_arguments do |keywords|
43
104
  keywords << :min_age if legacy_min_age != NOT_GIVEN
@@ -52,19 +113,41 @@ module Faker
52
113
  "#{prefix}#{values}#{check_alpha}"
53
114
  end
54
115
 
55
- # Generate GSM modem, device or mobile phone 15 digit IMEI number.
116
+ ##
117
+ # Produces a random IMEI (International Mobile Equipment Number) code.
118
+ #
119
+ # @return [String]
120
+ #
121
+ # @example
122
+ # Faker::Code.imei #=> "492033129092256"
123
+ #
124
+ # @faker.version 1.9.4
56
125
  def imei
57
126
  generate_imei
58
127
  end
59
128
 
60
- # Retrieves a real Amazon ASIN code list taken from
61
- # https://archive.org/details/asin_listing
129
+ ##
130
+ # Retrieves a real Amazon ASIN code from https://archive.org/details/asin_listing
131
+ #
132
+ # @return [String]
133
+ #
134
+ # @example
135
+ # Faker::Code.asin #=> "B000MZW1GE"
136
+ #
137
+ # @faker.version 1.9.4
62
138
  def asin
63
139
  fetch('code.asin')
64
140
  end
65
141
 
66
- # Generates Social Insurance Number issued in Canada
67
- # https://en.wikipedia.org/wiki/Social_Insurance_Number
142
+ ##
143
+ # Produces a random SIN (Social Insurance Number for Canada) code.
144
+ #
145
+ # @return [String]
146
+ #
147
+ # @example
148
+ # Faker::Code.sin #=> "996586962"
149
+ #
150
+ # @faker.version 1.9.4
68
151
  def sin
69
152
  # 1 - province or temporary resident
70
153
  # 2-8 - random numbers
@@ -90,8 +173,6 @@ module Faker
90
173
  def generate_imei
91
174
  str = Array.new(15, 0)
92
175
  sum = 0
93
- t = 0
94
- len_offset = 0
95
176
  len = 15
96
177
 
97
178
  # Fill in the first two values of the string based with the specified prefix.
@@ -78,6 +78,23 @@ module Faker
78
78
  end
79
79
  end
80
80
 
81
+ ##
82
+ # Produces a random USA driving licence number by state code passed.
83
+ #
84
+ # @return [String]
85
+ #
86
+ # @example
87
+ # Faker::DrivingLicence.usa_driving_licence #=> "V5598249"
88
+ # Faker::DrivingLicence.usa_driving_licence('new mexico') #=> "270692028"
89
+ # Faker::DrivingLicence.usa_driving_licence('New Mexico') #=> "68178637"
90
+ #
91
+ # @faker.version next
92
+ def usa_driving_licence(state = 'California')
93
+ bothify(fetch("driving_licence.usa.#{state.to_s.strip.downcase.gsub(' ', '_')}"))
94
+ rescue I18n::MissingTranslationData => _e
95
+ raise InvalidStatePassed, "Invalid state code passed for USA, '#{state}'"
96
+ end
97
+
81
98
  private
82
99
 
83
100
  def random_gender
@@ -104,4 +121,10 @@ module Faker
104
121
  end
105
122
  end
106
123
  end
124
+
125
+ class InvalidStatePassed < StandardError
126
+ def initialize(msg = 'Invalid state code passed')
127
+ super
128
+ end
129
+ end
107
130
  end