faker 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +83 -0
  3. data/README.md +9 -0
  4. data/lib/faker.rb +37 -15
  5. data/lib/faker/blockchain/aeternity.rb +4 -4
  6. data/lib/faker/books/dune.rb +15 -2
  7. data/lib/faker/books/lovecraft.rb +8 -4
  8. data/lib/faker/default/address.rb +4 -4
  9. data/lib/faker/default/bank.rb +3 -5
  10. data/lib/faker/default/barcode.rb +11 -11
  11. data/lib/faker/default/beer.rb +3 -3
  12. data/lib/faker/default/camera.rb +46 -0
  13. data/lib/faker/default/chile_rut.rb +3 -2
  14. data/lib/faker/default/code.rb +2 -2
  15. data/lib/faker/default/commerce.rb +1 -1
  16. data/lib/faker/default/company.rb +40 -10
  17. data/lib/faker/default/driving_licence.rb +1 -1
  18. data/lib/faker/default/drone.rb +25 -25
  19. data/lib/faker/default/faker_adjective.rb +35 -0
  20. data/lib/faker/default/finance.rb +21 -0
  21. data/lib/faker/default/food.rb +1 -1
  22. data/lib/faker/default/hipster.rb +8 -5
  23. data/lib/faker/default/id_number.rb +2 -2
  24. data/lib/faker/default/internet.rb +5 -4
  25. data/lib/faker/default/invoice.rb +1 -1
  26. data/lib/faker/default/json.rb +4 -4
  27. data/lib/faker/default/lorem.rb +2 -2
  28. data/lib/faker/default/measurement.rb +3 -2
  29. data/lib/faker/default/military.rb +26 -0
  30. data/lib/faker/default/mountain.rb +33 -0
  31. data/lib/faker/default/number.rb +1 -1
  32. data/lib/faker/default/omniauth.rb +2 -0
  33. data/lib/faker/default/relationship.rb +1 -1
  34. data/lib/faker/default/space.rb +1 -1
  35. data/lib/faker/default/stripe.rb +3 -3
  36. data/lib/faker/default/vehicle.rb +1 -1
  37. data/lib/faker/fantasy/tolkien.rb +67 -0
  38. data/lib/faker/games/clash_of_clans.rb +48 -0
  39. data/lib/faker/games/control.rb +1 -1
  40. data/lib/faker/games/dnd.rb +6 -6
  41. data/lib/faker/games/elder_scrolls.rb +26 -0
  42. data/lib/faker/games/heroes.rb +13 -0
  43. data/lib/faker/games/minecraft.rb +65 -0
  44. data/lib/faker/games/street_fighter.rb +4 -4
  45. data/lib/faker/games/super_mario.rb +48 -0
  46. data/lib/faker/games/world_of_warcraft.rb +26 -1
  47. data/lib/faker/japanese_media/conan.rb +48 -0
  48. data/lib/faker/japanese_media/doraemon.rb +48 -0
  49. data/lib/faker/japanese_media/dragon_ball.rb +26 -0
  50. data/lib/faker/japanese_media/naruto.rb +61 -0
  51. data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
  52. data/lib/faker/movies/hobbit.rb +4 -4
  53. data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
  54. data/lib/faker/movies/lord_of_the_rings.rb +3 -3
  55. data/lib/faker/movies/room.rb +63 -0
  56. data/lib/faker/movies/star_wars.rb +2 -2
  57. data/lib/faker/music/hiphop.rb +48 -0
  58. data/lib/faker/music/opera.rb +237 -1
  59. data/lib/faker/quotes/quote.rb +26 -0
  60. data/lib/faker/sports/volleyball.rb +74 -0
  61. data/lib/faker/tv_shows/buffy.rb +17 -4
  62. data/lib/faker/tv_shows/final_space.rb +51 -0
  63. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
  64. data/lib/faker/version.rb +1 -1
  65. data/lib/helpers/unique_generator.rb +3 -0
  66. data/lib/locales/en/adjective.yml +179 -0
  67. data/lib/locales/en/buffy.yml +1 -1
  68. data/lib/locales/en/camera.yml +611 -0
  69. data/lib/locales/en/clash_of_clan.yml +101 -0
  70. data/lib/locales/en/company.yml +2 -2
  71. data/lib/locales/en/conan.yml +171 -0
  72. data/lib/locales/en/demographic.yml +218 -5
  73. data/lib/locales/en/doraemon.yml +286 -0
  74. data/lib/locales/en/dota.yml +531 -63
  75. data/lib/locales/en/dragon_ball.yml +243 -1
  76. data/lib/locales/en/driving_license.yml +3 -0
  77. data/lib/locales/en/dune.yml +401 -131
  78. data/lib/locales/en/elder_scrolls.yml +583 -9
  79. data/lib/locales/en/fallout.yml +311 -133
  80. data/lib/locales/en/final_space.yml +37 -0
  81. data/lib/locales/en/finance.yml +53 -0
  82. data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
  83. data/lib/locales/en/half_life.yml +84 -3
  84. data/lib/locales/en/heroes.yml +408 -3
  85. data/lib/locales/en/heroes_of_the_storm.yml +131 -4
  86. data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
  87. data/lib/locales/en/jack_handey.yml +54 -0
  88. data/lib/locales/en/league_of_legends.yml +285 -6
  89. data/lib/locales/en/military.yml +179 -5
  90. data/lib/locales/en/minecraft.yml +273 -0
  91. data/lib/locales/en/mountain.yml +158 -0
  92. data/lib/locales/en/music.yml +451 -29
  93. data/lib/locales/en/myst.yml +87 -31
  94. data/lib/locales/en/naruto.yml +231 -0
  95. data/lib/locales/en/opera.yml +168 -0
  96. data/lib/locales/en/overwatch.yml +2650 -2622
  97. data/lib/locales/en/pokemon.yml +417 -4
  98. data/lib/locales/en/quote.yml +692 -163
  99. data/lib/locales/en/room.yml +68 -0
  100. data/lib/locales/en/source.yml +30 -0
  101. data/lib/locales/en/star_trek.yml +1 -1
  102. data/lib/locales/en/street_fighter.yml +4 -4
  103. data/lib/locales/en/studio_ghibli.yml +107 -0
  104. data/lib/locales/en/super_mario.yml +58 -0
  105. data/lib/locales/en/super_smash_bros.yml +16 -4
  106. data/lib/locales/en/tolkien.yml +2453 -0
  107. data/lib/locales/en/volleyball.yml +501 -0
  108. data/lib/locales/en/witcher.yml +389 -7
  109. data/lib/locales/en/world_of_warcraft.yml +122 -4
  110. data/lib/locales/en/zelda.yml +962 -4
  111. data/lib/locales/es.yml +56 -0
  112. data/lib/locales/ja.yml +5 -1
  113. data/lib/locales/pt-BR.yml +1 -1
  114. data/lib/locales/uk.yml +2 -0
  115. metadata +38 -10
  116. data/lib/locales/en/hobbit.yml +0 -19
  117. data/lib/locales/en/lord_of_the_rings.yml +0 -6
