faker 1.9.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +152 -6
  3. data/README.md +4 -0
  4. data/lib/faker/books/dune.rb +2 -2
  5. data/lib/faker/books/lovecraft.rb +18 -18
  6. data/lib/faker/creature/animal.rb +1 -1
  7. data/lib/faker/creature/cat.rb +1 -1
  8. data/lib/faker/creature/dog.rb +1 -1
  9. data/lib/faker/creature/horse.rb +1 -1
  10. data/lib/faker/default/address.rb +3 -3
  11. data/lib/faker/default/alphanumeric.rb +4 -4
  12. data/lib/faker/default/avatar.rb +1 -1
  13. data/lib/faker/default/bank.rb +2 -2
  14. data/lib/faker/default/boolean.rb +1 -1
  15. data/lib/faker/default/cannabis.rb +4 -0
  16. data/lib/faker/default/chile_rut.rb +3 -3
  17. data/lib/faker/default/code.rb +5 -5
  18. data/lib/faker/default/commerce.rb +4 -4
  19. data/lib/faker/default/company.rb +2 -2
  20. data/lib/faker/default/crypto_coin.rb +9 -4
  21. data/lib/faker/default/date.rb +9 -9
  22. data/lib/faker/default/demographic.rb +1 -1
  23. data/lib/faker/default/device.rb +2 -2
  24. data/lib/faker/default/driving_licence.rb +2 -2
  25. data/lib/faker/default/educator.rb +0 -3
  26. data/lib/faker/default/file.rb +3 -3
  27. data/lib/faker/default/fillmurray.rb +2 -2
  28. data/lib/faker/default/finance.rb +1 -1
  29. data/lib/faker/default/hipster.rb +16 -16
  30. data/lib/faker/default/id_number.rb +8 -8
  31. data/lib/faker/default/internet.rb +22 -21
  32. data/lib/faker/default/invoice.rb +3 -3
  33. data/lib/faker/default/json.rb +2 -2
  34. data/lib/faker/default/lorem.rb +20 -20
  35. data/lib/faker/default/lorem_flickr.rb +4 -4
  36. data/lib/faker/default/lorem_pixel.rb +1 -1
  37. data/lib/faker/default/markdown.rb +7 -7
  38. data/lib/faker/default/measurement.rb +8 -8
  39. data/lib/faker/default/name.rb +2 -4
  40. data/lib/faker/default/nhs.rb +7 -7
  41. data/lib/faker/default/number.rb +35 -32
  42. data/lib/faker/default/omniauth.rb +11 -11
  43. data/lib/faker/default/phone_number.rb +1 -1
  44. data/lib/faker/default/placeholdit.rb +1 -1
  45. data/lib/faker/default/relationship.rb +1 -1
  46. data/lib/faker/default/source.rb +2 -2
  47. data/lib/faker/default/south_africa.rb +1 -1
  48. data/lib/faker/default/space.rb +2 -2
  49. data/lib/faker/default/string.rb +1 -1
  50. data/lib/faker/default/stripe.rb +4 -4
  51. data/lib/faker/default/time.rb +23 -8
  52. data/lib/faker/default/twitter.rb +30 -30
  53. data/lib/faker/default/types.rb +7 -7
  54. data/lib/faker/default/vehicle.rb +5 -5
  55. data/lib/faker/default/world_cup.rb +2 -2
  56. data/lib/faker/games/dota.rb +1 -1
  57. data/lib/faker/games/elder_scrolls.rb +1 -1
  58. data/lib/faker/games/fallout.rb +1 -1
  59. data/lib/faker/games/half_life.rb +1 -1
  60. data/lib/faker/games/heroes.rb +1 -1
  61. data/lib/faker/games/heroes_of_the_storm.rb +1 -1
  62. data/lib/faker/games/league_of_legends.rb +1 -1
  63. data/lib/faker/games/myst.rb +1 -1
  64. data/lib/faker/games/overwatch.rb +1 -1
  65. data/lib/faker/games/pokemon.rb +1 -1
  66. data/lib/faker/games/sonic_the_hedgehog.rb +1 -1
  67. data/lib/faker/games/super_smash_bros.rb +1 -1
  68. data/lib/faker/games/witcher.rb +1 -1
  69. data/lib/faker/games/world_of_warcraft.rb +1 -1
  70. data/lib/faker/games/zelda.rb +1 -1
  71. data/lib/faker/japanese_media/dragon_ball.rb +1 -1
  72. data/lib/faker/japanese_media/one_piece.rb +1 -1
  73. data/lib/faker/japanese_media/sword_art_online.rb +1 -1
  74. data/lib/faker/movies/back_to_the_future.rb +1 -1
  75. data/lib/faker/movies/ghostbusters.rb +1 -1
  76. data/lib/faker/movies/harry_potter.rb +1 -1
  77. data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +1 -1
  78. data/lib/faker/movies/hobbit.rb +1 -1
  79. data/lib/faker/movies/lebowski.rb +1 -1
  80. data/lib/faker/movies/lord_of_the_rings.rb +1 -1
  81. data/lib/faker/movies/princess_bride.rb +1 -1
  82. data/lib/faker/movies/star_wars.rb +2 -2
  83. data/lib/faker/movies/v_for_vendetta.rb +1 -1
  84. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +1 -1
  85. data/lib/faker/tv_shows/bojack_horseman.rb +1 -1
  86. data/lib/faker/tv_shows/breaking_bad.rb +1 -1
  87. data/lib/faker/tv_shows/buffy.rb +1 -1
  88. data/lib/faker/tv_shows/community.rb +1 -1
  89. data/lib/faker/tv_shows/dr_who.rb +1 -1
  90. data/lib/faker/tv_shows/dumb_and_dumber.rb +1 -1
  91. data/lib/faker/tv_shows/family_guy.rb +1 -1
  92. data/lib/faker/tv_shows/friends.rb +1 -1
  93. data/lib/faker/tv_shows/game_of_thrones.rb +1 -1
  94. data/lib/faker/tv_shows/hey_arnold.rb +1 -1
  95. data/lib/faker/tv_shows/how_i_met_your_mother.rb +1 -1
  96. data/lib/faker/tv_shows/michael_scott.rb +1 -1
  97. data/lib/faker/tv_shows/new_girl.rb +1 -1
  98. data/lib/faker/tv_shows/parks_and_rec.rb +1 -1
  99. data/lib/faker/tv_shows/rick_and_morty.rb +1 -1
  100. data/lib/faker/tv_shows/ru_paul.rb +1 -1
  101. data/lib/faker/tv_shows/seinfeld.rb +1 -1
  102. data/lib/faker/tv_shows/silicon_valley.rb +1 -1
  103. data/lib/faker/tv_shows/simpsons.rb +1 -1
  104. data/lib/faker/tv_shows/south_park.rb +1 -1
  105. data/lib/faker/tv_shows/star_trek.rb +1 -1
  106. data/lib/faker/tv_shows/stargate.rb +1 -1
  107. data/lib/faker/tv_shows/stranger_things.rb +1 -1
  108. data/lib/faker/tv_shows/the_expanse.rb +1 -1
  109. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +1 -1
  110. data/lib/faker/tv_shows/the_it_crowd.rb +1 -1
  111. data/lib/faker/tv_shows/the_thick_of_it.rb +1 -1
  112. data/lib/faker/tv_shows/twin_peaks.rb +1 -1
  113. data/lib/faker/tv_shows/venture_bros.rb +1 -1
  114. data/lib/faker/version.rb +1 -1
  115. data/lib/locales/en-IND.yml +1 -1
  116. data/lib/locales/en.yml +51 -1
  117. data/lib/locales/en/address.yml +1 -4
  118. data/lib/locales/en/animal.yml +2 -2
  119. data/lib/locales/en/cannabis.yml +1 -0
  120. data/lib/locales/en/space.yml +1 -1
  121. data/lib/locales/en/super_smash_bros.yml +4 -0
  122. data/lib/locales/vi.yml +1 -1
  123. metadata +3 -11
  124. data/lib/faker/default/creature.rb +0 -6
  125. data/lib/faker/default/games.rb +0 -6
  126. data/lib/faker/default/japanese_media.rb +0 -6
  127. data/lib/faker/default/movies.rb +0 -6
  128. data/lib/faker/default/tv_shows.rb +0 -6
  129. data/lib/faker/deprecate/unreleased/football.rb +0 -35
  130. data/lib/faker/deprecate/unreleased/movies/grateful_dead.rb +0 -22
