faker 2.10.2 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +323 -0
  3. data/README.md +27 -2
  4. data/lib/faker.rb +57 -25
  5. data/lib/faker/blockchain/aeternity.rb +4 -4
  6. data/lib/faker/books/dune.rb +15 -2
  7. data/lib/faker/books/lovecraft.rb +8 -4
  8. data/lib/faker/default/address.rb +35 -5
  9. data/lib/faker/default/bank.rb +80 -3
  10. data/lib/faker/default/barcode.rb +154 -0
  11. data/lib/faker/default/beer.rb +3 -3
  12. data/lib/faker/default/blood.rb +48 -0
  13. data/lib/faker/default/business.rb +1 -1
  14. data/lib/faker/default/camera.rb +46 -0
  15. data/lib/faker/default/cannabis.rb +80 -0
  16. data/lib/faker/default/chile_rut.rb +47 -3
  17. data/lib/faker/default/code.rb +98 -17
  18. data/lib/faker/default/commerce.rb +74 -11
  19. data/lib/faker/default/company.rb +78 -11
  20. data/lib/faker/default/compass.rb +135 -0
  21. data/lib/faker/default/computer.rb +63 -0
  22. data/lib/faker/default/construction.rb +54 -0
  23. data/lib/faker/default/cosmere.rb +90 -0
  24. data/lib/faker/default/crypto_coin.rb +45 -0
  25. data/lib/faker/default/date.rb +16 -12
  26. data/lib/faker/default/driving_licence.rb +65 -0
  27. data/lib/faker/default/drone.rb +332 -0
  28. data/lib/faker/default/faker_adjective.rb +35 -0
  29. data/lib/faker/default/file.rb +49 -0
  30. data/lib/faker/default/finance.rb +45 -0
  31. data/lib/faker/default/food.rb +1 -1
  32. data/lib/faker/default/funny_name.rb +45 -0
  33. data/lib/faker/default/gender.rb +1 -1
  34. data/lib/faker/default/hipster.rb +101 -4
  35. data/lib/faker/default/id_number.rb +88 -2
  36. data/lib/faker/default/internet.rb +68 -10
  37. data/lib/faker/default/internet_http.rb +48 -0
  38. data/lib/faker/default/invoice.rb +33 -6
  39. data/lib/faker/default/json.rb +59 -4
  40. data/lib/faker/default/lorem.rb +2 -2
  41. data/lib/faker/default/lorem_flickr.rb +65 -0
  42. data/lib/faker/default/lorem_pixel.rb +22 -0
  43. data/lib/faker/default/markdown.rb +89 -0
  44. data/lib/faker/default/measurement.rb +93 -2
  45. data/lib/faker/default/military.rb +26 -0
  46. data/lib/faker/default/mountain.rb +33 -0
  47. data/lib/faker/default/name.rb +98 -0
  48. data/lib/faker/default/nhs.rb +19 -0
  49. data/lib/faker/default/number.rb +6 -8
  50. data/lib/faker/default/omniauth.rb +107 -52
  51. data/lib/faker/default/phone_number.rb +88 -5
  52. data/lib/faker/default/placeholdit.rb +21 -0
  53. data/lib/faker/default/relationship.rb +1 -1
  54. data/lib/faker/default/slack_emoji.rb +81 -0
  55. data/lib/faker/default/south_africa.rb +90 -0
  56. data/lib/faker/default/space.rb +1 -1
  57. data/lib/faker/default/string.rb +19 -3
  58. data/lib/faker/default/stripe.rb +64 -3
  59. data/lib/faker/default/twitter.rb +35 -0
  60. data/lib/faker/default/types.rb +80 -0
  61. data/lib/faker/default/university.rb +45 -0
  62. data/lib/faker/default/vehicle.rb +184 -4
  63. data/lib/faker/default/verb.rb +45 -0
  64. data/lib/faker/default/world_cup.rb +4 -4
  65. data/lib/faker/fantasy/tolkien.rb +67 -0
  66. data/lib/faker/games/clash_of_clans.rb +48 -0
  67. data/lib/faker/games/control.rb +113 -0
  68. data/lib/faker/games/dnd.rb +136 -0
  69. data/lib/faker/games/elder_scrolls.rb +26 -0
  70. data/lib/faker/games/heroes.rb +13 -0
  71. data/lib/faker/games/heroes_of_the_storm.rb +16 -5
  72. data/lib/faker/games/minecraft.rb +113 -0
  73. data/lib/faker/games/street_fighter.rb +61 -0
  74. data/lib/faker/games/super_mario.rb +48 -0
  75. data/lib/faker/games/warhammer_fantasy.rb +74 -0
  76. data/lib/faker/games/world_of_warcraft.rb +26 -1
  77. data/lib/faker/japanese_media/conan.rb +48 -0
  78. data/lib/faker/japanese_media/doraemon.rb +48 -0
  79. data/lib/faker/japanese_media/dragon_ball.rb +26 -0
  80. data/lib/faker/japanese_media/naruto.rb +61 -0
  81. data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
  82. data/lib/faker/movies/departed.rb +49 -0
  83. data/lib/faker/movies/hobbit.rb +4 -4
  84. data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
  85. data/lib/faker/movies/lord_of_the_rings.rb +3 -3
  86. data/lib/faker/movies/movie.rb +13 -0
  87. data/lib/faker/movies/room.rb +63 -0
  88. data/lib/faker/movies/star_wars.rb +2 -2
  89. data/lib/faker/music/hiphop.rb +48 -0
  90. data/lib/faker/music/opera.rb +237 -1
  91. data/lib/faker/music/pearl_jam.rb +50 -0
  92. data/lib/faker/music/phish.rb +27 -1
  93. data/lib/faker/music/prince.rb +64 -0
  94. data/lib/faker/music/rush.rb +37 -0
  95. data/lib/faker/music/show.rb +49 -0
  96. data/lib/faker/quotes/chiquito.rb +80 -0
  97. data/lib/faker/quotes/quote.rb +80 -1
  98. data/lib/faker/quotes/rajnikanth.rb +26 -0
  99. data/lib/faker/quotes/shakespeare.rb +36 -0
  100. data/lib/faker/sports/volleyball.rb +74 -0
  101. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +13 -0
  102. data/lib/faker/tv_shows/big_bang_theory.rb +37 -0
  103. data/lib/faker/tv_shows/buffy.rb +17 -4
  104. data/lib/faker/tv_shows/dr_who.rb +1 -1
  105. data/lib/faker/tv_shows/final_space.rb +51 -0
  106. data/lib/faker/tv_shows/futurama.rb +65 -0
  107. data/lib/faker/tv_shows/simpsons.rb +14 -0
  108. data/lib/faker/tv_shows/suits.rb +37 -0
  109. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
  110. data/lib/faker/version.rb +1 -1
  111. data/lib/helpers/base58.rb +1 -1
  112. data/lib/helpers/char.rb +22 -27
  113. data/lib/helpers/unique_generator.rb +3 -2
  114. data/lib/locales/de-AT.yml +4 -2
  115. data/lib/locales/de-CH.yml +1696 -1
  116. data/lib/locales/de.yml +4 -2
  117. data/lib/locales/en-AU.yml +50 -10
  118. data/lib/locales/en-CA.yml +2 -0
  119. data/lib/locales/en-GB.yml +1 -1
  120. data/lib/locales/en-IND.yml +2 -1
  121. data/lib/locales/en-MS.yml +2 -1
  122. data/lib/locales/en-NEP.yml +4 -1
  123. data/lib/locales/en-NZ.yml +3 -1
  124. data/lib/locales/en-PAK.yml +2 -1
  125. data/lib/locales/en-SG.yml +2 -1
  126. data/lib/locales/en-US.yml +36 -10
  127. data/lib/locales/en-au-ocker.yml +2 -1
  128. data/lib/locales/en.yml +0 -3
  129. data/lib/locales/en/address.yml +2 -0
  130. data/lib/locales/en/adjective.yml +179 -0
  131. data/lib/locales/en/animal.yml +1 -1
  132. data/lib/locales/en/aqua_teen_hunger_force.yml +33 -1
  133. data/lib/locales/en/bank.yml +1 -1
  134. data/lib/locales/en/barcode.yml +24 -0
  135. data/lib/locales/en/big_bang_theory.yml +38 -0
  136. data/lib/locales/en/blood.yml +13 -0
  137. data/lib/locales/en/buffy.yml +1 -1
  138. data/lib/locales/en/camera.yml +611 -0
  139. data/lib/locales/en/chiquito.yml +64 -0
  140. data/lib/locales/en/clash_of_clan.yml +101 -0
  141. data/lib/locales/en/company.yml +2 -2
  142. data/lib/locales/en/computer.yml +36 -0
  143. data/lib/locales/en/conan.yml +171 -0
  144. data/lib/locales/en/control.yml +247 -0
  145. data/lib/locales/en/demographic.yml +218 -5
  146. data/lib/locales/en/departed.yml +50 -0
  147. data/lib/locales/en/dnd.yml +451 -0
  148. data/lib/locales/en/doraemon.yml +286 -0
  149. data/lib/locales/en/dota.yml +531 -63
  150. data/lib/locales/en/dragon_ball.yml +243 -1
  151. data/lib/locales/en/driving_license.yml +181 -0
  152. data/lib/locales/en/drone.yml +95 -0
  153. data/lib/locales/en/dune.yml +401 -131
  154. data/lib/locales/en/elder_scrolls.yml +583 -9
  155. data/lib/locales/en/fallout.yml +311 -133
  156. data/lib/locales/en/final_space.yml +37 -0
  157. data/lib/locales/en/finance.yml +53 -0
  158. data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
  159. data/lib/locales/en/futurama.yml +344 -0
  160. data/lib/locales/en/half_life.yml +84 -3
  161. data/lib/locales/en/heroes.yml +408 -3
  162. data/lib/locales/en/heroes_of_the_storm.yml +131 -4
  163. data/lib/locales/en/house.yml +1 -1
  164. data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
  165. data/lib/locales/en/jack_handey.yml +54 -0
  166. data/lib/locales/en/league_of_legends.yml +285 -6
  167. data/lib/locales/en/military.yml +179 -5
  168. data/lib/locales/en/minecraft.yml +663 -0
  169. data/lib/locales/en/mountain.yml +158 -0
  170. data/lib/locales/en/movie.yml +192 -1
  171. data/lib/locales/en/music.yml +451 -29
  172. data/lib/locales/en/myst.yml +87 -31
  173. data/lib/locales/en/name.yml +6 -5
  174. data/lib/locales/en/naruto.yml +231 -0
  175. data/lib/locales/en/one_piece.yml +2 -2
  176. data/lib/locales/en/opera.yml +168 -0
  177. data/lib/locales/en/overwatch.yml +2650 -2622
  178. data/lib/locales/en/pearl_jam.yml +213 -0
  179. data/lib/locales/en/phish.yml +392 -1
  180. data/lib/locales/en/pokemon.yml +417 -4
  181. data/lib/locales/en/prince.yml +227 -0
  182. data/lib/locales/en/quote.yml +692 -163
  183. data/lib/locales/en/rajnikanth.yml +77 -0
  184. data/lib/locales/en/room.yml +68 -0
  185. data/lib/locales/en/rush.yml +32 -0
  186. data/lib/locales/en/show.yml +597 -0
  187. data/lib/locales/en/simpsons.yml +668 -0
  188. data/lib/locales/en/source.yml +30 -0
  189. data/lib/locales/en/star_trek.yml +1 -1
  190. data/lib/locales/en/star_wars.yml +568 -220
  191. data/lib/locales/en/street_fighter.yml +1524 -0
  192. data/lib/locales/en/studio_ghibli.yml +107 -0
  193. data/lib/locales/en/suits.yml +45 -0
  194. data/lib/locales/en/super_mario.yml +58 -0
  195. data/lib/locales/en/super_smash_bros.yml +16 -4
  196. data/lib/locales/en/tolkien.yml +2453 -0
  197. data/lib/locales/en/volleyball.yml +501 -0
  198. data/lib/locales/en/warhammer_fantasy.yml +582 -0
  199. data/lib/locales/en/witcher.yml +389 -7
  200. data/lib/locales/en/world_of_warcraft.yml +122 -4
  201. data/lib/locales/en/zelda.yml +962 -4
  202. data/lib/locales/es.yml +56 -0
  203. data/lib/locales/fi-FI.yml +1 -1
  204. data/lib/locales/fr-CA.yml +21 -5
  205. data/lib/locales/fr-CH.yml +2 -2
  206. data/lib/locales/fr.yml +8 -2
  207. data/lib/locales/id.yml +2 -1
  208. data/lib/locales/it.yml +2 -1
  209. data/lib/locales/ja.yml +5 -1
  210. data/lib/locales/ko.yml +94 -2
  211. data/lib/locales/nb-NO.yml +4 -2
  212. data/lib/locales/pt-BR.yml +2 -1
  213. data/lib/locales/pt.yml +3 -1
  214. data/lib/locales/ru.yml +3 -1
  215. data/lib/locales/sk.yml +4 -2
  216. data/lib/locales/uk.yml +2 -0
  217. metadata +89 -21
  218. data/lib/locales/en/hobbit.yml +0 -19
  219. data/lib/locales/en/lord_of_the_rings.yml +0 -6
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class Internet
5
+ class HTTP < Base
6
+ STATUS_CODES = {
7
+ information: [100, 101, 102, 103],
8
+ successful: [200, 201, 202, 203, 204, 205, 206, 207, 208, 226],
9
+ redirect: [300, 301, 302, 303, 304, 305, 306, 307, 308],
10
+ client_error: [400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412,
11
+ 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428,
12
+ 429, 431, 451],
13
+ server_error: [500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511]
14
+ }.freeze
15
+
16
+ STATUS_CODES_GROUPS = STATUS_CODES.keys.freeze
17
+
18
+ class << self
19
+ ##
20
+ # Produces an HTTP status code
21
+ #
22
+ # @return [Integer]
23
+ #
24
+ # @example
25
+ # Faker::Internet::HTTP.status_code #=> 418
26
+ # @example
27
+ # Faker::Internet::HTTP.status_code(group: :information) #=> 102
28
+ # @example
29
+ # Faker::Internet::HTTP.status_code(group: :successful) #=> 200
30
+ # @example
31
+ # Faker::Internet::HTTP.status_code(group: :redirect) #=> 306
32
+ # @example
33
+ # Faker::Internet::HTTP.status_code(group: :client_error) #=> 451
34
+ # @example
35
+ # Faker::Internet::HTTP.status_code(group: :server_error) #=> 502
36
+ #
37
+ # @faker.version 2.13.0
38
+ def status_code(group: nil)
39
+ return STATUS_CODES[STATUS_CODES_GROUPS.sample].sample unless group
40
+
41
+ raise ArgumentError, 'Invalid HTTP status code group' unless STATUS_CODES_GROUPS.include?(group)
42
+
43
+ STATUS_CODES[group].sample
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -5,7 +5,18 @@ module Faker
5
5
  flexible :invoice
