faker 2.2.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +131 -15
  3. data/README.md +2 -2
  4. data/lib/faker.rb +34 -0
  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 +60 -9
  12. data/lib/faker/books/lovecraft.rb +189 -33
  13. data/lib/faker/creature/animal.rb +9 -0
  14. data/lib/faker/creature/cat.rb +27 -0
  15. data/lib/faker/creature/dog.rb +72 -0
  16. data/lib/faker/creature/horse.rb +18 -0
  17. data/lib/faker/default/address.rb +10 -15
  18. data/lib/faker/default/alphanumeric.rb +29 -18
  19. data/lib/faker/default/app.rb +50 -11
  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 +38 -19
  23. data/lib/faker/default/bank.rb +4 -6
  24. data/lib/faker/default/boolean.rb +14 -4
  25. data/lib/faker/default/chile_rut.rb +6 -14
  26. data/lib/faker/default/chuck_norris.rb +1 -1
  27. data/lib/faker/default/code.rb +7 -13
  28. data/lib/faker/default/commerce.rb +8 -17
  29. data/lib/faker/default/company.rb +4 -6
  30. data/lib/faker/default/crypto_coin.rb +6 -9
  31. data/lib/faker/default/date.rb +76 -30
  32. data/lib/faker/default/demographic.rb +2 -3
  33. data/lib/faker/default/dessert.rb +27 -0
  34. data/lib/faker/default/device.rb +54 -0
  35. data/lib/faker/default/driving_licence.rb +5 -15
  36. data/lib/faker/default/electrical_components.rb +27 -0
  37. data/lib/faker/default/file.rb +9 -26
  38. data/lib/faker/default/fillmurray.rb +4 -11
  39. data/lib/faker/default/finance.rb +2 -3
  40. data/lib/faker/default/gender.rb +18 -0
  41. data/lib/faker/default/greek_philosophers.rb +18 -0
  42. data/lib/faker/default/hacker.rb +59 -1
  43. data/lib/faker/default/hipster.rb +21 -54
  44. data/lib/faker/default/house.rb +18 -0
  45. data/lib/faker/default/id_number.rb +5 -7
  46. data/lib/faker/default/industry_segments.rb +36 -0
  47. data/lib/faker/default/internet.rb +49 -76
  48. data/lib/faker/default/invoice.rb +7 -13
  49. data/lib/faker/default/json.rb +9 -16
  50. data/lib/faker/default/lorem.rb +38 -77
  51. data/lib/faker/default/lorem_flickr.rb +17 -48
  52. data/lib/faker/default/lorem_pixel.rb +7 -23
  53. data/lib/faker/default/markdown.rb +3 -7
  54. data/lib/faker/default/marketing.rb +9 -0
  55. data/lib/faker/default/measurement.rb +16 -24
  56. data/lib/faker/default/military.rb +45 -0
  57. data/lib/faker/default/name.rb +2 -3
  58. data/lib/faker/default/nation.rb +48 -5
  59. data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
  60. data/lib/faker/default/nhs.rb +2 -3
  61. data/lib/faker/default/number.rb +150 -51
  62. data/lib/faker/default/omniauth.rb +67 -63
  63. data/lib/faker/default/phone_number.rb +2 -3
  64. data/lib/faker/default/placeholdit.rb +6 -19
  65. data/lib/faker/default/programming_language.rb +18 -0
  66. data/lib/faker/default/relationship.rb +2 -3
  67. data/lib/faker/default/restaurant.rb +54 -2
  68. data/lib/faker/default/science.rb +27 -0
  69. data/lib/faker/default/source.rb +51 -14
  70. data/lib/faker/default/string.rb +2 -3
  71. data/lib/faker/default/stripe.rb +8 -12
  72. data/lib/faker/default/subscription.rb +45 -0
  73. data/lib/faker/default/superhero.rb +45 -0
  74. data/lib/faker/default/time.rb +102 -56
  75. data/lib/faker/default/twitter.rb +23 -32
  76. data/lib/faker/default/types.rb +12 -23
  77. data/lib/faker/default/vehicle.rb +8 -14
  78. data/lib/faker/default/world_cup.rb +5 -10
  79. data/lib/faker/games/dota.rb +49 -3
  80. data/lib/faker/games/elder_scrolls.rb +72 -0
  81. data/lib/faker/games/fallout.rb +37 -0
  82. data/lib/faker/games/game.rb +27 -0
  83. data/lib/faker/games/half_life.rb +27 -0
  84. data/lib/faker/games/heroes.rb +27 -0
  85. data/lib/faker/games/heroes_of_the_storm.rb +36 -0
  86. data/lib/faker/games/league_of_legends.rb +54 -0
  87. data/lib/faker/games/myst.rb +45 -0
  88. data/lib/faker/games/overwatch.rb +27 -0
  89. data/lib/faker/games/pokemon.rb +27 -0
  90. data/lib/faker/games/sonic_the_hedgehog.rb +27 -0
  91. data/lib/faker/games/super_smash_bros.rb +18 -0
  92. data/lib/faker/games/witcher.rb +54 -0
  93. data/lib/faker/games/world_of_warcraft.rb +18 -0
  94. data/lib/faker/games/zelda.rb +37 -1
  95. data/lib/faker/japanese_media/dragon_ball.rb +9 -0
  96. data/lib/faker/japanese_media/one_piece.rb +54 -0
  97. data/lib/faker/japanese_media/sword_art_online.rb +36 -0
  98. data/lib/faker/movies/back_to_the_future.rb +28 -0
  99. data/lib/faker/movies/ghostbusters.rb +28 -0
  100. data/lib/faker/movies/harry_potter.rb +54 -0
  101. data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +69 -0
  102. data/lib/faker/movies/hobbit.rb +37 -0
  103. data/lib/faker/movies/lebowski.rb +27 -0
  104. data/lib/faker/movies/lord_of_the_rings.rb +28 -0
  105. data/lib/faker/movies/movie.rb +9 -0
  106. data/lib/faker/movies/princess_bride.rb +19 -0
  107. data/lib/faker/movies/star_wars.rb +97 -6
  108. data/lib/faker/movies/v_for_vendetta.rb +29 -0
  109. data/lib/faker/music/grateful_dead.rb +18 -0
  110. data/lib/faker/music/phish.rb +9 -0
  111. data/lib/faker/music/rock_band.rb +9 -0
  112. data/lib/faker/music/umphreys_mcgee.rb +9 -0
  113. data/lib/faker/sports/basketball.rb +36 -0
  114. data/lib/faker/sports/football.rb +45 -0
  115. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +9 -0
  116. data/lib/faker/tv_shows/bojack_horseman.rb +28 -0
  117. data/lib/faker/tv_shows/breaking_bad.rb +18 -0
  118. data/lib/faker/tv_shows/buffy.rb +45 -0
  119. data/lib/faker/tv_shows/community.rb +19 -0
  120. data/lib/faker/tv_shows/dr_who.rb +78 -2
  121. data/lib/faker/tv_shows/dumb_and_dumber.rb +28 -0
  122. data/lib/faker/tv_shows/family_guy.rb +28 -0
  123. data/lib/faker/tv_shows/friends.rb +27 -0
  124. data/lib/faker/tv_shows/game_of_thrones.rb +46 -0
  125. data/lib/faker/tv_shows/hey_arnold.rb +27 -0
  126. data/lib/faker/tv_shows/how_i_met_your_mother.rb +37 -0
  127. data/lib/faker/tv_shows/michael_scott.rb +13 -0
  128. data/lib/faker/tv_shows/new_girl.rb +19 -0
  129. data/lib/faker/tv_shows/parks_and_rec.rb +18 -0
  130. data/lib/faker/tv_shows/rick_and_morty.rb +28 -0
  131. data/lib/faker/tv_shows/ru_paul.rb +18 -0
  132. data/lib/faker/tv_shows/seinfeld.rb +28 -0
  133. data/lib/faker/tv_shows/silicon_valley.rb +75 -0
  134. data/lib/faker/tv_shows/simpsons.rb +28 -0
  135. data/lib/faker/tv_shows/south_park.rb +19 -0
  136. data/lib/faker/tv_shows/star_trek.rb +36 -0
  137. data/lib/faker/tv_shows/stargate.rb +28 -0
  138. data/lib/faker/tv_shows/stranger_things.rb +19 -0
  139. data/lib/faker/tv_shows/the_expanse.rb +36 -0
  140. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +28 -0
  141. data/lib/faker/tv_shows/the_it_crowd.rb +37 -0
  142. data/lib/faker/tv_shows/the_thick_of_it.rb +28 -0
  143. data/lib/faker/tv_shows/twin_peaks.rb +28 -0
  144. data/lib/faker/tv_shows/venture_bros.rb +38 -0
  145. data/lib/faker/version.rb +1 -1
  146. data/lib/locales/en-CA.yml +1 -1
  147. data/lib/locales/en-TH.yml +360 -0
  148. data/lib/locales/en/color.yml +1 -1
  149. data/lib/locales/en/dr_who.yml +1 -1
  150. data/lib/locales/en/science.yml +1 -1
  151. data/lib/locales/ja.yml +8 -9
  152. data/lib/locales/th.yml +380 -0
  153. metadata +33 -14