@@ -80,7 +80,7 @@ module Faker
80
80
  #
81
81
  # @faker.version 1.6.2
82
82
  def ibu
83
- rand(10..100).to_s + ' IBU'
83
+ "#{rand(10..100)} IBU"
84
84
  end
85
85
 
86
86
  ##
@@ -93,7 +93,7 @@ module Faker
93
93
  #
94
94
  # @faker.version 1.6.2
95
95
  def alcohol
96
- rand(2.0..10.0).round(1).to_s + '%'
96
+ "#{rand(2.0..10.0).round(1)}%"
97
97
  end
98
98
 
99
99
  ##
@@ -106,7 +106,7 @@ module Faker
106
106
  #
107
107
  # @faker.version 1.6.2
108
108
  def blg
109
- rand(5.0..20.0).round(1).to_s + '°Blg'
109
+ "#{rand(5.0..20.0).round(1)}°Blg"
110
110
  end
111
111
  end
112
112
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class Camera < Base
5
+ class << self
6
+ ##
7
+ # Produces a brand of a camera
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Camera.brand #=> "Canon"
13
+ #
14
+ # @faker.version next
15
+ def brand
16
+ fetch('camera.brand')
17
+ end
18
+
19
+ ##
20
+ # Produces a model of camera
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Camera.model #=> "450D"
26
+ #
27
+ # @faker.version next
28
+ def model
29
+ fetch('camera.model')
30
+ end
31
+
32
+ ##
33
+ # Produces a brand with model
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::Camera.brand_with_model #=> "Canon 450D"
39
+ #
40
+ # @faker.version next
41
+ def brand_with_model
42
+ fetch('camera.brand_with_model')
43
+ end
44
+ end
45
+ end
46
+ end
@@ -46,9 +46,10 @@ module Faker
46
46
  partial_result