6
6
 
7
7
  class << self
8
- # Generate random amount between values with 2 decimals
8
+ ##
9
+ # Produces a random amount between values with 2 decimals
10
+ #
11
+ # @param from [Integer] Specifies lower limit.
12
+ # @param to [Integer] Specifies upper limit.
13
+ # @return [Integer]
14
+ #
15
+ # @example
16
+ # Faker::Finance.amount_between #=> 0
17
+ # Faker::Finance.amount_between(0, 10) #=> 4.33
18
+ #
19
+ # @faker.version 1.9.0
9
20
  def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 0)
10
21
  warn_for_deprecated_arguments do |keywords|
11
22
  keywords << :from if legacy_from != NOT_GIVEN
@@ -15,8 +26,16 @@ module Faker
15
26
  Faker::Base.rand_in_range(from, to).round(2)
16
27
  end
17
28
 
18
- # International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
19
- # ref is optional so that we can create unit tests
29
+ ##
30
+ # Produces a random valid reference accoring to the International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
31
+ #
32
+ # @param ref [String] Specifies reference base.
33
+ # @return [String]
34
+ #
35
+ # @example
36
+ # Faker::Invoice.creditor_reference #=> "RF34118592570724925498"
37
+ #
38
+ # @faker.version 1.9.0
20
39
  def creditor_reference(legacy_ref = NOT_GIVEN, ref: '')