@@ -24,9 +24,8 @@ module Faker
24
24
  end
25
25
 
26
26
  def height(legacy_unit = NOT_GIVEN, unit: :metric)
27
- if legacy_unit != NOT_GIVEN
28
- warn_with_uplevel 'Passing `unit` with the 1st argument of `Demographic.height` is deprecated. Use keyword argument like `Demographic.height(unit: ...)` instead.', uplevel: 1
29
- unit = legacy_unit
27
+ warn_for_deprecated_arguments do |keywords|
28
+ keywords << :unit if legacy_unit != NOT_GIVEN
30
29
  end
31
30
 
32
31
  case unit
@@ -5,14 +5,41 @@ module Faker
5
5
  flexible :dessert
6
6
 
7
7
  class << self
8
+ ##
9
+ # Produces the name of a dessert variety.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Dessert.variety #=> "Cake"
15
+ #
16
+ # @faker.version 1.8.0
8
17
  def variety
9
18
  fetch('dessert.variety')
10
19
  end
11
20
 
21
+ ##
22
+ # Produces the name of a dessert topping.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Dessert.topping #=> "Gummy Bears"
28
+ #
29
+ # @faker.version 1.8.0
12
30
  def topping
13
31
  fetch('dessert.topping')
14
32
  end
15
33
 
