faker 1.9.6 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +386 -6
  3. data/README.md +12 -5
  4. data/lib/faker.rb +56 -1
  5. data/lib/faker/blockchain/aeternity.rb +70 -0
  6. data/lib/faker/blockchain/bitcoin.rb +26 -0
  7. data/lib/faker/blockchain/ethereum.rb +10 -0
  8. data/lib/faker/blockchain/tezos.rb +62 -6
  9. data/lib/faker/books/book.rb +36 -0
  10. data/lib/faker/books/culture_series.rb +49 -0
  11. data/lib/faker/books/dune.rb +66 -5
  12. data/lib/faker/books/lovecraft.rb +221 -18
  13. data/lib/faker/creature/animal.rb +10 -1
  14. data/lib/faker/creature/cat.rb +28 -1
  15. data/lib/faker/creature/dog.rb +73 -1
  16. data/lib/faker/creature/horse.rb +19 -1
  17. data/lib/faker/default/address.rb +25 -5
  18. data/lib/faker/default/alphanumeric.rb +58 -9
  19. data/lib/faker/default/app.rb +55 -1
  20. data/lib/faker/default/appliance.rb +18 -0
  21. data/lib/faker/default/artist.rb +9 -0
  22. data/lib/faker/default/avatar.rb +43 -1
  23. data/lib/faker/default/bank.rb +10 -2
  24. data/lib/faker/default/boolean.rb +16 -1
  25. data/lib/faker/default/cannabis.rb +4 -0
  26. data/lib/faker/default/chile_rut.rb +13 -3
  27. data/lib/faker/default/chuck_norris.rb +1 -1
  28. data/lib/faker/default/code.rb +18 -5
  29. data/lib/faker/default/commerce.rb +18 -4
  30. data/lib/faker/default/company.rb +11 -3
  31. data/lib/faker/default/crypto_coin.rb +21 -4
  32. data/lib/faker/default/date.rb +122 -9
  33. data/lib/faker/default/demographic.rb +5 -1
  34. data/lib/faker/default/dessert.rb +27 -0
  35. data/lib/faker/default/device.rb +56 -2
  36. data/lib/faker/default/driving_licence.rb +13 -7
  37. data/lib/faker/default/educator.rb +0 -3
  38. data/lib/faker/default/electrical_components.rb +27 -0
  39. data/lib/faker/default/file.rb +20 -3
  40. data/lib/faker/default/fillmurray.rb +10 -2
  41. data/lib/faker/default/finance.rb +5 -1
  42. data/lib/faker/default/gender.rb +18 -0
  43. data/lib/faker/default/greek_philosophers.rb +18 -0
  44. data/lib/faker/default/hacker.rb +59 -1
  45. data/lib/faker/default/hipster.rb +55 -16
  46. data/lib/faker/default/house.rb +18 -0
  47. data/lib/faker/default/id_number.rb +85 -11
  48. data/lib/faker/default/industry_segments.rb +36 -0
  49. data/lib/faker/default/internet.rb +107 -22
  50. data/lib/faker/default/invoice.rb +16 -3
  51. data/lib/faker/default/json.rb +19 -2
  52. data/lib/faker/default/lorem.rb +91 -20
  53. data/lib/faker/default/lorem_flickr.rb +38 -5
  54. data/lib/faker/default/lorem_pixel.rb +10 -1
  55. data/lib/faker/default/markdown.rb +12 -7
  56. data/lib/faker/default/marketing.rb +9 -0
  57. data/lib/faker/default/measurement.rb +40 -8
  58. data/lib/faker/default/military.rb +45 -0
  59. data/lib/faker/default/name.rb +6 -4
  60. data/lib/faker/default/nation.rb +48 -5
  61. data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
  62. data/lib/faker/default/nhs.rb +11 -7
  63. data/lib/faker/default/number.rb +202 -30
  64. data/lib/faker/default/omniauth.rb +98 -15
  65. data/lib/faker/default/phone_number.rb +5 -1
  66. data/lib/faker/default/placeholdit.rb +11 -1
  67. data/lib/faker/default/programming_language.rb +18 -0
  68. data/lib/faker/default/relationship.rb +5 -1
  69. data/lib/faker/default/restaurant.rb +54 -2
  70. data/lib/faker/default/science.rb +27 -0
  71. data/lib/faker/default/source.rb +59 -3
  72. data/lib/faker/default/south_africa.rb +1 -1
  73. data/lib/faker/default/space.rb +2 -2
  74. data/lib/faker/default/string.rb +5 -1
  75. data/lib/faker/default/stripe.rb +20 -4
  76. data/lib/faker/default/subscription.rb +45 -0
  77. data/lib/faker/default/superhero.rb +45 -0
  78. data/lib/faker/default/time.rb +133 -8
  79. data/lib/faker/default/twitter.rb +62 -48
  80. data/lib/faker/default/types.rb +29 -7
  81. data/lib/faker/default/vehicle.rb +19 -6
  82. data/lib/faker/default/world_cup.rb +61 -2
  83. data/lib/faker/games/dota.rb +53 -2
  84. data/lib/faker/games/elder_scrolls.rb +73 -1
  85. data/lib/faker/games/fallout.rb +38 -1
  86. data/lib/faker/games/game.rb +27 -0
  87. data/lib/faker/games/half_life.rb +28 -1
  88. data/lib/faker/games/heroes.rb +28 -1
  89. data/lib/faker/games/heroes_of_the_storm.rb +37 -1
  90. data/lib/faker/games/league_of_legends.rb +55 -1
  91. data/lib/faker/games/myst.rb +46 -1
  92. data/lib/faker/games/overwatch.rb +28 -1
  93. data/lib/faker/games/pokemon.rb +28 -1
  94. data/lib/faker/games/sonic_the_hedgehog.rb +28 -1
  95. data/lib/faker/games/super_smash_bros.rb +19 -1
  96. data/lib/faker/games/witcher.rb +55 -1
  97. data/lib/faker/games/world_of_warcraft.rb +19 -1
  98. data/lib/faker/games/zelda.rb +38 -2
  99. data/lib/faker/japanese_media/dragon_ball.rb +10 -1
  100. data/lib/faker/japanese_media/one_piece.rb +55 -1
  101. data/lib/faker/japanese_media/sword_art_online.rb +37 -1
  102. data/lib/faker/movies/back_to_the_future.rb +29 -1
  103. data/lib/faker/movies/ghostbusters.rb +29 -1
  104. data/lib/faker/movies/harry_potter.rb +55 -1
  105. data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +70 -1
  106. data/lib/faker/movies/hobbit.rb +38 -1
  107. data/lib/faker/movies/lebowski.rb +28 -1
  108. data/lib/faker/movies/lord_of_the_rings.rb +29 -1
  109. data/lib/faker/movies/movie.rb +9 -0
  110. data/lib/faker/movies/princess_bride.rb +20 -1
  111. data/lib/faker/movies/star_wars.rb +101 -5
  112. data/lib/faker/movies/v_for_vendetta.rb +30 -1
  113. data/lib/faker/music/grateful_dead.rb +18 -0
  114. data/lib/faker/music/phish.rb +9 -0
  115. data/lib/faker/music/rock_band.rb +9 -0
  116. data/lib/faker/music/umphreys_mcgee.rb +9 -0
  117. data/lib/faker/sports/basketball.rb +36 -0
  118. data/lib/faker/sports/football.rb +45 -0
  119. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +10 -1
  120. data/lib/faker/tv_shows/bojack_horseman.rb +29 -1
  121. data/lib/faker/tv_shows/breaking_bad.rb +19 -1
  122. data/lib/faker/tv_shows/buffy.rb +46 -1
  123. data/lib/faker/tv_shows/community.rb +20 -1
  124. data/lib/faker/tv_shows/dr_who.rb +79 -3
  125. data/lib/faker/tv_shows/dumb_and_dumber.rb +29 -1
  126. data/lib/faker/tv_shows/family_guy.rb +29 -1
  127. data/lib/faker/tv_shows/friends.rb +28 -1
  128. data/lib/faker/tv_shows/game_of_thrones.rb +47 -1
  129. data/lib/faker/tv_shows/hey_arnold.rb +28 -1
  130. data/lib/faker/tv_shows/how_i_met_your_mother.rb +38 -1
  131. data/lib/faker/tv_shows/michael_scott.rb +14 -1
  132. data/lib/faker/tv_shows/new_girl.rb +20 -1
  133. data/lib/faker/tv_shows/parks_and_rec.rb +19 -1
  134. data/lib/faker/tv_shows/rick_and_morty.rb +29 -1
  135. data/lib/faker/tv_shows/ru_paul.rb +19 -1
  136. data/lib/faker/tv_shows/seinfeld.rb +29 -1
  137. data/lib/faker/tv_shows/silicon_valley.rb +76 -1
  138. data/lib/faker/tv_shows/simpsons.rb +29 -1
  139. data/lib/faker/tv_shows/south_park.rb +20 -1
  140. data/lib/faker/tv_shows/star_trek.rb +37 -1
  141. data/lib/faker/tv_shows/stargate.rb +29 -1
  142. data/lib/faker/tv_shows/stranger_things.rb +20 -1
  143. data/lib/faker/tv_shows/the_expanse.rb +37 -1
  144. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +29 -1
  145. data/lib/faker/tv_shows/the_it_crowd.rb +38 -1
  146. data/lib/faker/tv_shows/the_thick_of_it.rb +29 -1
  147. data/lib/faker/tv_shows/twin_peaks.rb +29 -1
  148. data/lib/faker/tv_shows/venture_bros.rb +39 -1
  149. data/lib/faker/version.rb +1 -1
  150. data/lib/locales/en-CA.yml +2 -1
  151. data/lib/locales/en-IND.yml +1 -1
  152. data/lib/locales/en-TH.yml +360 -0
  153. data/lib/locales/en.yml +4 -1
  154. data/lib/locales/en/address.yml +1 -4
  155. data/lib/locales/en/animal.yml +2 -2
  156. data/lib/locales/en/cannabis.yml +1 -0
  157. data/lib/locales/en/color.yml +1 -1
  158. data/lib/locales/en/dr_who.yml +1 -1
  159. data/lib/locales/en/science.yml +1 -1
  160. data/lib/locales/en/space.yml +1 -1
  161. data/lib/locales/en/super_smash_bros.yml +5 -0
  162. data/lib/locales/fr-CA.yml +1 -1
  163. data/lib/locales/ja.yml +12 -9
  164. data/lib/locales/th.yml +380 -0
  165. data/lib/locales/vi.yml +1 -1
  166. metadata +44 -27
  167. data/lib/faker/default/creature.rb +0 -6
  168. data/lib/faker/default/games.rb +0 -6
  169. data/lib/faker/default/japanese_media.rb +0 -6
  170. data/lib/faker/default/movies.rb +0 -6
  171. data/lib/faker/default/tv_shows.rb +0 -6
  172. data/lib/faker/deprecate/unreleased/football.rb +0 -35
  173. data/lib/faker/deprecate/unreleased/movies/grateful_dead.rb +0 -22