21
40
  warn_for_deprecated_arguments do |keywords|
22
41
  keywords << :ref if legacy_ref != NOT_GIVEN
@@ -24,11 +43,19 @@ module Faker
24
43
 
25
44
  ref = reference if ref.empty?
26
45
 
27
- 'RF' + iban_checksum('RF', ref) + ref
46
+ "RF#{iban_checksum('RF', ref)}#{ref}"
28
47
  end
29
48
 
30
- # Payment references have some rules in certain countries
31
- # ref is optional so that we can create unit tests
49
+ ##
50
+ # Produces a random valid reference.
51
+ #
52
+ # @param ref [String] Specifies reference base.
53
+ # @return [String]
54
+ #
55
+ # @example
56
+ # Faker::Invoice.reference #=> "45656646957845"
57
+ #
58
+ # @faker.version 1.9.0
32
59
  def reference(legacy_ref = NOT_GIVEN, ref: '')
33
60
  warn_for_deprecated_arguments do |keywords|
34
61
  keywords << :ref if legacy_ref != NOT_GIVEN
@@ -3,19 +3,74 @@ module Faker
3
3
  require 'json'
4
4
 
5
5
  class << self
6
+ ##
7
+ # Produces a random simple JSON formatted string.
8
+ #
9
+ # @param width [Integer] Specifies the number of key-value pairs.
10
+ # @param options [Hash] Specifies a Faker gem class to use for keys and for values, respectably. options_hash = {key: Class.method, value: Class.method}
11
+ # @return [Hash{String => String}]
12
+ #
13
+ # @example
14
+ # Faker::Json.shallow_json(width: 3, options: { key: 'RockBand.name', value: 'Seinfeld.quote' }) # =>
15
+ # {"Parliament Funkadelic":"They're real, and they're spectacular.",
16
+ # "Fleetwood Mac":"I'm not a lesbian. I hate men, but I'm not a lesbian.",
17
+ # "The Roots":"It became very clear to me sitting out there today that every decision
18
+ # I've made in my entire life has been wrong. My life is the complete opposite of everything
19
+ # I want it to be. Every instinct I have, in every aspect of life, be it something to wear,
20
+ # something to eat - it's all been wrong."}
21
+ #
22
+ # @faker.version 1.9.2
6
23
  def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