@@ -6,7 +6,7 @@ module Faker
6
6
  @last_rut = nil
7
7
 
8
8
  # Fixed param added for testing a specific RUT and check digit combination.
9
- def rut(min_rut = 1, fixed = false)
9
+ def rut(min_rut: 1, fixed: false)
10
10
  @last_rut = fixed ? min_rut : rand_in_range(min_rut, 99_999_999)
11
11
  end
12
12
 
@@ -34,8 +34,8 @@ module Faker
34
34
  dv
35
35
  end
36
36
 
37
- def full_rut(min_rut = 0, fixed = false)
38
- "#{rut(min_rut, fixed)}-#{dv}"
37
+ def full_rut(min_rut: 0, fixed: false)
38
+ "#{rut(min_rut: min_rut, fixed: fixed)}-#{dv}"
39
39
  end
40
40
 
41
41
  attr_reader :last_rut
@@ -12,26 +12,26 @@ module Faker
12
12
 
13
13
  # By default generates 10 sign isbn code in format 123456789-X
14
14
  # You can pass 13 to generate new 13 sign code
15
- def isbn(base = 10)
15
+ def isbn(base: 10)
16
16
  base == 13 ? generate_base13_isbn : generate_base10_isbn
17
17
  end
18
18
 
19
19
  # By default generates 13 sign ean code in format 1234567890123
