faker 3.2.3 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +141 -0
  3. data/README.md +12 -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/japanese_media/fullmetal_alchemist_brotherhood.rb +13 -10
  11. data/lib/faker/locations/australia.rb +43 -38
  12. data/lib/faker/movies/{room.rb → the_room.rb} +4 -4
  13. data/lib/faker/music/smashing_pumpkins.rb +64 -0
  14. data/lib/faker/version.rb +1 -1
  15. data/lib/helpers/deprecator.rb +30 -0
  16. data/lib/locales/bg.yml +0 -1
  17. data/lib/locales/da-DK.yml +529 -37
  18. data/lib/locales/de-AT.yml +3487 -26
  19. data/lib/locales/de-CH.yml +51 -59
  20. data/lib/locales/de.yml +7182 -100
  21. data/lib/locales/ee.yml +0 -1
  22. data/lib/locales/en/address.yml +1826 -561
  23. data/lib/locales/en/australia.yml +106 -105
  24. data/lib/locales/en/bank.yml +1 -1
  25. data/lib/locales/en/finance.yml +3 -3
  26. data/lib/locales/en/{fma_brotherhood.yml → fullmetal_alchemist_brotherhood.yml} +3 -3
  27. data/lib/locales/en/harry_potter.yml +1 -1
  28. data/lib/locales/en/id_number.yml +1 -1
  29. data/lib/locales/en/internet.yml +0 -4
  30. data/lib/locales/en/phone_number.yml +78 -3
  31. data/lib/locales/en/smashing_pumpkins.yml +382 -0
  32. data/lib/locales/en/{room.yml → the_room.yml} +1 -1
  33. data/lib/locales/en-AU.yml +718 -47
  34. data/lib/locales/en-CA.yml +373 -19
  35. data/lib/locales/en-GB.yml +116 -9
  36. data/lib/locales/en-IND.yml +1259 -17
  37. data/lib/locales/en-KE.yml +212 -0
  38. data/lib/locales/en-MS.yml +364 -18
  39. data/lib/locales/en-NEP.yml +212 -38
  40. data/lib/locales/en-NZ.yml +1153 -124
  41. data/lib/locales/en-PAK.yml +369 -11
  42. data/lib/locales/en-SG.yml +581 -17
  43. data/lib/locales/en-US.yml +6923 -83
  44. data/lib/locales/en-au-ocker.yml +266 -24
  45. data/lib/locales/es-AR.yml +4569 -4600
  46. data/lib/locales/es-MX.yml +0 -1
  47. data/lib/locales/es.yml +0 -1
  48. data/lib/locales/fr/internet.yml +0 -1
  49. data/lib/locales/fr-CA.yml +2733 -44
  50. data/lib/locales/fr-CH.yml +0 -1
  51. data/lib/locales/fr.yml +3 -1
  52. data/lib/locales/hy.yml +3624 -120
  53. data/lib/locales/id.yml +839 -12
  54. data/lib/locales/it.yml +1304 -33
  55. data/lib/locales/ko.yml +0 -1
  56. data/lib/locales/lt.yml +297 -16
  57. data/lib/locales/lv.yml +0 -1
  58. data/lib/locales/nb-NO.yml +518 -30
  59. data/lib/locales/nl.yml +0 -1
  60. data/lib/locales/pl.yml +0 -1
  61. data/lib/locales/pt-BR.yml +8155 -665
  62. data/lib/locales/pt.yml +844 -45
  63. data/lib/locales/ru.yml +1353 -70
  64. data/lib/locales/sk.yml +4410 -44
  65. data/lib/locales/tr.yml +0 -2
  66. data/lib/locales/uk.yml +1808 -47
  67. data/lib/locales/zh-CN/bank.yml +17 -0
  68. metadata +14 -10
  69. data/History.md +0 -176
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 112f3ff9d25ba44af343bb059444316208fc86e1c9fe4431255f539ec2fd024b
4
- data.tar.gz: 92ac1fb90a7a741c644a8141e2c57b4f03a3a42594b5419809ec1202f533bb06
3
+ metadata.gz: be60c8141d31082df945cc901a037a7cb113f778e55ad162ac94437591d8077e
4
+ data.tar.gz: 9daf53dae40a7ff80301d2b6ee34add1362ece01847d575fe60b8486d36956ad
5
5
  SHA512:
6
- metadata.gz: adf886de17ac9e4e26ac6a00df3a3d2adca6e1cf2d0a0492c04e0c983f67a318b70c904e2ce06029fc381540bc37aaa4826b6d4b1930c1a171ef9e18245934bd
7
- data.tar.gz: 21de6006567bc40cac19809a948235914081958cf62b44d5c44c6e834675a0b0d1d9a590533ee1177c6d405a320c3728799e29fd88a7986011e52a6973748394
6
+ metadata.gz: ef12b97fb9cfc95debc587e978c0d88d7a8fb46a3fe9f88069f2bd5e1472a747c5ff8b2fc970b71a36cee26323c5efe3252cf2bd20e936e0dc5e7f7aeaa3778d
7
+ data.tar.gz: 547705e2465dc97198c5b1da5a9bfa5e859f46f035fef05f6b4a5b5fe9b4302a3daef2ed8964d765b29781eeca81d41dca9100540f71808f2d4cbcf9be6f332f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,146 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.3.0](https://github.com/faker-ruby/faker/tree/v3.3.0) (2024-03-25)
4
+
5
+ ### Bug Fixes
6
+
7
+ * Remove the duplicate method Faker::Commerce.material description by @mmarusyk in https://github.com/faker-ruby/faker/pull/2914
8
+
9
+ ### Features
10
+
11
+ * Add Kenya to supported countries by @AndrewNduati in https://github.com/faker-ruby/faker/pull/2871
12
+ * Benchmarking loading JSON file vs YML file by @salochara in https://github.com/faker-ruby/faker/pull/2897
13
+
14
+ ### What's changed
15
+
16
+ * 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
17
+ * Fix/Deprecate FmaBrotherhood Generator by @kirkkwang in https://github.com/faker-ruby/faker/pull/2856
18
+ * Fix/Deprecate Faker::Australia to Faker::Locations::Australia by @keshavbiswa in https://github.com/faker-ruby/faker/pull/2869
19
+ * Add note about EOL dependencies by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2890
20
+
21
+ ### Update local dependencies
22
+
23
+ * Bump test-unit from 3.6.1 to 3.6.2 by @dependabot in https://github.com/faker-ruby/faker/pull/2906
24
+ * Bump i18n from 1.14.1 to 1.14.4 by @dependabot in https://github.com/faker-ruby/faker/pull/2913
25
+ * Bump rubocop from 1.60.2 to 1.62.1 by @dependabot in https://github.com/faker-ruby/faker/pull/2916
26
+ * Bump yard from 0.9.34 to 0.9.36 by @dependabot in https://github.com/faker-ruby/faker/pull/2909
27
+ * Bump minitest from 5.22.2 to 5.22.3 by @dependabot in https://github.com/faker-ruby/faker/pull/2917
28
+
29
+ ### New Contributors
30
+
31
+ * @AndrewNduati made their first contribution in https://github.com/faker-ruby/faker/pull/2871
32
+ * @Jamal-A-Mohamed made their first contribution in https://github.com/faker-ruby/faker/pull/2858
33
+ * @mmarusyk made their first contribution in https://github.com/faker-ruby/faker/pull/2914
34
+
35
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.2.3...v3.3.0
36
+
37
+ -------------------------
38
+
39
+ ## [v3.2.3](https://github.com/faker-ruby/faker/tree/v3.2.3) (2024-01-12)
40
+
41
+ ### What's Changed
42
+
43
+ Happy 2024 with a new faker-ruby release.
44
+
45
+ This version includes bug and documentation fixes, and some changes on the contributing guides.
46
+
47
+ ### faker-ruby is is not accepting new features proposals
48
+
49
+ 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.
50
+
51
+ 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.
52
+
53
+ ### Bug fixes
54
+ * Fix Phone number long number and other updates by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2842
55
+ * Favor 'The Room' instead of 'Room' by @kirkkwang in https://github.com/faker-ruby/faker/pull/2854
56
+ * Limit generated Discover cards to 19 digits by @jamie in https://github.com/faker-ruby/faker/pull/2845
57
+ * Fix Typo in README Link: Update sports.md to sport.md by @hatsu38 in https://github.com/faker-ruby/faker/pull/2859
58
+ * Fix country names and codes in address by @sudeeptarlekar in https://github.com/faker-ruby/faker/pull/2850
59
+ * fixed typo for README. Faker::JapaneseMedia::CowboyBebop by @jacoyutorius in https://github.com/faker-ruby/faker/pull/2863
60
+ * Fix typo in `Faker::Movies::HarryPotter.location` (Castelobruxo) by @leomartins1999 in https://github.com/faker-ruby/faker/pull/2866
61
+ * Fix flaky spec on `TestFakerFile#test_file_name` by @keshavbiswa in https://github.com/faker-ruby/faker/pull/2868
62
+ * Update `Internet#username` separator param to match with the example by @AlexandreL0pes in https://github.com/faker-ruby/faker/pull/2882
63
+ * fix polish bban_pattern by @artur1313 in https://github.com/faker-ruby/faker/pull/2887
64
+
65
+ ### What's Changed
66
+ * Add benchmark by @salochara in https://github.com/faker-ruby/faker/pull/2855
67
+ * Freeze new generator and locales by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2886
68
+ * Remove deprecate safe_email and free_email methods by @hatsu38 in https://github.com/faker-ruby/faker/pull/2841
69
+ * Update contribution guidelines and PULL_REQUEST_TEMPLATE by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2878
70
+ * Remove unmaintained `History.md` by @y-yagi in https://github.com/faker-ruby/faker/pull/2880
71
+ * Adds Ruby 3.3 to the CI matrix by @m-nakamura145 in https://github.com/faker-ruby/faker/pull/2883
72
+
73
+ ### Update local dependencies
74
+ * Bump rubocop from 1.58.0 to 1.59.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2865
75
+ * Bump rubocop-minitest from 0.34.3 to 0.34.4 by @dependabot in https://github.com/faker-ruby/faker/pull/2884
76
+ * Bump minitest version by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2889
77
+
78
+ ### New Contributors
79
+ * @kirkkwang made their first contribution in https://github.com/faker-ruby/faker/pull/2854
80
+ * @jamie made their first contribution in https://github.com/faker-ruby/faker/pull/2845
81
+ * @hatsu38 made their first contribution in https://github.com/faker-ruby/faker/pull/2859
82
+ * @salochara made their first contribution in https://github.com/faker-ruby/faker/pull/2855
83
+ * @jacoyutorius made their first contribution in https://github.com/faker-ruby/faker/pull/2863
84
+ * @leomartins1999 made their first contribution in https://github.com/faker-ruby/faker/pull/2866
85
+ * @keshavbiswa made their first contribution in https://github.com/faker-ruby/faker/pull/2868
86
+ * @y-yagi made their first contribution in https://github.com/faker-ruby/faker/pull/2880
87
+ * @AlexandreL0pes made their first contribution in https://github.com/faker-ruby/faker/pull/2882
88
+ * @m-nakamura145 made their first contribution in https://github.com/faker-ruby/faker/pull/2883
89
+ * @artur1313 made their first contribution in https://github.com/faker-ruby/faker/pull/2887
90
+
91
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.2.2...v.3.2.3
92
+
93
+ -------------------------
94
+
95
+ ## [v3.2.2](https://github.com/faker-ruby/faker/tree/v3.2.2) (2023-11-03)
96
+
97
+ Happy November with a new faker-ruby release.
98
+
99
+ This version:
100
+ - adds generators
101
+ - fixes bugs
102
+ - updates dev and dependencies
103
+ - updates docs
104
+
105
+ ### Features
106
+ * feat: add danish country code by @hoshy in https://github.com/faker-ruby/faker/pull/2818
107
+ * Add `zh-CN` translations for Bank names by @guxiaobai in https://github.com/faker-ruby/faker/pull/2840
108
+ * Add Code Scanning by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2835
109
+ * Add Japanese for Games Touhou by @shiroemons in https://github.com/faker-ruby/faker/pull/2829
110
+ * Added Faker::Company.indian_gst_number fixed #2823 by @ankitkhadria in https://github.com/faker-ruby/faker/pull/2825
111
+ * Adds Smashing Pumpkins to the Music module by @redconfetti in https://github.com/faker-ruby/faker/pull/2817
112
+
113
+ ### Bug fixes
114
+ * Delete doc/default/michael_scott.md by @jmromer in https://github.com/faker-ruby/faker/pull/2837
115
+ * Fix typo in `lib/locales/README.md` by @BelaBartok39 in https://github.com/faker-ruby/faker/pull/2812
116
+
117
+ ### What's Changed
118
+ * Update contributing and maintaining guides by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2836
119
+ * Changed tests from x.times loop to deterministically_verify helper. #2813 issue by @fernandomenolli in https://github.com/faker-ruby/faker/pull/2816
120
+ * Improve `#deterministically_verify` helper by @erichmachado in https://github.com/faker-ruby/faker/pull/2828
121
+
122
+ ### Update local dependencies
123
+ * Bump minitest from 5.19.0 to 5.20.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2826
124
+ * Bump rake from 13.0.6 to 13.1.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2846
125
+ * Bump rubocop-minitest from 0.32.2 to 0.33.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2843
126
+ * Bump rubocop from 1.57.1 to 1.57.2 by @dependabot in https://github.com/faker-ruby/faker/pull/2844
127
+ * Bump timecop from 0.9.6 to 0.9.8 by @dependabot in https://github.com/faker-ruby/faker/pull/2811
128
+
129
+ ## New Contributors
130
+ * @BelaBartok39 made their first contribution in https://github.com/faker-ruby/faker/pull/2812
131
+ * @fernandomenolli made their first contribution in https://github.com/faker-ruby/faker/pull/2816
132
+ * @hoshy made their first contribution in https://github.com/faker-ruby/faker/pull/2818
133
+ * @shiroemons made their first contribution in https://github.com/faker-ruby/faker/pull/2829
134
+ * @erichmachado made their first contribution in https://github.com/faker-ruby/faker/pull/2828
135
+ * @jmromer made their first contribution in https://github.com/faker-ruby/faker/pull/2837
136
+ * @guxiaobai made their first contribution in https://github.com/faker-ruby/faker/pull/2840
137
+ * @redconfetti made their first contribution in https://github.com/faker-ruby/faker/pull/2817
138
+ * @ankitkhadria made their first contribution in https://github.com/faker-ruby/faker/pull/2825
139
+
140
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.2.1...v3.2.2
141
+
142
+ -------------------------
143
+
3
144
  ## [v3.2.1](https://github.com/faker-ruby/faker/tree/v3.2.1) (2023-08-11)
4
145
 
5
146
  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)