7
24
  warn_for_deprecated_arguments do |keywords|
8
25
  keywords << :width if legacy_width != NOT_GIVEN
9
26
  keywords << :options if legacy_options != NOT_GIVEN
10
27
  end
11
28
 
12
- options[:key] = 'Faker::' + options[:key]
13
- options[:value] = 'Faker::' + options[:value]
29
+ options[:key] = "Faker::#{options[:key]}"
30
+ options[:value] = "Faker::#{options[:value]}"
14
31
 
15
32
  hash = build_shallow_hash(width, options)
16
33
  JSON.generate(hash)
17
34
  end
18
35
 
36
+ ##
37
+ # Produces a random nested JSON formatted string that can take JSON as an additional argument.
38
+ #
39
+ # @param json [Hash{String => String}] Specifies a Json.shallow_json and uses its keys as keys of the nested JSON.
40
+ # @param width [Integer] Specifies the number of nested key-value pairs.
41
+ # @param options [Hash] Specifies a Faker gem class to use for nested keys and for values, respectably. options_hash = {key: Class.method, value: Class.method}
42
+ # @return [Hash{String => String}]
43
+ #
44
+ # @example
45
+ # json = Faker::Json.shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.last_name' })
46
+ # puts json # =>
47
+ # {"Alisha":"Olson","Everardo":"DuBuque","Bridgette":"Turner"}
48
+ #
49
+ # json2 = Faker::Json.add_depth_to_json(json: json, width: 2, options: { key: 'Name.first_name', value: 'Name.last_name' })
50
+ # puts json2 # =>
51
+ # {"Alisha":{"Daisy":"Trantow","Oda":"Haag"},
52
+ # "Everardo":{"Javier":"Marvin","Eliseo":"Schuppe"},
53
+ # "Bridgette":{"Jorge":"Kertzmann","Lelah":"MacGyver"}}
54
+ #
55
+ # json3 = Faker::Json.add_depth_to_json(json: json2, width: 4, options: { key: 'Name.first_name', value: 'Name.last_name' })
56
+ # puts json3 # =>
57
+ # {"Alisha":
58
+ # {"Daisy":
59
+ # {"Bulah":"Wunsch","Cristian":"Champlin","Lester":"Bartoletti","Greg":"Jacobson"},
60
+ # "Oda":
61
+ # {"Salvatore":"Kuhlman","Aubree":"Okuneva","Larry":"Schmitt","Velva":"Gibson"}},
62
+ # "Everardo":
63
+ # {"Javier":
64
+ # {"Eduardo":"Orn","Laila":"Kub","Thad":"Legros","Dion":"Wilderman"},
65
+ # "Eliseo":
66
+ # {"Olin":"Hilpert","Marisa":"Greenfelder","Karlee":"Schmitt","Judd":"Larkin"}},
67
+ # "Bridgette":
68
+ # {"Jorge":
69
+ # {"Eloy":"Pfeffer","Kody":"Hansen","Paxton":"Lubowitz","Abe":"Lesch"},
70
+ # "Lelah":
71
+ # {"Rick":"Wiza","Bonita":"Bayer","Gardner":"Auer","Felicity":"Abbott"}}}
72
+ #
73
+ # @faker.version 1.9.2
19
74
  # rubocop:disable Metrics/ParameterLists
