faker 3.2.3 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +160 -0
  3. data/README.md +13 -5
  4. data/lib/faker/default/company.rb +68 -0
  5. data/lib/faker/default/id_number.rb +23 -20
  6. data/lib/faker/default/internet.rb +1 -39
  7. data/lib/faker/default/json.rb +2 -2
  8. data/lib/faker/default/phone_number.rb +37 -18
  9. data/lib/faker/default/south_africa.rb +3 -3
  10. data/lib/faker/{music/show.rb → default/theater.rb} +11 -8
  11. data/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb +13 -10
  12. data/lib/faker/locations/australia.rb +43 -38
  13. data/lib/faker/movies/{room.rb → the_room.rb} +4 -4
  14. data/lib/faker/music/smashing_pumpkins.rb +64 -0
  15. data/lib/faker/version.rb +1 -1
  16. data/lib/helpers/deprecator.rb +30 -0
  17. data/lib/locales/bg.yml +0 -1
  18. data/lib/locales/da-DK.yml +529 -37
  19. data/lib/locales/de-AT.yml +3487 -26
  20. data/lib/locales/de-CH.yml +51 -59
  21. data/lib/locales/de.yml +7182 -100
  22. data/lib/locales/ee.yml +0 -1
  23. data/lib/locales/en/address.yml +1826 -561
  24. data/lib/locales/en/australia.yml +106 -105
  25. data/lib/locales/en/bank.yml +1 -1
  26. data/lib/locales/en/finance.yml +3 -3
  27. data/lib/locales/en/{fma_brotherhood.yml → fullmetal_alchemist_brotherhood.yml} +3 -3
  28. data/lib/locales/en/harry_potter.yml +1 -1
  29. data/lib/locales/en/id_number.yml +1 -1
  30. data/lib/locales/en/internet.yml +0 -4
  31. data/lib/locales/en/phone_number.yml +78 -3
  32. data/lib/locales/en/smashing_pumpkins.yml +382 -0
  33. data/lib/locales/en/{room.yml → the_room.yml} +1 -1
  34. data/lib/locales/en/{show.yml → theater.yml} +1 -1
  35. data/lib/locales/en-AU.yml +718 -47
  36. data/lib/locales/en-CA.yml +373 -19
  37. data/lib/locales/en-GB.yml +116 -9
  38. data/lib/locales/en-IND.yml +1259 -17
  39. data/lib/locales/en-KE.yml +212 -0
  40. data/lib/locales/en-MS.yml +364 -18
  41. data/lib/locales/en-NEP.yml +212 -38
  42. data/lib/locales/en-NZ.yml +1153 -124
  43. data/lib/locales/en-PAK.yml +369 -11
  44. data/lib/locales/en-SG.yml +581 -17
  45. data/lib/locales/en-US.yml +6914 -74
  46. data/lib/locales/en-au-ocker.yml +266 -24
  47. data/lib/locales/es-AR.yml +4569 -4600
  48. data/lib/locales/es-MX.yml +0 -1
  49. data/lib/locales/es.yml +0 -1
  50. data/lib/locales/fr/internet.yml +0 -1
  51. data/lib/locales/fr-CA.yml +2733 -44
  52. data/lib/locales/fr-CH.yml +0 -1
  53. data/lib/locales/fr.yml +3 -1
  54. data/lib/locales/hy.yml +3624 -120
  55. data/lib/locales/id.yml +839 -12
  56. data/lib/locales/it.yml +1304 -33
  57. data/lib/locales/ko.yml +0 -1
  58. data/lib/locales/lt.yml +297 -16
  59. data/lib/locales/lv.yml +0 -1
  60. data/lib/locales/nb-NO.yml +518 -30
  61. data/lib/locales/nl.yml +0 -1
  62. data/lib/locales/pl.yml +0 -1
  63. data/lib/locales/pt-BR.yml +8155 -665
  64. data/lib/locales/pt.yml +844 -45
  65. data/lib/locales/ru.yml +1353 -70
  66. data/lib/locales/sk.yml +4410 -44
  67. data/lib/locales/tr.yml +0 -2
  68. data/lib/locales/uk.yml +1808 -47
  69. data/lib/locales/zh-CN/bank.yml +17 -0
  70. metadata +17 -13
  71. data/History.md +0 -176
  72. /data/lib/faker/default/{nhs.rb → national_health_service.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 112f3ff9d25ba44af343bb059444316208fc86e1c9fe4431255f539ec2fd024b
4
- data.tar.gz: 92ac1fb90a7a741c644a8141e2c57b4f03a3a42594b5419809ec1202f533bb06
3
+ metadata.gz: 9cb066b564608902aac8699487a9d11cb48bac922915f51b2ca7d5e9ed2c3d5f
4
+ data.tar.gz: edfabcbea53ec9ed1c7acd2dcf6c8fe6475efa56bae692758aaf6103de771993
5
5
  SHA512:
6
- metadata.gz: adf886de17ac9e4e26ac6a00df3a3d2adca6e1cf2d0a0492c04e0c983f67a318b70c904e2ce06029fc381540bc37aaa4826b6d4b1930c1a171ef9e18245934bd
7
- data.tar.gz: 21de6006567bc40cac19809a948235914081958cf62b44d5c44c6e834675a0b0d1d9a590533ee1177c6d405a320c3728799e29fd88a7986011e52a6973748394
6
+ metadata.gz: f76bde79e5d96a73b34d487a7bb2a8d1cc5f05631d9ba48952edbb2a3f6470409586a974676c329b7a61112f338c33ad631e6362a4c54242e4d61efe52f1f29c
7
+ data.tar.gz: dcb683004a0cc255d076059a3b199870a921473355358d25afd73f904255db7f30297779ec75364ddebb2f806a6a874ef0e328e3dcce0549a3b6dfea8ee96e0a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,165 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.3.1](https://github.com/faker-ruby/faker/tree/v3.3.1) (2024-04-02)
4
+
5
+ ### Bug fixes
6
+
7
+ * Fix bug on phone number generator for `en-US` locale caused by incorrect `.yml` file structure by @aprescott in https://github.com/faker-ruby/faker/pull/2924
8
+
9
+ ### What's Changed
10
+
11
+ * Added docs for Deprecator in CONTRIBUTING.md by @keshavbiswa in https://github.com/faker-ruby/faker/pull/2919
12
+ * Rename Faker::show to Faker::Theater by @keshavbiswa in https://github.com/faker-ruby/faker/pull/2921
13
+ * renamed nhs to national_health_service by @keshavbiswa in https://github.com/faker-ruby/faker/pull/2923
14
+
15
+ ### New Contributors
16
+ * @aprescott made their first contribution in https://github.com/faker-ruby/faker/pull/2924
17
+
18
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.3.0...v3.3.1
19
+
20
+ -------------------------
21
+
22
+ ## [v3.3.0](https://github.com/faker-ruby/faker/tree/v3.3.0) (2024-03-25)
23
+
24
+ ### Bug Fixes
25
+
26
+ * Remove the duplicate method Faker::Commerce.material description by @mmarusyk in https://github.com/faker-ruby/faker/pull/2914
27
+
28
+ ### Features
29
+
30
+ * Add Kenya to supported countries by @AndrewNduati in https://github.com/faker-ruby/faker/pull/2871
31
+ * Benchmarking loading JSON file vs YML file by @salochara in https://github.com/faker-ruby/faker/pull/2897
32
+
33
+ ### What's changed
34
+
35
+ * Fix/Deprecate `Faker::IDNumber` to `Faker::IdNumber` to be more consistent with other generator's naming convention. by @Jamal-A-Mohamed in https://github.com/faker-ruby/faker/pull/2858
36
+ * Fix/Deprecate FmaBrotherhood Generator by @kirkkwang in https://github.com/faker-ruby/faker/pull/2856
37
+ * Fix/Deprecate Faker::Australia to Faker::Locations::Australia by @keshavbiswa in https://github.com/faker-ruby/faker/pull/2869
38
+ * Add note about EOL dependencies by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2890
39
+
40
+ ### Update local dependencies
41
+
42
+ * Bump test-unit from 3.6.1 to 3.6.2 by @dependabot in https://github.com/faker-ruby/faker/pull/2906
43
+ * Bump i18n from 1.14.1 to 1.14.4 by @dependabot in https://github.com/faker-ruby/faker/pull/2913
44
+ * Bump rubocop from 1.60.2 to 1.62.1 by @dependabot in https://github.com/faker-ruby/faker/pull/2916
45
+ * Bump yard from 0.9.34 to 0.9.36 by @dependabot in https://github.com/faker-ruby/faker/pull/2909
46
+ * Bump minitest from 5.22.2 to 5.22.3 by @dependabot in https://github.com/faker-ruby/faker/pull/2917
47
+
48
+ ### New Contributors
49
+
50
+ * @AndrewNduati made their first contribution in https://github.com/faker-ruby/faker/pull/2871
51
+ * @Jamal-A-Mohamed made their first contribution in https://github.com/faker-ruby/faker/pull/2858
52
+ * @mmarusyk made their first contribution in https://github.com/faker-ruby/faker/pull/2914
53
+
54
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.2.3...v3.3.0
55
+
56
+ -------------------------
57
+
58
+ ## [v3.2.3](https://github.com/faker-ruby/faker/tree/v3.2.3) (2024-01-12)
59
+
60
+ ### What's Changed
61
+
62
+ Happy 2024 with a new faker-ruby release.
63
+
64
+ This version includes bug and documentation fixes, and some changes on the contributing guides.
65
+
66
+ ### faker-ruby is is not accepting new features proposals
67
+
68
+ As we [discussed here](https://github.com/orgs/faker-ruby/discussions/2877), we want to improve faker's performance and organization. There hasn't been to many bug reports and most of the open issues are related to performance and confusion around using faker.
69
+
70
+ As we have limited time to invest in faker, reviewing _new_ generators and locales prevent us from focusing on the big picture work. With this decision, we hope to make the necessary changes for faker to go to the next level. Please read the Contributing guides for ways to help us get there.
71
+
72
+ ### Bug fixes
73
+ * Fix Phone number long number and other updates by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2842
74
+ * Favor 'The Room' instead of 'Room' by @kirkkwang in https://github.com/faker-ruby/faker/pull/2854
75
+ * Limit generated Discover cards to 19 digits by @jamie in https://github.com/faker-ruby/faker/pull/2845
76
+ * Fix Typo in README Link: Update sports.md to sport.md by @hatsu38 in https://github.com/faker-ruby/faker/pull/2859
77
+ * Fix country names and codes in address by @sudeeptarlekar in https://github.com/faker-ruby/faker/pull/2850
78
+ * fixed typo for README. Faker::JapaneseMedia::CowboyBebop by @jacoyutorius in https://github.com/faker-ruby/faker/pull/2863
79
+ * Fix typo in `Faker::Movies::HarryPotter.location` (Castelobruxo) by @leomartins1999 in https://github.com/faker-ruby/faker/pull/2866
80
+ * Fix flaky spec on `TestFakerFile#test_file_name` by @keshavbiswa in https://github.com/faker-ruby/faker/pull/2868
81
+ * Update `Internet#username` separator param to match with the example by @AlexandreL0pes in https://github.com/faker-ruby/faker/pull/2882
82
+ * fix polish bban_pattern by @artur1313 in https://github.com/faker-ruby/faker/pull/2887
83
+
84
+ ### What's Changed
85
+ * Add benchmark by @salochara in https://github.com/faker-ruby/faker/pull/2855
86
+ * Freeze new generator and locales by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2886
87
+ * Remove deprecate safe_email and free_email methods by @hatsu38 in https://github.com/faker-ruby/faker/pull/2841
88
+ * Update contribution guidelines and PULL_REQUEST_TEMPLATE by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2878
89
+ * Remove unmaintained `History.md` by @y-yagi in https://github.com/faker-ruby/faker/pull/2880
90
+ * Adds Ruby 3.3 to the CI matrix by @m-nakamura145 in https://github.com/faker-ruby/faker/pull/2883
91
+
92
+ ### Update local dependencies
93
+ * Bump rubocop from 1.58.0 to 1.59.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2865
94
+ * Bump rubocop-minitest from 0.34.3 to 0.34.4 by @dependabot in https://github.com/faker-ruby/faker/pull/2884
95
+ * Bump minitest version by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2889
96
+
97
+ ### New Contributors
98
+ * @kirkkwang made their first contribution in https://github.com/faker-ruby/faker/pull/2854
99
+ * @jamie made their first contribution in https://github.com/faker-ruby/faker/pull/2845
100
+ * @hatsu38 made their first contribution in https://github.com/faker-ruby/faker/pull/2859
101
+ * @salochara made their first contribution in https://github.com/faker-ruby/faker/pull/2855
102
+ * @jacoyutorius made their first contribution in https://github.com/faker-ruby/faker/pull/2863
103
+ * @leomartins1999 made their first contribution in https://github.com/faker-ruby/faker/pull/2866
104
+ * @keshavbiswa made their first contribution in https://github.com/faker-ruby/faker/pull/2868
105
+ * @y-yagi made their first contribution in https://github.com/faker-ruby/faker/pull/2880
106
+ * @AlexandreL0pes made their first contribution in https://github.com/faker-ruby/faker/pull/2882
107
+ * @m-nakamura145 made their first contribution in https://github.com/faker-ruby/faker/pull/2883
108
+ * @artur1313 made their first contribution in https://github.com/faker-ruby/faker/pull/2887
109
+
110
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.2.2...v.3.2.3
111
+
112
+ -------------------------
113
+
114
+ ## [v3.2.2](https://github.com/faker-ruby/faker/tree/v3.2.2) (2023-11-03)
115
+
116
+ Happy November with a new faker-ruby release.
117
+
118
+ This version:
119
+ - adds generators
120
+ - fixes bugs
121
+ - updates dev and dependencies
122
+ - updates docs
123
+
124
+ ### Features
125
+ * feat: add danish country code by @hoshy in https://github.com/faker-ruby/faker/pull/2818
126
+ * Add `zh-CN` translations for Bank names by @guxiaobai in https://github.com/faker-ruby/faker/pull/2840
127
+ * Add Code Scanning by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2835
128
+ * Add Japanese for Games Touhou by @shiroemons in https://github.com/faker-ruby/faker/pull/2829
129
+ * Added Faker::Company.indian_gst_number fixed #2823 by @ankitkhadria in https://github.com/faker-ruby/faker/pull/2825
130
+ * Adds Smashing Pumpkins to the Music module by @redconfetti in https://github.com/faker-ruby/faker/pull/2817
131
+
132
+ ### Bug fixes
133
+ * Delete doc/default/michael_scott.md by @jmromer in https://github.com/faker-ruby/faker/pull/2837
134
+ * Fix typo in `lib/locales/README.md` by @BelaBartok39 in https://github.com/faker-ruby/faker/pull/2812
135
+
136
+ ### What's Changed
137
+ * Update contributing and maintaining guides by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2836
138
+ * Changed tests from x.times loop to deterministically_verify helper. #2813 issue by @fernandomenolli in https://github.com/faker-ruby/faker/pull/2816
139
+ * Improve `#deterministically_verify` helper by @erichmachado in https://github.com/faker-ruby/faker/pull/2828
140
+
141
+ ### Update local dependencies
142
+ * Bump minitest from 5.19.0 to 5.20.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2826
143
+ * Bump rake from 13.0.6 to 13.1.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2846
144
+ * Bump rubocop-minitest from 0.32.2 to 0.33.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2843
145
+ * Bump rubocop from 1.57.1 to 1.57.2 by @dependabot in https://github.com/faker-ruby/faker/pull/2844
146
+ * Bump timecop from 0.9.6 to 0.9.8 by @dependabot in https://github.com/faker-ruby/faker/pull/2811
147
+
148
+ ## New Contributors
149
+ * @BelaBartok39 made their first contribution in https://github.com/faker-ruby/faker/pull/2812
150
+ * @fernandomenolli made their first contribution in https://github.com/faker-ruby/faker/pull/2816
151
+ * @hoshy made their first contribution in https://github.com/faker-ruby/faker/pull/2818
152
+ * @shiroemons made their first contribution in https://github.com/faker-ruby/faker/pull/2829
153
+ * @erichmachado made their first contribution in https://github.com/faker-ruby/faker/pull/2828
154
+ * @jmromer made their first contribution in https://github.com/faker-ruby/faker/pull/2837
155
+ * @guxiaobai made their first contribution in https://github.com/faker-ruby/faker/pull/2840
156
+ * @redconfetti made their first contribution in https://github.com/faker-ruby/faker/pull/2817
157
+ * @ankitkhadria made their first contribution in https://github.com/faker-ruby/faker/pull/2825
158
+
159
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.2.1...v3.2.2
160
+
161
+ -------------------------
162
+
3
163
  ## [v3.2.1](https://github.com/faker-ruby/faker/tree/v3.2.1) (2023-08-11)
4
164
 
5
165
  Happy August with a new Faker release! 🎉
data/README.md CHANGED
@@ -248,7 +248,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
248
248
  - [Faker::Hipster](doc/default/hipster.md)
249
249
  - [Faker::Hobby](doc/default/hobby.md)
250
250
  - [Faker::House](doc/default/house.md)
251
- - [Faker::IDNumber](doc/default/id_number.md)
251
+ - [Faker::IdNumber](doc/default/id_number.md)
252
252
  - [Faker::IndustrySegments](doc/default/industry_segments.md)
253
253
  - [Faker::Internet](doc/default/internet.md)
254
254
  - [Faker::Invoice](doc/default/invoice.md)
@@ -284,6 +284,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
284
284
  - [Faker::Superhero](doc/default/superhero.md)
285
285
  - [Faker::Tea](doc/default/tea.md)
286
286
  - [Faker::Team](doc/default/team.md)
287
+ - [Faker::Theater](doc/default/theater.md)
287
288
  - [Faker::Time](doc/default/time.md)
288
289
  - [Faker::Twitter](doc/default/twitter.md)
289
290
  - [Faker::Types](doc/default/types.md)
@@ -376,7 +377,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
376
377
  - [Faker::JapaneseMedia::Naruto](doc/japanese_media/naruto.md)
377
378
  - [Faker::JapaneseMedia::Doraemon](doc/japanese_media/doraemon.md)
378
379
  - [Faker::JapaneseMedia::Conan](doc/japanese_media/conan.md)
379
- - [Faker::JapaneseMedia::FmaBrotherhood](doc/japanese_media/fullmetal_alchemist_brotherhood.md)
380
+ - [Faker::JapaneseMedia::FullmetalAlchemistBrotherhood](doc/japanese_media/fullmetal_alchemist_brotherhood.md)
380
381
  </details>
381
382
 
382
383
  <details>
@@ -411,6 +412,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
411
412
  - [Faker::Music::Prince](doc/music/prince.md)
412
413
  - [Faker::Music::RockBand](doc/music/rock_band.md)
413
414
  - [Faker::Music::Rush](doc/music/rush.md)
415
+ - [Faker::Music::SmashingPumpkins](doc/music/smashing_pumpkins.md)
414
416
  - [Faker::Music::UmphreysMcgee](doc/music/umphreys_mcgee.md)
415
417
  </details>
416
418
 
@@ -426,7 +428,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
426
428
  <details>
427
429
  <summary>Sports</summary>
428
430
 
429
- - [Faker::Sports](doc/sports/sports.md)
431
+ - [Faker::Sport](doc/sports/sport.md)
430
432
  - [Faker::Sports::Basketball](doc/sports/basketball.md)
431
433
  - [Faker::Sports::Chess](doc/sports/chess.md)
432
434
  - [Faker::Sports::Football](doc/sports/football.md)
@@ -476,12 +478,18 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
476
478
  - [Faker::TvShows::VentureBros](doc/tv_shows/venture_bros.md)
477
479
  </details>
478
480
 
481
+ <details>
482
+ <summary>Locations</summary>
483
+
484
+ - [Faker::Locations::Australia](doc/locations/australia.md)
485
+ </details>
486
+
479
487
  ## Contributing
480
488
 
481
- If you have problems, please create a [GitHub Issue](/.github/ISSUE_TEMPLATE/bug-report.md).
489
+ **Note**: We are not accepting proposals for new generators and locales. The [Contributing](CONTRIBUTING.md) guide has a few notes about this decision.
482
490
 
483
491
  Take a look at the [Contributing](CONTRIBUTING.md) document for
484
- instructions on setting up the repo on your machine, understanding the codebase,
492
+ instructions on setting up the repo on your machine, opening bug reports, understanding the codebase,
485
493
  and creating a good pull request.
486
494
 
487
495
  There is a [Discord channel](https://discord.gg/RMumTwB) to discuss anything
@@ -464,6 +464,61 @@ module Faker
464
464
  fetch('company.sic_code')
465
465
  end
466
466
 
467
+ ##
468
+ # Get a random Indian Goods and Services Tax (GST) number.
469
+ # For more on Indian tax number here:
470
+ # https://simple.wikipedia.org/wiki/GSTIN
471
+ # @params state code [String] Any state code.
472
+ #
473
+ # @return [String]
474
+ # @example
475
+ # Faker::Company.indian_gst_number #=> "15VQPNZ2126J2ZU"
476
+ # Faker::Company.indian_gst_number(state_code: "22") #=> "22ZVWEY6632K0ZN"
477
+ #
478
+ # @faker.version 3.2.1
479
+ def indian_gst_number(state_code: nil)
480
+ # Check if state code is valid
481
+ state_code_ranges = [('02'..'38'), ['98']]
482
+ if state_code && !(state_code_ranges[0].include?(state_code) || state_code == '98')
483
+ raise ArgumentError, 'state code must be in a range of 02 to 38 or 98'
484
+ end
485
+
486
+ PositionalGenerator.new(:string) do |gen|
487
+ # Generate a state code if not given
488
+ if state_code
489
+ gen.lit(state_code, name: :state_code_param)
490
+ else
491
+ gen.letter(name: :state_code_param, length: 1, ranges: state_code_ranges)
492
+ end
493
+
494
+ # Construct taxpayer number
495
+ gen.group(name: :taxpayer_number) do |g_|
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)
498
+ g_.letter(length: 1, ranges: ['A'..'Z'])
499
+ g_.int(length: 4, ranges: [0..9999])
500
+ g_.letter(length: 1, ranges: ['A'..'Z'])
501
+ end
502
+
503
+ gen.int(name: :registration_number, length: 1, ranges: [0..9])
504
+
505
+ gen.letter(name: :z_char, length: 1, ranges: [['Z']])
506
+
507
+ gen.computed(deps: %i[state_code_param taxpayer_number registration_number]) do |state_code_param, taxpayer_number, registration_number|
508
+ gst_base = "#{state_code_param}#{taxpayer_number}#{registration_number}"
509
+ chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
510
+ values = gst_base.chars
511
+ sum = values.map.with_index do |char, index|
512
+ product = chars.index(char) * (index.odd? ? 2 : 1)
513
+ (product / chars.length).floor + (product % chars.length)
514
+ end.reduce(:+)
515
+
516
+ checksum = (chars.length - (sum % chars.length)) % chars.length
517
+ chars[checksum]
518
+ end
519
+ end.generate
520
+ end
521
+
467
522
  private
468
523
 
469
524
  # Mod11 functionality from https://github.com/badmanski/mod11/blob/master/lib/mod11.rb
@@ -605,6 +660,19 @@ module Faker
605
660
 
606
661
  result.to_s[0].to_i + result.to_s[1].to_i
607
662
  end
663
+
664
+ def calculate_gst_checksum(state_code, taxpayer_number, registration_number)
665
+ gst_base = "#{state_code}#{taxpayer_number}#{registration_number}"
666
+ chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
667
+ values = gst_base.upcase.chars
668
+ sum = values.map.with_index do |char, index|
669
+ product = chars.index(char) * (index.odd? ? 2 : 1)
670
+ (product / chars.length).floor + (product % chars.length)
671
+ end.reduce(:+)
672
+
673
+ checksum = (chars.length - (sum % chars.length)) % chars.length
674
+ chars[checksum]
675
+ end
608
676
  end
609
677
  end
610
678
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faker
4
- class IDNumber < Base
4
+ class IdNumber < Base
5
5
  CHECKS = 'TRWAGMYFPDXBNJZSQVHLCKE'
6
6
  INVALID_SSN = [
7
7
  /0{3}-\d{2}-\d{4}/,
@@ -25,7 +25,7 @@ module Faker
25
25
  # @return [String]
26
26
  #
27
27
  # @example
28
- # Faker::IDNumber.valid #=> "552-56-3593"
28
+ # Faker::IdNumber.valid #=> "552-56-3593"
29
29
  #
30
30
  # @faker.version 1.6.0
31
31
  def valid
@@ -38,7 +38,7 @@ module Faker
38
38
  # @return [String]
39
39
  #
40
40
  # @example
41
- # Faker::IDNumber.invalid #=> "311-72-0000"
41
+ # Faker::IdNumber.invalid #=> "311-72-0000"
42
42
  #
43
43
  # @faker.version 1.6.0
44
44
  def invalid
@@ -71,7 +71,7 @@ module Faker
71
71
  # @return [String]
72
72
  #
73
73
  # @example
74
- # Faker::IDNumber.spanish_citizen_number #=> "53290236-H"
74
+ # Faker::IdNumber.spanish_citizen_number #=> "53290236-H"
75
75
  #
76
76
  # @faker.version 1.9.0
77
77
  def spanish_citizen_number
@@ -87,7 +87,7 @@ module Faker
87
87
  # @return [String]
88
88
  #
89
89
  # @example
90
- # Faker::IDNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y"
90
+ # Faker::IdNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y"
91
91
  #
92
92
  # @faker.version 1.9.0
93
93
  def spanish_foreign_citizen_number
@@ -106,8 +106,8 @@ module Faker
106
106
  # @return [String]
107
107
  #
108
108
  # @example
109
- # Faker::IDNumber.south_african_id_number #=> "8105128870184"
110
- # Faker::IDNumber.valid_south_african_id_number #=> "8105128870184"
109
+ # Faker::IdNumber.south_african_id_number #=> "8105128870184"
110
+ # Faker::IdNumber.valid_south_african_id_number #=> "8105128870184"
111
111
  #
112
112
  # @faker.version 1.9.2
113
113
  def valid_south_african_id_number
@@ -129,7 +129,7 @@ module Faker
129
129
  # @return [String]
130
130
  #
131
131
  # @example
132
- # Faker::IDNumber.invalid_south_african_id_number #=> "1642972065088"
132
+ # Faker::IdNumber.invalid_south_african_id_number #=> "1642972065088"
133
133
  #
134
134
  # @faker.version 1.9.2
135
135
  def invalid_south_african_id_number
@@ -156,8 +156,8 @@ module Faker
156
156
  # @return [String]
157
157
  #
158
158
  # @example
159
- # Faker::IDNumber.brazilian_citizen_number #=> "53540542221"
160
- # Faker::IDNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21"
159
+ # Faker::IdNumber.brazilian_citizen_number #=> "53540542221"
160
+ # Faker::IdNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21"
161
161
  #
162
162
  # @faker.version 1.9.2
163
163
  def brazilian_citizen_number(formatted: false)
@@ -177,8 +177,8 @@ module Faker
177
177
  # @return [String]
178
178
  #
179
179
  # @example
180
- # Faker::IDNumber.brazilian_id #=> "493054029"
181
- # Faker::IDNumber.brazilian_id(formatted: true) #=> "49.305.402-9"
180
+ # Faker::IdNumber.brazilian_id #=> "493054029"
181
+ # Faker::IdNumber.brazilian_id(formatted: true) #=> "49.305.402-9"
182
182
  #
183
183
  # @faker.version 2.1.2
184
184
  def brazilian_id(formatted: false)
@@ -196,7 +196,7 @@ module Faker
196
196
  # @return [String]
197
197
  #
198
198
  # @example
199
- # Faker::IDNumber.chilean_id #=> "15620613-K"
199
+ # Faker::IdNumber.chilean_id #=> "15620613-K"
200
200
  #
201
201
  # @faker.version 2.1.2
202
202
  def chilean_id
@@ -213,8 +213,8 @@ module Faker
213
213
  # @return [String]
214
214
  #
215
215
  # @example
216
- # Faker::IDNumber.croatian_id #=> "88467617508"
217
- # Faker::IDNumber.croatian_id(international: true) #=> "HR88467617508"
216
+ # Faker::IdNumber.croatian_id #=> "88467617508"
217
+ # Faker::IdNumber.croatian_id(international: true) #=> "HR88467617508"
218
218
  #
219
219
  # @faker.version next
220
220
  def croatian_id(international: false)
@@ -238,10 +238,10 @@ module Faker
238
238
  # @return [String]
239
239
  #
240
240
  # @example
241
- # Faker::IDNumber.danish_id_number #=> "0503909980"
242
- # Faker::IDNumber.danish_id_number(formatted: true) #=> "050390-9980"
243
- # Faker::IDNumber.danish_id_number(birthday: Date.new(1990, 3, 5)) #=> "0503909980"
244
- # Faker::IDNumber.danish_id_number(gender: :female) #=> "0503909980"
241
+ # Faker::IdNumber.danish_id_number #=> "0503909980"
242
+ # Faker::IdNumber.danish_id_number(formatted: true) #=> "050390-9980"
243
+ # Faker::IdNumber.danish_id_number(birthday: Date.new(1990, 3, 5)) #=> "0503909980"
244
+ # Faker::IdNumber.danish_id_number(gender: :female) #=> "0503909980"
245
245
  #
246
246
  # @faker.version next
247
247
  def danish_id_number(formatted: false, birthday: Faker::Date.birthday, gender: nil)
@@ -275,7 +275,7 @@ module Faker
275
275
  # @return [String]
276
276
  #
277
277
  # @example
278
- # Faker::IDNumber.french_insee_number #=> "53290236-H"
278
+ # Faker::IdNumber.french_insee_number #=> "53290236-H"
279
279
  #
280
280
  # @faker.version next
281
281
  def french_insee_number
@@ -421,4 +421,7 @@ module Faker
421
421
  end
422
422
  end
423
423
  end
424
+
425
+ include Faker::Deprecator
426
+ deprecate_generator('IDNumber', IdNumber)
424
427
  end
@@ -15,8 +15,6 @@ module Faker
15
15
  ].each(&:freeze).freeze
16
16
 
17
17
  class << self
18
- extend Gem::Deprecate
19
-
20
18
  ##
21
19
  # Returns the email address
22
20
  #
@@ -50,42 +48,6 @@ module Faker
50
48
  construct_email(sanitized_local_part, generate_domain)
51
49
  end
52
50
 
53
- ##
54
- # Returns the email address with domain either gmail.com, yahoo.com or hotmail.com
55
- #
56
- # @return [String]
57
- #
58
- # @param name [String]
59
- #
60
- # @example
61
- # Faker::Internet.free_email #=> "samsmith@gmail.com"
62
- # Faker::Internet.free_email(name: 'smith') #=> "smith@yahoo.com"
63
- def free_email(name: nil)
64
- construct_email(
65
- sanitize_email_local_part(username(specifier: name)),
66
- fetch('internet.free_email')
67
- )
68
- end
69
- deprecate :free_email, :email, 2023, 10
70
-
71
- ##
72
- # Returns the email address with fixed domain name as 'example'
73
- #
74
- # @return [String]
75
- #
76
- # @param name [String]
77
- #
78
- # @example
79
- # Faker::Internet.safe_email #=> "samsmith@example.com"
80
- # Faker::Internet.safe_email(name: 'smith') #=> "smith@example.net"
81
- def safe_email(name: nil)
82
- construct_email(
83
- sanitize_email_local_part(username(specifier: name)),
84
- "example.#{sample(%w[org com net])}"
85
- )
86
- end
87
- deprecate :safe_email, :email, 2023, 10
88
-
89
51
  ##
90
52
  # Returns the username
91
53
  #
@@ -98,7 +60,7 @@ module Faker
98
60
  # Faker::Internet.username(specifier: 10) #=> "lulu.goodwin"
99
61
  # Faker::Internet.username(specifier: 5..10) #=> "morris"
100
62
  # Faker::Internet.username(specifier: 5..10) #=> "berryberry"
101
- # Faker::Internet.username(specifier: 20, separators: ['-']) #=> "nikki_sawaynnikki_saway"
63
+ # Faker::Internet.username(specifier: 20, separators: ['_']) #=> "nikki_sawaynnikki_saway"
102
64
  def username(specifier: nil, separators: %w[. _])
103
65
  with_locale(:en) do
104
66
  return shuffle(specifier.scan(/[[:word:]]+/)).join(sample(separators)).downcase if specifier.respond_to?(:scan)
@@ -71,7 +71,7 @@ module Faker
71
71
  options[:value] = "Faker::#{options[:value]}"
72
72
 
73
73
  hash = JSON.parse(json)
74
- hash.each do |key, _|
74
+ hash.each_key do |key|
75
75
  add_hash_to_bottom(hash, [key], width, options)
76
76
  end
77
77
  JSON.generate(hash)
@@ -93,7 +93,7 @@ module Faker
93
93
  def add_hash_to_bottom(hash, key_array, width, options)
94
94
  key_string = build_keys_from_array(key_array)
95
95
  if eval("hash#{key_string}").is_a?(::Hash)
96
- eval("hash#{key_string}").each do |key, _|
96
+ eval("hash#{key_string}").each_key do |key|
97
97
  key_array << key
98
98
  add_hash_to_bottom(hash, key_array, width, options)
99
99
  end