47
47
  end
48
48
  partial_check_digit = 11 - (digit_sum % 11)
49
- if partial_check_digit == 11
49
+ case partial_check_digit
50
+ when 11
50
51
  '0'
51
- elsif partial_check_digit == 10
52
+ when 10
52
53
  'k'
53
54
  else
54
55
  partial_check_digit.to_s
@@ -160,7 +160,7 @@ module Faker
160
160
  partial = Array.new(7) { Faker::Config.random.rand(0..9) }.join
161
161
 
162
162
  # Generate 9th digit
163
- check_digit = generate_sin_check_digit(registry + partial + '0').to_s
163
+ check_digit = generate_sin_check_digit("#{registry}#{partial}0").to_s
164
164
 
165
165
  registry + partial + check_digit
166
166
  end
@@ -218,7 +218,7 @@ module Faker
218
218
  def generate_base13_isbn
219
219
  values = regexify(/\d{12}/)
220
220
  remainder = sum(values) { |value, index| index.even? ? value.to_i : value.to_i * 3 } % 10
221
- values << "-#{((10 - remainder) % 10)}"
221
+ values << "-#{(10 - remainder) % 10}"
222
222
  end
223
223
 
224
224
  def sum(values)
@@ -121,7 +121,7 @@ module Faker
121
121
  price = (rand(range) * 100).floor / 100.0
122
122
  if as_string
123
123
  price_parts = price.to_s.split('.')
124
- price = price_parts[0] + '.' + price_parts[-1].ljust(2, '0')
124
+ price = "#{price_parts[0]}.#{price_parts[-1].ljust(2, '0')}"
125
125
  end
126
126
  price
127
127
  end
@@ -162,10 +162,17 @@ module Faker
162
162
  # @faker.version 1.8.5
163
163
  #
164
164
  # Get a random Spanish organization number. See more here https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal
165
- def spanish_organisation_number
165
+ def spanish_organisation_number(organization_type: nil)
166
166
  # Valid leading character: A, B, C, D, E, F, G, H, J, N, P, Q, R, S, U, V, W
167
- # 7 digit numbers
168
- [sample(self::ULetters), format('%07d', rand(10**7))].join
167
+ # format: 1 digit letter (organization type) + 7 digit numbers + 1 digit control (letter or number based on
168
+ # organization type)
169
+ letters = %w[A B C D E F G H J N P Q R S U V W]
170
+
171
+ organization_type = sample(letters) unless letters.include?(organization_type)
172
+ code = format('%07d', rand(10**7))
173
+ control = spanish_cif_control_digit(organization_type, code)
174
+
175
+ [organization_type, code, control].join
169
176
  end
170
177
 
171
178
  ##
@@ -457,13 +464,11 @@ module Faker
457
464
  end
458
465
  end
459
466
 
460
- control_digit = if (sum % 10).zero?
461
- 0
462
- else
463
- (sum / 10 + 1) * 10 - sum
464
- end
465
-
466
- control_digit
467
+ if (sum % 10).zero?
468
+ 0
469
+ else
470
+ (sum / 10 + 1) * 10 - sum
471
+ end
467
472
  end
468
473
 
469
474
  def abn_checksum(abn)