20
20
  # You can pass 8 to generate ean8 code
21
- def ean(base = 13)
21
+ def ean(base: 13)
22
22
  base == 8 ? generate_base8_ean : generate_base13_ean
23
23
  end
24
24
 
25
25
  def rut
26
- value = Number.number(8)
26
+ value = Number.number(digits: 8).to_s
27
27
  vd = rut_verificator_digit(value)
28
28
  value << "-#{vd}"
29
29
  end
30
30
 
31
31
  # By default generates a Singaporean NRIC ID for someone
32
32
  # who is born between the age of 18 and 65.
33
- def nric(min_age = 18, max_age = 65)
34
- birthyear = Date.birthday(min_age, max_age).year
33
+ def nric(min_age: 18, max_age: 65)
34
+ birthyear = Date.birthday(min_age: min_age, max_age: max_age).year
35
35
  prefix = birthyear < 2000 ? 'S' : 'T'
36
36
  values = birthyear.to_s[-2..-1]
37
37
  values << regexify(/\d{5}/)
@@ -7,15 +7,15 @@ module Faker
7
7
  fetch('color.name')
8
8
  end
9
9
 
10
- def promotion_code(digits = 6)
10
+ def promotion_code(digits: 6)
11
11
  [
12
12
  fetch('commerce.promotion_code.adjective'),
13
13
  fetch('commerce.promotion_code.noun'),
14
- Faker::Number.number(digits)
14
+ Faker::Number.number(digits: digits)
15
15
  ].join
16
16
  end
17
17
 
18
- def department(max = 3, fixed_amount = false)
18
+ def department(max: 3, fixed_amount: false)
19
19
  num = max if fixed_amount
