faker 2.20.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +184 -7
  3. data/History.md +1 -1
  4. data/README.md +15 -11
  5. data/lib/faker/blockchain/aeternity.rb +1 -1
  6. data/lib/faker/blockchain/ethereum.rb +1 -1
  7. data/lib/faker/blockchain/tezos.rb +1 -1
  8. data/lib/faker/books/dune.rb +2 -10
  9. data/lib/faker/books/lovecraft.rb +7 -38
  10. data/lib/faker/default/address.rb +5 -25
  11. data/lib/faker/default/{faker_adjective.rb → adjective.rb} +0 -0
  12. data/lib/faker/default/alphanumeric.rb +2 -8
  13. data/lib/faker/default/app.rb +1 -10
  14. data/lib/faker/default/avatar.rb +1 -12
  15. data/lib/faker/default/bank.rb +9 -17
  16. data/lib/faker/default/boolean.rb +1 -4
  17. data/lib/faker/default/chile_rut.rb +8 -14
  18. data/lib/faker/default/code.rb +10 -23
  19. data/lib/faker/default/color.rb +77 -6
  20. data/lib/faker/default/commerce.rb +3 -17
  21. data/lib/faker/default/company.rb +6 -14
  22. data/lib/faker/default/crypto_coin.rb +3 -15
  23. data/lib/faker/default/date.rb +5 -38
  24. data/lib/faker/default/demographic.rb +1 -5
  25. data/lib/faker/default/driving_licence.rb +1 -11
  26. data/lib/faker/default/file.rb +5 -24
  27. data/lib/faker/default/fillmurray.rb +1 -10
  28. data/lib/faker/default/finance.rb +17 -7
  29. data/lib/faker/default/hipster.rb +6 -45
  30. data/lib/faker/default/id_number.rb +108 -11
  31. data/lib/faker/default/internet.rb +34 -71
  32. data/lib/faker/default/invoice.rb +3 -16
  33. data/lib/faker/default/json.rb +2 -20
  34. data/lib/faker/default/lorem.rb +9 -66
  35. data/lib/faker/default/lorem_flickr.rb +4 -32
  36. data/lib/faker/default/lorem_pixel.rb +4 -10
  37. data/lib/faker/default/markdown.rb +6 -11
  38. data/lib/faker/default/measurement.rb +8 -40
  39. data/lib/faker/default/name.rb +1 -5
  40. data/lib/faker/default/nhs.rb +2 -6
  41. data/lib/faker/default/number.rb +10 -55
  42. data/lib/faker/default/omniauth.rb +5 -39
  43. data/lib/faker/default/phone_number.rb +1 -5
  44. data/lib/faker/default/placeholdit.rb +1 -12
  45. data/lib/faker/default/relationship.rb +1 -5
  46. data/lib/faker/default/source.rb +3 -16
  47. data/lib/faker/default/string.rb +1 -5
  48. data/lib/faker/default/stripe.rb +4 -20
  49. data/lib/faker/default/time.rb +4 -32
  50. data/lib/faker/default/twitter.rb +3 -17
  51. data/lib/faker/default/types.rb +5 -27
  52. data/lib/faker/default/vehicle.rb +21 -21
  53. data/lib/faker/default/vulnerability_identifier.rb +23 -0
  54. data/lib/faker/default/world_cup.rb +2 -11
  55. data/lib/faker/games/dota.rb +1 -5
  56. data/lib/faker/games/tarkov.rb +205 -0
  57. data/lib/faker/japanese_media/kamen_rider.rb +2 -2
  58. data/lib/faker/japanese_media/one_piece.rb +1 -1
  59. data/lib/faker/movies/hackers.rb +48 -0
  60. data/lib/faker/movies/star_wars.rb +1 -5
  61. data/lib/faker/movies/tron.rb +161 -0
  62. data/lib/faker/sports/mountaineering.rb +22 -0
  63. data/lib/faker/sports/sport.rb +110 -0
  64. data/lib/faker/version.rb +1 -1
  65. data/lib/faker.rb +15 -63
  66. data/lib/helpers/base58.rb +1 -1
  67. data/lib/helpers/unique_generator.rb +13 -11
  68. data/lib/locales/en/australia.yml +3 -4
  69. data/lib/locales/en/computer.yml +23 -4
  70. data/lib/locales/en/dota.yml +113 -0
  71. data/lib/locales/en/file.yml +9 -1
  72. data/lib/locales/en/finance.yml +3 -1
  73. data/lib/locales/en/game.yml +0 -1
  74. data/lib/locales/en/hackers.yml +53 -0
  75. data/lib/locales/en/heroes.yml +2 -2
  76. data/lib/locales/en/internet.yml +29 -0
  77. data/lib/locales/en/mountaineering.yml +14 -0
  78. data/lib/locales/en/movie.yml +2 -1
  79. data/lib/locales/en/naruto.yml +2 -3
  80. data/lib/locales/en/one_piece.yml +1 -1
  81. data/lib/locales/en/opera.yml +1 -1
  82. data/lib/locales/en/overwatch.yml +5 -7
  83. data/lib/locales/en/source.yml +5 -0
  84. data/lib/locales/en/sport.yml +130 -0
  85. data/lib/locales/en/tarkov.yml +593 -0
  86. data/lib/locales/en/tron.yml +227 -0
  87. data/lib/locales/en/vehicle.yml +2809 -75
  88. data/lib/locales/en-AU.yml +1 -1
  89. data/lib/locales/en-CA.yml +1 -0
  90. data/lib/locales/es-AR.yml +2 -2
  91. data/lib/locales/fi-FI.yml +2 -1
  92. data/lib/locales/fr/adjective.yml +266 -0
  93. data/lib/locales/fr/ancient.yml +141 -0
  94. data/lib/locales/hy.yml +1 -1
  95. data/lib/locales/ja/adjective.yml +148 -0
  96. data/lib/locales/ja/dog.yml +1 -0
  97. data/lib/locales/ja/emotion.yml +51 -0
  98. data/lib/locales/ja/naruto.yml +230 -0
  99. data/lib/locales/ja/relationship.yml +10 -0
  100. data/lib/locales/pl.yml +1 -1
  101. data/lib/locales/th.yml +76 -76
  102. metadata +65 -25