@@ -376,7 +376,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
376
376
  - [Faker::JapaneseMedia::Naruto](doc/japanese_media/naruto.md)
377
377
  - [Faker::JapaneseMedia::Doraemon](doc/japanese_media/doraemon.md)
378
378
  - [Faker::JapaneseMedia::Conan](doc/japanese_media/conan.md)
379
- - [Faker::JapaneseMedia::FmaBrotherhood](doc/japanese_media/fullmetal_alchemist_brotherhood.md)
379
+ - [Faker::JapaneseMedia::FullmetalAlchemistBrotherhood](doc/japanese_media/fullmetal_alchemist_brotherhood.md)
380
380
  </details>
381
381
 
382
382
  <details>
@@ -411,6 +411,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
411
411
  - [Faker::Music::Prince](doc/music/prince.md)
412
412
  - [Faker::Music::RockBand](doc/music/rock_band.md)
413
413
  - [Faker::Music::Rush](doc/music/rush.md)
414
+ - [Faker::Music::SmashingPumpkins](doc/music/smashing_pumpkins.md)
414
415
  - [Faker::Music::UmphreysMcgee](doc/music/umphreys_mcgee.md)
415
416
  </details>
416
417
 
@@ -426,7 +427,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
426
427
  <details>
427
428
  <summary>Sports</summary>