20
75
  def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
21
76
  # rubocop:enable Metrics/ParameterLists
@@ -29,8 +84,8 @@ module Faker
29
84
  keywords << :options if legacy_options != NOT_GIVEN
30
85
  end
31
86
 
32
- options[:key] = 'Faker::' + options[:key]
33
- options[:value] = 'Faker::' + options[:value]
87
+ options[:key] = "Faker::#{options[:key]}"
88
+ options[:value] = "Faker::#{options[:value]}"
34
89
 
35
90
  hash = JSON.parse(json)
36
91
  hash.each do |key, _|
@@ -107,9 +107,9 @@ module Faker
107
107
 
108
108
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
109
109
 
110
- paragraph += ' ' + paragraph(sentence_count: 3, supplemental: supplemental) while paragraph.length < number
110
+ paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number
111
111
 
112
- paragraph[0...number - 1] + '.'
112
+ "#{paragraph[0...number - 1]}."
113
113
  end
114
114
 
115
115
  # rubocop:disable Metrics/ParameterLists
@@ -5,6 +5,22 @@ module Faker
5
5
  class << self
6
6
  SUPPORTED_COLORIZATIONS = %w[red green blue].freeze
7
7
 
8
+ ##
9
+ # Produces a random image URL from loremflickr.com.
10
+ #
11
+ # @param size [String] Specifies the size of image to generate.
12
+ # @param search_terms [Array<String>] Adds search terms to the image URL.
13
+ # @param match_all [Boolean] Add "all" as part of the URL.
14
+ # @return [String]
15
+ #
16
+ # @example
17
+ # Faker::LoremFlickr.image #=> "https://loremflickr.com/300/300"
18
+ # Faker::LoremFlickr.image(size: "50x60") #=> "https://loremflickr.com/50/60"
19
+ # Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports']) #=> "https://loremflickr.com/50/60/sports"
20
+ # Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/50/60/sports,fitness"
21
+ # Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/50/60/sports,fitness/all"
22
+ #
23
+ # @faker.version 1.9.0
8
24
  # rubocop:disable Metrics/ParameterLists