@@ -17,8 +17,6 @@ module Faker
17
17
  end
18
18
 
19
19
  class << self
20
- # rubocop:disable Metrics/ParameterLists
21
-
22
20
  ##
23
21
  # Generate a mock Omniauth response from Google.
24
22
  #
@@ -29,13 +27,7 @@ module Faker
29
27
  # @return [Hash] An auth hash in the format provided by omniauth-google.
30
28
  #
31
29
  # @faker.version 1.8.0
32
- def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 9).to_s)
33
- warn_for_deprecated_arguments do |keywords|
34
- keywords << :name if legacy_name != NOT_GIVEN
35
- keywords << :email if legacy_email != NOT_GIVEN
36
- keywords << :uid if legacy_uid != NOT_GIVEN
37
- end
38
-
30
+ def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s)
39
31
  auth = Omniauth.new(name: name, email: email)
40
32
  {
41
33
  provider: 'google_oauth2',
@@ -95,14 +87,7 @@ module Faker
95
87
  # @return [Hash] An auth hash in the format provided by omniauth-facebook.
96
88
  #
97
89
  # @faker.version 1.8.0
98
- def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
99
- warn_for_deprecated_arguments do |keywords|
100
- keywords << :name if legacy_name != NOT_GIVEN
101
- keywords << :email if legacy_email != NOT_GIVEN
102
- keywords << :username if legacy_username != NOT_GIVEN
103
- keywords << :uid if legacy_uid != NOT_GIVEN
104
- end
105
-
90
+ def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
106
91
  auth = Omniauth.new(name: name, email: email)
107
92
  username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
108
93
  {
@@ -154,13 +139,7 @@ module Faker
154
139
  # @return [Hash] An auth hash in the format provided by omniauth-twitter.
155
140
  #
156
141
  # @faker.version 1.8.0
157
- def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
158
- warn_for_deprecated_arguments do |keywords|
159
- keywords << :name if legacy_name != NOT_GIVEN
160
- keywords << :nickname if legacy_nickname != NOT_GIVEN
161
- keywords << :uid if legacy_uid != NOT_GIVEN
162
- end
163
-
142
+ def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
164
143
  auth = Omniauth.new(name: name)
165
144
  nickname ||= auth.name.downcase.delete(' ')
166
145
  location = city_state
@@ -243,13 +222,7 @@ module Faker
243
222
  # @return [Hash] An auth hash in the format provided by omniauth-linkedin.
244
223
  #
245
224
  # @faker.version 1.8.0
246
- def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 6).to_s)
247
- warn_for_deprecated_arguments do |keywords|
248
- keywords << :name if legacy_name != NOT_GIVEN
249
- keywords << :email if legacy_email != NOT_GIVEN
250
- keywords << :uid if legacy_uid != NOT_GIVEN
251
- end
252
-
225
+ def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s)
253
226
  auth = Omniauth.new(name: name, email: email)