428
429
 
429
- - [Faker::Sports](doc/sports/sports.md)
430
+ - [Faker::Sport](doc/sports/sport.md)
430
431
  - [Faker::Sports::Basketball](doc/sports/basketball.md)
431
432
  - [Faker::Sports::Chess](doc/sports/chess.md)
432
433
  - [Faker::Sports::Football](doc/sports/football.md)
@@ -476,12 +477,18 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
476
477
  - [Faker::TvShows::VentureBros](doc/tv_shows/venture_bros.md)
477
478
  </details>
478
479
 
480
+ <details>
481
+ <summary>Locations</summary>
482
+
483
+ - [Faker::Locations::Australia](doc/locations/australia.md)
484
+ </details>
485
+
479
486
  ## Contributing
480
487
 
481
- If you have problems, please create a [GitHub Issue](/.github/ISSUE_TEMPLATE/bug-report.md).
488
+ **Note**: We are not accepting proposals for new generators and locales. The [Contributing](CONTRIBUTING.md) guide has a few notes about this decision.
482
489
 
483
490
  Take a look at the [Contributing](CONTRIBUTING.md) document for
484
- instructions on setting up the repo on your machine, understanding the codebase,
491
+ instructions on setting up the repo on your machine, opening bug reports, understanding the codebase,
485
492
  and creating a good pull request.