@@ -528,6 +533,31 @@ module Faker
528
533
  end % 11 % 10
529
534
  ).to_s
530
535
  end
536
+
537
+ def spanish_cif_control_digit(organization_type, code)
538
+ letters = %w[J A B C D E F G H]
539
+
540
+ control = code.split('').each_with_index.inject(0) do |sum, (value, index)|
541
+ if (index + 1).even?
542
+ sum + value.to_i
543
+ else
544
+ sum + spanish_b_algorithm(value.to_i)
545
+ end
546
+ end
547
+
548
+ control = control.to_s[-1].to_i
549
+ control = control.zero? ? control : 10 - control
550
+
551
+ %w[A B C D E F G H J U V].include?(organization_type) ? control : letters[control]
552
+ end
553
+
554
+ def spanish_b_algorithm(value)
555
+ result = value.to_i * 2
556
+
557
+ return result if result < 10
558
+
559
+ result.to_s[0].to_i + result.to_s[1].to_i
560
+ end
531
561
  end
532
562
  end
533
563
  end
@@ -88,7 +88,7 @@ module Faker
88
88
  # Faker::DrivingLicence.usa_driving_licence('new mexico') #=> "270692028"
89
89
  # Faker::DrivingLicence.usa_driving_licence('New Mexico') #=> "68178637"
90
90
  #
91
- # @faker.version next
91
+ # @faker.version 2.14.0
92
92
  def usa_driving_licence(state = 'California')
93
93
  bothify(fetch("driving_licence.usa.#{state.to_s.strip.downcase.gsub(' ', '_')}"))
94
94
  rescue I18n::MissingTranslationData => _e
@@ -11,7 +11,7 @@ module Faker
11
11
  # @example
12
12
  # Faker::Drone.name #=> "DJI Mavic Air 2"
13
13
  #
14
- # @faker.version next
14
+ # @faker.version 2.14.0
15
15
  def name
16
16
  fetch('drone.name')
17
17
  end
@@ -24,7 +24,7 @@ module Faker
24
24
  # @example
25
25
  # Faker::Drone.weight #=> "570 g"
26
26
  #
27
- # @faker.version next
27
+ # @faker.version 2.14.0
28
28
  def weight
29
29
  parse('drone.weight')
30
30
  end
@@ -37,7 +37,7 @@ module Faker
37
37
  # @example
38
38
  # Faker::Drone.max_ascent_speed #=> "4 m/s"
39
39
  #
40
- # @faker.version next
40
+ # @faker.version 2.14.0
41
41
  def max_ascent_speed
42
42
  parse('drone.max_ascent_speed')
43
43
  end
@@ -50,7 +50,7 @@ module Faker
50
50
  # @example
51
51
  # Faker::Drone.max_descent_speed #=> "4 m/s"
52
52
  #
53
- # @faker.version next
53
+ # @faker.version 2.14.0
54
54
  def max_descent_speed
55
55
  parse('drone.max_descent_speed')
56
56
  end
@@ -63,7 +63,7 @@ module Faker
63
63
  # @example
64
64
  # Faker::Drone.flight_time #=> "34 min"
65
65
  #
66
- # @faker.version next
66
+ # @faker.version 2.14.0
67
67
  def flight_time
68
68
  parse('drone.flight_time')
69
69
  end
@@ -76,7 +76,7 @@ module Faker
76
76
  # @example
77
77
  # Faker::Drone.max_altitude #=> "5000 m"
78
78
  #
79
- # @faker.version next
79
+ # @faker.version 2.14.0
80
80
  def max_altitude
81
81
  parse('drone.max_altitude')
82
82
  end
@@ -89,7 +89,7 @@ module Faker
89
89
  # @example
90
90
  # Faker::Drone.max_flight_distance #=> "18500 m"
91
91
  #
92
- # @faker.version next
92
+ # @faker.version 2.14.0
93
93
  def max_flight_distance
94
94
  parse('drone.max_flight_distance')
95
95
  end
@@ -102,7 +102,7 @@ module Faker
102
102
  # @example
103
103
  # Faker::Drone.max_speed #=> "19 m/s"