@@ -1,15 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faker
4
- module Creature
4
+ class Creature
5
5
  class Horse < Base
6
6
  flexible :horse
7
7
 
8
8
  class << self
9
+ ##
10
+ # Produces a random name for a horse
11
+ #
12
+ # @return [String]
13
+ #
14
+ # @example
15
+ # Faker::Creature::Horse.name #=> "Noir"
16
+ #
17
+ # @faker.version 1.9.2
9
18
  def name
10
19
  fetch('creature.horse.name')
11
20
  end
12
21
 
22
+ ##
23
+ # Produces a random horse breed
24
+ #
25
+ # @return [String]
26
+ #
27
+ # @example
28
+ # Faker::Creature::Horse.breed #=> "Spanish Barb see Barb Horse"
29
+ #
30
+ # @faker.version 1.9.2
13
31
  def breed
14
32
  fetch('creature.horse.breed')
15
33
  end
@@ -5,7 +5,11 @@ module Faker
5
5
  flexible :address
6
6
 
7
7
  class << self
8
- def city(options = {})
8
+ def city(legacy_options = NOT_GIVEN, options: {})
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :options if legacy_options != NOT_GIVEN
11
+ end
12
+
9
13
  parse(options[:with_state] ? 'address.city_with_state' : 'address.city')
