faker 2.20.0 → 2.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +123 -0
  3. data/README.md +5 -6
  4. data/lib/faker/blockchain/aeternity.rb +1 -1
  5. data/lib/faker/blockchain/ethereum.rb +1 -1
  6. data/lib/faker/blockchain/tezos.rb +1 -1
  7. data/lib/faker/default/{faker_adjective.rb → adjective.rb} +0 -0
  8. data/lib/faker/default/bank.rb +4 -4
  9. data/lib/faker/default/chile_rut.rb +8 -4
  10. data/lib/faker/default/code.rb +7 -7
  11. data/lib/faker/default/company.rb +4 -4
  12. data/lib/faker/default/file.rb +3 -3
  13. data/lib/faker/default/finance.rb +16 -2
  14. data/lib/faker/default/id_number.rb +106 -1
  15. data/lib/faker/default/internet.rb +24 -3
  16. data/lib/faker/default/markdown.rb +5 -5
  17. data/lib/faker/default/nhs.rb +1 -1
  18. data/lib/faker/default/vehicle.rb +18 -5
  19. data/lib/faker/default/vulnerability_identifier.rb +23 -0
  20. data/lib/faker/japanese_media/kamen_rider.rb +2 -2
  21. data/lib/faker/japanese_media/one_piece.rb +1 -1
  22. data/lib/faker/movies/tron.rb +161 -0
  23. data/lib/faker/sports/mountaineering.rb +22 -0
  24. data/lib/faker/sports/sport.rb +110 -0
  25. data/lib/faker/version.rb +1 -1
  26. data/lib/faker.rb +15 -10
  27. data/lib/helpers/base58.rb +1 -1
  28. data/lib/helpers/unique_generator.rb +13 -11
  29. data/lib/locales/en/australia.yml +3 -4
  30. data/lib/locales/en/computer.yml +23 -4
  31. data/lib/locales/en/dota.yml +113 -0
  32. data/lib/locales/en/file.yml +9 -1
  33. data/lib/locales/en/finance.yml +3 -1
  34. data/lib/locales/en/game.yml +0 -1
  35. data/lib/locales/en/internet.yml +29 -0
  36. data/lib/locales/en/mountaineering.yml +14 -0
  37. data/lib/locales/en/movie.yml +2 -1
  38. data/lib/locales/en/naruto.yml +2 -3
  39. data/lib/locales/en/one_piece.yml +1 -1
  40. data/lib/locales/en/sport.yml +121 -0
  41. data/lib/locales/en/tron.yml +227 -0
  42. data/lib/locales/en/vehicle.yml +2809 -75
  43. data/lib/locales/en-AU.yml +1 -1
  44. data/lib/locales/fr/adjective.yml +266 -0
  45. data/lib/locales/ja/adjective.yml +148 -0
  46. data/lib/locales/ja/dog.yml +1 -0
  47. data/lib/locales/ja/emotion.yml +51 -0
  48. data/lib/locales/ja/naruto.yml +230 -0
  49. data/lib/locales/ja/relationship.yml +10 -0
  50. data/lib/locales/pl.yml +1 -1
  51. metadata +26 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 263e2d15636da915718fec1db63ac9595f87b2a075ddaa0e536ce89a57523b81
4
- data.tar.gz: 677c2ee1537ece0e18820f72ac1a528c3581f60e298d51c125ff9d673d6e6022
3
+ metadata.gz: 5d8cd66a58c224a6a003a614df1b81c934ddf8eb4033d51f4cc4df2a0b377193
4
+ data.tar.gz: f761e03f47cd4e7b04d5c5f70e9639576e628613b5f3eca232b21a38e3aa810d
5
5
  SHA512:
6
- metadata.gz: ad45cb3518237236a31bf97d0bbe48214cef9ef1debca67f3d4ea5cb0c105c9d045d37fd22f33cc9da90be89ddb1ce8113d9a016f4f18098a679e5e9e53521d0
7
- data.tar.gz: 449074010c194137d0f9bc77e4730f09058559016e780a4ca78c1bcb4f650002e22f8c6af0668f1f1d6ee43e25f11793855df496095ab0e314c8a24923daba29
6
+ metadata.gz: 6a902462978f950d791e6ba96b1ce48fdd3b2db3e1336871a48b98410c6dd5f6f29397f8763f1c3786398162a140e1f664849ee6469c538d8d68d81d0c875b35
7
+ data.tar.gz: c4996e30be72c6f8b747e236bc139585695c9e554982794ab5b78961a9944b632ae4c408218b47a5799e015d536164356538dbf748a1290ff69353e1e3aa390a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,128 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.23.0](https://github.com/faker-ruby/faker/tree/v2.23.0) (2022-09-01)
4
+
5
+ * Fix Japanese plural by @akmhmgc in https://github.com/faker-ruby/faker/pull/2517
6
+ * Update rubocop requirement from = 1.26.0 to = 1.28.2 by @dependabot in https://github.com/faker-ruby/faker/pull/2483
7
+ * Add sports to `Faker::Sport` by @matt17r in https://github.com/faker-ruby/faker/pull/2397
8
+ * [Internet::Password] Improve mix_case and special_characters support by @meuble in https://github.com/faker-ruby/faker/pull/2308
9
+ * Danish id number by @jokklan in https://github.com/faker-ruby/faker/pull/2511
10
+ * Add generator for vulnerability identifiers by @NobodysNightmare in https://github.com/faker-ruby/faker/pull/2367
11
+ * Add the ability to generate a mime type of a specific media type by @ric2b in https://github.com/faker-ruby/faker/pull/2518
12
+ * Add IDNumber.french_insee_number by @Spone in https://github.com/faker-ruby/faker/pull/2455
13
+ * fix flaky user agent test by @thdaraujo in https://github.com/faker-ruby/faker/pull/2530
14
+ * Update GitHub Issues and Pull Request Templates [ci-skip] by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2531
15
+ * fix: ensure generated passwords have correct characters when mixed_case & special_characters enabled by @tiff-o in https://github.com/faker-ruby/faker/pull/2532
16
+ * Thread safety by @kiskoza in https://github.com/faker-ruby/faker/pull/2520
17
+ * Fix warning instance variable uninitialized by @akmhmgc in https://github.com/faker-ruby/faker/pull/2535
18
+ * fix italy VAT and add italy condominium fiscal code generator by @FiloSpaTeam in https://github.com/faker-ruby/faker/pull/2491
19
+ * Add ChileRut.full_formatted_rut by @KarlHeitmann in https://github.com/faker-ruby/faker/pull/2460
20
+ * Updated versions and added more operating systems by @abrahamparayil in https://github.com/faker-ruby/faker/pull/2536
21
+ * Add vehicle version generator by @trinaldi in https://github.com/faker-ruby/faker/pull/2540
22
+ * Fix computer test by @trinaldi in https://github.com/faker-ruby/faker/pull/2543
23
+ * Drop support for EOL Ruby versions (`2.5` and `2.6`) by @nickmendezFlatiron in https://github.com/faker-ruby/faker/pull/2538
24
+ * Update minitest requirement from = 5.15.0 to = 5.16.3 by @dependabot in https://github.com/faker-ruby/faker/pull/2547
25
+ * Update rubocop requirement from = 1.28.2 to = 1.35.1 by @dependabot in https://github.com/faker-ruby/faker/pull/2548
26
+ * Fix `fma_brotherhood` usage example by @y0n0zawa in https://github.com/faker-ruby/faker/pull/2552
27
+
28
+ ------------------------------------------------------------------------------
29
+
30
+ ## [v2.22.0](https://github.com/faker-ruby/faker/tree/v2.22.0) (2022-07-28)
31
+
32
+ ## Bug/Fixes
33
+
34
+ - [PR #2500](https://github.com/faker-ruby/faker/pull/2500) Fix: Duplicate array before concatenating [@mattr](https://github.com/mattr)
35
+ - [PR #2488](https://github.com/faker-ruby/faker/pull/2488) Fixed random selection issue [@sudeeptarlekar](https://github.com/sudeeptarlekar)
36
+ - [PR #2475](https://github.com/faker-ruby/faker/pull/2475) Update regex used for Faker::Vehicle#vin [@erayalkis](https://github.com/erayalkis)
37
+
38
+ ## Chores
39
+
40
+ - [PR #2513](https://github.com/faker-ruby/faker/pull/2513) Remove broken docs [@vbrazo](https://github.com/vbrazo)
41
+ - [PR #2502](https://github.com/faker-ruby/faker/pull/2502) Update actions/checkout version in GitHub actions [@jdufresne](https://github.com/jdufresne)
42
+ - [PR #2501](https://github.com/faker-ruby/faker/pull/2501) Make ReadMe more consise [@jenniferdewan](https://github.com/jenniferdewan)
43
+ - [PR #2489](https://github.com/faker-ruby/faker/pull/2489) Change a filename to follow naming conventions [@yasuhiron777](https://github.com/yasuhiron777)
44
+
45
+ ## Feature Request
46
+
47
+ - [PR #2477](https://github.com/faker-ruby/faker/pull/2477) feat: add bot_user_agent method for generate web crawle's user agents [@a-chacon](https://github.com/a-chacon)
48
+ - [PR #2465](https://github.com/faker-ruby/faker/pull/2465) Add a new sports section for mountaineers [@LeviLong01](https://github.com/LeviLong01)
49
+
50
+ ## Update locales
51
+
52
+ - [PR #2509](https://github.com/faker-ruby/faker/pull/2509) Add all Dota 2 heroes [@JCFarrow](https://github.com/JCFarrow)
53
+ - [PR #2507](https://github.com/faker-ruby/faker/pull/2507) Update dog.yml [@Kedaruma-Bond](https://github.com/Kedaruma-Bond)
54
+ - [PR #2503](https://github.com/faker-ruby/faker/pull/2503) Update pl.yml [@marek-witkowski](https://github.com/marek-witkowski)
55
+ - [PR #2499](https://github.com/faker-ruby/faker/pull/2499) Fix: Use pattern to define Australian cell phone formats [@mattr](https://github.com/mattr)
56
+ - [PR #2497](https://github.com/faker-ruby/faker/pull/2497) Fix typos in Australia [@mattr](https://github.com/mattr)
57
+ - [PR #2490](https://github.com/faker-ruby/faker/pull/2490) Added Japanese adjective translations [@yasuhiron777](https://github.com/yasuhiron777)
58
+
59
+ ------------------------------------------------------------------------------
60
+
61
+ ## [v2.21.0](https://github.com/faker-ruby/faker/tree/v2.21.0) (2022-05-12)
62
+
63
+ ## Bug/Fixes
64
+
65
+ - [PR #2443](https://github.com/faker-ruby/faker/pull/2443) Fixed error for random in markdown [@sudeeptarlekar](https://github.com/sudeeptarlekar)
66
+
67
+ ## Feature Request
68
+
69
+ - [PR #2252](https://github.com/faker-ruby/faker/pull/2252) Add Faker::Movies::Tron [@craineum](https://github.com/craineum)
70
+
71
+ ## Update locales
72
+ - [PR #2485](https://github.com/faker-ruby/faker/pull/2485) Add japanese translations for emotion [@kenboo0426](https://github.com/kenboo0426)
73
+ - [PR #2479](https://github.com/faker-ruby/faker/pull/2479) Add japanese translations for naruto [@johnmanjiro13](https://github.com/johnmanjiro13)
74
+ - [PR #2478](https://github.com/faker-ruby/faker/pull/2478) Add Japanese translation for relationships [@shouichi](https://github.com/shouichi)
75
+ - [PR #2469](https://github.com/faker-ruby/faker/pull/2467) Fix blank row in game.yml [@KingYoSun](https://github.com/KingYoSun)
76
+ - [PR #2467](https://github.com/faker-ruby/faker/pull/2467) French traduction of adjectives [@Beygs](https://github.com/Beygs)
77
+
78
+ ## Update local dependencies
79
+
80
+ - Update rubocop to `1.26.0`
81
+ - Update timecop to `0.95.0`
82
+
83
+ ------------------------------------------------------------------------------
84
+
85
+ ## [v2.20.0](https://github.com/faker-ruby/faker/tree/v2.20.0) (2022-03-05)
86
+
87
+ ## Documentation
88
+
89
+ - [PR #2421](https://github.com/faker-ruby/faker/pull/2421) Add general documentation for Faker::Camera [@aleksandrilyin](https://github.com/aleksandrilyin)
90
+
91
+
92
+ ## Feature Request
93
+
94
+ - [PR #2457](https://github.com/faker-ruby/faker/pull/2457) add Command & Conquer games [@Awilum](https://github.com/Awilum)
95
+ - [PR #2456](https://github.com/faker-ruby/faker/pull/2456) fix heading for faker hobby doc [@Awilum](https://github.com/Awilum)
96
+ - [PR #2411](https://github.com/faker-ruby/faker/pull/2411) Add mock data for Auth0 OAuth [@Norio4](https://github.com/Norio4)
97
+ - [PR #2396](https://github.com/faker-ruby/faker/pull/2396) Add Brooklyn Nine Nine into tv shows category [@fralps](https://github.com/fralps)
98
+ - [PR #2395](https://github.com/faker-ruby/faker/pull/2395) Add The Kingkiller Chronicle [@fblupi](https://github.com/fblupi)
99
+ - [PR #2392](https://github.com/faker-ruby/faker/pull/2392) Update LV locale - cell phone numbers should be 8 symbols [@tmikoss](https://github.com/tmikoss)
100
+ - [PR #2383](https://github.com/faker-ruby/faker/pull/2383) Add Faker::JapaneseMedia::KamenRider#transformation_device [@boardfish](https://github.com/boardfish)
101
+ - [PR #2382](https://github.com/faker-ruby/faker/pull/2382) Add collectible devices [@boardfish](https://github.com/boardfish)
102
+ - [PR #2378](https://github.com/faker-ruby/faker/pull/2378) Re-add the Faker::Internet.base64 method [@ashishra0](https://github.com/ashishra0)
103
+ - [PR #2374](https://github.com/faker-ruby/faker/pull/2374) Add Faker::JapaneseMedia::KamenRider [@boardfish](https://github.com/boardfish)
104
+ - [PR #1656](https://github.com/faker-ruby/faker/pull/1656) Add bible entries [@enowbi](https://github.com/enowbi)
105
+
106
+ ## Update locales
107
+
108
+ - [PR #2462](https://github.com/faker-ruby/faker/pull/2462) Add Sora and Hollow Bastion to SuperSmashBros yml files [@gazayas](https://github.com/gazayas)
109
+ - [PR #2458](https://github.com/faker-ruby/faker/pull/2458) Fix typo on Tom Jobim's name [@andrerferrer](https://github.com/andrerferrer)
110
+ - [PR #2452](https://github.com/faker-ruby/faker/pull/2452) updated Timor-Leste in en/addresses.yml [@masukomi](https://github.com/masukomi)
111
+ - [PR #2450](https://github.com/faker-ruby/faker/pull/2450) dividing male and female Arabic names [@Alfulayt](https://github.com/Alfulayt)
112
+ - [PR #2381](https://github.com/faker-ruby/faker/pull/2381) Remove duplicates and clean up Faker::JapaneseMedia::KamenRider [@boardfish](https://github.com/boardfish)
113
+ - [PR #2405](https://github.com/faker-ruby/faker/pull/2405) Add countries in Japanese [@lawriecate](https://github.com/lawriecate)
114
+ - [PR #2403](https://github.com/faker-ruby/faker/pull/2403) add Faker::Animal in pt-BR [@thiago-henrique-leite](https://github.com/thiago-henrique-leite)
115
+ - [PR #2377](https://github.com/faker-ruby/faker/pull/2377) Fix non striped coffe blender [@ngouy](https://github.com/ngouy)
116
+
117
+ ## Update local dependencies
118
+
119
+ - Update rubocop to `1.25.0`
120
+ - Update rake to `13.0.6`
121
+ - Update test-unit to `3.5.3`
122
+ - Update yard to `0.9.27`
123
+
124
+ ------------------------------------------------------------------------------
125
+
3
126
  ## [v2.19.0](https://github.com/faker-ruby/faker/tree/v2.19.0) (2021-08-22)
4
127
 
5
128
  ## Bug/Fixes
data/README.md CHANGED
@@ -6,7 +6,6 @@
6
6
  [![Inline docs](https://inch-ci.org/github/faker-ruby/faker.svg?branch=master)](https://inch-ci.org/github/faker-ruby/faker)
7
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/test_coverage)](https://codeclimate.com/github/stympy/faker/test_coverage)
8
8
  [![Maintainability](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/maintainability)](https://codeclimate.com/github/stympy/faker/maintainability)
9
- [![SemVer compatibility](https://api.dependabot.com/badges/compatibility_score?dependency-name=faker&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=faker&package-manager=bundler&version-scheme=semver)
10
9
 
11
10
  This gem is a port of [Perl's Data::Faker library](https://metacpan.org/pod/Data::Faker) that generates fake data.
12
11
 
@@ -218,6 +217,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
218
217
  - [Faker::University](doc/default/university.md)
219
218
  - [Faker::Vehicle](doc/default/vehicle.md)
220
219
  - [Faker::Verbs](doc/default/verbs.md)
220
+ - [Faker::VulnerabilityIdentifier](doc/default/vulnerability_identifier.md)
221
221
  - [Faker::WorldCup](doc/default/world_cup.md)
222
222
 
223
223
  ### Blockchain
@@ -291,6 +291,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
291
291
  - [Faker::Movies::LordOfTheRings](doc/movies/lord_of_the_rings.md)
292
292
  - [Faker::Movies::PrincessBride](doc/movies/princess_bride.md)
293
293
  - [Faker::Movies::StarWars](doc/movies/star_wars.md)
294
+ - [Faker::Movies::TRON](doc/movies/tron.md)
294
295
  - [Faker::Movies::VForVendetta](doc/movies/v_for_vendetta.md)
295
296
 
296
297
  ### Music
@@ -354,11 +355,9 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
354
355
  - [Faker::TvShows::VentureBros](doc/tv_shows/venture_bros.md)
355
356
 
356
357
  ## Customization
357
- Since you may want to make addresses and other types of data look different
358
- depending on where in the world you are (US postal codes vs. UK postal codes,
359
- for example), Faker uses the I18n gem to store strings (like state names) and
360
- formats (US postal codes are NNNNN while UK postal codes are AAN NAA),
361
- allowing you to get different formats by switching locales.
358
+ You may want Faker to print information depending on your location in the world.
359
+ To assist you in this, Faker uses I18n gem to store strings and formats to
360
+ represent the names and postal codes of the area of your choosing.
362
361
  Just set the locale you want as shown below, and Faker will take care of the rest.
363
362
 
364
363
  ```ruby
@@ -61,7 +61,7 @@ module Faker
61
61
  def rand_strings(length = 50)
62
62
  hex_alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
63
63
  var = +''
64
- length.times { var << sample(shuffle(hex_alphabet.split(''))) }
64
+ length.times { var << sample(shuffle(hex_alphabet.chars)) }
65
65
  var
66
66
  end
67
67
  end
@@ -17,7 +17,7 @@ module Faker
17
17
  def address
18
18
  hex_alphabet = '0123456789abcdef'
19
19
  var = +'0x'
20
- 40.times { var << sample(shuffle(hex_alphabet.split(''))) }
20
+ 40.times { var << sample(shuffle(hex_alphabet.chars)) }
21
21
  var
22
22
  end
23
23
  end
@@ -125,7 +125,7 @@ module Faker
125
125
  # @return [String]
126
126
  def encode_tz(prefix, payload_size)
127
127
  prefix = PREFIXES.fetch(prefix)
128
- packed = prefix.map(&:chr).join('') + Faker::Config.random.bytes(payload_size)
128
+ packed = prefix.map(&:chr).join + Faker::Config.random.bytes(payload_size)
129
129
  checksum = OpenSSL::Digest::SHA256.digest(OpenSSL::Digest::SHA256.digest(packed))[0..3]
130
130
  Faker::Base58.encode(packed + checksum)
131
131
  end
@@ -23,7 +23,7 @@ module Faker
23
23
 
24
24
  output = ''
25
25
 
26
- output += rand.to_s[2..-1] while output.length < digits
26
+ output += rand.to_s[2..] while output.length < digits
27
27
 
28
28
  output[0...digits]
29
29
  end
@@ -145,7 +145,7 @@ module Faker
145
145
  private
146
146
 
147
147
  def checksum(num_string)
148
- num_array = num_string.split('').map(&:to_i)
148
+ num_array = num_string.chars.map(&:to_i)
149
149
  (
150
150
  7 * (num_array[0] + num_array[3] + num_array[6]) +
151
151
  3 * (num_array[1] + num_array[4] + num_array[7]) +
@@ -194,8 +194,8 @@ module Faker
194
194
 
195
195
  def compile_fraction(routing_num)
196
196
  prefix = (1..50).to_a.map(&:to_s).sample
197
- numerator = routing_num.split('')[5..8].join.to_i.to_s
198
- denominator = routing_num.split('')[0..4].join.to_i.to_s
197
+ numerator = routing_num.chars[5..8].join.to_i.to_s
198
+ denominator = routing_num.chars[0..4].join.to_i.to_s
199
199
  "#{prefix}-#{numerator}/#{denominator}"
200
200
  end
201
201
 
@@ -37,7 +37,7 @@ module Faker
37
37
  #
38
38
  # @faker.version 1.9.2
39
39
  def dv
40
- split_reversed_rut = @last_rut.to_s.reverse.split('')
40
+ split_reversed_rut = @last_rut.to_s.reverse.chars
41
41
  seq = [2, 3, 4, 5, 6, 7]
42
42
  i = 0
43
43
  digit_sum = split_reversed_rut.reduce(0) do |sum, n|
@@ -82,14 +82,18 @@ module Faker
82
82
  # Faker::ChileRut.full_rut(min_rut: 20890156) #=> "30686957-4"
83
83
  # Faker::ChileRut.full_rut(min_rut: 30686957, fixed: true) #=> "30686957-4"
84
84
  #
85
- # @faker.version 1.9.2
86
- def full_rut(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 0, fixed: false)
85
+ # @faker.version next
86
+ def full_rut(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 0, fixed: false, formatted: false)
87
87
  warn_for_deprecated_arguments do |keywords|
88
88
  keywords << :min_rut if legacy_min_rut != NOT_GIVEN
89
89
  keywords << :fixed if legacy_fixed != NOT_GIVEN
90
90
  end
91
91
 
92
- "#{rut(min_rut: min_rut, fixed: fixed)}-#{dv}"
92
+ if formatted
93
+ "#{rut(min_rut: min_rut, fixed: fixed).to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1.').reverse}-#{dv}"
94
+ else
95
+ "#{rut(min_rut: min_rut, fixed: fixed)}-#{dv}"
96
+ end
93
97
  end
94
98
 
95
99
  attr_reader :last_rut
@@ -107,7 +107,7 @@ module Faker
107
107
 
108
108
  birthyear = Date.birthday(min_age: min_age, max_age: max_age).year
109
109
  prefix = birthyear < 2000 ? 'S' : 'T'
110
- values = birthyear.to_s[-2..-1]
110
+ values = birthyear.to_s[-2..]
111
111
  values << regexify(/\d{5}/)
112
112
  check_alpha = generate_nric_check_alphabet(values, prefix)
113
113
  "#{prefix}#{values}#{check_alpha}"
@@ -206,7 +206,7 @@ module Faker
206
206
  str[len - 1] = (10 - (sum % 10)) % 10
207
207
 
208
208
  # Output the IMEI value.
209
- str.join('')
209
+ str.join
210
210
  end
211
211
 
212
212
  def generate_base10_isbn
@@ -222,20 +222,20 @@ module Faker
222
222
  end
223
223
 
224
224
  def sum(values)
225
- values.split(//).each_with_index.inject(0) do |sum, (value, index)|
225
+ values.chars.each_with_index.inject(0) do |sum, (value, index)|
226
226
  sum + yield(value, index)
227
227
  end
228
228
  end
229
229
 
230
230
  def generate_base8_ean
231
231
  values = regexify(/\d{7}/)
232
- check_digit = 10 - values.split(//).each_with_index.inject(0) { |s, (v, i)| s + v.to_i * EAN_CHECK_DIGIT8[i] } % 10
232
+ check_digit = 10 - values.chars.each_with_index.inject(0) { |s, (v, i)| s + v.to_i * EAN_CHECK_DIGIT8[i] } % 10
233
233
  values << (check_digit == 10 ? 0 : check_digit).to_s
234
234
  end
235
235
 
236
236
  def generate_base13_ean
237
237
  values = regexify(/\d{12}/)
238
- check_digit = 10 - values.split(//).each_with_index.inject(0) { |s, (v, i)| s + v.to_i * EAN_CHECK_DIGIT13[i] } % 10
238
+ check_digit = 10 - values.chars.each_with_index.inject(0) { |s, (v, i)| s + v.to_i * EAN_CHECK_DIGIT13[i] } % 10
239
239
  values << (check_digit == 10 ? 0 : check_digit).to_s
240
240
  end
241
241
 
@@ -243,13 +243,13 @@ module Faker
243
243
  EAN_CHECK_DIGIT13 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3].freeze
244
244
 
245
245
  def rut_verificator_digit(rut)
246
- total = rut.to_s.rjust(8, '0').split(//).zip(%w[3 2 7 6 5 4 3 2]).collect { |a, b| a.to_i * b.to_i }.inject(:+)
246
+ 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(:+)
247
247
  (11 - total % 11).to_s.gsub(/10/, 'k').gsub(/11/, '0')
248
248
  end
249
249
 
250
250
  def generate_nric_check_alphabet(values, prefix)
251
251
  weight = %w[2 7 6 5 4 3 2]
252
- total = values.split(//).zip(weight).collect { |a, b| a.to_i * b.to_i }.inject(:+)
252
+ total = values.chars.zip(weight).collect { |a, b| a.to_i * b.to_i }.inject(:+)
253
253
  total += 4 if prefix == 'T'
254
254
  %w[A B C D E F G H I Z J][10 - total % 11]
255
255
  end
@@ -296,7 +296,7 @@ module Faker
296
296
  result = Array.new(3) { rand(1..9) } + Array.new(7) { rand(10) }
297
297
  break if (weight_sum(result, weights) % 11) == result[9]
298
298
  end
299
- result.join('')
299
+ result.join
300
300
  end
301
301
 
302
302
  ##
@@ -321,7 +321,7 @@ module Faker
321
321
  random_digits = Array.new(length) { rand(10) }
322
322
  break if collect_regon_sum(random_digits) == random_digits.last
323
323
  end
324
- random_digits.join('')
324
+ random_digits.join
325
325
  end
326
326
 
327
327
  ##
@@ -459,7 +459,7 @@ module Faker
459
459
  def luhn_algorithm(number)
460
460
  multiplications = []
461
461
 
462
- number.to_s.reverse.split(//).each_with_index do |digit, i|
462
+ number.to_s.reverse.chars.each_with_index do |digit, i|
463
463
  multiplications << if i.even?
464
464
  digit.to_i * 2
465
465
  else
@@ -553,7 +553,7 @@ module Faker
553
553
  def spanish_cif_control_digit(organization_type, code)
554
554
  letters = %w[J A B C D E F G H I]
555
555
 
556
- control = code.split('').each_with_index.inject(0) do |sum, (value, index)|
556
+ control = code.chars.each_with_index.inject(0) do |sum, (value, index)|
557
557
  if (index + 1).even?
558
558
  sum + value.to_i
559
559
  else
@@ -57,9 +57,9 @@ module Faker
57
57
  # @example
58
58
  # Faker::File.mime_type #=> "application/pdf"
59
59
  #
60
- # @faker.version 1.6.4
61
- def mime_type
62
- fetch('file.mime_type')
60
+ # @faker.version next
61
+ def mime_type(media_type: nil)
62
+ media_type ? fetch("file.mime_type.#{media_type}") : sample(sample(translate('faker.file.mime_type').values))
63
63
  end
64
64
 
65
65
  # rubocop:disable Metrics/ParameterLists
@@ -28,9 +28,9 @@ module Faker
28
28
 
29
29
  # calculate the luhn checksum digit
30
30
  multiplier = 1
31
- luhn_sum = template.gsub(/[^0-9]/, '').split('').reverse.map(&:to_i).inject(0) do |sum, digit|
31
+ luhn_sum = template.gsub(/[^0-9]/, '').chars.reverse.map(&:to_i).inject(0) do |sum, digit|
32
32
  multiplier = (multiplier == 2 ? 1 : 2)
33
- sum + (digit * multiplier).to_s.split('').map(&:to_i).inject(0) { |digit_sum, cur| digit_sum + cur }
33
+ sum + (digit * multiplier).to_s.chars.map(&:to_i).inject(0) { |digit_sum, cur| digit_sum + cur }
34
34
  end
35
35
 
36
36
  # the sum plus whatever the last digit is must be a multiple of 10. So, the
@@ -97,6 +97,20 @@ module Faker
97
97
  def stock_market
98
98
  fetch('finance.stock_market')
99
99
  end
100
+
101
+ ##
102
+ # Returns a random condominium fiscal code.
103
+ #
104
+ # @param country [String] Two capital letter country code to use for the vat number.
105
+ # @return [String]
106
+ #
107
+ # @example
108
+ # Faker::Finance.condominium_fiscal_code #=> "012345678"
109
+ #
110
+ # @faker.version next
111
+ def condominium_fiscal_code(country: 'IT')
112
+ numerify(fetch("finance.condominium_fiscal_code.#{country}"))
113
+ end
100
114
  end
101
115
  end
102
116
  end
@@ -219,6 +219,72 @@ module Faker
219
219
  "#{prefix}#{digits}#{checksum_digit}"
220
220
  end
221
221
 
222
+ ##
223
+ # Produces a random Danish ID Number (CPR number).
224
+ # CPR number is 10 digits. Digit 1-6 is the birthdate (format "DDMMYY").
225
+ # Digit 7-10 is a sequence number.
226
+ # Digit 7 digit is a control digit that determines the century of birth.
227
+ # Digit 10 reveals the gender: # even is female, odd is male.
228
+ #
229
+ # @param formatted [Boolean] Specifies if the number is formatted with dividers.
230
+ # @param birthday [Date] Specifies the birthday for the id number.
231
+ # @param gender [Symbol] Specifies the gender for the id number. Must be one :male or :female if present.
232
+ # @return [String]
233
+ #
234
+ # @example
235
+ # Faker::IDNumber.danish_id_number #=> "0503909980"
236
+ # Faker::IDNumber.danish_id_number(formatted: true) #=> "050390-9980"
237
+ # Faker::IDNumber.danish_id_number(birthday: Date.new(1990, 3, 5)) #=> "0503909980"
238
+ # Faker::IDNumber.danish_id_number(gender: :female) #=> "0503909980"
239
+ #
240
+ # @faker.version next
241
+ def danish_id_number(formatted: false, birthday: Faker::Date.birthday, gender: nil)
242
+ valid_control_digits = danish_control_digits(birthday)
243
+ control_digit = sample(valid_control_digits)
244
+ digits = (0..9).to_a
245
+ gender = gender.to_sym if gender.respond_to?(:to_sym)
246
+ gender_digit = case gender
247
+ when nil
248
+ sample(digits)
249
+ when :male
250
+ sample(digits.select(&:odd?))
251
+ when :female
252
+ sample(digits.select(&:even?))
253
+ else
254
+ raise ArgumentError, "Invalid gender #{gender}. Must be one of male, female, or be omitted."
255
+ end
256
+
257
+ [
258
+ birthday.strftime('%d%m%y'),
259
+ formatted ? '-' : '',
260
+ control_digit,
261
+ Faker::Number.number(digits: 2),
262
+ gender_digit
263
+ ].join
264
+ end
265
+
266
+ ##
267
+ # Produces a random French social security number (INSEE number).
268
+ #
269
+ # @return [String]
270
+ #
271
+ # @example
272
+ # Faker::IDNumber.french_insee_number #=> "53290236-H"
273
+ #
274
+ # @faker.version next
275
+ def french_insee_number
276
+ num = [
277
+ [1, 2].sample(random: Faker::Config.random), # gender
278
+ Faker::Number.between(from: 0, to: 99).to_s.rjust(2, '0'), # year of birth
279
+ Faker::Number.between(from: 1, to: 12).to_s.rjust(2, '0'), # month of birth
280
+ Faker::Number.number(digits: 5), # place of birth
281
+ Faker::Number.number(digits: 3) # order number
282
+ ].join
283
+ mod = num.to_i % 97
284
+ check = (97 - mod).to_s.rjust(2, '0')
285
+ "#{num}#{check}"
286
+ end
287
+
222
288
  private
223
289
 
224
290
  def croatian_id_checksum_digit(digits)
@@ -266,7 +332,7 @@ module Faker
266
332
  .with_index { |_, i| (i + 1).odd? }
267
333
 
268
334
  sum_of_odd_digits = odd_digits_without_last_character.map(&:to_i).reduce(:+)
269
- even_digits_times_two = (even_digits.join('').to_i * 2).to_s
335
+ even_digits_times_two = (even_digits.join.to_i * 2).to_s
270
336
  sum_of_even_digits = even_digits_times_two.chars.map(&:to_i).reduce(:+)
271
337
 
272
338
  total_sum = sum_of_odd_digits + sum_of_even_digits
@@ -305,6 +371,45 @@ module Faker
305
371
  digits.include?(subtraction) ? digits[subtraction] : subtraction.to_s
306
372
  end
307
373
 
374
+ def danish_control_digits(birthday)
375
+ year = birthday.year
376
+ century = year.to_s.slice(0, 2).to_i
377
+ year_digits = year.to_s.slice(2, 2).to_i
378
+ error_message = "Invalid birthday: #{birthday}. Danish CPR numbers are only distributed to persons born between 1858 and 2057."
379
+
380
+ case century
381
+ when 18
382
+ # If 5, 6, 7 or 8 and the year numbers are greater than or equal to 58, you were born in 18XX.
383
+ case year_digits
384
+ when 58..99
385
+ [5, 6, 7, 8]
386
+ else
387
+ raise ArgumentError, error_message
388
+ end
389
+ when 19
390
+ # If 0, 1, 2 or 3, you are always born in 19XX.
391
+ # If 4 or 9, you are born in 19XX if the year digits are greater than 36.
392
+
393
+ case year_digits
394
+ when 0..36
395
+ [0, 1, 2, 3]
396
+ else # 37..99
397
+ [0, 1, 2, 3, 4, 9]
398
+ end
399
+ else
400
+ # If 4, 5, 6, 7, 8 or 9 and the year digits are less than or equal to 36, you were born in 20XX.
401
+ # 5, 6, 7 and 8 are not distributed to persons, with year digits from and including 37 to and including 57.
402
+ case year_digits
403
+ when 0..36
404
+ [4, 5, 6, 7, 8, 9]
405
+ when 37..57
406
+ [5, 6, 7, 8]
407
+ else
408
+ raise ArgumentError, error_message
409
+ end
410
+ end
411
+ end
412
+
308
413
  def _translate(key)
309
414
  parse("id_number.#{key}")
310
415
  end
@@ -174,6 +174,8 @@ module Faker
174
174
  keywords << :special_characters if legacy_special_characters != NOT_GIVEN
175
175
  end
176
176
 
177
+ raise ArgumentError, 'Password of length 1 can not have both mixed case and special characters' if min_length <= 1 && mix_case && special_characters
178
+
177
179
  min_alpha = mix_case && min_length > 1 ? 2 : 0
178
180
  temp = Lorem.characters(number: min_length, min_alpha: min_alpha)
179
181
  diff_length = max_length - min_length
@@ -200,6 +202,8 @@ module Faker
200
202
  end
201
203
  end
202
204
 
205
+ temp[rand(temp.size - 1)] = Lorem.characters(number: 1, min_alpha: 1).upcase if mix_case && special_characters && !temp.match(/[A-z]+/)
206
+
203
207
  temp
204
208
  end
205
209
  # rubocop:enable Metrics/ParameterLists
@@ -266,7 +270,7 @@ module Faker
266
270
  # @example
267
271
  # Faker::Internet.domain_word #=> "senger"
268
272
  def domain_word
269
- with_locale(:en) { Char.prepare(Company.name.split(' ').first) }
273
+ with_locale(:en) { Char.prepare(Company.name.split.first) }
270
274
  end
271
275
 
272
276
  ## Returns the domain suffix e.g. com, org, co, biz, info etc.
@@ -521,6 +525,23 @@ module Faker
521
525
  sample(agents)
522
526
  end
523
527
 
528
+ ##
529
+ # Generate Web Crawler's user agents
530
+ #
531
+ # @return [String]
532
+ #
533
+ # @param vendor [String] Name of vendor, supported vendors are googlebot, bingbot, duckduckbot, baiduspider, yandexbot
534
+ #
535
+ # @example
536
+ # Faker::Internet.bot_user_agent #=> "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)"
537
+ # Faker::Internet.bot_user_agent(vendor: 'googlebot') #=> "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/99.0.4844.84 Safari/537.36"
538
+ # Faker::Internet.bot_user_agent(vendor: 'bingbot') #=> "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/86.0.4240.68 Safari/537.36 Edg/86.0.622.31"
539
+ def bot_user_agent(vendor: nil)
540
+ agent_hash = translate('faker.internet.bot_user_agent')
541
+ agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)]
542
+ sample(agents)
543
+ end
544
+
524
545
  ##
525
546
  # Generated universally unique identifier
526
547
  #
@@ -592,10 +613,10 @@ module Faker
592
613
  Array('0'..'9'),
593
614
  Array('A'..'Z'),
594
615
  Array('a'..'z'),
595
- "!#$%&'*+-/=?^_`{|}~.".split(//)
616
+ "!#$%&'*+-/=?^_`{|}~.".chars
596
617
  ].flatten
597
618
 
598
- local_part.split(//).map do |char|
619
+ local_part.chars.map do |char|
599
620
  char_range.include?(char) ? char : '#'
600
621
  end.join
601
622
  end
@@ -27,7 +27,7 @@ module Faker
27
27
  # @faker.version 1.8.0
28
28
  def emphasis
29
29
  paragraph = Faker::Lorem.paragraph(sentence_count: 3)
30
- words = paragraph.split(' ')
30
+ words = paragraph.split
31
31
  position = rand(0..words.length - 1)
32
32
  formatting = fetch('markdown.emphasis')
33
33
  words[position] = "#{formatting}#{words[position]}#{formatting}"
@@ -50,7 +50,7 @@ module Faker
50
50
  number.times do |i|
51
51
  result << "#{i}. #{Faker::Lorem.sentence(word_count: 1)} \n"
52
52
  end
53
- result.join('')
53
+ result.join
54
54
  end
55
55
 
56
56
  ##
@@ -69,7 +69,7 @@ module Faker
69
69
  number.times do |_i|
70
70
  result << "* #{Faker::Lorem.sentence(word_count: 1)} \n"
71
71
  end
72
- result.join('')
72
+ result.join
73
73
  end
74
74
 
75
75
  ##
@@ -133,7 +133,7 @@ module Faker
133
133
  def random(*args)
134
134
  method_list = available_methods
135
135
  args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
136
- send(method_list[rand(0..method_list.length - 1)])
136
+ send(method_list[Faker::Config.random.rand(0..method_list.length - 1)])
137
137
  end
138
138
 
139
139
  ##
@@ -168,7 +168,7 @@ module Faker
168
168
  private
169
169
 
170
170
  def available_methods
171
- Markdown.public_methods(false) - Base.methods
171
+ (Markdown.public_methods(false) - Base.methods).sort
172
172
  end
173
173
  end
174
174
  end