20
20
  num ||= 1 + rand(max)
21
21
 
@@ -34,7 +34,7 @@ module Faker
34
34
  fetch('commerce.product_name.material')
35
35
  end
36
36
 
37
- def price(range = 0..100.0, as_string = false)
37
+ def price(range: 0..100.0, as_string: false)
38
38
  price = (rand(range) * 100).floor / 100.0
39
39
  if as_string
40
40
  price_parts = price.to_s.split('.')
@@ -126,7 +126,7 @@ module Faker
126
126
  end
127
127
 
128
128
  # Get a random Polish register of national economy number. More info https://pl.wikipedia.org/wiki/REGON
129
- def polish_register_of_national_economy(length = 9)
129
+ def polish_register_of_national_economy(length: 9)
130
130
  raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length
131
131
 
132
132
  random_digits = []
@@ -198,7 +198,7 @@ module Faker
198
198
  def luhn_algorithm(number)
199
199
  multiplications = []
200
200
 
201
- number.reverse.split(//).each_with_index do |digit, i|
201
+ number.to_s.reverse.split(//).each_with_index do |digit, i|
202
202
  multiplications << if i.even?
203
203
  digit.to_i * 2
204
204
  else
@@ -7,15 +7,15 @@ module Faker
7
7
  ACRONYM = 1
8
8
  URL_LOGO = 2
9
9
 
10
- def coin_name(coin = coin_array)
10
+ def coin_name(coin: coin_array)
11
11
  coin[COIN_NAME]
12
12
  end
13
13
 
14
- def acronym(coin = coin_array)
14
+ def acronym(coin: coin_array)
15
15
  coin[ACRONYM]
16
16
  end
17
17
 
18
- def url_logo(coin = coin_array)
18
+ def url_logo(coin: coin_array)
19
19
  coin[URL_LOGO]
20
20
  end
21
21
 
@@ -25,7 +25,12 @@ module Faker
25
25
 
26
26
  def coin_hash
27
27
  coin = coin_array
28
- { name: coin_name(coin), acronym: acronym(coin), url_logo: url_logo(coin) }
28
+
29
+ {
30
+ name: coin_name(coin: coin),
31
+ acronym: acronym(coin: coin),
32
+ url_logo: url_logo(coin: coin)
33
+ }
29
34
  end
30
35
  end
31
36
  end
@@ -3,45 +3,45 @@
3
3
  module Faker
4
4
  class Date < Base
5
5
  class << self
6
- def between(from, to)
6
+ def between(from:, to:)
7
7
  from = get_date_object(from)
8
8
  to = get_date_object(to)
9
9
 
10
10
  Faker::Base.rand_in_range(from, to)
11
11
  end
12
12
 
13
- def between_except(from, to, excepted)
13
+ def between_except(from:, to:, excepted:)
14
14
  raise ArgumentError, 'From date, to date and excepted date must not be the same' if from == to && to == excepted
15
15
 
16
16
  excepted = get_date_object(excepted)
17
17
 
18
18
  loop do
19
- date = between(from, to)
19
+ date = between(from: from, to: to)
20
20
  break date.to_date if date != excepted
21
21
  end
22
22
  end
23
23
 
24
- def forward(days = 365)
24
+ def forward(days: 365)
25
25
  from = ::Date.today + 1
26
26
  to = ::Date.today + days
27
27
 
28
- between(from, to).to_date
28
+ between(from: from, to: to).to_date
29
29
  end
30
30
 
31
- def backward(days = 365)
31
+ def backward(days: 365)
32
32
  from = ::Date.today - days
33
33
  to = ::Date.today - 1
34
34
 
35
- between(from, to).to_date
35
+ between(from: from, to: to).to_date
36
36
  end
37
37
 
38
- def birthday(min_age = 18, max_age = 65)
38
+ def birthday(min_age: 18, max_age: 65)
39
39
  t = ::Date.today
40
40
 
41
41
  from = birthday_date(t, max_age)
42
42
  to = birthday_date(t, min_age)
43
43
 
44
- between(from, to).to_date
44
+ between(from: from, to: to).to_date
45
45
  end
46
46
 
47
47
  private
@@ -23,7 +23,7 @@ module Faker
23
23
  fetch('demographic.sex')
24
24
  end
25
25
 
26
- def height(unit = :metric)
26
+ def height(unit: :metric)
27
27
  case unit
28
28
  when :imperial
29
29
  inches = rand_in_range(57, 86)
@@ -4,7 +4,7 @@ module Faker
4
4
  class Device < Base
5
5
  class << self
6
6
  def build_number
7
- Faker::Number.between(1, 500)
7
+ Faker::Number.between(from: 1, to: 500)
8
8
  end
9
9
 
10
10
  def manufacturer
@@ -24,7 +24,7 @@ module Faker
24
24
  end
25
25
 
26
26
  def version
27
- Faker::Number.between(1, 1000)
27
+ Faker::Number.between(from: 1, to: 1000)
28
28
  end
29
29
  end
30
30
  end
@@ -9,7 +9,7 @@ module Faker
9
9
  def british_driving_licence(last_name: Faker::Name.last_name,
10
10
  initials: Faker::Name.initials,
11
11
  gender: random_gender,
12
- date_of_birth: Faker::Date.birthday(18, 65))
12
+ date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65))
13
13
  [
14
14
  gb_licence_padding(last_name, 5),
15
15
  gb_licence_year(date_of_birth, gender),
@@ -19,7 +19,7 @@ module Faker
19
19
  end
20
20
 
21
21
  def northern_irish_driving_licence
22
- Faker::Number.number(8)
22
+ Faker::Number.number(digits: 8).to_s
23
23
  end
24
24
 
25
25
  def uk_driving_licence(*args)
@@ -5,8 +5,6 @@ module Faker
5
5
  flexible :educator
6
6
 
7
7
  class << self
8
- extend Gem::Deprecate
9
-
10
8
  def university
11
9
  "#{parse('educator.name')} #{fetch('educator.tertiary.type')}"
12
10
  end
@@ -16,7 +14,6 @@ module Faker
16
14
  end
17
15
 
18
16
  alias course degree
19
- deprecate :course, :course_name, 2018, 10
20
17
 
21
18
  def subject
22
19
  fetch('educator.tertiary.degree.subject')
@@ -3,7 +3,7 @@
3
3
  module Faker
4
4
  class File < Base
5
5
  class << self
6
- def dir(segment_count = 3, root = nil, directory_separator = '/')
6
+ def dir(segment_count: 3, root: nil, directory_separator: '/')
7
7
  Array
8
8
  .new(segment_count) { Faker::Internet.slug }
9
9
  .unshift(root)
@@ -20,8 +20,8 @@ module Faker
20
20
  fetch('file.mime_type')
21
21
  end
22
22
 
23
- def file_name(dir = nil, name = nil, ext = nil, directory_separator = '/')
24
- dir ||= dir(1)
23
+ def file_name(dir: nil, name: nil, ext: nil, directory_separator: '/')
24
+ dir ||= dir(segment_count: 1)
25
25
  name ||= Faker::Lorem.word.downcase
26
26
  ext ||= extension
27
27
 
@@ -3,12 +3,12 @@
3
3
  module Faker
4
4
  class Fillmurray < Base
5
5
  class << self
6
- def image(grayscale = false, width = 200, height = 200)
6
+ def image(grayscale: false, width: 200, height: 200)
7
7
  raise ArgumentError, 'Width should be a number' unless width.to_s =~ /^\d+$/
8
8
  raise ArgumentError, 'Height should be a number' unless height.to_s =~ /^\d+$/
9
9
  raise ArgumentError, 'Grayscale should be a boolean' unless [true, false].include?(grayscale)
10
10
 
11
- grayscale == true ? "https://fillmurray.com/g/#{width}/#{height}" : "https://fillmurray.com/#{width}/#{height}"
11
+ "https://www.fillmurray.com#{'/g' if grayscale == true}/#{width}/#{height}"
12
12
  end
13
13
  end
14
14
  end
@@ -26,7 +26,7 @@ module Faker
26
26
  template.gsub('L', luhn_digit.to_s)
27
27
  end
28
28
 
29
- def vat_number(country = 'BR')
29
+ def vat_number(country: 'BR')
30
30
  numerify(fetch("finance.vat_number.#{country}"))
31
31
  rescue I18n::MissingTranslationData
32
32
  raise ArgumentError, "Could not find vat number for #{country}"
@@ -8,8 +8,8 @@ module Faker
8
8
  random_word =~ /\s/ ? word : random_word
9
9
  end
10
10
 
11
- def words(num = 3, supplemental = false, spaces_allowed = false)
12
- resolved_num = resolve(num)
11
+ def words(number: 3, supplemental: false, spaces_allowed: false)
12
+ resolved_num = resolve(number)
13
13
  word_list = (
14
14
  translate('faker.hipster.words') +
15
15
  (supplemental ? translate('faker.lorem.words') : [])
@@ -22,36 +22,36 @@ module Faker
22
22
  words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
23
23
  end
24
24
 
25
- def sentence(word_count = 4, supplemental = false, random_words_to_add = 6)
26
- words(word_count + rand(random_words_to_add.to_i).to_i, supplemental, true).join(' ').capitalize + '.'
25
+ def sentence(word_count: 4, supplemental: false, random_words_to_add: 6)
26
+ words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
27
27
  end
28
28
 
29
- def sentences(sentence_count = 3, supplemental = false)
29
+ def sentences(number: 3, supplemental: false)
30
30
  [].tap do |sentences|
31
- 1.upto(resolve(sentence_count)) do
32
- sentences << sentence(3, supplemental)
31
+ 1.upto(resolve(number)) do
32
+ sentences << sentence(word_count: 3, supplemental: supplemental)
33
33
  end
34
34
  end
35
35
  end
36
36
 
37
- def paragraph(sentence_count = 3, supplemental = false, random_sentences_to_add = 3)
38
- sentences(resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental).join(' ')
37
+ def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
38
+ sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
39
39
  end
40
40
 
41
- def paragraphs(paragraph_count = 3, supplemental = false)
41
+ def paragraphs(number: 3, supplemental: false)
42
42
  [].tap do |paragraphs|
43
- 1.upto(resolve(paragraph_count)) do
44
- paragraphs << paragraph(3, supplemental)
43
+ 1.upto(resolve(number)) do
44
+ paragraphs << paragraph(sentence_count: 3, supplemental: supplemental)
45
45
  end
46
46
  end
47
47
  end
48
48
 
49
- def paragraph_by_chars(chars = 256, supplemental = false)
50
- paragraph = paragraph(3, supplemental)
49
+ def paragraph_by_chars(characters: 256, supplemental: false)
50
+ paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
51
51
 
52
- paragraph += ' ' + paragraph(3, supplemental) while paragraph.length < chars
52
+ paragraph += ' ' + paragraph(sentence_count: 3, supplemental: supplemental) while paragraph.length < characters
53
53
 
54
- paragraph[0...chars - 1] + '.'
54
+ paragraph[0...characters - 1] + '.'
55
55
  end
56
56
  end
57
57
  end
@@ -29,7 +29,7 @@ module Faker
29
29
  end
30
30
 
31
31
  def spanish_citizen_number
32
- num = Faker::Number.number(8)
32
+ num = Faker::Number.number(digits: 8)
33
33
  mod = num.to_i % 23
34
34
  check = CHECKS[mod]
35
35
  "#{num}-#{check}"
@@ -37,7 +37,7 @@ module Faker
37
37
 
38
38
  def spanish_foreign_citizen_number
39
39
  code = 'XYZ'
40
- digits = Faker::Number.number(7)
40
+ digits = Faker::Number.number(digits: 7)
41
41
  prefix = code[rand(code.length)]
42
42
  prefix_val = 'XYZ'.index(prefix).to_s
43
43
  mod = "#{prefix_val}#{digits}".to_i % 23
@@ -48,7 +48,7 @@ module Faker
48
48
  def valid_south_african_id_number
49
49
  id_number = [
50
50
  Faker::Date.birthday.strftime('%y%m%d'),
51
- Faker::Number.number(4),
51
+ Faker::Number.number(digits: 4),
52
52
  ZA_CITIZENSHIP_DIGITS.sample(random: Faker::Config.random),
53
53
  ZA_RACE_DIGIT
54
54
  ].join
@@ -60,14 +60,14 @@ module Faker
60
60
 
61
61
  def invalid_south_african_id_number
62
62
  invalid_date_of_birth = [
63
- Faker::Number.number(2),
64
- Faker::Number.between(13, 99),
65
- Faker::Number.between(32, 99)
63
+ Faker::Number.number(digits: 2),
64
+ Faker::Number.between(from: 13, to: 99),
65
+ Faker::Number.between(from: 32, to: 99)
66
66
  ].map(&:to_s).join
67
67
 
68
68
  id_number = [
69
69
  invalid_date_of_birth,
70
- Faker::Number.number(4),
70
+ Faker::Number.number(digits: 4),
71
71
  ZA_CITIZENSHIP_DIGITS.sample(random: Faker::Config.random),
72
72
  ZA_RACE_DIGIT
73
73
  ].join
@@ -76,7 +76,7 @@ module Faker
76
76
  end
77
77
 
78
78
  def brazilian_citizen_number(formatted: false)
79
- digits = Faker::Number.leading_zero_number(9) until digits&.match(/(\d)((?!\1)\d)+/)
79
+ digits = Faker::Number.leading_zero_number(digits: 9) until digits&.match(/(\d)((?!\1)\d)+/)
80
80
  first_digit = brazilian_citizen_number_checksum_digit(digits)
81
81
  second_digit = brazilian_citizen_number_checksum_digit(digits + first_digit)
82
82
  number = [digits, first_digit, second_digit].join
@@ -3,23 +3,23 @@
3
3
  module Faker
4
4
  class Internet < Base
5
5
  class << self
6
- def email(name = nil, *separators)
6
+ def email(name: nil, separators: nil)
7
7
  if separators
8
- [username(name, separators), domain_name].join('@')
8
+ [username(specifier: name, separators: separators), domain_name].join('@')
9
9
  else
10
- [username(name), domain_name].join('@')
10
+ [username(specifier: name), domain_name].join('@')
11
11
  end
12
12
  end
13
13
 
14
- def free_email(name = nil)
15
- [username(name), fetch('internet.free_email')].join('@')
14
+ def free_email(name: nil)
15
+ [username(specifier: name), fetch('internet.free_email')].join('@')
16
16
  end
17
17
 
18
- def safe_email(name = nil)
19
- [username(name), 'example.' + sample(%w[org com net])].join('@')
18
+ def safe_email(name: nil)
19
+ [username(specifier: name), 'example.' + sample(%w[org com net])].join('@')
20
20
  end
21
21
 
22
- def username(specifier = nil, separators = %w[. _])
22
+ def username(specifier: nil, separators: %w[. _])
23
23
  with_locale(:en) do
24
24
  return shuffle(specifier.scan(/[[:word:]]+/)).join(sample(separators)).downcase if specifier.respond_to?(:scan)
25
25
 
@@ -30,7 +30,7 @@ module Faker
30
30
  tries = 0 # Don't try forever in case we get something like 1_000_000.
31
31
  result = nil
32
32
  loop do
33
- result = username(nil, separators)
33
+ result = username(specifier: nil, separators: separators)
34
34
  tries += 1
35
35
  break unless result.length < specifier && tries < 7
36
36
  end
@@ -39,7 +39,7 @@ module Faker
39
39
  tries = 0
40
40
  result = nil
41
41
  loop do
42
- result = username(specifier.min, separators)
42
+ result = username(specifier: specifier.min, separators: separators)
43
43
  tries += 1
44
44
  break unless !specifier.include?(result.length) && tries < 7
45
45
  end
@@ -55,12 +55,13 @@ module Faker
55
55
  end
56
56
  end
57
57
 
58
- def password(min_length = 8, max_length = 16, mix_case = true, special_chars = false)
59
- temp = Lorem.characters(min_length)
58
+ def password(min_length: 8, max_length: 16, mix_case: true, special_characters: false)
59
+ temp = Lorem.characters(number: min_length)
60
60
  diff_length = max_length - min_length
61
+
61
62
  if diff_length.positive?
62
63
  diff_rand = rand(diff_length + 1)
63
- temp += Lorem.characters(diff_rand)
64
+ temp += Lorem.characters(number: diff_rand)
64
65
  end
65
66
 
66
67
  if mix_case
@@ -69,7 +70,7 @@ module Faker
69
70
  end
70
71
  end
71
72
 
72
- if special_chars
73
+ if special_characters
73
74
  chars = %w[! @ # $ % ^ & *]
74
75
  rand(1..min_length).times do |i|
75
76
  temp[i] = chars[rand(chars.length)]
@@ -79,7 +80,7 @@ module Faker
79
80
  temp
80
81
  end
81
82
 
82
- def domain_name(subdomain = false)
83
+ def domain_name(subdomain: false)
83
84
  with_locale(:en) do
84
85
  domain_elements = [Char.prepare(domain_word), domain_suffix]
85
86
  domain_elements.unshift(Char.prepare(domain_word)) if subdomain
@@ -87,7 +88,7 @@ module Faker
87
88
  end
88
89
  end
89
90
 
90
- def fix_umlauts(string = '')
91
+ def fix_umlauts(string: '')
91
92
  Char.fix_umlauts(string)
92
93
  end
93
94
 
@@ -99,7 +100,7 @@ module Faker
99
100
  fetch('internet.domain_suffix')
100
101
  end
101
102
 
102
- def mac_address(prefix = '')
103
+ def mac_address(prefix: '')
103
104
  prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
104
105
  address_digits = Array.new((6 - prefix_digits.size)) { rand(256) }
105
106
  (prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':')
@@ -173,20 +174,20 @@ module Faker
173
174
  "#{ip_v6_address}/#{rand(1..127)}"
174
175
  end
175
176
 
176
- def url(host = domain_name, path = "/#{username}", scheme = 'http')
177
+ def url(host: domain_name, path: "/#{username}", scheme: 'http')
177
178
  "#{scheme}://#{host}#{path}"
178
179
  end
179
180
 
180
- def slug(words = nil, glue = nil)
181
+ def slug(words: nil, glue: nil)
181
182
  glue ||= sample(%w[- _])
182
- (words || Faker::Lorem.words(2).join(' ')).delete(',.').gsub(' ', glue).downcase
183
+ (words || Faker::Lorem.words(number: 2).join(' ')).delete(',.').gsub(' ', glue).downcase
183
184
  end
184
185
 
185
186
  def device_token
186
187
  shuffle(rand(16**64).to_s(16).rjust(64, '0').chars.to_a).join
187
188
  end
188
189
 
189
- def user_agent(vendor = nil)
190
+ def user_agent(vendor: nil)
190
191
  agent_hash = translate('faker.internet.user_agent')
191
192
  agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)]
192
193
  sample(agents)