10
14
  end
11
15
 
@@ -13,7 +17,11 @@ module Faker
13
17
  parse('address.street_name')
14
18
  end
15
19
 
16
- def street_address(include_secondary = false)
20
+ def street_address(legacy_include_secondary = NOT_GIVEN, include_secondary: false)
21
+ warn_for_deprecated_arguments do |keywords|
22
+ keywords << :include_secondary if legacy_include_secondary != NOT_GIVEN
23
+ end
24
+
17
25
  numerify(parse('address.street_address') + (include_secondary ? ' ' + secondary_address : ''))
18
26
  end
19
27
 
@@ -29,7 +37,11 @@ module Faker
29
37
  parse('address.community')
30
38
  end
31
39
 
32
- def zip_code(state_abbreviation = '')
40
+ def zip_code(legacy_state_abbreviation = NOT_GIVEN, state_abbreviation: '')
41
+ warn_for_deprecated_arguments do |keywords|
42
+ keywords << :state_abbreviation if legacy_state_abbreviation != NOT_GIVEN
43
+ end
44
+
33
45
  if state_abbreviation.empty?
34
46
  letterified_string = letterify(fetch('address.postcode'))
35
47
  return numerify(letterified_string, leading_zero: true)
@@ -71,11 +83,19 @@ module Faker
71
83
  fetch('address.country')