34
+ ##
35
+ # Produces the name of a dessert flavor.
36
+ #
37
+ # @return [String]
38
+ #
39
+ # @example
40
+ # Faker::Dessert.flavor #=> "Salted Caramel"
41
+ #
42
+ # @faker.version 1.8.0
16
43
  def flavor
17
44
  fetch('dessert.flavor')
18
45
  end
@@ -3,26 +3,80 @@
3
3
  module Faker
4
4
  class Device < Base
5
5
  class << self
6
+ ##
7
+ # Produces a build number between 1 and 500.
8
+ #
9
+ # @return [Integer]
10
+ #
11
+ # @example
12
+ # Faker::Device.build_number #=> 5
13
+ #
14
+ # @faker.version 1.9.0
6
15
  def build_number
7
16
  Faker::Number.between(from: 1, to: 500)
8
17
  end
9
18
 
19
+ ##
20
+ # Produces the name of a manufacturer for a device.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Device.manufacturer #=> "Apple"
26
+ #
27
+ # @faker.version 1.9.0
10
28
  def manufacturer
11
29
  fetch('device.manufacturer')
12
30
  end
13
31
 
32
+ ##
33
+ # Produces a model name for a device.
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::Device.model_name #=> "iPhone 4"
39
+ #
40
+ # @faker.version 1.9.0
14
41
  def model_name
15
42
  fetch('device.model_name')
16
43
  end
17
44
 