9
25
  def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: [], match_all: false)
10
26
  # rubocop:enable Metrics/ParameterLists
@@ -17,6 +33,22 @@ module Faker
17
33
  build_url(size, nil, search_terms, match_all)
18
34
  end
19
35
 
36
+ ##
37
+ # Produces a random grayscale image URL from loremflickr.com.
38
+ #
39
+ # @param size [String] Specifies the size of image to generate.
40
+ # @param search_terms [Array<String>] Adds search terms to the image URL.
41
+ # @param match_all [Boolean] Add "all" as part of the URL.
42
+ # @return [String]
43
+ #
44
+ # @example
45
+ # Faker::LoremFlickr.grayscale_image #=> "https://loremflickr.com/g/300/300/all"
46
+ # Faker::LoremFlickr.grayscale_image(size: "50x60") #=> "https://loremflickr.com/g/50/60/all"
47
+ # Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports']) #=> "https://loremflickr.com/g/50/60/sports"
48
+ # Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/50/60/g/sports,fitness"
49
+ # Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/g/50/60/sports,fitness/all"
50
+ #
51
+ # @faker.version 1.9.0
20
52
  # rubocop:disable Metrics/ParameterLists
21
53
  def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
22
54
  # rubocop:enable Metrics/ParameterLists
@@ -31,6 +63,22 @@ module Faker
31
63
  build_url(size, 'g', search_terms, match_all)
32
64
  end
33
65
 
66
+ ##
67
+ # Produces a random pixelated image URL from loremflickr.com.
68
+ #
69
+ # @param size [String] Specifies the size of image to generate.
70
+ # @param search_terms [Array<String>] Adds search terms to the image URL.
71
+ # @param match_all [Boolean] Add "all" as part of the URL.
72
+ # @return [String]
73
+ #
74
+ # @example
75
+ # Faker::LoremFlickr.pixelated_image #=> "https://loremflickr.com/p/300/300/all"
76
+ # Faker::LoremFlickr.pixelated_image(size: "50x60") #=> "https://loremflickr.com/p/50/60/all"
77
+ # Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports']) #=> "https://loremflickr.com/p/50/60/sports"
78
+ # Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/p/50/60/sports,fitness"
79
+ # Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/p/50/60/sports,fitness/all"
80
+ #
81
+ # @faker.version 1.9.0
34
82
  # rubocop:disable Metrics/ParameterLists
35
83
  def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
36
84
  # rubocop:enable Metrics/ParameterLists
@@ -45,6 +93,23 @@ module Faker
45
93
  build_url(size, 'p', search_terms, match_all)
46
94
  end
47
95
 