72
84
  end
73
85
 
74
- def country_by_code(code: 'US')
86
+ def country_by_code(legacy_code = NOT_GIVEN, code: 'US')
87
+ warn_for_deprecated_arguments do |keywords|
88
+ keywords << :code if legacy_code != NOT_GIVEN
89
+ end
90
+
75
91
  fetch('address.country_by_code.' + code)
76
92
  end
77
93
 
78
- def country_name_to_code(name: 'united_states')
94
+ def country_name_to_code(legacy_name = NOT_GIVEN, name: 'united_states')
95
+ warn_for_deprecated_arguments do |keywords|
96
+ keywords << :name if legacy_name != NOT_GIVEN
97
+ end
98
+
79
99
  fetch('address.country_by_name.' + name)
80
100
  end
81
101
 
@@ -2,22 +2,71 @@
2
2
 
3
3
  module Faker
4
4
  class Alphanumeric < Base
5
- class << self
6
- ALPHABET = ('a'..'z').to_a
7
- ALPHANUMS = ALPHABET + (0..9).to_a
5
+ ##
6
+ # List of characters allowed for alphanumeric strings
7
+ # @private
8
+ ALPHANUMS = LLetters + Numbers
8
9
 
9
- def alpha(char_count = 32)
10
- char_count = resolve(char_count)
10
+ class << self
11
+ ##
12
+ # Produces a random string of alphabetic characters (no digits)
13
+ #
14
+ # @param number [Integer] The length of the string to generate
15
+ #
16
+ # @return [String]
17
+ #
18
+ # @example
19
+ # Faker::Alphanumeric.alpha(number: 10) #=> "zlvubkrwga"
20
+ #
21
+ # @faker.version 1.9.2
22
+ def alpha(legacy_number = NOT_GIVEN, number: 32)
23
+ warn_for_deprecated_arguments do |keywords|
24
+ keywords << :number if legacy_number != NOT_GIVEN
25
+ end
26
+ char_count = resolve(number)
11
27
  return '' if char_count.to_i < 1
12
28
 
13
- Array.new(char_count) { sample(ALPHABET) }.join
29
+ Array.new(char_count) { sample(self::LLetters) }.join
14
30
  end
15
31
 