254
227
  first_name = auth.first_name.downcase
255
228
  last_name = auth.last_name.downcase
@@ -322,13 +295,7 @@ module Faker
322
295
  # @return [Hash] An auth hash in the format provided by omniauth-github.
323
296
  #
324
297
  # @faker.version 1.8.0
325
- def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 8).to_s)
326
- warn_for_deprecated_arguments do |keywords|
327
- keywords << :name if legacy_name != NOT_GIVEN
328
- keywords << :email if legacy_email != NOT_GIVEN
329
- keywords << :uid if legacy_uid != NOT_GIVEN
330
- end
331
-
298
+ def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s)
332
299
  auth = Omniauth.new(name: name, email: email)
333
300
  login = auth.name.downcase.tr(' ', '-')
334
301
  html_url = "https://github.com/#{login}"
@@ -385,7 +352,6 @@ module Faker
385
352
  }
386
353
  }
387
354
  end
388
- # rubocop:enable Metrics/ParameterLists
389
355
 
390
356
  ##
391
357
  # Generate a mock Omniauth response from Apple.
@@ -123,11 +123,7 @@ module Faker
123
123
  # Faker::PhoneNumber.extension #=> "3764"
124
124
  #
125
125
  # @faker.version 1.3.0
126
- def subscriber_number(legacy_length = NOT_GIVEN, length: 4)
127
- warn_for_deprecated_arguments do |keywords|
128
- keywords << :length if legacy_length != NOT_GIVEN
129
- end
130
-
126
+ def subscriber_number(length: 4)
131
127
  rand.to_s[2..(1 + length)]
132
128
  end
133
129
 
@@ -5,8 +5,6 @@ module Faker
5
5
  class << self
6
6
  SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
7
7
 
8
- # rubocop:disable Metrics/ParameterLists
9
-
10
8
  ##
11
9
  # Produces a random placeholder image from https://via.placeholder.com.
12
10
  #
@@ -28,15 +26,7 @@ module Faker
28
26
  # Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://via.placeholder.com/50x50.jpg/ffffff/000?text=Some Custom Text"
29
27
  #
30
28
  # @faker.version 1.6.0