45
+ ##
46
+ # Produces the name of a platform for a device.
47
+ #
48
+ # @return [String]
49
+ #
50
+ # @example
51
+ # Faker::Device.platform #=> "webOS"
52
+ #
53
+ # @faker.version 1.9.0
18
54
  def platform
19
55
  fetch('device.platform')
20
56
  end
21
57
 
58
+ ##
59
+ # Produces a serial code for a device.
60
+ #
61
+ # @return [String]
62
+ #
63
+ # @example
64
+ # Faker::Device.serial #=> "ejfjnRNInxh0363JC2WM"
65
+ #
66
+ # @faker.version 1.9.0
22
67
  def serial
23
68
  fetch('device.serial')
24
69
  end
25
70
 
71
+ ##
72
+ # Produces a version number between 1 and 1000.
73
+ #
74
+ # @return [Integer]
75
+ #
76
+ # @example
77
+ # Faker::Device.version #=> 42
78
+ #
79
+ # @faker.version 1.9.0
26
80
  def version
27
81
  Faker::Number.between(from: 1, to: 1000)
28
82
  end
@@ -9,21 +9,11 @@ module Faker
9
9
  # rubocop:disable Metrics/ParameterLists
10
10
  def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_GIVEN, legacy_gender = NOT_GIVEN, legacy_date_of_birth = NOT_GIVEN, last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65))
11
11
  # rubocop:enable Metrics/ParameterLists
12
- if legacy_last_name != NOT_GIVEN
13
- warn_with_uplevel 'Passing `last_name` with the 1st argument of `DrivingLicence.british_driving_licence` is deprecated. Use keyword argument like `DrivingLicence.british_driving_licence(last_name: ...)` instead.', uplevel: 1
14
- last_name = legacy_last_name
15
- end
16
- if legacy_initials != NOT_GIVEN
17
- warn_with_uplevel 'Passing `initials` with the 2nd argument of `DrivingLicence.british_driving_licence` is deprecated. Use keyword argument like `DrivingLicence.british_driving_licence(initials: ...)` instead.', uplevel: 1
18
- initials = legacy_initials
19
- end
20
- if legacy_gender != NOT_GIVEN
21
- warn_with_uplevel 'Passing `gender` with the 3rd argument of `DrivingLicence.british_driving_licence` is deprecated. Use keyword argument like `DrivingLicence.british_driving_licence(gender: ...)` instead.', uplevel: 1
22
- gender = legacy_gender
23
- end
24
- if legacy_date_of_birth != NOT_GIVEN
25
- warn_with_uplevel 'Passing `date_of_birth` with the 4th argument of `DrivingLicence.british_driving_licence` is deprecated. Use keyword argument like `DrivingLicence.british_driving_licence(date_of_birth: ...)` instead.', uplevel: 1
26
- date_of_birth = legacy_date_of_birth
12
+ warn_for_deprecated_arguments do |keywords|
13
+ keywords << :last_name if legacy_last_name != NOT_GIVEN
14
+ keywords << :initials if legacy_initials != NOT_GIVEN
15
+ keywords << :gender if legacy_gender != NOT_GIVEN
16
+ keywords << :date_of_birth if legacy_date_of_birth != NOT_GIVEN
27
17
  end
28
18
 
29
19
  [
@@ -5,14 +5,41 @@ module Faker
5
5
  flexible :electrical_components
6
6
 
7
7
  class << self
8
+ ##
9
+ # Produces an active electrical component.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::ElectricalComponents.active #=> "Transistor"
15
+ #
16
+ # @faker.version 1.9.0
8
17
  def active
9
18
  fetch('electrical_components.active')
10
19
  end
11
20
 
21
+ ##
22
+ # Produces a passive electrical component.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::ElectricalComponents.passive #=> "Resistor"
28
+ #
29
+ # @faker.version 1.9.0
12
30
  def passive
13
31
  fetch('electrical_components.passive')
14
32
  end
15
33
 
34
+ ##
35
+ # Produces an electromechanical electrical component.
36
+ #
37
+ # @return [String]
38
+ #
39
+ # @example
40
+ # Faker::ElectricalComponents.electromechanical #=> "Toggle Switch"
41
+ #
42
+ # @faker.version 1.9.0
16
43
  def electromechanical
17
44
  fetch('electrical_components.electromechanical')
18
45
  end
@@ -6,17 +6,10 @@ module Faker
6
6
  # rubocop:disable Metrics/ParameterLists
7
7
  def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: '/')