96
+ ##
97
+ # Produces a random colorized image URL from loremflickr.com.
98
+ #
99
+ # @param size [String] Specifies the size of image to generate.
100
+ # @param color [String] Specifies the color of image to generate.
101
+ # @param search_terms [Array<String>] Adds search terms to the image URL.
102
+ # @param match_all [Boolean] Add "all" as part of the URL.
103
+ # @return [String]
104
+ #
105
+ # @example
106
+ # Faker::LoremFlickr.image #=> "https://loremflickr.com/red/300/300/all"
107
+ # Faker::LoremFlickr.image(size: "50x60", color: 'blue') #=> "https://loremflickr.com/blue/50/60/all"
108
+ # Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports']) #=> "https://loremflickr.com/blue/50/60/sports"
109
+ # Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/blue/50/60/sports,fitness"
110
+ # Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/blue/50/60/sports,fitness/all"
111
+ #
112
+ # @faker.version 1.9.0
48
113
  # rubocop:disable Metrics/ParameterLists
49
114
  def colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
50
115
  # rubocop:enable Metrics/ParameterLists
@@ -17,6 +17,28 @@ module Faker
17
17
  technics
18
18
  transport].freeze
19
19
 
20
+ ##
21
+ # Produces a random image URL from lorempixel.com.
22
+ #
23
+ # @param size [String] Specifies the size of image to generate.
24
+ # @param is_gray [Boolean] Determines if the image is gray.
25
+ # @param category [Symbol] Adds the category of the generated image to the URL.
26
+ # @param number [Integer] Adds a number as part of the URL.
27
+ # @param text [Integer] Adds dummy text as part of the URL.
28
+ # @param secure [Boolean] Changes the image URL between http and https.
29
+ # @return [String]
30
+ #
31
+ # @example
32
+ # Faker::LoremPixel.image #=> "https://lorempixel.com/300/300"
33
+ # Faker::LoremPixel.image(size: "50x60") #=> "https://lorempixel.com/50/60"
34
+ # Faker::LoremPixel.image(size: "50x60", is_gray: true) #=> "https://lorempixel.com/g/50/60"
35
+ # Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports') #=> "https://lorempixel.com/50/60/sports"
36
+ # Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: 3) #=> "https://lorempixel.com/50/60/sports/3"
37
+ # Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: 3, text: 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/3/Dummy-text"
38
+ # Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: nil, text: 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/Dummy-text"
39
+ # Faker::LoremPixel.image(secure: false) #=> "http://lorempixel.com/300/300"
40
+ #
41
+ # @faker.version 1.7.0
20
42
  # rubocop:disable Metrics/ParameterLists
21
43
  def image(legacy_size = NOT_GIVEN, legacy_is_gray = NOT_GIVEN, legacy_category = NOT_GIVEN, legacy_number = NOT_GIVEN, legacy_text = NOT_GIVEN, legacy_secure = NOT_GIVEN, size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true)
22
44
  warn_for_deprecated_arguments do |keywords|
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class Markdown < Base
5
5
  class << self
6
+ ##
7
+ # Produces a random header format.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Markdown.headers #=> "##### Autem"
13
+ #
14
+ # @faker.version 1.8.0
6
15
  def headers
7
16
  "#{fetch('markdown.headers')} #{Lorem.word.capitalize}"
8
17
  end
9
18
 
19
+ ##
20
+ # Produces a random emphasis formatting on a random word in two sentences.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Markdown.emphasis #=> "_Incidunt atque quis repellat id impedit. Quas numquam quod incidunt dicta non. Blanditiis delectus laudantium atque reiciendis qui._"
26
+ #
27
+ # @faker.version 1.8.0
10
28
  def emphasis
11
29
  paragraph = Faker::Lorem.paragraph(sentence_count: 3)
12
30
  words = paragraph.split(' ')
@@ -16,6 +34,15 @@ module Faker
16
34
  words.join(' ')
17
35
  end
18
36
 
37
+ ##
38
+ # Produces a random ordered list of items between 1 and 10 randomly.
39
+ #
40
+ # @return [String]
41
+ #
42
+ # @example
43
+ # Faker::Markdown.ordered_list #=> "1. Qui reiciendis non consequatur atque.\n2. Quo doloremque veritatis tempora aut.\n3. Aspernatur.\n4. Ea ab.\n5. Qui.\n6. Sit pariatur nemo eveniet.\n7. Molestiae aut.\n8. Nihil molestias iure placeat.\n9. Dolore autem quisquam."
44
+ #
45
+ # @faker.version 1.8.0
19
46
  def ordered_list
20
47
  number = rand(1..10)