31
- def image(legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_background_color = NOT_GIVEN, legacy_text_color = NOT_GIVEN, legacy_text = NOT_GIVEN, size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
32
- warn_for_deprecated_arguments do |keywords|
33
- keywords << :size if legacy_size != NOT_GIVEN
34
- keywords << :format if legacy_format != NOT_GIVEN
35
- keywords << :background_color if legacy_background_color != NOT_GIVEN
36
- keywords << :text_color if legacy_text_color != NOT_GIVEN
37
- keywords << :text if legacy_text != NOT_GIVEN
38
- end
39
-
29
+ def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
40
30
  background_color = generate_color if background_color == :random
41
31
  text_color = generate_color if text_color == :random
42
32
 
@@ -51,7 +41,6 @@ module Faker
51
41
  image_url += "?text=#{text}" if text
52
42
  image_url
53
43
  end
54
- # rubocop:enable Metrics/ParameterLists
55
44
 
56
45
  private
57
46
 
@@ -14,11 +14,7 @@ module Faker
14
14
  # Faker::Relationship.familial #=> "Grandfather"
15
15
  #
16
16
  # @faker.version 1.9.2
17
- def familial(legacy_connection = NOT_GIVEN, connection: nil)
18
- warn_for_deprecated_arguments do |keywords|
19
- keywords << :connection if legacy_connection != NOT_GIVEN
20
- end
21
-
17
+ def familial(connection: nil)
22
18
  familial_connections = translate('faker.relationship.familial').keys
23
19
 
24
20
  if connection.nil?
@@ -17,11 +17,7 @@ module Faker
17
17
  # #=> "alert('Hello World!');"
18
18
  #
19
19
  # @faker.version 1.9.0
20
- def hello_world(legacy_lang = NOT_GIVEN, lang: :ruby)
21
- warn_for_deprecated_arguments do |keywords|
22
- keywords << :lang if legacy_lang != NOT_GIVEN
23
- end
24
-
20
+ def hello_world(lang: :ruby)
25
21
  fetch("source.hello_world.#{lang}")
26
22
  end
27
23
 
@@ -39,13 +35,7 @@ module Faker
39
35
  # #=> "console.log('foo bar');"
40
36
  #
41
37
  # @faker.version 1.9.0
42
- def print(legacy_str = NOT_GIVEN, legacy_lang = NOT_GIVEN, str: 'some string', lang: :ruby)
43
- warn_for_deprecated_arguments do |keywords|
44
- keywords << :str if legacy_str != NOT_GIVEN
45
- end
46
- warn_for_deprecated_arguments do |keywords|
47
- keywords << :lang if legacy_lang != NOT_GIVEN
48
- end
38
+ def print(str: 'some string', lang: :ruby)
49
39
  code = fetch("source.print.#{lang}")
50
40
  code.gsub('faker_string_to_print', str)
51
41
  end
@@ -65,10 +55,7 @@ module Faker
65
55
  # # }"
66
56
  #
67
57
  # @faker.version 1.9.0
68
- def print_1_to_10(legacy_lang = NOT_GIVEN, lang: :ruby)
69
- warn_for_deprecated_arguments do |keywords|
70
- keywords << :lang if legacy_lang != NOT_GIVEN
71
- end
58
+ def print_1_to_10(lang: :ruby)
72
59
  fetch("source.print_1_to_10.#{lang}")
73
60
  end
74
61
  end
@@ -17,11 +17,7 @@ module Faker
17
17
  # Faker::String.random(length: [1, (2..5), [3, 6], nil]) #=> "葓L#ћ"
18
18
  #
19
19
  # @faker.version 1.9.0
20
- def random(legacy_length = NOT_GIVEN, length: 32)
21
- warn_for_deprecated_arguments do |keywords|
22
- keywords << :length if legacy_length != NOT_GIVEN
23
- end
24
-
20
+ def random(length: 32)
25
21
  utf8string select_a length
26
22
  end
27
23
 
@@ -14,11 +14,7 @@ module Faker
14
14
  # Faker::Stripe.valid_card(card_type: "visa_debit") #=> "4000056655665556"
15
15
  #
16
16
  # @faker.version 1.9.0
17
- def valid_card(legacy_card_type = NOT_GIVEN, card_type: nil)
18
- warn_for_deprecated_arguments do |keywords|
19
- keywords << :card_type if legacy_card_type != NOT_GIVEN
20
- end
21
-
17
+ def valid_card(card_type: nil)
22
18
  valid_cards = translate('faker.stripe.valid_cards').keys
23
19
 
24
20
  if card_type.nil?
@@ -44,11 +40,7 @@ module Faker
44
40
  # Faker::Stripe.valid_token(card_type: "mc_debit") #=> "tok_mastercard_debit"
45
41
  #
46
42
  # @faker.version 1.9.0
47
- def valid_token(legacy_card_type = NOT_GIVEN, card_type: nil)
48
- warn_for_deprecated_arguments do |keywords|
49
- keywords << :card_type if legacy_card_type != NOT_GIVEN
50
- end
51
-
43
+ def valid_token(card_type: nil)
52
44
  valid_tokens = translate('faker.stripe.valid_tokens').keys
53
45
 
54
46
  if card_type.nil?
@@ -73,11 +65,7 @@ module Faker
73
65
  # Faker::Stripe.invalid_card(card_error: "addressZipFail") #=> "4000000000000010"
74
66
  #
75
67
  # @faker.version 1.9.0
76
- def invalid_card(legacy_card_error = NOT_GIVEN, card_error: nil)
77
- warn_for_deprecated_arguments do |keywords|
78
- keywords << :card_error if legacy_card_error != NOT_GIVEN
79
- end
80
-
68
+ def invalid_card(card_error: nil)
81
69
  invalid_cards = translate('faker.stripe.invalid_cards').keys
82
70
 
83
71
  if card_error.nil?
@@ -130,11 +118,7 @@ module Faker
130
118
  # Faker::Stripe.ccv(card_type: "amex") #=> "1234"
131
119
  #
132
120
  # @faker.version 1.9.0
133
- def ccv(legacy_card_type = NOT_GIVEN, card_type: nil)
134
- warn_for_deprecated_arguments do |keywords|
135
- keywords << :card_type if legacy_card_type != NOT_GIVEN
136
- end
137
-
121
+ def ccv(card_type: nil)
138
122
  (card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s
139
123
  end
140
124
  end
@@ -13,8 +13,6 @@ module Faker
13
13
  }.freeze
14
14
 
15
15
  class << self
16
- # rubocop:disable Metrics/ParameterLists
17
-
18
16
  ##
19
17
  # Produce a random time between two times.
20
18
  #
@@ -37,13 +35,7 @@ module Faker
37
35
  # Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :long) #=> "2018年10月16日(火) 10時48分27秒 -0500"
38
36
  #
39
37
  # @faker.version 1.5.0
40
- def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, format: nil)
41
- warn_for_deprecated_arguments do |keywords|
42
- keywords << :from if legacy_from != NOT_GIVEN
43
- keywords << :to if legacy_to != NOT_GIVEN
44
- keywords << :format if legacy_format != NOT_GIVEN
45
- end
46
-
38
+ def between(from:, to:, format: nil)
47
39
  from = get_time_object(from)