104
104
  #
105
- # @faker.version next
105
+ # @faker.version 2.14.0
106
106
  def max_speed
107
107
  parse('drone.max_speed')
108
108
  end
@@ -115,7 +115,7 @@ module Faker
115
115
  # @example
116
116
  # Faker::Drone.max_wind_resistance #=> "10.5 m/s"
117
117
  #
118
- # @faker.version next
118
+ # @faker.version 2.14.0
119
119
  def max_wind_resistance
120
120
  parse('drone.max_wind_resistance')
121
121
  end
@@ -128,7 +128,7 @@ module Faker
128
128
  # @example
129
129
  # Faker::Drone.max_angular_velocity #=> "250 degree/s"
130
130
  #
131
- # @faker.version next
131
+ # @faker.version 2.14.0
132
132
  def max_angular_velocity
133
133
  parse('drone.max_angular_velocity')
134
134
  end
@@ -141,7 +141,7 @@ module Faker
141
141
  # @example
142
142
  # Faker::Drone.max_tilt_angle #=> "35 degrees"
143
143
  #
144
- # @faker.version next
144
+ # @faker.version 2.14.0
145
145
  def max_tilt_angle
146
146
  parse('drone.max_tilt_angle')
147
147
  end
@@ -154,7 +154,7 @@ module Faker
154
154
  # @example
155
155
  # Faker::Drone.operating_temperature #=> "14-104F"
156
156
  #
157
- # @faker.version next
157
+ # @faker.version 2.14.0
158
158
  def operating_temperature
159
159
  parse('drone.operating_temperature')
160
160
  end
@@ -167,7 +167,7 @@ module Faker
167
167
  # @example
168
168
  # Faker::Drone.battery_capacity #=> "3500 mAh"
169
169
  #
170
- # @faker.version next
170
+ # @faker.version 2.14.0
171
171
  def battery_capacity
172
172
  parse('drone.battery_capacity')
173
173
  end
@@ -180,7 +180,7 @@ module Faker
180
180
  # @example
181
181
  # Faker::Drone.battery_voltage #=> "13.2V"
182
182
  #
183
- # @faker.version next
183
+ # @faker.version 2.14.0
184
184
  def battery_voltage
185
185
  parse('drone.battery_voltage')
186
186
  end
@@ -193,7 +193,7 @@ module Faker
193
193
  # @example
194
194
  # Faker::Drone.battery_type #=> "LiPo 4S"
195
195
  #
196
- # @faker.version next
196
+ # @faker.version 2.14.0
197
197
  def battery_type
198
198
  parse('drone.battery_type')
199
199
  end
@@ -206,7 +206,7 @@ module Faker
206
206
  # @example
207
207
  # Faker::Drone.battery_weight #=> "198 g"
208
208
  #
209
- # @faker.version next
209
+ # @faker.version 2.14.0
210
210
  def battery_weight
211
211
  parse('drone.battery_weight')
212
212
  end
@@ -219,7 +219,7 @@ module Faker
219
219
  # @example
220
220
  # Faker::Drone.charging_temperature #=> "41-104F"
221
221
  #
222
- # @faker.version next
222
+ # @faker.version 2.14.0
223
223
  def charging_temperature
224
224
  parse('drone.charging_temperature')
225
225
  end
@@ -232,7 +232,7 @@ module Faker
232
232
  # @example
233
233
  # Faker::Drone.max_charging_power #=> "38W"
234
234
  #
235
- # @faker.version next
235
+ # @faker.version 2.14.0
236
236
  def max_charging_power
237
237
  parse('drone.max_charging_power')
238
238
  end
@@ -245,7 +245,7 @@ module Faker
245
245
  # @example
246
246
  # Faker::Drone.iso #=> "100-3200"
247
247
  #
248
- # @faker.version next
248
+ # @faker.version 2.14.0
249
249
  def iso
250
250
  parse('drone.iso')
251
251
  end
@@ -258,7 +258,7 @@ module Faker
258
258
  # @example
259
259
  # Faker::Drone.max_resolution #=> "48MP"
