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 +4 -4
- data/CHANGELOG.md +120 -6
- data/README.md +2 -4
- data/lib/faker/default/alphanumeric.rb +1 -1
- data/lib/faker/default/code.rb +4 -0
- data/lib/faker/default/company.rb +1 -1
- data/lib/faker/default/driving_licence.rb +1 -1
- data/lib/faker/default/finance.rb +2 -2
- data/lib/faker/default/id_number.rb +1 -4
- data/lib/faker/default/internet.rb +1 -1
- data/lib/faker/default/invoice.rb +3 -3
- data/lib/faker/default/json.rb +7 -2
- data/lib/faker/default/national_health_service.rb +1 -2
- data/lib/faker/default/placeholdit.rb +1 -1
- data/lib/faker/default/theater.rb +0 -3
- data/lib/faker/games/heroes_of_the_storm.rb +0 -11
- data/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb +0 -3
- data/lib/faker/locations/australia.rb +0 -3
- data/lib/faker/movies/star_wars.rb +1 -1
- data/lib/faker/tv_shows/buffy.rb +0 -13
- data/lib/faker/tv_shows/dr_who.rb +0 -13
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +0 -13
- data/lib/faker/version.rb +1 -1
- data/lib/faker.rb +7 -3
- data/lib/helpers/deprecator.rb +69 -4
- data/lib/locales/de-CH.yml +31 -0
- data/lib/locales/en/cosmere.yml +1 -1
- data/lib/locales/en/finance.yml +1 -1
- data/lib/locales/en/music.yml +25 -25
- data/lib/locales/en/restaurant.yml +1 -1
- data/lib/locales/en-PAK.yml +24 -1
- data/lib/locales/fr/address.yml +761 -8
- data/lib/locales/ja/book.yml +492 -3
- data/lib/locales/ja/lorem.yml +1 -1
- data/lib/locales/nl.yml +9 -1
- data/lib/locales/pt-BR.yml +50 -0
- metadata +4 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc659ae3f4a2f8e2d7f7fc3a22903c5a1e81138110b8ddeced3b6969ad92e22d
|
4
|
+
data.tar.gz: a0370b7a158c4fe7a40b3a32500e45997cb0fa5b753e507f65cbbebe66523c2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
[](https://github.com/faker-ruby/faker/actions?query=workflow%3ATests)
|
5
5
|
[](https://badge.fury.io/rb/faker)
|
6
6
|
[](https://inch-ci.org/github/faker-ruby/faker)
|
7
|
-
[](https://codeclimate.com/github/stympy/faker/test_coverage)
|
8
|
-
[](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
|
-
|
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
|
-
|
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.
|
data/lib/faker/default/code.rb
CHANGED
@@ -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]]
|
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'])
|
@@ -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
|
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 #=> "
|
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])
|
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(
|
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::
|
17
|
-
# Faker::
|
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
|
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]
|
data/lib/faker/default/json.rb
CHANGED
@@ -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)}".
|
24
|
-
.chars
|
23
|
+
"#{base_number}#{check_digit(number: base_number)}".chars
|
25
24
|
.insert(3, ' ')
|
26
25
|
.insert(7, ' ')
|
27
26
|
.join
|
@@ -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
|
#
|
data/lib/faker/tv_shows/buffy.rb
CHANGED
@@ -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
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')).
|
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
|
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')).
|
278
|
+
Dir.glob(File.join(mydir, 'faker', '/**/*.rb')).each { |file| require file }
|
data/lib/helpers/deprecator.rb
CHANGED
@@ -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/
|
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
|
-
|
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] = {
|
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
|