48
40
  to = get_time_object(to)
49
41
 
@@ -79,14 +71,7 @@ module Faker
79
71
  # #=> "Fri, 19 Oct 2018 15:17:46 -0500"
80
72
  #
81
73
  # @faker.version 1.0.0
82
- def between_dates(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, period: :all, format: nil)
83
- warn_for_deprecated_arguments do |keywords|
84
- keywords << :from if legacy_from != NOT_GIVEN
85
- keywords << :to if legacy_to != NOT_GIVEN
86
- keywords << :period if legacy_period != NOT_GIVEN
87
- keywords << :format if legacy_format != NOT_GIVEN
88
- end
89
-
74
+ def between_dates(from:, to:, period: :all, format: nil)
90
75
  date = Faker::Date.between(from: from, to: to)
91
76
  time = date_with_random_time(date, period)
92
77
  time_with_format(time, format)
@@ -107,13 +92,7 @@ module Faker
107
92
  # #=> "October 21, 2018 20:47"
108
93
  #
109
94
  # @faker.version 1.5.0
110
- def forward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
111
- warn_for_deprecated_arguments do |keywords|
112
- keywords << :days if legacy_days != NOT_GIVEN
113
- keywords << :period if legacy_period != NOT_GIVEN
114
- keywords << :format if legacy_format != NOT_GIVEN
115
- end
116
-
95
+ def forward(days: 365, period: :all, format: nil)
117
96
  time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format)
118
97
  end
119
98
 
@@ -132,16 +111,9 @@ module Faker
132
111
  # #=> "14 Oct 07:44"
133
112
  #
134
113
  # @faker.version 1.5.0
135
- def backward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
136
- warn_for_deprecated_arguments do |keywords|
137
- keywords << :days if legacy_days != NOT_GIVEN
138
- keywords << :period if legacy_period != NOT_GIVEN
139
- keywords << :format if legacy_format != NOT_GIVEN
140
- end
141
-
114
+ def backward(days: 365, period: :all, format: nil)
142
115
  time_with_format(date_with_random_time(Faker::Date.backward(days: days), period), format)
143
116
  end
144
- # rubocop:enable Metrics/ParameterLists
145
117
 
146
118
  private
147
119
 
@@ -16,12 +16,7 @@ module Faker
16
16
  # Faker::Twitter.user(include_email: true) # Simulate an authenticated user with the email permission
17
17
  #
18
18
  # @faker.version 1.7.3