8
8
  # rubocop:enable Metrics/ParameterLists
9
- if legacy_segment_count != NOT_GIVEN
10
- warn_with_uplevel 'Passing `segment_count` with the 1st argument of `File.dir` is deprecated. Use keyword argument like `File.dir(segment_count: ...)` instead.', uplevel: 1
11
- segment_count = legacy_segment_count
12
- end
13
- if legacy_root != NOT_GIVEN
14
- warn_with_uplevel 'Passing `root` with the 2nd argument of `File.dir` is deprecated. Use keyword argument like `File.dir(root: ...)` instead.', uplevel: 1
15
- root = legacy_root
16
- end
17
- if legacy_directory_separator != NOT_GIVEN
18
- warn_with_uplevel 'Passing `directory_separator` with the 3rd argument of `File.dir` is deprecated. Use keyword argument like `File.dir(directory_separator: ...)` instead.', uplevel: 1
19
- directory_separator = legacy_directory_separator
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :segment_count if legacy_segment_count != NOT_GIVEN
11
+ keywords << :root if legacy_root != NOT_GIVEN
12
+ keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN
20
13
  end
21
14
 
22
15
  Array
@@ -38,21 +31,11 @@ module Faker
38
31
  # rubocop:disable Metrics/ParameterLists
39
32
  def file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, dir: nil, name: nil, ext: nil, directory_separator: '/')
40
33
  # rubocop:enable Metrics/ParameterLists
41
- if legacy_dir != NOT_GIVEN
42
- warn_with_uplevel 'Passing `dir` with the 1st argument of `File.file_name` is deprecated. Use keyword argument like `File.file_name(dir: ...)` instead.', uplevel: 1
43
- dir = legacy_dir
44
- end
45
- if legacy_name != NOT_GIVEN
46
- warn_with_uplevel 'Passing `name` with the 2nd argument of `File.file_name` is deprecated. Use keyword argument like `File.file_name(name: ...)` instead.', uplevel: 1
47
- name = legacy_name
48
- end
49
- if legacy_ext != NOT_GIVEN
50
- warn_with_uplevel 'Passing `ext` with the 3rd argument of `File.file_name` is deprecated. Use keyword argument like `File.file_name(ext: ...)` instead.', uplevel: 1
51
- ext = legacy_ext
52
- end
53
- if legacy_directory_separator != NOT_GIVEN
54
- warn_with_uplevel 'Passing `directory_separator` with the 4th argument of `File.file_name` is deprecated. Use keyword argument like `File.file_name(directory_separator: ...)` instead.', uplevel: 1
55
- directory_separator = legacy_directory_separator
34
+ warn_for_deprecated_arguments do |keywords|
35
+ keywords << :dir if legacy_dir != NOT_GIVEN
36
+ keywords << :name if legacy_name != NOT_GIVEN
37
+ keywords << :ext if legacy_ext != NOT_GIVEN
38
+ keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN
56
39
  end
57
40
 
58
41
  dir ||= dir(segment_count: 1)
@@ -6,17 +6,10 @@ module Faker
6
6
  # rubocop:disable Metrics/ParameterLists
7
7
  def image(legacy_grayscale = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_height = NOT_GIVEN, grayscale: false, width: 200, height: 200)
8
8
  # rubocop:enable Metrics/ParameterLists
