faker 3.4.2 → 3.5.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf806bbcecec3b286e05fe7c79f0b4274708a3a7f55add0b3488a3ba8bf574f6
4
- data.tar.gz: 688f47f7f92a4b58281ef2e3beb0df72e134e916929d7aa1ff4e6db07af9151d
3
+ metadata.gz: dc659ae3f4a2f8e2d7f7fc3a22903c5a1e81138110b8ddeced3b6969ad92e22d
4
+ data.tar.gz: a0370b7a158c4fe7a40b3a32500e45997cb0fa5b753e507f65cbbebe66523c2a
5
5
  SHA512:
6
- metadata.gz: 4cd84609a1b8b0d846f5185cd544141e22d8296a2bcbe4a613daabcdadde8afa1039a9087dafbf7b7ccba7668ff5c506b1ca25cbebd3520455760a16dea45cd6
7
- data.tar.gz: ab939601c6ceeb1f051d708687a61e2a89c3e9da77881159866a73cb5039c9292101cb48d3b19c36607b1cbf25192e8895e7e49b0dde1e88c0e07c0e24e75f01
6
+ metadata.gz: fa3feb382544da65be21255d723278ef89ba1c470a572267b61c5adb9c4e5b171668356bd30f339be12a735d605722118ad0e6d302b3c3774e987cd76bdc3763
7
+ data.tar.gz: 031cadfc32e4f3faaf68d971a18cda06caa01a610da3449a4fe3d5fe9c0523979b4426b9fbb699a6a6f2511958223875d783e7b792aebb390a4d871bbbbae59d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,119 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.5.2](https://github.com/faker-ruby/faker/tree/v3.5.2) (2025-07-01)
4
+
5
+ Happy Canada Day! 🍁
6
+
7
+ This version adds and improves some locales and fixes some bugs.
8
+
9
+ Thanks to all contributors!
10
+
11
+ ### Improvements & Bug fixes
12
+ * Correct `Faker::Address.city` and `Faker::Address.street_address` for `:fr` locale by @brupla6126 in https://github.com/faker-ruby/faker/pull/3018
13
+ * fix condominium_fiscal_code generator length from 9 to 11 characters by @FiloSpaTeam in https://github.com/faker-ruby/faker/pull/3037
14
+ * Add Cell Phone, Default Time Zone and State Abbreviation translation for en-PAK locale by @wonderer007 in https://github.com/faker-ruby/faker/pull/3024
15
+ * Fix usage docs header indentation by @jaredsmithse in https://github.com/faker-ruby/faker/pull/3049
16
+ * Fix nl phone format by @klaaspieter in https://github.com/faker-ruby/faker/pull/3050
17
+ * Fix typo in `ja/book` locale by @thdaraujo in https://github.com/faker-ruby/faker/pull/3062
18
+ * fix a typo by @jethrodaniel in https://github.com/faker-ruby/faker/pull/3060
19
+ * Fix typo in `restaurant.yml` by @daniel-nerdgeschoss in https://github.com/faker-ruby/faker/pull/3067
20
+ * Fix city address with number in `locales/fr/address.yml` by @brupla6126 in https://github.com/faker-ruby/faker/pull/3071
21
+ * Fix unclosed quote in `locales/en/cosmere.yml` by @bensheldon in https://github.com/faker-ruby/faker/pull/3075
22
+ * Remove inappropriate word from ja lorem by @se4weed in https://github.com/faker-ruby/faker/pull/3095
23
+ * Add mountains to de-CH locale by @codez in https://github.com/faker-ruby/faker/pull/3066
24
+ * Bump i18n from 1.14.6 to 1.14.7 by @dependabot in https://github.com/faker-ruby/faker/pull/3042
25
+
26
+ ### Chore
27
+ * ci: run against Ruby 3.4 by @thdaraujo in https://github.com/faker-ruby/faker/pull/3079
28
+ * Fix Broken CI by @wonderer007 in https://github.com/faker-ruby/faker/pull/3073
29
+
30
+ ### Update local dependencies
31
+ * Bump rubocop from 1.67.0 to 1.68.0 by @dependabot in https://github.com/faker-ruby/faker/pull/3020
32
+ * Bump rubocop from 1.68.0 to 1.69.2 by @dependabot in https://github.com/faker-ruby/faker/pull/3035
33
+ * Bump rubocop version + offenses fixes by @stefannibrasil in https://github.com/faker-ruby/faker/pull/3053
34
+ * deps: update dev dependencies by @thdaraujo in https://github.com/faker-ruby/faker/pull/3078
35
+ * Bump rubocop-minitest and fix rubocop's offense by @stefannibrasil in https://github.com/faker-ruby/faker/pull/3052
36
+ * Bump rubocop-minitest from 0.38.0 to 0.38.1 by @dependabot in https://github.com/faker-ruby/faker/pull/3088
37
+ * Bump rubocop-rake from 0.6.0 to 0.7.1 by @dependabot in https://github.com/faker-ruby/faker/pull/3059
38
+ * deps: bump `rubocop-minitest` from `0.37.1` to `0.38.0`. by @thdaraujo in https://github.com/faker-ruby/faker/pull/3080
39
+ * Bump minitest from 5.25.1 to 5.25.4 by @dependabot in https://github.com/faker-ruby/faker/pull/3031
40
+ * Bump test-unit from 3.6.2 to 3.6.7 by @dependabot in https://github.com/faker-ruby/faker/pull/3038
41
+ * Bump benchmark from 0.3.0 to 0.4.0 by @dependabot in https://github.com/faker-ruby/faker/pull/3021
42
+ * Bump benchmark from 0.4.0 to 0.4.1 by @dependabot in https://github.com/faker-ruby/faker/pull/3087
43
+ * Bump pry from 0.14.2 to 0.15.2 by @dependabot in https://github.com/faker-ruby/faker/pull/3039
44
+ * Bump rake from 13.2.1 to 13.3.0 by @dependabot in https://github.com/faker-ruby/faker/pull/3086
45
+ * Bump test-unit from 3.6.8 to 3.6.9 by @dependabot in https://github.com/faker-ruby/faker/pull/3096
46
+
47
+ ### New Contributors
48
+ * @brupla6126 made their first contribution in https://github.com/faker-ruby/faker/pull/3018
49
+ * @jaredsmithse made their first contribution in https://github.com/faker-ruby/faker/pull/3049
50
+ * @klaaspieter made their first contribution in https://github.com/faker-ruby/faker/pull/3050
51
+ * @jethrodaniel made their first contribution in https://github.com/faker-ruby/faker/pull/3060
52
+ * @daniel-nerdgeschoss made their first contribution in https://github.com/faker-ruby/faker/pull/3067
53
+ * @bensheldon made their first contribution in https://github.com/faker-ruby/faker/pull/3075
54
+ * @se4weed made their first contribution in https://github.com/faker-ruby/faker/pull/3095
55
+
56
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.5.1...v3.5.2
57
+
58
+ ---------------------------------
59
+
60
+ ## [v3.5.1](https://github.com/faker-ruby/faker/tree/v3.5.1) (2024-10-18)
61
+
62
+ Happy October! 🎃
63
+
64
+ This version **drops support for Ruby < 3.0**. We only support one EOL Ruby version at a time. Please upgrade to Ruby 3.0 to update to this and future versions of faker-ruby.
65
+
66
+ Besides that, this version removes deprecated generators, fixes some bugs, and adds a Security Policy.
67
+
68
+ Thanks to all contributors!
69
+
70
+ ### Breaking Changes
71
+ * Drop support for Ruby 2.7 by @tatheerf02 in https://github.com/faker-ruby/faker/pull/3006
72
+ * Removes deprecated generators by @stefannibrasil in https://github.com/faker-ruby/faker/pull/3014
73
+
74
+ The following deprecated generators are being removed. Please use the new generators:
75
+
76
+
77
+ | Deprecated | New |
78
+ | -------- | ------- |
79
+ | Faker::TvShows::TheFreshPrinceOfBelAir.celebrity | Faker::TvShows::TheFreshPrinceOfBelAir.actor |
80
+ | Faker::TvShows::Buffy.celebrity | Faker::TvShows::Buffy.actor |
81
+ | Faker::TvShows::DrWho.villian | Faker::TvShows::DrWho.villain |
82
+ | Faker::Games::HeroesOfTheStorm.class | Faker::Games::HeroesOfTheStorm.class_name |
83
+ | Faker::JapaneseMedia::FmaBrotherhood | Faker::JapaneseMedia::FullmetalAlchemistBrotherhood |
84
+ | Faker::Show | Faker::Theater |
85
+ | Faker::Australia | Faker::Locations::Australia |
86
+ | Faker::IDNumber | Faker::IdNumber |
87
+
88
+ ### Improvements & Bug fixes
89
+ * Fix typos by @tagliala in https://github.com/faker-ruby/faker/pull/2982
90
+ * Fix benchmark:all_methods task by excluding Faker::Deprecator module from benchmark target by @amatsuda in https://github.com/faker-ruby/faker/pull/2988
91
+ * Add Brazilian Portuguese translations for `Faker::Subscription` by @murichristopher in https://github.com/faker-ruby/faker/pull/2960
92
+ * Deprecator improvements by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2997
93
+ * Faker::Alphanumeric.alphanumeric determinism fix by @admtnnr in https://github.com/faker-ruby/faker/pull/2996
94
+ * Remove CodeClimate badges by @tagliala in https://github.com/faker-ruby/faker/pull/3003
95
+ * Update Company.logo example url by @dirschn in https://github.com/faker-ruby/faker/pull/3007
96
+ * fix(music.band): removes leading whitespace by @JeremasPosta in https://github.com/faker-ruby/faker/pull/3015
97
+ * Create SECURITY.md by @stefannibrasil in https://github.com/faker-ruby/faker/pull/3016
98
+
99
+ ### Update local dependencies
100
+ * Bump i18n from 1.14.5 to 1.14.6 by @dependabot in https://github.com/faker-ruby/faker/pull/3005
101
+ * Bump minitest from 5.24.1 to 5.25.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2991
102
+ * Bump rubocop-minitest from 0.35.1 to 0.36.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2999
103
+ * Bump yard from 0.9.36 to 0.9.37 by @dependabot in https://github.com/faker-ruby/faker/pull/3000
104
+ * Bump rubocop from 1.65.1 to 1.66.1 by @dependabot in https://github.com/faker-ruby/faker/pull/3001
105
+
106
+ ### New Contributors
107
+ * @murichristopher made their first contribution in https://github.com/faker-ruby/faker/pull/2960
108
+ * @admtnnr made their first contribution in https://github.com/faker-ruby/faker/pull/2996
109
+ * @dirschn made their first contribution in https://github.com/faker-ruby/faker/pull/3007
110
+ * @tatheerf02 made their first contribution in https://github.com/faker-ruby/faker/pull/3006
111
+ * @JeremasPosta made their first contribution in https://github.com/faker-ruby/faker/pull/3015
112
+
113
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.4.2...v3.5.1
114
+
115
+ --------------------------------------
116
+
3
117
  ## [v3.4.2](https://github.com/faker-ruby/faker/tree/v3.4.2) (2024-07-16)
4
118
 
5
119
  Happy July with a new faker-ruby release.
@@ -36,7 +150,7 @@ Breaking change was introduced in "Add test range param to NHS numbers" by @nean
36
150
  * Bump rubocop from 1.64.1 to 1.65.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2979
37
151
  * Bump rubocop-minitest from 0.35.0 to 0.35.1 by @dependabot in https://github.com/faker-ruby/faker/pull/2980
38
152
 
39
- ## New Contributors
153
+ ### New Contributors
40
154
  * @twk-mn made their first contribution in https://github.com/faker-ruby/faker/pull/2961
41
155
  * @neanias made their first contribution in https://github.com/faker-ruby/faker/pull/2947
42
156
  * @garrettgregor made their first contribution in https://github.com/faker-ruby/faker/pull/2963
@@ -79,7 +193,7 @@ Breaking change was introduced in "Add test range param to NHS numbers" by @nean
79
193
  * Bump minitest from 5.22.3 to 5.23.1 by @dependabot in https://github.com/faker-ruby/faker/pull/2957
80
194
  * Bump rubocop from 1.63.4 to 1.64.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2958
81
195
 
82
- ## New Contributors
196
+ ### New Contributors
83
197
 
84
198
  * @connie-feng made their first contribution in https://github.com/faker-ruby/faker/pull/2930
85
199
  * @andrelaszlo made their first contribution in https://github.com/faker-ruby/faker/pull/2927
@@ -234,7 +348,7 @@ This version:
234
348
  * Bump rubocop from 1.57.1 to 1.57.2 by @dependabot in https://github.com/faker-ruby/faker/pull/2844
235
349
  * Bump timecop from 0.9.6 to 0.9.8 by @dependabot in https://github.com/faker-ruby/faker/pull/2811
236
350
 
237
- ## New Contributors
351
+ ### New Contributors
238
352
  * @BelaBartok39 made their first contribution in https://github.com/faker-ruby/faker/pull/2812
239
353
  * @fernandomenolli made their first contribution in https://github.com/faker-ruby/faker/pull/2816
240
354
  * @hoshy made their first contribution in https://github.com/faker-ruby/faker/pull/2818
@@ -298,7 +412,7 @@ Other changes included in this version:
298
412
  * Update rubocop-minitest requirement from = 0.30.0 to = 0.31.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2759
299
413
  * Bump minitest from 5.18.1 to 5.19.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2804
300
414
 
301
- ## New Contributors
415
+ ### New Contributors
302
416
  * @old-dead-account made their first contribution in https://github.com/faker-ruby/faker/pull/2742
303
417
  * @IvanReyesO7 made their first contribution in https://github.com/faker-ruby/faker/pull/2744
304
418
  * @DeepakRaj228 made their first contribution in https://github.com/faker-ruby/faker/pull/2741
@@ -365,7 +479,7 @@ Other changes included in this version:
365
479
  * Add Faker::Company.department generator by @acuppy in https://github.com/faker-ruby/faker/pull/2737
366
480
  * Update Pull Request template and guides by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2749
367
481
 
368
- ## New Contributors
482
+ ### New Contributors
369
483
  * @lexisvar made their first contribution in https://github.com/faker-ruby/faker/pull/2699
370
484
  * @danieldiekmeier made their first contribution in https://github.com/faker-ruby/faker/pull/2700
371
485
  * @AaronRustad made their first contribution in https://github.com/faker-ruby/faker/pull/2706
@@ -2549,7 +2663,7 @@ Fix lib/faker/version.rb
2549
2663
  - Fixed typo in dutch translation [\#679](https://github.com/stympy/faker/pull/679) ([nschmoller](https://github.com/nschmoller))
2550
2664
  - Add pokemon [\#677](https://github.com/stympy/faker/pull/677) ([bakunyo](https://github.com/bakunyo))
2551
2665
  - Food [\#672](https://github.com/stympy/faker/pull/672) ([martymclaugh](https://github.com/martymclaugh))
2552
- - Added charcaters and houses data for game of thrones in en.yml [\#670](https://github.com/stympy/faker/pull/670) ([vamsipavanmahesh](https://github.com/vamsipavanmahesh))
2666
+ - Added characters and houses data for game of thrones in en.yml [\#670](https://github.com/stympy/faker/pull/670) ([vamsipavanmahesh](https://github.com/vamsipavanmahesh))
2553
2667
  - add Faker::Commerce.promotion\_code [\#669](https://github.com/stympy/faker/pull/669) ([jGRUBBS](https://github.com/jGRUBBS))
2554
2668
  - Eliminate and prevent leading and trailing white space [\#665](https://github.com/stympy/faker/pull/665) ([retroGiant89](https://github.com/retroGiant89))
2555
2669
  - Fix for memory overflow error Issue: \#478 [\#664](https://github.com/stympy/faker/pull/664) ([anuj-verma](https://github.com/anuj-verma))
data/README.md CHANGED
@@ -4,8 +4,6 @@
4
4
  [![Tests](https://github.com/faker-ruby/faker/workflows/Tests/badge.svg)](https://github.com/faker-ruby/faker/actions?query=workflow%3ATests)
5
5
  [![Gem Version](https://badge.fury.io/rb/faker.svg)](https://badge.fury.io/rb/faker)
6
6
  [![Inline docs](https://inch-ci.org/github/faker-ruby/faker.svg?branch=main)](https://inch-ci.org/github/faker-ruby/faker)
7
- [![Test Coverage](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/test_coverage)](https://codeclimate.com/github/stympy/faker/test_coverage)
8
- [![Maintainability](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/maintainability)](https://codeclimate.com/github/stympy/faker/maintainability)
9
7
 
10
8
  Faker is a port of [Perl's Data::Faker library](https://metacpan.org/pod/Data::Faker).
11
9
  It's a library for generating fake data such as names, addresses, and phone numbers.
@@ -40,7 +38,7 @@ and it was the original impetus for the creation of this gem.
40
38
  - [Notes](#notes)
41
39
  - [Getting Started](#getting-started)
42
40
  - [Usage](#usage)
43
- - [A note about the Generators versions](#a-note-about-the-generators-versions)
41
+ - [A note about the Generators versions](#a-note-about-the-generators-versions)
44
42
  - [Ensuring unique values](#ensuring-unique-values)
45
43
  - [Deterministic Random](#deterministic-random)
46
44
  - [Customization](#customization)
@@ -91,7 +89,7 @@ Faker::ProgrammingLanguage.name #=> "Ruby"
91
89
 
92
90
  For a complete list of the generators, see [Generators](#generators).
93
91
 
94
- #### A note about the Generators versions
92
+ ### A note about the Generators versions
95
93
 
96
94
  If you get a `uninitialized constant Faker::[some_class]` error, your version of
97
95
  the gem is behind main.
@@ -60,7 +60,7 @@ module Faker
60
60
  randoms = Array.new(random_count) { sample(ALPHANUMS) }
61
61
 
62
62
  combined = alphas + numbers + randoms
63
- combined.shuffle.join
63
+ shuffle!(combined).join
64
64
  end
65
65
  end
66
66
  end
@@ -168,6 +168,7 @@ module Faker
168
168
 
169
169
  # Reporting body identifier
170
170
  RBI = %w[01 10 30 33 35 44 45 49 50 51 52 53 54 86 91 98 99].freeze
171
+ private_constant :RBI
171
172
 
172
173
  def generate_imei
173
174
  str = Array.new(15, 0)
@@ -269,7 +270,10 @@ module Faker
269
270
  end
270
271
 
271
272
  EAN_CHECK_DIGIT8 = [3, 1, 3, 1, 3, 1, 3].freeze
273
+ private_constant :EAN_CHECK_DIGIT8
274
+
272
275
  EAN_CHECK_DIGIT13 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3].freeze
276
+ private_constant :EAN_CHECK_DIGIT13
273
277
 
274
278
  def rut_verificator_digit(rut)
275
279
  total = rut.to_s.rjust(8, '0').chars.zip(%w[3 2 7 6 5 4 3 2]).collect { |a, b| a.to_i * b.to_i }.inject(:+)
@@ -494,7 +494,7 @@ module Faker
494
494
  # Construct taxpayer number
495
495
  gen.group(name: :taxpayer_number) do |g_|
496
496
  g_.letter(length: 3, ranges: ['A'..'Z'])
497
- g_.letter(length: 1, ranges: [%w[A B C F G H L J P T K]].to_a)
497
+ g_.letter(length: 1, ranges: [%w[A B C F G H L J P T K]])
498
498
  g_.letter(length: 1, ranges: ['A'..'Z'])
499
499
  g_.int(length: 4, ranges: [0..9999])
500
500
  g_.letter(length: 1, ranges: ['A'..'Z'])
@@ -104,7 +104,7 @@ module Faker
104
104
  end
105
105
  g.computed do
106
106
  gender_marker = gender == :female ? 50 : 0
107
- format('%02d', (dob.month + gender_marker))
107
+ format('%02d', dob.month + gender_marker)
108
108
  end
109
109
  g.computed do
110
110
  format('%02d', dob.day)
@@ -97,11 +97,11 @@ module Faker
97
97
  ##
98
98
  # Returns a random condominium fiscal code.
99
99
  #
100
- # @param country [String] Two capital letter country code to use for the vat number.
100
+ # @param country [String] Two capital letter country code to use for the condominium fiscal code number.
101
101
  # @return [String]
102
102
  #
103
103
  # @example
104
- # Faker::Finance.condominium_fiscal_code #=> "012345678"
104
+ # Faker::Finance.condominium_fiscal_code #=> "01234567890"
105
105
  #
106
106
  # @faker.version next
107
107
  def condominium_fiscal_code(country: 'IT')
@@ -12,7 +12,7 @@ module Faker
12
12
  ].freeze
13
13
  ZA_RACE_DIGIT = '8'
14
14
  ZA_CITIZENSHIP_DIGITS = %w[0 1].freeze
15
- BRAZILIAN_ID_FORMAT = /(\d{1,2})(\d{3})(\d{3})([\dX])/.freeze
15
+ BRAZILIAN_ID_FORMAT = /(\d{1,2})(\d{3})(\d{3})([\dX])/
16
16
  BRAZILIAN_ID_FROM = 10_000_000
17
17
  BRAZILIAN_ID_TO = 99_999_999
18
18
 
@@ -421,7 +421,4 @@ module Faker
421
421
  end
422
422
  end
423
423
  end
424
-
425
- include Faker::Deprecator
426
- deprecate_generator('IDNumber', IdNumber)
427
424
  end
@@ -267,7 +267,7 @@ module Faker
267
267
  # Faker::Internet.mac_address(prefix: 'aa:44') #=> "aa:44:30:88:6e:95"
268
268
  def mac_address(prefix: '')
269
269
  prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
270
- address_digits = Array.new((6 - prefix_digits.size)) { rand(256) }
270
+ address_digits = Array.new(6 - prefix_digits.size) { rand(256) }
271
271
  (prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':')
272
272
  end
273
273
 
@@ -13,8 +13,8 @@ module Faker
13
13
  # @return [Integer]
14
14
  #
15
15
  # @example
16
- # Faker::Finance.amount_between #=> 0
17
- # Faker::Finance.amount_between(0, 10) #=> 4.33
16
+ # Faker::Invoice.amount_between #=> 0
17
+ # Faker::Invoice.amount_between(from: 0, to: 10) #=> 4.33
18
18
  #
19
19
  # @faker.version 1.9.0
20
20
  def amount_between(from: 0, to: 0)
@@ -22,7 +22,7 @@ module Faker
22
22
  end
23
23
 
24
24
  ##
25
- # Produces a random valid reference accoring to the International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
25
+ # Produces a random valid reference according to the International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
26
26
  #
27
27
  # @param ref [String] Specifies reference base.
28
28
  # @return [String]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Faker
2
4
  class Json < Base
3
5
  require 'json'
@@ -104,17 +106,20 @@ module Faker
104
106
  end
105
107
 
106
108
  def add_hash(key_array, hash, width, options)
107
- string_to_eval = 'hash'
109
+ string_to_eval = 'hash'.dup
110
+
108
111
  key_array.length.times do |index|
109
112
  string_to_eval << "['#{key_array[index]}']"
110
113
  end
111
114
  string_to_eval << " = #{build_shallow_hash(width, options)}"
112
115
  eval(string_to_eval)
116
+
113
117
  hash
114
118
  end
115
119
 
116
120
  def build_keys_from_array(key_array)
117
- key_string = ''
121
+ key_string = ''.dup
122
+
118
123
  key_array.each do |value|
119
124
  key_string << "['#{value}']"
120
125
  end
@@ -20,8 +20,7 @@ module Faker
20
20
  # If the check digit is equivalent to 10, the number is invalid.
21
21
  # See https://en.wikipedia.org/wiki/NHS_number
22
22
  base_number -= 1 if check_digit(number: base_number) == 10
23
- "#{base_number}#{check_digit(number: base_number)}".to_s
24
- .chars
23
+ "#{base_number}#{check_digit(number: base_number)}".chars
25
24
  .insert(3, ' ')
26
25
  .insert(7, ' ')
27
26
  .join
@@ -45,7 +45,7 @@ module Faker
45
45
  private
46
46
 
47
47
  def generate_color
48
- format('%06x', (rand * 0xffffff))
48
+ format('%06x', rand * 0xffffff)
49
49
  end
50
50
  end
51
51
  end
@@ -46,7 +46,4 @@ module Faker
46
46
  end
47
47
  end
48
48
  end
49
-
50
- include Faker::Deprecator
51
- deprecate_generator('Show', Theater)
52
49
  end
@@ -17,17 +17,6 @@ module Faker
17
17
  fetch('heroes_of_the_storm.battlegrounds')
18
18
  end
19
19
 
20
- ##
21
- # This method is deprecated. The implementation will be removed in a near future release.
22
- # Use `HeroesOfTheStorm.class_name` instead.
23
- #
24
- # @deprecated Use {#class_name} instead.
25
- def class
26
- warn '`HeroesOfTheStorm.class` is deprecated. Use `HeroesOfTheStorm.class_name` instead.'
27
-
28
- super
29
- end
30
-
31
20
  ##
32
21
  # Produces a class name from Heroes of the Storm.
33
22
  #
@@ -44,8 +44,5 @@ module Faker
44
44
  end
45
45
  end
46
46
  end
47
-
48
- include Faker::Deprecator
49
- deprecate_generator('FmaBrotherhood', FullmetalAlchemistBrotherhood)
50
47
  end
51
48
  end
@@ -46,7 +46,4 @@ module Faker
46
46
  end
47
47
  end
48
48
  end
49
-
50
- include Deprecator
51
- deprecate_generator('Australia', Locations::Australia)
52
49
  end
@@ -204,7 +204,7 @@ module Faker
204
204
  # @example
205
205
  # Faker::Movies::StarWars.droids
206
206
  #
207
- # @faker.versionn 1.6.2
207
+ # @faker.version 1.6.2
208
208
  def droids
209
209
  fetch_all('star_wars.droids')
210
210
  end
@@ -45,19 +45,6 @@ module Faker
45
45
  fetch('buffy.actors')
46
46
  end
47
47
 
48
- ##
49
- # Produces a actor from Buffy the Vampire Slayer.
50
- #
51
- # @return [String]
52
- #
53
- # @example
54
- # Faker::TvShows::Buffy.celebrity #=> "John Ritter"
55
- #
56
- # @deprecated Use the `actor` method instead.
57
- #
58
- # @faker.version 1.9.2
59
- alias celebrity actor
60
-
61
48
  ##
62
49
  # Produces a big bad from Buffy the Vampire Slayer.
63
50
  #
@@ -84,19 +84,6 @@ module Faker
84
84
  fetch('dr_who.villains')
85
85
  end
86
86
 
87
- ##
88
- # Produces a villain from Doctor Who.
89
- #
90
- # @return [String]
91
- #
92
- # @example
93
- # Faker::TvShows::DrWho.villian #=> "The Master"
94
- #
95
- # @deprecated Use the correctly-spelled `villain` method instead.
96
- #
97
- # @faker.version 1.8.0
98
- alias villian villain
99
-
100
87
  ##
101
88
  # Produces a species from Doctor Who.
102
89
  #
@@ -32,19 +32,6 @@ module Faker
32
32
  fetch('the_fresh_prince_of_bel_air.actors')
33
33
  end
34
34
 
35
- ##
36
- # Produces a actor from The Fresh Prince of Bel-Air.
37
- #
38
- # @return [String]
39
- #
40
- # @example
41
- # Faker::TvShows::TheFreshPrinceOfBelAir.celebrity #=> "Quincy Jones"
42
- #
43
- # @deprecated Use the `actor` method instead.
44
- #
45
- # @faker.version 1.8.3
46
- alias celebrity actor
47
-
48
35
  ##
49
36
  # Produces a quote from The Fresh Prince of Bel-Air.
50
37
  #
data/lib/faker/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faker # :nodoc:
4
- VERSION = '3.4.2'
4
+ VERSION = '3.5.2'
5
5
  end
data/lib/faker.rb CHANGED
@@ -5,7 +5,7 @@ mydir = __dir__
5
5
  require 'psych'
6
6
  require 'i18n'
7
7
 
8
- Dir.glob(File.join(mydir, 'helpers', '*.rb')).sort.each { |file| require file }
8
+ Dir.glob(File.join(mydir, 'helpers', '*.rb')).each { |file| require file }
9
9
 
10
10
  I18n.load_path += Dir[File.join(mydir, 'locales', '**/*.yml')]
11
11
 
@@ -107,7 +107,7 @@ module Faker
107
107
  # with an array of values and selecting one of them.
108
108
  def fetch(key)
109
109
  fetched = sample(translate("faker.#{key}"))
110
- if fetched&.match(%r{^/}) && fetched&.match(%r{/$}) # A regex
110
+ if fetched&.match(%r{^/}) && fetched.match(%r{/$}) # A regex
111
111
  regexify(fetched)
112
112
  else
113
113
  fetched
@@ -249,6 +249,10 @@ module Faker
249
249
  list.shuffle(random: Faker::Config.random)
250
250
  end
251
251
 
252
+ def shuffle!(list)
253
+ list.shuffle!(random: Faker::Config.random)
254
+ end
255
+
252
256
  def rand(max = nil)
253
257
  if max.nil?
254
258
  Faker::Config.random.rand
@@ -271,4 +275,4 @@ module Faker
271
275
  end
272
276
 
273
277
  # require faker objects
274
- Dir.glob(File.join(mydir, 'faker', '/**/*.rb')).sort.each { |file| require file }
278
+ Dir.glob(File.join(mydir, 'faker', '/**/*.rb')).each { |file| require file }
@@ -1,17 +1,70 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Based on Rails ActiveSupport Deprecator
4
- # https://github.com/rails/rails/blob/6f0d1ad14b92b9f5906e44740fce8b4f1c7075dc/activesupport/lib/active_support/deprecation/constant_accessor.rb
4
+ # https://github.com/rails/rails/blob/main/activesupport/lib/active_support/deprecation/constant_accessor.rb
5
5
 
6
6
  # rubocop:disable Style/ClassVars
7
7
  module Faker
8
+ # Provides a way to rename generators, including their namespaces, with a deprecation cycle in which
9
+ # both the old and new names work, but using the old one prints a deprecation message.
10
+ #
11
+ # Deprecator provides a deprecate_generator method to be used when
12
+ # renaming a generator. For example, let's say we want to change the following Generator's
13
+ # name to <tt>Faker::NewGenerator</tt>:
14
+ #
15
+ # module Faker
16
+ # class Generator
17
+ # def self.generate
18
+ # "be kind"
19
+ # end
20
+ # end
21
+ # end
22
+ #
23
+ # To rename it, you need to do the update the name and declare the deprecation by
24
+ # including the <tt>Deprecator</tt> module and using the deprecate_generator method:
25
+ #
26
+ # module Faker
27
+ # class NewGenerator
28
+ # def self.generate
29
+ # "be kind"
30
+ # end
31
+ # end
32
+ #
33
+ # include Deprecator
34
+ # deprecate_generator('DeprecatedGenerator', NewGenerator)
35
+ # end
36
+ #
37
+ # The first argument is a constant name (no colons) as a string. It is the name of
38
+ # the constant you want to deprecate.
39
+ #
40
+ # The second argument is the constant path of the replacement (no colons) as a constant.
41
+ #
42
+ # For this to work, a +const_missing+ hook is installed. When users
43
+ # reference the deprecated constant, the callback prints the
44
+ # message and constantizes the replacement.
45
+ #
46
+ # With that in place, references to <tt>Faker::Deprecator</tt> still work, they
47
+ # evaluate to <tt>Faker::NewGenerator</tt> now, and trigger a deprecation warning:
48
+ #
49
+ # Faker::Generator.generate
50
+ # # DEPRECATION WARNING: Faker::Generator is deprecated. Use Faker::NewGenerator instead
51
+ # # "be kind"
52
+ #
53
+ # For testing the deprecations, we provide <tt>assert_deprecated</tt>
54
+ # and <tt>assert_not_deprecated</tt> matchers.
55
+ #
56
+ # There's also a <tt>Faker::Deprecator.skip_warning</tt> helper to silence
57
+ # the deprecation messages in the *test* output. Use it for generators that have lots of tests
58
+ # to avoid too many noise when running the tests.
8
59
  module Deprecator
9
60
  def self.included(base)
10
61
  extension = Module.new do
11
62
  def const_missing(missing_const_name)
12
63
  if class_variable_defined?(:@@_deprecated_constants) && (replacement = class_variable_get(:@@_deprecated_constants)[missing_const_name.to_s])
13
64
  unless Faker::Deprecator.skip_warning?
14
- $stdout.puts("DEPRECATION WARNING: #{name}::#{replacement[:old_generator]} is deprecated. Use #{replacement[:new_constant]} instead.")
65
+ deprecated_message = "#{name}::#{replacement[:old_generator]} is deprecated."
66
+ replacement_message = "Use #{replacement[:new_constant]} instead."
67
+ $stdout.puts("DEPRECATION WARNING: #{deprecated_message} #{replacement_message}")
15
68
  end
16
69
 
17
70
  return replacement[:new_constant]
@@ -22,13 +75,25 @@ module Faker
22
75
 
23
76
  def deprecate_generator(old_generator_name, new_generator_constant)
24
77
  class_variable_set(:@@_deprecated_constants, {}) unless class_variable_defined?(:@@_deprecated_constants)
25
- class_variable_get(:@@_deprecated_constants)[old_generator_name] = { new_constant: new_generator_constant, old_generator: old_generator_name }
78
+ class_variable_get(:@@_deprecated_constants)[old_generator_name] = {
79
+ new_constant: new_generator_constant,
80
+ old_generator: old_generator_name
81
+ }
26
82
  end
27
83
  end
28
84
 
29
85
  base.singleton_class.prepend extension
30
86
  end
31
87
 
88
+ # Silence deprecation warnings within the block.
89
+ #
90
+ # Faker::Generator.generate
91
+ # # => DEPRECATION WARNING: Faker::Generator is deprecated. Use Faker::NewGenerator instead.
92
+ #
93
+ # Faker::Deprecator.skip_warning do
94
+ # Faker::Generator.generate
95
+ # end
96
+ # # => nil
32
97
  def self.skip_warning
33
98
  original = Faker::Deprecator.skip
34
99
  Faker::Deprecator.skip = true
@@ -38,7 +103,7 @@ module Faker
38
103
  end
39
104
 
40
105
  def self.skip_warning?
41
- skip == true
106
+ @skip == true
42
107
  end
43
108
 
44
109
  def self.skip