19
- def user(legacy_include_status = NOT_GIVEN, legacy_include_email = NOT_GIVEN, include_status: true, include_email: false)
20
- warn_for_deprecated_arguments do |keywords|
21
- keywords << :include_status if legacy_include_status != NOT_GIVEN
22
- keywords << :include_email if legacy_include_email != NOT_GIVEN
23
- end
24
-
19
+ def user(include_status: true, include_email: false)
25
20
  user_id = id
26
21
  background_image_url = Faker::LoremPixel.image(size: '600x400') # TODO: Make the dimensions change
27
22
  profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48')
@@ -85,12 +80,7 @@ module Faker
85
80
  # Faker::Twitter.status(include_photo: true) # Includes entities for an attached image
86
81
  #
87
82
  # @faker.version 1.7.3
88
- def status(legacy_include_user = NOT_GIVEN, legacy_include_photo = NOT_GIVEN, include_user: true, include_photo: false)
89
- warn_for_deprecated_arguments do |keywords|
90
- keywords << :include_user if legacy_include_user != NOT_GIVEN
91
- keywords << :include_photo if legacy_include_photo != NOT_GIVEN
92
- end
93
-
83
+ def status(include_user: true, include_photo: false)
94
84
  status_id = id
95
85
  status = {
96
86
  id: status_id,
@@ -161,11 +151,7 @@ module Faker
161
151
  }
162
152
  end
163
153
 
164
- def status_entities(legacy_include_photo = NOT_GIVEN, include_photo: false)
165
- warn_for_deprecated_arguments do |keywords|
166
- keywords << :include_photo if legacy_include_photo != NOT_GIVEN
167
- end
168
-
154
+ def status_entities(include_photo: false)
169
155
  entities = {
170
156
  hashtags: [],
171
157
  symbols: [],
@@ -16,11 +16,7 @@ module Faker
16
16
  # Faker::Types.rb_string #=> "foobar"
17
17
  #
18
18
  # @faker.version 1.8.6
19
- def rb_string(legacy_words = NOT_GIVEN, words: 1)
20
- warn_for_deprecated_arguments do |keywords|
21
- keywords << :words if legacy_words != NOT_GIVEN
22
- end
23
-
19
+ def rb_string(words: 1)
24
20
  resolved_num = resolve(words)
25
21
  word_list =
26
22
  translate('faker.lorem.words')
@@ -51,12 +47,7 @@ module Faker
51
47
  # Faker::Types.rb_integer #=> 1
52
48
  #
53
49
  # @faker.version 1.8.6
54
- def rb_integer(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 100)
55
- warn_for_deprecated_arguments do |keywords|
56
- keywords << :from if legacy_from != NOT_GIVEN
57
- keywords << :to if legacy_to != NOT_GIVEN
58
- end
59
-
50
+ def rb_integer(from: 0, to: 100)
60
51
  rand(from..to).to_i
61
52
  end
62
53
 
@@ -72,12 +63,7 @@ module Faker
72
63
  # Faker::Types.rb_hash(number: 2) #=> {name: "bob", last: "marley"}
73
64
  #
74
65
  # @faker.version 1.8.6
75
- def rb_hash(legacy_number = NOT_GIVEN, legacy_type = NOT_GIVEN, number: 1, type: -> { random_type })
76
- warn_for_deprecated_arguments do |keywords|
77
- keywords << :number if legacy_number != NOT_GIVEN
78
- keywords << :type if legacy_type != NOT_GIVEN
79
- end
80
-
66
+ def rb_hash(number: 1, type: -> { random_type })
81
67
  {}.tap do |hsh|
82
68
  Lorem.words(number: number * 2).uniq.first(number).each do |s|
83
69
  value = type.is_a?(Proc) ? type.call : type
@@ -98,11 +84,7 @@ module Faker
98
84
  # Faker::Types.complex_rb_hash(number: 2) #=> {user: {first: "bob", last: "marley"}, son: ["damien", "marley"]}
99
85
  #
100
86
  # @faker.version 1.8.6
101
- def complex_rb_hash(legacy_number = NOT_GIVEN, number: 1)
102
- warn_for_deprecated_arguments do |keywords|
103
- keywords << :number if legacy_number != NOT_GIVEN
104
- end
105
-
87
+ def complex_rb_hash(number: 1)
106
88
  rb_hash(number: number, type: -> { random_complex_type })
107
89
  end
108
90
 
@@ -117,11 +99,7 @@ module Faker
117
99
  # Faker::Types.rb_array(len: 4) #=> ["a", 1, 2, "bob"]
118
100
  #
119
101
  # @faker.version 1.8.6
120
- def rb_array(legacy_len = NOT_GIVEN, len: 1)
121
- warn_for_deprecated_arguments do |keywords|
122
- keywords << :len if legacy_len != NOT_GIVEN
123
- end
124
-
102
+ def rb_array(len: 1)
125
103
  [].tap do |ar|
126
104
  len.times do
127
105
  ar.push random_type
@@ -9,7 +9,7 @@ module Faker
9
9
  VIN_LETTERS = 'ABCDEFGHJKLMNPRSTUVWXYZ'
10
10
  VIN_MAP = '0123456789X'
11
11
  VIN_WEIGHTS = '8765432X098765432'
12
- VIN_REGEX = /^[A-Z0-9]{3}[A-Z0-9]{5}[A-Z0-9]{1}[A-Z0-9]{1}[A-Z0-0]{1}[A-Z0-9]{1}\d{5}$/.freeze
12
+ VIN_REGEX = /^([A-HJ-NPR-Z0-9]){3}[A-HJ-NPR-Z0-9]{5}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}\d{5}$/.freeze
13
13
  SG_CHECKSUM_WEIGHTS = [3, 14, 2, 12, 2, 11, 1].freeze