9
- if legacy_grayscale != NOT_GIVEN
10
- warn_with_uplevel 'Passing `grayscale` with the 1st argument of `Fillmurray.image` is deprecated. Use keyword argument like `Fillmurray.image(grayscale: ...)` instead.', uplevel: 1
11
- grayscale = legacy_grayscale
12
- end
13
- if legacy_width != NOT_GIVEN
14
- warn_with_uplevel 'Passing `width` with the 2nd argument of `Fillmurray.image` is deprecated. Use keyword argument like `Fillmurray.image(width: ...)` instead.', uplevel: 1
15
- width = legacy_width
16
- end
17
- if legacy_height != NOT_GIVEN
18
- warn_with_uplevel 'Passing `height` with the 3rd argument of `Fillmurray.image` is deprecated. Use keyword argument like `Fillmurray.image(height: ...)` instead.', uplevel: 1
19
- height = legacy_height
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :grayscale if legacy_grayscale != NOT_GIVEN
11
+ keywords << :width if legacy_width != NOT_GIVEN
12
+ keywords << :height if legacy_height != NOT_GIVEN
20
13
  end
21
14
 
22
15
  raise ArgumentError, 'Width should be a number' unless width.to_s =~ /^\d+$/
@@ -27,9 +27,8 @@ module Faker
27
27
  end
28
28
 
29
29
  def vat_number(legacy_country = NOT_GIVEN, country: 'BR')
30
- if legacy_country != NOT_GIVEN
31
- warn_with_uplevel 'Passing `country` with the 1st argument of `Finance.vat_number` is deprecated. Use keyword argument like `Finance.vat_number(country: ...)` instead.', uplevel: 1
32
- country = legacy_country
30
+ warn_for_deprecated_arguments do |keywords|
31
+ keywords << :country if legacy_country != NOT_GIVEN
33
32
  end
34
33
 
35
34
  numerify(fetch("finance.vat_number.#{country}"))
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class Gender < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of a gender identity.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Gender.type #=> "Non-binary"
13
+ #
14
+ # @faker.version 1.9.0
6
15
  def type
7
16
  fetch('gender.types')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces either 'Male' or 'Female'.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Gender.binary_type #=> "Female"
26
+ #
27
+ # @faker.version 1.9.0
10
28
  def binary_type
11
29
  fetch('gender.binary_types')
12
30
  end
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class GreekPhilosophers < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of a Greek philosopher.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::GreekPhilosophers.name #=> "Socrates"
13
+ #
14
+ # @faker.version 1.9.0
6
15
  def name
7
16
  fetch('greek_philosophers.names')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces a quote from a Greek philosopher.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::GreekPhilosophers.quote #=> "Only the educated are free."
26
+ #
27
+ # @faker.version 1.9.0
10
28
  def quote
11
29
  fetch('greek_philosophers.quotes')
12
30
  end
@@ -1,35 +1,93 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Port of http://shinytoylabs.com/jargon/
4
3
  module Faker
4
+ # Port of http://shinytoylabs.com/jargon/
5
+ # Are you having trouble writing tech-savvy dialogue for your latest screenplay?
6
+ # Worry not! Hollywood-grade technical talk is ready to fill out any form where you need to look smart.
5
7
  class Hacker < Base
6
8
  flexible :hacker
7
9
 
8
10
  class << self
11
+ ##
12
+ # Produces something smart.
13
+ #
14
+ # @return [String]
15
+ #
16
+ # @example
17
+ # Faker::Hacker.say_something_smart
18
+ # #=> "Try to compress the SQL interface, maybe it will program the back-end hard drive!"
19
+ #
20
+ # @faker.version 1.4.0
9
21
  def say_something_smart
10
22
  sample(phrases)
11
23
  end
12
24
 
25
+ ##
26
+ # Short technical abbreviations.
27
+ #
28
+ # @return [String]
29
+ #
30
+ # @example
31
+ # Faker::Hacker.abbreviation #=> "RAM"
32
+ #
33
+ # @faker.version 1.4.0
13
34
  def abbreviation
14
35
  fetch('hacker.abbreviation')
15
36
  end
16
37
 
38
+ ##
39
+ # Hacker-centric adjectives.
40
+ #
41
+ # @return [String]
42
+ #
43
+ # @example
44
+ # Faker::Hacker.adjective #=> "open-source"
45
+ #
46
+ # @faker.version 1.4.0
17
47
  def adjective