260
260
  #
261
- # @faker.version next
261
+ # @faker.version 2.14.0
262
262
  def max_resolution
263
263
  parse('drone.max_resolution')
264
264
  end
@@ -271,7 +271,7 @@ module Faker
271
271
  # @example
272
272
  # Faker::Drone.photo_format #=> "JPEG"
273
273
  #
274
- # @faker.version next
274
+ # @faker.version 2.14.0
275
275
  def photo_format
276
276
  parse('drone.photo_format')
277
277
  end
@@ -284,7 +284,7 @@ module Faker
284
284
  # @example
285
285
  # Faker::Drone.video_format #=> "MP4"
286
286
  #
287
- # @faker.version next
287
+ # @faker.version 2.14.0
288
288
  def video_format
289
289
  parse('drone.video_format')
290
290
  end
@@ -297,7 +297,7 @@ module Faker
297
297
  # @example
298
298
  # Faker::Drone.shutter_speed_range #=> "8-1/8000s"
299
299
  #
300
- # @faker.version next
300
+ # @faker.version 2.14.0
301
301
  def shutter_speed_range
302
302
  "#{fetch('drone.max_shutter_speed')}-#{fetch('drone.min_shutter_speed')}#{fetch('drone.shutter_speed_units')}"
303
303
  end
@@ -310,7 +310,7 @@ module Faker
310
310
  # @example
311
311
  # Faker::Drone.max_shutter_speed #=> "60s"
312
312
  #
313
- # @faker.version next
313
+ # @faker.version 2.14.0
314
314
  def max_shutter_speed
315
315
  "#{fetch('drone.max_shutter_speed')}#{fetch('drone.shutter_speed_units')}"
316
316
  end
@@ -323,7 +323,7 @@ module Faker
323
323
  # @example
324
324
  # Faker::Drone.min_shutter_speed #=> "1/8000s"
325
325
  #
326
- # @faker.version next
326
+ # @faker.version 2.14.0
327
327
  def min_shutter_speed
328
328
  "#{fetch('drone.min_shutter_speed')}#{fetch('drone.shutter_speed_units')}"
329
329
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class Adjective < Base
5
+ flexible :adjective
6
+
7
+ class << self
8
+ ##
9
+ # Produces a positive adjective.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Adjective.positive #=> "Kind"
15
+ #
16
+ # @faker.version next
17
+ def positive
18
+ fetch('adjective.positive')
19
+ end
20
+
21
+ ##
22
+ # Produces a negative adjective.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Adjective.negative #=> "Creepy"
28
+ #
29
+ # @faker.version next
30
+ def negative
31
+ fetch('adjective.negative')
32
+ end
33
+ end
34
+ end
35
+ end
@@ -6,6 +6,8 @@ module Faker
6
6
  diners_club jcb switch solo dankort
7
7
  maestro forbrugsforeningen laser].freeze
8
8
 
9
+ MARKET_LIST = %i[nyse nasdaq].freeze
10
+
9
11
  class << self
10
12
  ##
11
13
  # Produces a random credit card number.
@@ -63,6 +65,25 @@ module Faker
63
65
  def vat_number_keys
64
66
  translate('faker.finance.vat_number').keys
65
67
  end
68
+
69
+ ##
70
+ # Returns a randomly-selected stock ticker from a specified market.
71
+ #
72
+ # @param markets [String] The name of the market to choose the ticker from (e.g. NYSE, NASDAQ)
73
+ # @return [String]
74
+ #
75
+ # @example
76
+ # Faker::Finance.ticker #=> 'AMZN'
77
+ # Faker::Finance.vat_number('NASDAQ') #=> 'GOOG'
78
+ #
79
+ # @faker.version next
80
+ def ticker(*markets)
81
+ markets = MARKET_LIST if markets.empty?
82
+ market = sample(markets)
83
+ fetch("finance.ticker.#{market}")
84
+ rescue I18n::MissingTranslationData
85
+ raise ArgumentError, "Could not find market named #{market}"
86
+ end
66
87
  end
67
88
  end
68
89
  end