14
14
  SG_CHECKSUM_CHARS = 'AYUSPLJGDBZXTRMKHEC'
15
15
 
@@ -62,11 +62,7 @@ module Faker
62
62
  # Faker::Vehicle.model(make_of_model: 'Toyota') #=> "Prius"
63
63
  #
64
64
  # @faker.version 1.6.4
65
- def model(legacy_make_of_model = NOT_GIVEN, make_of_model: '')
66
- warn_for_deprecated_arguments do |keywords|
67
- keywords << :make_of_model if legacy_make_of_model != NOT_GIVEN
68
- end
69
-
65
+ def model(make_of_model: '')
70
66
  return fetch("vehicle.models_by_make.#{make}") if make_of_model.empty?
71
67
 
72
68
  fetch("vehicle.models_by_make.#{make_of_model}")
@@ -249,12 +245,7 @@ module Faker
249
245
  # Faker::Vehicle.kilometrage #=> 35378
250
246
  #
251
247
  # @faker.version 1.6.4
252
- def mileage(legacy_min = NOT_GIVEN, legacy_max = NOT_GIVEN, min: MILEAGE_MIN, max: MILEAGE_MAX)
253
- warn_for_deprecated_arguments do |keywords|
254
- keywords << :min if legacy_min != NOT_GIVEN
255
- keywords << :max if legacy_max != NOT_GIVEN
256
- end
257
-
248
+ def mileage(min: MILEAGE_MIN, max: MILEAGE_MAX)
258
249
  rand_in_range(min, max)
259
250
  end
260
251
 
@@ -271,11 +262,7 @@ module Faker
271
262
  # Faker::Vehicle.license_plate(state_abbreviation: 'FL') #=> "977 UNU"
272
263
  #
273
264
  # @faker.version 1.6.4
274
- def license_plate(legacy_state_abreviation = NOT_GIVEN, state_abbreviation: '')
275
- warn_for_deprecated_arguments do |keywords|
276
- keywords << :state_abbreviation if legacy_state_abreviation != NOT_GIVEN
277
- end
278
-
265
+ def license_plate(state_abbreviation: '')
279
266
  return regexify(bothify(fetch('vehicle.license_plate'))) if state_abbreviation.empty?
280
267
 
281
268
  key = "vehicle.license_plate_by_state.#{state_abbreviation}"
@@ -297,6 +284,19 @@ module Faker
297
284
  "#{plate_number}#{singapore_checksum(plate_number)}"
298
285
  end
299
286
 
287
+ ##
288
+ # Produces a car version
289
+ #
290
+ # @return [String]
291
+ #
292
+ # @example
293
+ # Faker::Vehicle.version #=> "40 TFSI Premium"
294
+ #
295
+ # @faker.version next
296
+ def version
297
+ fetch('vehicle.version')
298
+ end
299
+
300
300
  private