21
48
 
@@ -26,6 +53,15 @@ module Faker
26
53
  result.join('')
27
54
  end
28
55
 
56
+ ##
57
+ # Produces a random unordered list of items between 1 and 10 randomly.
58
+ #
59
+ # @return [String]
60
+ #
61
+ # @example
62
+ # Faker::Markdown.unordered_list #=> "* Voluptatum aliquid tempora molestiae facilis non sed.\n* Nostrum omnis iste impedit voluptatum dolor.\n* Esse quidem et facere."
63
+ #
64
+ # @faker.version 1.8.0
29
65
  def unordered_list
30
66
  number = rand(1..10)
31
67
 
@@ -36,14 +72,41 @@ module Faker
36
72
  result.join('')
37
73
  end
38
74
 
75
+ ##
76
+ # Produces a random inline code snippet between two sentences.
77
+ #
78
+ # @return [String]
79
+ #
80
+ # @example
81
+ # Faker::Markdown.inline_code #=> "Aut eos quis suscipit. `Dignissimos voluptatem expedita qui.` Quo doloremque veritatis tempora aut."
82
+ #
83
+ # @faker.version 1.8.0
39
84
  def inline_code
40
85
  "`#{Faker::Lorem.sentence(word_count: 1)}`"
41
86
  end
42
87
 
88
+ ##
89
+ # Produces a random code block formatted in Ruby.
90
+ #
91
+ # @return [String]
92
+ #
93
+ # @example
94
+ # Faker::Markdown.block_code #=> "```ruby\nEos quasi qui.\n```"
95
+ #
96
+ # @faker.version 1.8.0
43
97
  def block_code
44
98
  "```ruby\n#{Lorem.sentence(word_count: 1)}\n```"
45
99
  end
46
100
 
101
+ ##
102
+ # Produces a random 3x4 table with a row of headings, a row of hyphens and two rows of data
103
+ #
104
+ # @return [String]
105
+ #
106
+ # @example
107
+ # Faker::Markdown.table #=> "ad | similique | voluptatem\n---- | ---- | ----\ncorrupti | est | rerum\nmolestiae | quidem | et"
108
+ #
109
+ # @faker.version 1.8.0
47
110
  def table
48
111
  table = []
49
112
  3.times do
@@ -53,12 +116,38 @@ module Faker
53
116
  table.join("\n")
54
117
  end
55
118
 
119
+ ##
120
+ # Produces a random method from the methods above or the methods listed in the arguments.
121
+ #
122
+ # @param methods [Symbol] Specify which methods to use.
123
+ # @return [String, Array<String>]
124
+ #
125
+ # @example
126
+ # Faker::Markdown.random #=> returns output from a single method outlined above
127
+ # Faker::Markdown.random("table") #=> returns output from any single method outlined above except for "table"
128
+ # Faker::Markdown.random("ordered_list", "unordered_list") #=> returns output from any single method outlined above except for either ordered_list and unordered_list
129
+ #
130
+ # @faker.version 1.8.0
56
131
  def random(*args)
57
132
  method_list = available_methods
58
133
  args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
59
134
  send(method_list[rand(0..method_list.length - 1)])
60
135
  end
61
136
 
137
+ ##
138
+ # Produces a simulated blog-esque text-heavy block in markdown
139
+ #
140
+ # Keyword arguments: sentences, repeat
141
+ # @param sentences [Integer] Specifies how many sentences make a text block.
142
+ # @param repeat [Integer] Specifies how many times the text block repeats.
143
+ # @return [String]
144
+ #
145
+ # @example
146
+ # Faker::Markdown.sandwich #=> returns newline separated content of 1 header, 1 default lorem paragraph, and 1 random markdown element
147
+ # Faker::Markdown.sandwich(sentences: 5) #=> returns newline separated content of 1 header, 1 5-sentence lorem paragraph, and 1 random markdown element
148
+ # Faker::Markdown.sandwich(sentences: 6, repeat: 3) #=> returns newline separated content of 1 header, and then 3 sections consisting of, here, 1 6-sentence lorem paragraph and 1 random markdown element. The random markdown element is chosen at random in each iteration of the paragraph-markdown pairing.
149
+ #
150
+ # @faker.version 1.8.0
62
151
  def sandwich(legacy_sentences = NOT_GIVEN, legacy_repeat = NOT_GIVEN, sentences: 3, repeat: 1)
63
152
  warn_for_deprecated_arguments do |keywords|
64
153
  keywords << :sentences if legacy_sentences != NOT_GIVEN