16
- def alphanumeric(char_count = 32)
17
- char_count = resolve(char_count)
32
+ ##
33
+ # Produces a random string of alphanumeric characters
34
+ #
35
+ # @param number [Integer] The number of characters to generate
36
+ # @param min_alpha [Integer] The minimum number of alphabetic to add to the string
37
+ # @param min_numeric [Integer] The minimum number of numbers to add to the string
38
+ #
39
+ # @return [String]
40
+ #
41
+ # @example
42
+ # Faker::Alphanumeric.alphanumeric(number: 10) #=> "3yfq2phxtb"
43
+ # @example
44
+ # Faker::Alphanumeric.alphanumeric(number: 10, min_alpha: 3) #=> "3yfq2phxtb"
45
+ # @example
46
+ # Faker::Alphanumeric.alphanumeric(number: 10, min_alpha: 3, min_numeric: 3) #=> "3yfq2phx8b"
47
+ #
48
+ # @faker.version 2.1.3
49
+ def alphanumeric(legacy_number = NOT_GIVEN, number: 32, min_alpha: 0, min_numeric: 0)
50
+ warn_for_deprecated_arguments do |keywords|
51
+ keywords << :number if legacy_number != NOT_GIVEN
52
+ end
53
+ char_count = resolve(number)
18
54
  return '' if char_count.to_i < 1
55
+ raise ArgumentError, 'min_alpha must be greater than or equal to 0' if min_alpha&.negative?
56
+ raise ArgumentError, 'min_numeric must be greater than or equal to 0' if min_numeric&.negative?
57
+
58
+ return Array.new(char_count) { sample(ALPHANUMS) }.join if min_alpha.zero? && min_numeric.zero?
59
+
60
+ raise ArgumentError, 'min_alpha + min_numeric must be <= number' if min_alpha + min_numeric > char_count
61
+
62
+ random_count = char_count - min_alpha - min_numeric
63
+
64
+ alphas = Array.new(min_alpha) { sample(self::LLetters) }
65
+ numbers = Array.new(min_numeric) { sample(self::Numbers) }
66
+ randoms = Array.new(random_count) { sample(ALPHANUMS) }
19
67
 
20
- Array.new(char_count) { sample(ALPHANUMS) }.join
68
+ combined = alphas + numbers + randoms
69
+ combined.shuffle.join
21
70
  end
22
71
  end
23
72
  end
@@ -3,19 +3,73 @@
3
3
  module Faker
4
4
  class App < Base
5
5
  class << self
6
+ ##
7
+ # Produces an app name.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::App.name #=> "Treeflex"
13
+ #
14
+ # @faker.version 1.4.3
6
15
  def name
7
16
  fetch('app.name')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces a version string.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::App.version #=> "1.85"
26
+ #
27
+ # @faker.version 1.4.3
10
28
  def version
11
29
  parse('app.version')
12
30
  end
13
31
 
32
+ ##
33
+ # Produces the name of an app's author.
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::App.author #=> "Daphne Swift"
39
+ #
40
+ # @faker.version 1.4.3
14
41
  def author
15
42
  parse('app.author')
16
43
  end
17
44
 
18
- def semantic_version(major: 0..9, minor: 0..9, patch: 1..9)
45
+ # rubocop:disable Metrics/ParameterLists
46
+
47
+ ##
48
+ # Produces a String representing a semantic version identifier.
49
+ #
50
+ # @param major [Integer, Range] An integer to use or a range to pick the integer from.
51
+ # @param minor [Integer, Range] An integer to use or a range to pick the integer from.
52
+ # @param patch [Integer, Range] An integer to use or a range to pick the integer from.
53
+ # @return [String]
54
+ #
55
+ # @example
56
+ # Faker::App.semantic_version #=> "3.2.5"
57
+ # @example
58
+ # Faker::App.semantic_version(major: 42) #=> "42.5.2"
59
+ # @example
60
+ # Faker::App.semantic_version(minor: 100..101) #=> "42.100.4"
61
+ # @example
62
+ # Faker::App.semantic_version(patch: 5..6) #=> "7.2.6"
63
+ #
64
+ # @faker.version 1.4.3
65
+ def semantic_version(legacy_major = NOT_GIVEN, legacy_minor = NOT_GIVEN, legacy_patch = NOT_GIVEN, major: 0..9, minor: 0..9, patch: 1..9)
66
+ # rubocop:enable Metrics/ParameterLists
67
+ warn_for_deprecated_arguments do |keywords|
68
+ keywords << :major if legacy_major != NOT_GIVEN
69
+ keywords << :minor if legacy_minor != NOT_GIVEN
70
+ keywords << :patch if legacy_patch != NOT_GIVEN
71
+ end
72
+
19
73
  [major, minor, patch].map { |chunk| sample(Array(chunk)) }.join('.')