486
493
 
487
494
  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
@@ -4,12 +4,14 @@ module Faker
4
4
  class PhoneNumber < Base
5
5
  class << self
6
6
  ##
7
- # Produces a random phone number in a random format (may or may not have a country code, extension and can have different dividers).
7
+ # Produces a phone number in a random format without the country code and it can have different dividers.
8
8
  #
9
9
  # @return [String]
10
10
  #
11
11
  # @example
12
- # Faker::PhoneNumber.phone_number #=> "397.693.1309 x4321"
12
+ # Faker::PhoneNumber.phone_number #=> "(504) 113-1705"
13
+ # Faker::PhoneNumber.phone_number #=> "662.291.7201"
14
+ # Faker::PhoneNumber.phone_number #=> "9415283713"
13
15
  #
14
16
  # @faker.version 0.3.0
15
17
  def phone_number
@@ -17,12 +19,14 @@ module Faker
17
19
  end
18
20
 
19
21
  ##
20
- # Produces a random cell phone number in a random format (may or may not have a country code and can have different dividers).
22
+ # Produces a random cell phone number in a random format without the country code and it can have different dividers.
21
23
  #
22
24
  # @return [String]
23
25
  #
24
26
  # @example
25
- # Faker::PhoneNumber.cell_phone #=> "(186)285-7925"
27
+ # Faker::PhoneNumber.cell_phone #=> "(836) 115-8995"
28
+ # Faker::PhoneNumber.cell_phone #=> "382-597-5739"
29
+ # Faker::PhoneNumber.cell_phone #=> "316.828.1822"
26
30
  #
27
31
  # @faker.version 1.0.0
28
32
  def cell_phone
@@ -36,10 +40,12 @@ module Faker
36
40
  #
37
41
  # @example
38
42
  # Faker::PhoneNumber.country_code #=> "+20"
43
+ # Faker::PhoneNumber.country_code #=> "+39"
44
+ # Faker::PhoneNumber.country_code #=> "+852"
39
45
  #
40
46
  # @faker.version 1.9.2
41
47
  def country_code
42
- "+#{fetch('country_code')}"
48
+ "+#{fetch('phone_number.country_code')}"
43
49
  end
44
50
 
45
51
  ##
@@ -48,7 +54,9 @@ module Faker
48
54
  # @return [String]
49
55
  #
50
56
  # @example
51
- # Faker::PhoneNumber.phone_number_with_country_code #=> "+95 1-672-173-8153"
57
+ # Faker::PhoneNumber.phone_number_with_country_code #=> "+55 466-746-6882"
58
+ # Faker::PhoneNumber.phone_number_with_country_code #=> "+81 3718219558"
59
+ # Faker::PhoneNumber.phone_number_with_country_code #=> "+49 140 957 9846"
52
60
  #
53
61
  # @faker.version 1.9.2
54
62
  def phone_number_with_country_code