301
301
 
302
302
  def first_eight(number)
@@ -320,7 +320,7 @@ module Faker
320
320
  end
321
321
 
322
322
  def vin_char_to_number(char)
323
- index = VIN_LETTERS.split('').index(char)
323
+ index = VIN_LETTERS.chars.index(char)
324
324
 
325
325
  return char.to_i if index.nil?
326
326
 
@@ -328,14 +328,14 @@ module Faker
328
328
  end
329
329
 
330
330
  def singapore_checksum(plate_number)
331
- padded_alphabets = format('%3s', plate_number[/^[A-Z]+/]).tr(' ', '-').split('')
332
- padded_digits = format('%04d', plate_number[/\d+/]).split('').map(&:to_i)
331
+ padded_alphabets = format('%3s', plate_number[/^[A-Z]+/]).tr(' ', '-').chars
332
+ padded_digits = format('%04d', plate_number[/\d+/]).chars.map(&:to_i)
333
333
  sum = [*padded_alphabets, *padded_digits].each_with_index.reduce(0) do |memo, (char, i)|
334
334
  value = char.is_a?(Integer) ? char : char.ord - 64
335
335
  memo + (SG_CHECKSUM_WEIGHTS[i] * value)
336
336
  end
337
337
 
338
- SG_CHECKSUM_CHARS.split('')[sum % 19]
338
+ SG_CHECKSUM_CHARS.chars[sum % 19]
339
339
  end
340
340
  end
341
341
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class VulnerabilityIdentifier < Base
5
+ class << self
6
+ ##
7
+ # Produces a Common Vulnerabilities and Exposures (CVE) identifier.
8
+ #
9
+ # @param year [Integer] The year-part of the CVE identifier (defaults to the current year)
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # Faker::VulnerabilityIdentifier.cve #=> "CVE-2021-1337"
14
+ # Faker::VulnerabilityIdentifier.cve(year: 1999) #=> "CVE-1999-0523"
15
+ #
16
+ # @faker.version next
17
+ def cve(year: ::Date.today.year)
18
+ index = rand_in_range(1, 99_999).to_s.rjust(4, '0')
19
+ "CVE-#{year}-#{index}"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -53,11 +53,7 @@ module Faker
53
53
  # Faker::WorldCup.group #=> "Russia"
54
54
  #
55
55
  # @faker.version 2.13.0
56
- def group(legacy_group = NOT_GIVEN, group: 'group_A')
57
- warn_for_deprecated_arguments do |keywords|
58
- keywords << :group if legacy_group != NOT_GIVEN
59
- end
60
-
56
+ def group(group: 'group_A')
61
57
  fetch("world_cup.groups.#{group}")
62
58
  end
63
59
 
@@ -73,12 +69,7 @@ module Faker
73
69
  # Faker::WorldCup.roster(country: 'Spain', type: 'forwards') #=> "Diego Costa"
74
70
  #
75
71
  # @faker.version 2.13.0
76
- def roster(legacy_country = NOT_GIVEN, legacy_type = NOT_GIVEN, country: 'Egypt', type: 'coach')
77
- warn_for_deprecated_arguments do |keywords|
78
- keywords << :country if legacy_country != NOT_GIVEN
79
- keywords << :type if legacy_type != NOT_GIVEN
80
- end
81
-
72
+ def roster(country: 'Egypt', type: 'coach')
82
73
  fetch("world_cup.rosters.#{country}.#{type}")
83
74
  end
84
75
  end
@@ -80,11 +80,7 @@ module Faker
80
80
  # Faker::Games::Dota.quote(hero: 'alchemist') #=> "Better living through alchemy!"
81
81
  #
82
82
  # @faker.version 1.9.0
83
- def quote(legacy_hero = NOT_GIVEN, hero: 'abaddon')
84
- warn_for_deprecated_arguments do |keywords|
85
- keywords << :hero if legacy_hero != NOT_GIVEN
86
- end
87
-
83
+ def quote(hero: 'abaddon')
88
84
  fetch("games.dota.#{hero}.quote")
89
85
  end
90
86
  end