20
74
  end
21
75
  end
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class Appliance < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of an appliance brand.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Appliance.brand #=> "Bosch"
13
+ #
14
+ # @faker.version 1.9.0
6
15
  def brand
7
16
  fetch('appliance.brand')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces the name of a type of appliance equipment.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Appliance.equipment #=> "Appliance plug"
26
+ #
27
+ # @faker.version 1.9.0
10
28
  def equipment
11
29
  fetch('appliance.equipment')
12
30
  end
@@ -3,6 +3,15 @@
3
3
  module Faker
4
4
  class Artist < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of an artist.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Artist.name #=> "Michelangelo"
13
+ #
14
+ # @faker.version 1.8.8
6
15
  def name
7
16
  fetch('artist.names')
8
17
  end
@@ -3,9 +3,51 @@
3
3
  module Faker
4
4
  class Avatar < Base
5
5
  class << self
6
+ # @private
6
7
  SUPPORTED_FORMATS = %w[png jpg bmp].freeze
7
8
 
8
- def image(slug = nil, size = '300x300', format = 'png', set = 'set1', bgset = nil)
9
+ # rubocop:disable Metrics/ParameterLists
10
+
11
+ ##
12
+ # Produces a URL for an avatar from robohash.org
13
+ #
14
+ # @param slug [String, nil]
15
+ # @param size [String] image size in pixels, in the format of 'AxB'
16
+ # @param format [String] The image file format
17
+ # @param set [String] The avatar set to use
18
+ # @param bgset [String, nil] The background set to use
19
+ # @return [String] A robohash.org URL
20
+ #
21
+ # @example
22
+ # Faker::Avatar.image
23
+ # #=> "https://robohash.org/sitsequiquia.png?size=300x300&set=set1"
24
+ # @example
25
+ # Faker::Avatar.image(slug: "my-own-slug")
26
+ # #=> "https://robohash.org/my-own-slug.png?size=300x300&set=set1"
27
+ # @example
28
+ # Faker::Avatar.image(slug: "my-own-slug", size: "50x50")
29
+ # #=> "https://robohash.org/my-own-slug.png?size=50x50&set=set1"
30
+ # @example
31
+ # Faker::Avatar.image(slug: "my-own-slug", size: "50x50", format: "jpg")
32
+ # #=> "https://robohash.org/my-own-slug.jpg?size=50x50&set=set1"
33
+ # @example
34
+ # Faker::Avatar.image(slug: "my-own-slug", size: "50x50", format: "bmp")
35
+ # #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1"
36
+ # @example
37
+ # Faker::Avatar.image(slug: "my-own-slug", size: "50x50", format: "bmp", set: "set1", bgset: "bg1")
38
+ # #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1&bgset=bg1"
39
+ #
40
+ # @faker.version 1.4.3
41
+ def image(legacy_slug = NOT_GIVEN, legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_set = NOT_GIVEN, legacy_bgset = NOT_GIVEN, slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil)
42
+ # rubocop:enable Metrics/ParameterLists
43
+ warn_for_deprecated_arguments do |keywords|
44
+ keywords << :slug if legacy_slug != NOT_GIVEN
45
+ keywords << :size if legacy_size != NOT_GIVEN
46
+ keywords << :format if legacy_format != NOT_GIVEN
47
+ keywords << :set if legacy_set != NOT_GIVEN
48
+ keywords << :bgset if legacy_bgset != NOT_GIVEN
49
+ end
50
+
9
51
  raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