@@ -61,7 +69,9 @@ module Faker
61
69
  # @return [String]
62
70
  #
63
71
  # @example
64
- # Faker::PhoneNumber.cell_phone_with_country_code #=> "+974 (190) 987-9034"
72
+ # Faker::PhoneNumber.cell_phone_with_country_code #=> "+852 (190) 987-9034"
73
+ # Faker::PhoneNumber.cell_phone_with_country_code #=> "+64 (820) 583-6474"
74
+ # Faker::PhoneNumber.cell_phone_with_country_code #=> "+1 591.871.7985"
65
75
  #
66
76
  # @faker.version 1.9.2
67
77
  def cell_phone_with_country_code
@@ -69,12 +79,14 @@ module Faker
69
79
  end
70
80
 
71
81
  ##
72
- # Produces a random phone number in e164 format.
82
+ # Produces a random phone number in e164 format, i.e., without any dividers.
73
83
  #
74
84
  # @return [String]
75
85
  #
76
86
  # @example
77
- # Faker::PhoneNumber.cell_phone_in_e164 #=> "+944937040625"
87
+ # Faker::PhoneNumber.cell_phone_in_e164 #=> "+542024834991"
88
+ # Faker::PhoneNumber.cell_phone_in_e164 #=> "+8522846847703"
89
+ # Faker::PhoneNumber.cell_phone_in_e164 #=> "+649477546575"
78
90
  #
79
91
  # @faker.version 1.9.2
80
92
  def cell_phone_in_e164
@@ -82,49 +94,56 @@ module Faker
82
94
  end
83
95
 
84
96
  ##
85
- # Produces a random US or Canada-based area code.
97
+ # Produces a random area code.
86
98
  #
87
99
  # @return [String]
88
100
  #
89
101
  # @example
90
102
  # Faker::PhoneNumber.area_code #=> "201"
103
+ # Faker::PhoneNumber.area_code #=> "613"
104
+ # Faker::PhoneNumber.area_code #=> "321"
91
105
  #
92
106
  # @faker.version 1.3.0
93
107
  def area_code
94
108
  fetch('phone_number.area_code')
95
- rescue I18n::MissingTranslationData
96
- nil
97
109
  end
98
110
 
99
111
  ##
100
- # Produces a random US or Canada-based exchange code.
112
+ # Produces a random exchange code.
101
113
  #
102
114
  # @return [String]
103
115
  #
104
116
  # @example
105
117
  # Faker::PhoneNumber.exchange_code #=> "208"
118
+ # Faker::PhoneNumber.exchange_code #=> "415"
119
+ # Faker::PhoneNumber.exchange_code #=> "652"
106
120
  #
107
121
  # @faker.version 1.3.0
108
122
  def exchange_code
109
123
  fetch('phone_number.exchange_code')
110
- rescue I18n::MissingTranslationData
111
- nil
112
124
  end
113
125
 
114
126
  ##
115
- # Produces a random US or Canada-based extension / subscriber number. Can be used for both extensions and last four digits of phone number.
127
+ # Produces a random extension / subscriber number. Can be used for both extensions and last four digits of phone number.
116
128
  #
117
- # @param length [Integer] Specifies the length of the return value.
129
+ # @param length [Integer] Specifies the length of the return value. Defaults to 4.
118
130
  # @return [String]
119
131
  #
120
132
  # @example
121
133
  # Faker::PhoneNumber.subscriber_number #=> "3873"
122
134
  # Faker::PhoneNumber.subscriber_number(length: 2) #=> "39"
123
135
  # Faker::PhoneNumber.extension #=> "3764"
136
+ # Faker::PhoneNumber.extension(length: 2) => "37"
124
137
  #
125
138
  # @faker.version 1.3.0
126
139
  def subscriber_number(length: 4)
127
- rand.to_s[2..(1 + length)]
140
+ if !length.is_a?(Integer) || length > 10
141
+ raise ArgumentError, 'length must be an Integer and be lesser than 10'
142
+ end
143
+
144
+ generate(:string) do |g|
145
+ g.int(length: length)
146
+ end
128
147
  end
129
148
 
130
149
  alias extension subscriber_number