18
48
  fetch('hacker.adjective')
19
49
  end
20
50
 
51
+ ##
52
+ # Only the best hacker-related nouns.
53
+ #
54
+ # @return [String]
55
+ #
56
+ # @example
57
+ # Faker::Hacker.noun #=> "bandwidth"
58
+ #
59
+ # @faker.version 1.4.0
21
60
  def noun
22
61
  fetch('hacker.noun')
23
62
  end
24
63
 
64
+ ##
65
+ # Actions that hackers take.
66
+ #
67
+ # @return [String]
68
+ #
69
+ # @example
70
+ # Faker::Hacker.verb #=> "bypass"
71
+ #
72
+ # @faker.version 1.4.0
25
73
  def verb
26
74
  fetch('hacker.verb')
27
75
  end
28
76
 
77
+ ##
78
+ # Produces a verb that ends with '-ing'.
79
+ #
80
+ # @return [String]
81
+ #
82
+ # @example
83
+ # Faker::Hacker.ingverb #=> "synthesizing"
84
+ #
85
+ # @faker.version 1.4.0
29
86
  def ingverb
30
87
  fetch('hacker.ingverb')
31
88
  end
32
89
 
90
+ # @private
33
91
  def phrases
34
92
  ["If we #{verb} the #{noun}, we can get to the #{abbreviation} #{noun} through the #{adjective} #{abbreviation} #{noun}!",
35
93
  "We need to #{verb} the #{adjective} #{abbreviation} #{noun}!",
@@ -11,17 +11,10 @@ module Faker
11
11
  # rubocop:disable Metrics/ParameterLists
12
12
  def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
13
13
  # rubocop:enable Metrics/ParameterLists
14
- if legacy_number != NOT_GIVEN
15
- warn_with_uplevel 'Passing `number` with the 1st argument of `Hipster.words` is deprecated. Use keyword argument like `Hipster.words(number: ...)` instead.', uplevel: 1
16
- number = legacy_number
17
- end
18
- if legacy_supplemental != NOT_GIVEN
19
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.words` is deprecated. Use keyword argument like `Hipster.words(supplemental: ...)` instead.', uplevel: 1
20
- supplemental = legacy_supplemental
21
- end
22
- if legacy_spaces_allowed != NOT_GIVEN
23
- warn_with_uplevel 'Passing `spaces_allowed` with the 3rd argument of `Hipster.words` is deprecated. Use keyword argument like `Hipster.words(spaces_allowed: ...)` instead.', uplevel: 1
24
- spaces_allowed = legacy_spaces_allowed
14
+ warn_for_deprecated_arguments do |keywords|
15
+ keywords << :number if legacy_number != NOT_GIVEN
16
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
17
+ keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN
25
18
  end
26
19
 
27
20
  resolved_num = resolve(number)
@@ -40,30 +33,19 @@ module Faker
40
33
  # rubocop:disable Metrics/ParameterLists
41
34
  def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6)
42
35
  # rubocop:enable Metrics/ParameterLists
43
- if legacy_word_count != NOT_GIVEN
44
- warn_with_uplevel 'Passing `word_count` with the 1st argument of `Hipster.sentence` is deprecated. Use keyword argument like `Hipster.sentence(word_count: ...)` instead.', uplevel: 1
45
- word_count = legacy_word_count
46
- end
47
- if legacy_supplemental != NOT_GIVEN
48
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.sentence` is deprecated. Use keyword argument like `Hipster.sentence(supplemental: ...)` instead.', uplevel: 1
49
- supplemental = legacy_supplemental
50
- end
51
- if legacy_random_words_to_add != NOT_GIVEN
52
- warn_with_uplevel 'Passing `random_words_to_add` with the 3rd argument of `Hipster.sentence` is deprecated. Use keyword argument like `Hipster.sentence(random_words_to_add: ...)` instead.', uplevel: 1
53
- random_words_to_add = legacy_random_words_to_add
36
+ warn_for_deprecated_arguments do |keywords|
37
+ keywords << :word_count if legacy_word_count != NOT_GIVEN
38
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
39
+ keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
54
40
  end
55
41
 
56
42
  words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
57
43
  end
58
44
 
59
45
  def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
60
- if legacy_number != NOT_GIVEN
61
- warn_with_uplevel 'Passing `number` with the 1st argument of `Hipster.sentences` is deprecated. Use keyword argument like `Hipster.sentences(number: ...)` instead.', uplevel: 1
62
- number = legacy_number
63
- end
64
- if legacy_supplemental != NOT_GIVEN
65
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.sentences` is deprecated. Use keyword argument like `Hipster.sentences(supplemental: ...)` instead.', uplevel: 1
66
- supplemental = legacy_supplemental
46
+ warn_for_deprecated_arguments do |keywords|
47
+ keywords << :number if legacy_number != NOT_GIVEN
48
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
67
49
  end
68
50
 
69
51
  [].tap do |sentences|
@@ -76,30 +58,19 @@ module Faker
76
58
  # rubocop:disable Metrics/ParameterLists
77
59
  def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
78
60
  # rubocop:enable Metrics/ParameterLists
79
- if legacy_sentence_count != NOT_GIVEN
80
- warn_with_uplevel 'Passing `sentence_count` with the 1st argument of `Hipster.paragraph` is deprecated. Use keyword argument like `Hipster.paragraph(sentence_count: ...)` instead.', uplevel: 1
81
- sentence_count = legacy_sentence_count
82
- end
83
- if legacy_supplemental != NOT_GIVEN
84
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.paragraph` is deprecated. Use keyword argument like `Hipster.paragraph(supplemental: ...)` instead.', uplevel: 1
85
- supplemental = legacy_supplemental
86
- end
87
- if legacy_random_sentences_to_add != NOT_GIVEN
88
- warn_with_uplevel 'Passing `random_sentences_to_add` with the 3rd argument of `Hipster.paragraph` is deprecated. Use keyword argument like `Hipster.paragraph(random_sentences_to_add: ...)` instead.', uplevel: 1
89
- random_sentences_to_add = legacy_random_sentences_to_add
61
+ warn_for_deprecated_arguments do |keywords|
62
+ keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
63
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
64
+ keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
90
65
  end
91
66
 
92
67
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
93
68
  end
94
69
 
95
70
  def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
96
- if legacy_number != NOT_GIVEN
97
- warn_with_uplevel 'Passing `number` with the 1st argument of `Hipster.paragraphs` is deprecated. Use keyword argument like `Hipster.paragraphs(number: ...)` instead.', uplevel: 1
98
- number = legacy_number
99
- end
100
- if legacy_supplemental != NOT_GIVEN
101
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.paragraphs` is deprecated. Use keyword argument like `Hipster.paragraphs(supplemental: ...)` instead.', uplevel: 1
102
- supplemental = legacy_supplemental
71
+ warn_for_deprecated_arguments do |keywords|
72
+ keywords << :number if legacy_number != NOT_GIVEN
73
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
103
74
  end
104
75
 
105
76
  [].tap do |paragraphs|
@@ -110,13 +81,9 @@ module Faker
110
81
  end
111
82
 
112
83
  def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false)
113
- if legacy_characters != NOT_GIVEN
114
- warn_with_uplevel 'Passing `characters` with the 1st argument of `Hipster.paragraph_by_chars` is deprecated. Use keyword argument like `Hipster.paragraph_by_chars(characters: ...)` instead.', uplevel: 1
115
- characters = legacy_characters
116
- end
117
- if legacy_supplemental != NOT_GIVEN
118
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.paragraph_by_chars` is deprecated. Use keyword argument like `Hipster.paragraph_by_chars(supplemental: ...)` instead.', uplevel: 1
119
- supplemental = legacy_supplemental
84
+ warn_for_deprecated_arguments do |keywords|
85
+ keywords << :characters if legacy_characters != NOT_GIVEN
86
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
120
87
  end
121
88
 
122
89
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)