10
52
  raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format)
11
53
 
@@ -5,7 +5,11 @@ module Faker
5
5
  flexible :bank
6
6
 
7
7
  class << self
8
- def account_number(digits = 10)
8
+ def account_number(legacy_digits = NOT_GIVEN, digits: 10)
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :digits if legacy_digits != NOT_GIVEN
11
+ end
12
+
9
13
  output = ''
10
14
 
11
15
  output += rand.to_s[2..-1] while output.length < digits
@@ -13,10 +17,14 @@ module Faker
13
17
  output[0...digits]
14
18
  end
15
19
 
16
- def iban(country_code = 'GB')
20
+ def iban(legacy_country_code = NOT_GIVEN, country_code: 'GB')
17
21
  # Each country has it's own format for bank accounts
18
22
  # Many of them use letters in certain parts of the account
19
23
  # Using regex patterns we can create virtually any type of bank account
24
+ warn_for_deprecated_arguments do |keywords|
25
+ keywords << :country_code if legacy_country_code != NOT_GIVEN
26
+ end
27
+
20
28
  begin
21
29
  pattern = fetch("bank.iban_details.#{country_code.downcase}.bban_pattern")
22
30
  rescue I18n::MissingTranslationData
@@ -3,7 +3,22 @@
3
3
  module Faker
4
4
  class Boolean < Base
5
5
  class << self
6
- def boolean(true_ratio = 0.5)
6
+ ##
7
+ # Produces a boolean
8
+ #
9
+ # @param true_ratio [Float] The likelihood (as a float, out of 1.0) for the method to return `true`.
10
+ # @return [Boolean]
11
+ #
12
+ # @example
13
+ # Faker::Boolean.boolean #=> true
14
+ # @example
15
+ # Faker::Boolean.boolean(true_ratio: 0.2) #=> false
16
+ #
17
+ # @faker.version 1.6.2
18
+ def boolean(legacy_true_ratio = NOT_GIVEN, true_ratio: 0.5)
19
+ warn_for_deprecated_arguments do |keywords|
20
+ keywords << :true_ratio if legacy_true_ratio != NOT_GIVEN
21
+ end
7
22
  (rand < true_ratio)
8
23
  end
9
24
  end
@@ -37,5 +37,9 @@ module Faker
37
37
  def self.buzzword
38
38
  fetch('cannabis.buzzwords')
39
39
  end
40
+
41
+ def self.brand
42
+ fetch('cannabis.brands')
43
+ end
40
44
  end
41
45
  end
@@ -6,7 +6,12 @@ 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(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 1, fixed: false)
10
+ warn_for_deprecated_arguments do |keywords|
11
+ keywords << :min_rut if legacy_min_rut != NOT_GIVEN
12
+ keywords << :fixed if legacy_fixed != NOT_GIVEN
13
+ end
14
+
10
15
  @last_rut = fixed ? min_rut : rand_in_range(min_rut, 99_999_999)
11
16
  end
12
17
 
@@ -34,8 +39,13 @@ module Faker
34
39
  dv
35
40
  end
36
41
 
37
- def full_rut(min_rut = 0, fixed = false)
38
- "#{rut(min_rut, fixed)}-#{dv}"
42
+ def full_rut(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 0, fixed: false)
43
+ warn_for_deprecated_arguments do |keywords|
44
+ keywords << :min_rut if legacy_min_rut != NOT_GIVEN
45
+ keywords << :fixed if legacy_fixed != NOT_GIVEN
46
+ end
47
+
48
+ "#{rut(min_rut: min_rut, fixed: fixed)}-#{dv}"
39
49
  end
40
50
 
41
51
  attr_reader :last_rut
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Faker
4
4
  class ChuckNorris < Base
5
- flexible :name
5
+ flexible :chuck_norris
6
6
 
7
7
  class << self
8
8
  # from: https://github.com/jenkinsci/chucknorris-plugin/blob/master/src/main/java/hudson/plugins/chucknorris/FactGenerator.java