faker 2.11.0 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +421 -13
  3. data/History.md +4 -4
  4. data/README.md +33 -3
  5. data/lib/faker.rb +28 -23
  6. data/lib/faker/blockchain/aeternity.rb +4 -4
  7. data/lib/faker/blockchain/bitcoin.rb +2 -2
  8. data/lib/faker/blockchain/tezos.rb +30 -2
  9. data/lib/faker/books/dune.rb +15 -2
  10. data/lib/faker/books/lovecraft.rb +8 -4
  11. data/lib/faker/creature/bird.rb +203 -0
  12. data/lib/faker/default/address.rb +35 -5
  13. data/lib/faker/default/app.rb +1 -1
  14. data/lib/faker/default/avatar.rb +1 -1
  15. data/lib/faker/default/bank.rb +96 -3
  16. data/lib/faker/default/barcode.rb +165 -0
  17. data/lib/faker/default/beer.rb +3 -3
  18. data/lib/faker/default/blood.rb +48 -0
  19. data/lib/faker/default/business.rb +1 -1
  20. data/lib/faker/default/camera.rb +46 -0
  21. data/lib/faker/default/cannabis.rb +10 -0
  22. data/lib/faker/default/chile_rut.rb +47 -3
  23. data/lib/faker/default/chuck_norris.rb +1 -0
  24. data/lib/faker/default/code.rb +98 -17
  25. data/lib/faker/default/commerce.rb +74 -11
  26. data/lib/faker/default/company.rb +96 -11
  27. data/lib/faker/default/compass.rb +135 -0
  28. data/lib/faker/default/computer.rb +63 -0
  29. data/lib/faker/default/construction.rb +54 -0
  30. data/lib/faker/default/cosmere.rb +90 -0
  31. data/lib/faker/default/crypto.rb +17 -4
  32. data/lib/faker/default/crypto_coin.rb +45 -0
  33. data/lib/faker/default/date.rb +16 -12
  34. data/lib/faker/default/driving_licence.rb +67 -1
  35. data/lib/faker/default/drone.rb +332 -0
  36. data/lib/faker/default/educator.rb +13 -0
  37. data/lib/faker/default/faker_adjective.rb +35 -0
  38. data/lib/faker/default/file.rb +53 -2
  39. data/lib/faker/default/finance.rb +45 -0
  40. data/lib/faker/default/food.rb +1 -1
  41. data/lib/faker/default/gender.rb +1 -1
  42. data/lib/faker/default/hipster.rb +107 -10
  43. data/lib/faker/default/id_number.rb +122 -2
  44. data/lib/faker/default/internet.rb +266 -12
  45. data/lib/faker/default/internet_http.rb +48 -0
  46. data/lib/faker/default/invoice.rb +33 -6
  47. data/lib/faker/default/json.rb +61 -5
  48. data/lib/faker/default/lorem.rb +160 -5
  49. data/lib/faker/default/lorem_flickr.rb +67 -7
  50. data/lib/faker/default/lorem_pixel.rb +23 -0
  51. data/lib/faker/default/markdown.rb +91 -0
  52. data/lib/faker/default/measurement.rb +93 -2
  53. data/lib/faker/default/military.rb +26 -0
  54. data/lib/faker/default/mountain.rb +33 -0
  55. data/lib/faker/default/name.rb +98 -0
  56. data/lib/faker/default/nhs.rb +19 -0
  57. data/lib/faker/default/number.rb +28 -13
  58. data/lib/faker/default/omniauth.rb +62 -14
  59. data/lib/faker/default/phone_number.rb +88 -5
  60. data/lib/faker/default/placeholdit.rb +23 -1
  61. data/lib/faker/default/relationship.rb +1 -1
  62. data/lib/faker/default/science.rb +26 -0
  63. data/lib/faker/default/slack_emoji.rb +81 -0
  64. data/lib/faker/default/south_africa.rb +90 -0
  65. data/lib/faker/default/space.rb +1 -1
  66. data/lib/faker/default/string.rb +20 -3
  67. data/lib/faker/default/stripe.rb +64 -3
  68. data/lib/faker/default/tea.rb +41 -0
  69. data/lib/faker/default/twitter.rb +35 -0
  70. data/lib/faker/default/types.rb +84 -3
  71. data/lib/faker/default/university.rb +45 -0
  72. data/lib/faker/default/vehicle.rb +184 -4
  73. data/lib/faker/default/verb.rb +45 -0
  74. data/lib/faker/default/world_cup.rb +4 -4
  75. data/lib/faker/fantasy/tolkien.rb +67 -0
  76. data/lib/faker/games/clash_of_clans.rb +48 -0
  77. data/lib/faker/games/control.rb +113 -0
  78. data/lib/faker/games/dnd.rb +136 -0
  79. data/lib/faker/games/elder_scrolls.rb +26 -0
  80. data/lib/faker/games/heroes.rb +13 -0
  81. data/lib/faker/games/heroes_of_the_storm.rb +16 -5
  82. data/lib/faker/games/minecraft.rb +113 -0
  83. data/lib/faker/games/street_fighter.rb +61 -0
  84. data/lib/faker/games/super_mario.rb +48 -0
  85. data/lib/faker/games/touhou.rb +75 -0
  86. data/lib/faker/games/warhammer_fantasy.rb +74 -0
  87. data/lib/faker/games/witcher.rb +39 -0
  88. data/lib/faker/games/world_of_warcraft.rb +26 -1
  89. data/lib/faker/japanese_media/conan.rb +48 -0
  90. data/lib/faker/japanese_media/doraemon.rb +48 -0
  91. data/lib/faker/japanese_media/dragon_ball.rb +26 -0
  92. data/lib/faker/japanese_media/naruto.rb +61 -0
  93. data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
  94. data/lib/faker/movies/departed.rb +49 -0
  95. data/lib/faker/movies/hobbit.rb +4 -4
  96. data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
  97. data/lib/faker/movies/lord_of_the_rings.rb +3 -3
  98. data/lib/faker/movies/movie.rb +13 -0
  99. data/lib/faker/movies/room.rb +63 -0
  100. data/lib/faker/movies/star_wars.rb +74 -2
  101. data/lib/faker/music/hiphop.rb +48 -0
  102. data/lib/faker/music/music.rb +12 -0
  103. data/lib/faker/music/opera.rb +237 -1
  104. data/lib/faker/music/pearl_jam.rb +50 -0
  105. data/lib/faker/music/phish.rb +27 -1
  106. data/lib/faker/music/prince.rb +64 -0
  107. data/lib/faker/music/rock_band.rb +12 -0
  108. data/lib/faker/music/rush.rb +37 -0
  109. data/lib/faker/music/show.rb +49 -0
  110. data/lib/faker/quotes/quote.rb +80 -1
  111. data/lib/faker/quotes/rajnikanth.rb +1 -0
  112. data/lib/faker/quotes/shakespeare.rb +70 -0
  113. data/lib/faker/sports/volleyball.rb +74 -0
  114. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +13 -0
  115. data/lib/faker/tv_shows/big_bang_theory.rb +37 -0
  116. data/lib/faker/tv_shows/buffy.rb +17 -4
  117. data/lib/faker/tv_shows/dr_who.rb +1 -1
  118. data/lib/faker/tv_shows/final_space.rb +51 -0
  119. data/lib/faker/tv_shows/futurama.rb +65 -0
  120. data/lib/faker/tv_shows/simpsons.rb +14 -0
  121. data/lib/faker/tv_shows/suits.rb +37 -0
  122. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
  123. data/lib/faker/version.rb +1 -1
  124. data/lib/helpers/base58.rb +1 -1
  125. data/lib/helpers/char.rb +22 -27
  126. data/lib/helpers/unique_generator.rb +0 -2
  127. data/lib/locales/de-AT.yml +4 -2
  128. data/lib/locales/de-CH.yml +1696 -1
  129. data/lib/locales/de.yml +4 -2
  130. data/lib/locales/en-AU.yml +50 -10
  131. data/lib/locales/en-CA.yml +2 -0
  132. data/lib/locales/en-GB.yml +1 -1
  133. data/lib/locales/en-IND.yml +2 -1
  134. data/lib/locales/en-MS.yml +2 -1
  135. data/lib/locales/en-NEP.yml +4 -1
  136. data/lib/locales/en-NZ.yml +3 -1
  137. data/lib/locales/en-PAK.yml +2 -1
  138. data/lib/locales/en-SG.yml +2 -1
  139. data/lib/locales/en-US.yml +37 -11
  140. data/lib/locales/en-au-ocker.yml +2 -1
  141. data/lib/locales/en.yml +0 -3
  142. data/lib/locales/en/address.yml +2 -0
  143. data/lib/locales/en/adjective.yml +179 -0
  144. data/lib/locales/en/animal.yml +1 -1
  145. data/lib/locales/en/aqua_teen_hunger_force.yml +33 -1
  146. data/lib/locales/en/bank.yml +1 -1
  147. data/lib/locales/en/barcode.yml +24 -0
  148. data/lib/locales/en/big_bang_theory.yml +38 -0
  149. data/lib/locales/en/bird.yml +1281 -0
  150. data/lib/locales/en/blood.yml +13 -0
  151. data/lib/locales/en/book.yml +487 -3
  152. data/lib/locales/en/buffy.yml +1 -1
  153. data/lib/locales/en/camera.yml +611 -0
  154. data/lib/locales/en/clash_of_clan.yml +101 -0
  155. data/lib/locales/en/company.yml +2 -2
  156. data/lib/locales/en/computer.yml +36 -0
  157. data/lib/locales/en/conan.yml +171 -0
  158. data/lib/locales/en/control.yml +247 -0
  159. data/lib/locales/en/demographic.yml +218 -5
  160. data/lib/locales/en/departed.yml +50 -0
  161. data/lib/locales/en/device.yml +112 -4
  162. data/lib/locales/en/dnd.yml +451 -0
  163. data/lib/locales/en/doraemon.yml +286 -0
  164. data/lib/locales/en/dota.yml +531 -63
  165. data/lib/locales/en/dragon_ball.yml +243 -1
  166. data/lib/locales/en/driving_license.yml +181 -0
  167. data/lib/locales/en/drone.yml +95 -0
  168. data/lib/locales/en/dune.yml +270 -131
  169. data/lib/locales/en/educator.yml +6 -0
  170. data/lib/locales/en/elder_scrolls.yml +583 -9
  171. data/lib/locales/en/fallout.yml +311 -133
  172. data/lib/locales/en/final_space.yml +37 -0
  173. data/lib/locales/en/finance.yml +53 -0
  174. data/lib/locales/en/football.yml +3 -3
  175. data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
  176. data/lib/locales/en/futurama.yml +344 -0
  177. data/lib/locales/en/half_life.yml +84 -3
  178. data/lib/locales/en/heroes.yml +408 -3
  179. data/lib/locales/en/heroes_of_the_storm.yml +131 -4
  180. data/lib/locales/en/house.yml +1 -1
  181. data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
  182. data/lib/locales/en/jack_handey.yml +54 -0
  183. data/lib/locales/en/league_of_legends.yml +285 -6
  184. data/lib/locales/en/lebowski.yml +1 -1
  185. data/lib/locales/en/lovecraft.yml +76 -6
  186. data/lib/locales/en/military.yml +179 -5
  187. data/lib/locales/en/minecraft.yml +663 -0
  188. data/lib/locales/en/mountain.yml +158 -0
  189. data/lib/locales/en/movie.yml +192 -1
  190. data/lib/locales/en/music.yml +461 -29
  191. data/lib/locales/en/myst.yml +87 -31
  192. data/lib/locales/en/name.yml +5 -4
  193. data/lib/locales/en/naruto.yml +231 -0
  194. data/lib/locales/en/one_piece.yml +2 -2
  195. data/lib/locales/en/opera.yml +168 -0
  196. data/lib/locales/en/overwatch.yml +2650 -2622
  197. data/lib/locales/en/pearl_jam.yml +213 -0
  198. data/lib/locales/en/phish.yml +392 -1
  199. data/lib/locales/en/pokemon.yml +417 -4
  200. data/lib/locales/en/prince.yml +227 -0
  201. data/lib/locales/en/quote.yml +692 -163
  202. data/lib/locales/en/rock_band.yml +1 -0
  203. data/lib/locales/en/room.yml +68 -0
  204. data/lib/locales/en/rush.yml +32 -0
  205. data/lib/locales/en/science.yml +355 -3
  206. data/lib/locales/en/shakespeare.yml +21 -24
  207. data/lib/locales/en/show.yml +597 -0
  208. data/lib/locales/en/simpsons.yml +668 -0
  209. data/lib/locales/en/source.yml +30 -0
  210. data/lib/locales/en/space.yml +1 -1
  211. data/lib/locales/en/star_trek.yml +1 -1
  212. data/lib/locales/en/star_wars.yml +568 -220
  213. data/lib/locales/en/street_fighter.yml +1524 -0
  214. data/lib/locales/en/studio_ghibli.yml +107 -0
  215. data/lib/locales/en/suits.yml +45 -0
  216. data/lib/locales/en/super_mario.yml +58 -0
  217. data/lib/locales/en/super_smash_bros.yml +18 -4
  218. data/lib/locales/en/tea.yml +172 -0
  219. data/lib/locales/en/tolkien.yml +2453 -0
  220. data/lib/locales/en/touhou.yml +839 -0
  221. data/lib/locales/en/volleyball.yml +501 -0
  222. data/lib/locales/en/warhammer_fantasy.yml +582 -0
  223. data/lib/locales/en/witcher.yml +426 -7
  224. data/lib/locales/en/world_of_warcraft.yml +122 -4
  225. data/lib/locales/en/zelda.yml +962 -4
  226. data/lib/locales/es-AR.yml +4603 -0
  227. data/lib/locales/es.yml +56 -0
  228. data/lib/locales/fi-FI.yml +1 -1
  229. data/lib/locales/fr-CA.yml +21 -5
  230. data/lib/locales/fr-CH.yml +2 -2
  231. data/lib/locales/fr.yml +1 -113
  232. data/lib/locales/fr/address.yml +21 -0
  233. data/lib/locales/fr/book.yml +7 -0
  234. data/lib/locales/fr/color.yml +4 -0
  235. data/lib/locales/fr/company.yml +17 -0
  236. data/lib/locales/fr/compass.yml +23 -0
  237. data/lib/locales/fr/demographic.yml +4 -0
  238. data/lib/locales/fr/gender.yml +6 -0
  239. data/lib/locales/fr/internet.yml +5 -0
  240. data/lib/locales/fr/lorem.yml +5 -0
  241. data/lib/locales/fr/measurement.yml +7 -0
  242. data/lib/locales/fr/name.yml +21 -0
  243. data/lib/locales/fr/phone_number.yml +7 -0
  244. data/lib/locales/fr/pokemon.yml +9 -0
  245. data/lib/locales/id.yml +3 -1
  246. data/lib/locales/it.yml +2 -1
  247. data/lib/locales/ja/README.md +13 -0
  248. data/lib/locales/ja/address.yml +17 -0
  249. data/lib/locales/ja/ancient.yml +4 -0
  250. data/lib/locales/ja/bank.yml +4 -0
  251. data/lib/locales/ja/book.yml +7 -0
  252. data/lib/locales/ja/coffee.yml +4 -0
  253. data/lib/locales/ja/color.yml +4 -0
  254. data/lib/locales/ja/commerce.yml +11 -0
  255. data/lib/locales/ja/company.yml +8 -0
  256. data/lib/locales/ja/creature.yml +9 -0
  257. data/lib/locales/ja/food.yml +4 -0
  258. data/lib/locales/ja/games.yml +18 -0
  259. data/lib/locales/ja/gender.yml +4 -0
  260. data/lib/locales/ja/lorem.yml +9 -0
  261. data/lib/locales/ja/name.yml +13 -0
  262. data/lib/locales/ja/phone_number.yml +7 -0
  263. data/lib/locales/ja/restaurant.yml +11 -0
  264. data/lib/locales/ja/space.yml +5 -0
  265. data/lib/locales/ja/subscription.yml +8 -0
  266. data/lib/locales/ja/university.yml +9 -0
  267. data/lib/locales/ko.yml +94 -2
  268. data/lib/locales/nb-NO.yml +4 -2
  269. data/lib/locales/pt-BR.yml +3 -1
  270. data/lib/locales/pt.yml +3 -1
  271. data/lib/locales/ru.yml +42 -1
  272. data/lib/locales/sk.yml +4 -2
  273. data/lib/locales/uk.yml +2 -0
  274. metadata +133 -24
  275. data/lib/locales/en/hobbit.yml +0 -19
  276. data/lib/locales/en/lord_of_the_rings.yml +0 -6
  277. data/lib/locales/ja.yml +0 -101
@@ -72,6 +72,19 @@ module Faker
72
72
  parse('educator.secondary_school')
73
73
  end
74
74
 
75
+ ##
76
+ # Produces a primary school.
77
+ #
78
+ # @return [String]
79
+ #
80
+ # @example
81
+ # Faker::Educator.primary_school #=> "Brighthurst Elementary School"
82
+ #
83
+ # @faker.version next
84
+ def primary_school
85
+ parse('educator.primary_school')
86
+ end
87
+
75
88
  ##
76
89
  # Produces a campus name.
77
90
  #
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class Adjective < Base
5
+ flexible :adjective
6
+
7
+ class << self
8
+ ##
9
+ # Produces a positive adjective.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Adjective.positive #=> "Kind"
15
+ #
16
+ # @faker.version next
17
+ def positive
18
+ fetch('adjective.positive')
19
+ end
20
+
21
+ ##
22
+ # Produces a negative adjective.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Adjective.negative #=> "Creepy"
28
+ #
29
+ # @faker.version next
30
+ def negative
31
+ fetch('adjective.negative')
32
+ end
33
+ end
34
+ end
35
+ end
@@ -4,8 +4,23 @@ module Faker
4
4
  class File < Base
5
5
  class << self
6
6
  # rubocop:disable Metrics/ParameterLists
7
+
8
+ ##
9
+ # Produces a random directory name.
10
+ #
11
+ # @param segment_count [Integer] Specifies the number of nested folders in the generated string.
12
+ # @param root [String] Specifies the root of the generated string.
13
+ # @param directory_separator [String] Specifies the separator between the segments.
14
+ # @return [String]
15
+ #
16
+ # @example
17
+ # Faker::File.dir #=> "et_error/sint_voluptas/quas_veritatis"
18
+ # Faker::File.dir(segment_count: 2) #=> "ea-suscipit/ut-deleniti"
19
+ # Faker::File.dir(segment_count: 3, root: nil, directory_separator: '/') #=> "est_porro/fugit_eveniet/incidunt-autem"
20
+ # Faker::File.dir(segment_count: 3, root: nil, directory_separator: '\\') #=> "aut-ullam\\quia_quisquam\\ut-eos"
21
+ #
22
+ # @faker.version 1.6.4
7
23
  def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: ::File::Separator)
8
- # rubocop:enable Metrics/ParameterLists
9
24
  warn_for_deprecated_arguments do |keywords|
10
25
  keywords << :segment_count if legacy_segment_count != NOT_GIVEN
11
26
  keywords << :root if legacy_root != NOT_GIVEN
@@ -19,18 +34,53 @@ module Faker
19
34
  .join(directory_separator)
20
35
  .squeeze(directory_separator)
21
36
  end
37
+ # rubocop:enable Metrics/ParameterLists
22
38
 
39
+ ##
40
+ # Produces a random file extension.
41
+ #
42
+ # @return [String]
43
+ #
44
+ # @example
45
+ # Faker::File.extension #=> "mp3"
46
+ #
47
+ # @faker.version 1.6.4
23
48
  def extension
24
49
  fetch('file.extension')
25
50
  end
26
51
 
52
+ ##
53
+ # Produces a random mime type.
54
+ #
55
+ # @return [String]
56
+ #
57
+ # @example
58
+ # Faker::File.mime_type #=> "application/pdf"
59
+ #
60
+ # @faker.version 1.6.4
27
61
  def mime_type
28
62
  fetch('file.mime_type')
29
63
  end
30
64
 
31
65
  # rubocop:disable Metrics/ParameterLists
66
+
67
+ ##
68
+ # Produces a random file name.
69
+ #
70
+ # @param dir [String] Specifies the path used for the generated file.
71
+ # @param name [String] Specifies the filename used for the generated file.
72
+ # @param ext [String] Specifies the extension used the generated file.
73
+ # @param directory_separator [String] Specifies the separator between the directory and name elements.
74
+ # @return [String]
75
+ #
76
+ # @example
77
+ # Faker::File.file_name(dir: 'path/to') #=> "path/to/something_random.jpg"
78
+ # Faker::File.file_name(dir: 'foo/bar', name: 'baz') #=> "foo/bar/baz.zip"
79
+ # Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'doc') #=> "foo/bar/baz.doc"
80
+ # Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'mp3', directory_separator: '\\') #=> "foo/bar\\baz.mp3"
81
+ #
82
+ # @faker.version 1.6.4
32
83
  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: ::File::Separator)
33
- # rubocop:enable Metrics/ParameterLists
34
84
  warn_for_deprecated_arguments do |keywords|
35
85
  keywords << :dir if legacy_dir != NOT_GIVEN
36
86
  keywords << :name if legacy_name != NOT_GIVEN
@@ -44,6 +94,7 @@ module Faker
44
94
 
45
95
  [dir, name].join(directory_separator) + ".#{ext}"
46
96
  end
97
+ # rubocop:enable Metrics/ParameterLists
47
98
  end
48
99
  end
49
100
  end
@@ -6,7 +6,21 @@ module Faker
6
6
  diners_club jcb switch solo dankort
7
7
  maestro forbrugsforeningen laser].freeze
8
8
 
9
+ MARKET_LIST = %i[nyse nasdaq].freeze
10
+
9
11
  class << self
12
+ ##
13
+ # Produces a random credit card number.
14
+ #
15
+ # @param types [String] Specific credit card type.
16
+ # @return [String]
17
+ #
18
+ # @example
19
+ # Faker::Finance.credit_card #=> "3018-348979-1853"
20
+ # Faker::Finance.credit_card(:mastercard) #=> "6771-8921-2291-6236"
21
+ # Faker::Finance.credit_card(:mastercard, :visa) #=> "4448-8934-1277-7195"
22
+ #
23
+ # @faker.version 1.2.0
10
24
  def credit_card(*types)
11
25
  types = CREDIT_CARD_TYPES if types.empty?
12
26
  type = sample(types)
@@ -26,6 +40,18 @@ module Faker
26
40
  template.gsub('L', luhn_digit.to_s)
27
41
  end
28
42
 
43
+ ##
44
+ # Produces a random vat number.
45
+ #
46
+ # @param country [String] Two capital letter country code to use for the vat number.
47
+ # @return [String]
48
+ #
49
+ # @example
50
+ # Faker::Finance.vat_number #=> "BR38.395.329/2471-83"
51
+ # Faker::Finance.vat_number('DE') #=> "DE593306671"
52
+ # Faker::Finance.vat_number('ZA') #=> "ZA79494416181"
53
+ #
54
+ # @faker.version 1.9.2
29
55
  def vat_number(legacy_country = NOT_GIVEN, country: 'BR')
30
56
  warn_for_deprecated_arguments do |keywords|
31
57
  keywords << :country if legacy_country != NOT_GIVEN
@@ -39,6 +65,25 @@ module Faker
39
65
  def vat_number_keys
40
66
  translate('faker.finance.vat_number').keys
41
67
  end
68
+
69
+ ##
70
+ # Returns a randomly-selected stock ticker from a specified market.
71
+ #
72
+ # @param markets [String] The name of the market to choose the ticker from (e.g. NYSE, NASDAQ)
73
+ # @return [String]
74
+ #
75
+ # @example
76
+ # Faker::Finance.ticker #=> 'AMZN'
77
+ # Faker::Finance.vat_number('NASDAQ') #=> 'GOOG'
78
+ #
79
+ # @faker.version next
80
+ def ticker(*markets)
81
+ markets = MARKET_LIST if markets.empty?
82
+ market = sample(markets)
83
+ fetch("finance.ticker.#{market}")
84
+ rescue I18n::MissingTranslationData
85
+ raise ArgumentError, "Could not find market named #{market}"
86
+ end
42
87
  end
43
88
  end
44
89
  end
@@ -93,7 +93,7 @@ module Faker
93
93
  #
94
94
  # @faker.version 1.7.0
95
95
  def measurement
96
- fetch('food.measurement_sizes') + ' ' + fetch('food.measurements')
96
+ "#{fetch('food.measurement_sizes')} #{fetch('food.measurements')}"
97
97
  end
98
98
 
99
99
  ##
@@ -37,7 +37,7 @@ module Faker
37
37
  # @example
38
38
  # Faker::Gender.short_binary_type #=> "f"
39
39
  #
40
- # @faker.version next
40
+ # @faker.version 2.13.0
41
41
  def short_binary_type
42
42
  fetch('gender.short_binary_types')
43
43
  end
@@ -3,14 +3,38 @@
3
3
  module Faker
4
4
  class Hipster < Base
5
5
  class << self
6
+ ##
7
+ # Produces a random hipster word.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Hipster.word #=> "irony"
13
+ #
14
+ # @faker.version 1.6.0
6
15
  def word
7
16
  random_word = sample(translate('faker.hipster.words'))
8
17
  random_word =~ /\s/ ? word : random_word
9
18
  end
10
19
 
11
20
  # rubocop:disable Metrics/ParameterLists
21
+
22
+ ##
23
+ # Produces a random hipster word.
24
+ #
25
+ # @param number [Integer] Specifies the number of words returned
26
+ # @param supplemental [Boolean] Specifies if the words are supplemental
27
+ # @param spaces_allowed [Boolean] Specifies if the words may contain spaces
28
+ # @return [Array<String>]
29
+ #
30
+ # @example
31
+ # Faker::Hipster.words #=> ["pug", "pitchfork", "chia"]
32
+ # Faker::Hipster.words(number: 4) #=> ["ugh", "cardigan", "poutine", "stumptown"]
33
+ # Faker::Hipster.words(number: 4, supplemental: true) #=> ["iste", "seitan", "normcore", "provident"]
34
+ # Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"]
35
+ #
36
+ # @faker.version 1.6.0
12
37
  def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
13
- # rubocop:enable Metrics/ParameterLists
14
38
  warn_for_deprecated_arguments do |keywords|
15
39
  keywords << :number if legacy_number != NOT_GIVEN
16
40
  keywords << :supplemental if legacy_supplemental != NOT_GIVEN
@@ -30,18 +54,49 @@ module Faker
30
54
  words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
31
55
  end
32
56
 
33
- # rubocop:disable Metrics/ParameterLists
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)
35
- # rubocop:enable Metrics/ParameterLists
57
+ ##
58
+ # Produces a random hipster sentence.
59
+ #
60
+ # @param word_count [Integer] Specifies the number of words in the sentence
61
+ # @param supplemental [Boolean] Specifies if the words are supplemental
62
+ # @param random_words_to_add [Integer] Specifies the number of random words to add
63
+ # @param open_compounds_allowed [Boolean] Specifies if the generated sentence can contain words having additional spaces
64
+ # @return [String]
65
+ #
66
+ # @example
67
+ # Faker::Hipster.sentence #=> "Park iphone leggings put a bird on it."
68
+ # Faker::Hipster.sentence(word_count: 3) #=> "Pour-over swag godard."
69
+ # Faker::Hipster.sentence(word_count: 3, supplemental: true) #=> "Beard laboriosam sequi celiac."
70
+ # Faker::Hipster.sentence(word_count: 3, supplemental: false, random_words_to_add: 4) #=> "Bitters retro mustache aesthetic biodiesel 8-bit."
71
+ # Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 4) #=> "Occaecati deleniti messenger bag meh crucifix autem."
72
+ # Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: true) #=> "Kale chips nihil eos."
73
+ # Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie."
74
+ #
75
+ # @faker.version 1.6.0
76
+ 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, open_compounds_allowed: true)
36
77
  warn_for_deprecated_arguments do |keywords|
37
78
  keywords << :word_count if legacy_word_count != NOT_GIVEN
38
79
  keywords << :supplemental if legacy_supplemental != NOT_GIVEN
39
80
  keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
40
81
  end
41
82
 
42
- words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
83
+ "#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}."
43
84
  end
44
-
85
+ # rubocop:enable Metrics/ParameterLists
86
+
87
+ ##
88
+ # Produces random hipster sentences.
89
+ #
90
+ # @param number [Integer] Specifies the number of sentences returned
91
+ # @param supplemental [Boolean] Specifies if the words are supplemental
92
+ # @return [Array<String>]
93
+ #
94
+ # @example
95
+ # Faker::Hipster.sentences #=> ["Godard pitchfork vinegar chillwave everyday 90's whatever.", "Pour-over artisan distillery street waistcoat.", "Salvia yr leggings franzen blue bottle."]
96
+ # Faker::Hipster.sentences(number: 1) #=> ["Before they sold out pinterest venmo umami try-hard ugh hoodie artisan."]
97
+ # Faker::Hipster.sentences(number: 1, supplemental: true) #=> ["Et sustainable optio aesthetic et."]
98
+ #
99
+ # @faker.version 1.6.0
45
100
  def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
46
101
  warn_for_deprecated_arguments do |keywords|
47
102
  keywords << :number if legacy_number != NOT_GIVEN
@@ -56,8 +111,24 @@ module Faker
56
111
  end
57
112
 
58
113
  # rubocop:disable Metrics/ParameterLists
114
+
115
+ ##
116
+ # Produces a random hipster paragraph.
117
+ #
118
+ # @param sentence_count [Integer] Specifies the number of sentences in the paragraph
119
+ # @param supplemental [Boolean] Specifies if the words are supplemental
120
+ # @param random_sentences_to_add [Boolean] Specifies the number of random sentences to add
121
+ # @return [String]
122
+ #
123
+ # @example
124
+ # Faker::Hipster.paragraph #=> "Migas fingerstache pbr&b tofu. Polaroid distillery typewriter echo tofu actually. Slow-carb fanny pack pickled direct trade scenester mlkshk plaid. Banjo venmo chambray cold-pressed typewriter. Fap skateboard intelligentsia."
125
+ # Faker::Hipster.paragraph(sentence_count: 2) #=> "Yolo tilde farm-to-table hashtag. Lomo kitsch disrupt forage +1."
126
+ # Faker::Hipster.paragraph(sentence_count: 2, supplemental: true) #=> "Typewriter iste ut viral kombucha voluptatem. Sint voluptates saepe. Direct trade irony chia excepturi yuccie. Biodiesel esse listicle et quam suscipit."
127
+ # Faker::Hipster.paragraph(sentence_count: 2, supplemental: false, random_sentences_to_add: 4) #=> "Selvage vhs chartreuse narwhal vinegar. Authentic vinyl truffaut carry vhs pop-up. Hammock everyday iphone locavore thundercats bitters vegan goth. Fashion axe banh mi shoreditch whatever artisan."
128
+ # Faker::Hipster.paragraph(sentence_count: 2, supplemental: true, random_sentences_to_add: 4) #=> "Deep v gluten-free unde waistcoat aperiam migas voluptas dolorum. Aut drinking illo sustainable sapiente. Direct trade fanny pack kale chips ennui semiotics."
129
+ #
130
+ # @faker.version 1.6.0
59
131
  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)
60
- # rubocop:enable Metrics/ParameterLists
61
132
  warn_for_deprecated_arguments do |keywords|
62
133
  keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
63
134
  keywords << :supplemental if legacy_supplemental != NOT_GIVEN
@@ -66,7 +137,21 @@ module Faker
66
137
 
67
138
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
68
139
  end
69
-
140
+ # rubocop:enable Metrics/ParameterLists
141
+
142
+ ##
143
+ # Produces random hipster paragraphs.
144
+ #
145
+ # @param number [Integer] Specifies the number of paragraphs
146
+ # @param supplemental [Boolean] Specifies if the words are supplemental
147
+ # @return [Array<String>]
148
+ #
149
+ # @example
150
+ # Faker::Hipster.paragraphs #=> ["Tilde microdosing blog cliche meggings. Intelligentsia five dollar toast forage yuccie. Master kitsch knausgaard. Try-hard everyday trust fund mumblecore.", "Normcore viral pickled. Listicle humblebrag swag tote bag. Taxidermy street hammock neutra butcher cred kale chips. Blog portland humblebrag trust fund irony.", "Single-origin coffee fixie cleanse tofu xoxo. Post-ironic tote bag ramps gluten-free locavore mumblecore hammock. Umami loko twee. Ugh kitsch before they sold out."]
151
+ # Faker::Hipster.paragraphs(number: 1) #=> ["Skateboard cronut synth +1 fashion axe. Pop-up polaroid skateboard asymmetrical. Ennui fingerstache shoreditch before they sold out. Tattooed pitchfork ramps. Photo booth yr messenger bag raw denim bespoke locavore lomo synth."]
152
+ # Faker::Hipster.paragraphs(number: 1, supplemental: true) #=> ["Quae direct trade pbr&b quo taxidermy autem loko. Umami quas ratione migas cardigan sriracha minima. Tenetur perspiciatis pickled sed eum doloribus truffaut. Excepturi dreamcatcher meditation."]
153
+ #
154
+ # @faker.version 1.6.0
70
155
  def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
71
156
  warn_for_deprecated_arguments do |keywords|
72
157
  keywords << :number if legacy_number != NOT_GIVEN
@@ -80,6 +165,18 @@ module Faker
80
165
  end
81
166
  end
82
167
 
168
+ ##
169
+ # Produces a random hipster paragraph by characters.
170
+ #
171
+ # @param characters [Integer] Specifies the number of characters in the paragraph
172
+ # @param supplemental [Boolean] Specifies if the words are supplemental
173
+ # @return [String]
174
+ #
175
+ # @example
176
+ # Faker::Hipster.paragraph_by_chars #=> "Truffaut stumptown trust fund 8-bit messenger bag portland. Meh kombucha selvage swag biodiesel. Lomo kinfolk jean shorts asymmetrical diy. Wayfarers portland twee stumptown. Wes anderson biodiesel retro 90's pabst. Diy echo 90's mixtape semiotics. Cornho."
177
+ # Faker::Hipster.paragraph_by_chars(characters: 256, supplemental: false) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green."
178
+ #
179
+ # @faker.version 1.6.0
83
180
  def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false)
84
181
  warn_for_deprecated_arguments do |keywords|
85
182
  keywords << :characters if legacy_characters != NOT_GIVEN
@@ -88,9 +185,9 @@ module Faker
88
185
 
89
186
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
90
187
 
91
- paragraph += ' ' + paragraph(sentence_count: 3, supplemental: supplemental) while paragraph.length < characters
188
+ paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters
92
189
 
93
- paragraph[0...characters - 1] + '.'
190
+ "#{paragraph[0...characters - 1]}."
94
191
  end
95
192
  end
96
193
  end
@@ -19,10 +19,28 @@ module Faker
19
19
  CHILEAN_MODULO = 11
20
20
 
21
21
  class << self
22
+ ##
23
+ # Produces a random valid US Social Security number.
24
+ #
25
+ # @return [String]
26
+ #
27
+ # @example
28
+ # Faker::IDNumber.valid #=> "552-56-3593"
29
+ #
30
+ # @faker.version 1.6.0
22
31
  def valid
23
32
  _translate('valid')
24
33
  end
25
34
 
35
+ ##
36
+ # Produces a random invalid US Social Security number.
37
+ #
38
+ # @return [String]
39
+ #
40
+ # @example
41
+ # Faker::IDNumber.invalid #=> "311-72-0000"
42
+ #
43
+ # @faker.version 1.6.0
26
44
  def invalid
27
45
  _translate('invalid')
28
46
  end
@@ -33,6 +51,15 @@ module Faker
33
51
  INVALID_SSN.any? { |regex| regex =~ ssn } ? ssn_valid : ssn
34
52
  end
35
53
 
54
+ ##
55
+ # Produces a random Spanish citizen identifier (DNI).
56
+ #
57
+ # @return [String]
58
+ #
59
+ # @example
60
+ # Faker::IDNumber.spanish_citizen_number #=> "53290236-H"
61
+ #
62
+ # @faker.version 1.9.0
36
63
  def spanish_citizen_number
37
64
  num = Faker::Number.number(digits: 8)
38
65
  mod = num.to_i % 23
@@ -40,6 +67,15 @@ module Faker
40
67
  "#{num}-#{check}"
41
68
  end
42
69
 
70
+ ##
71
+ # Produces a random Spanish foreign born citizen identifier (NIE).
72
+ #
73
+ # @return [String]
74
+ #
75
+ # @example
76
+ # Faker::IDNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y"
77
+ #
78
+ # @faker.version 1.9.0
43
79
  def spanish_foreign_citizen_number
44
80
  code = 'XYZ'
45
81
  digits = Faker::Number.number(digits: 7)
@@ -50,6 +86,16 @@ module Faker
50
86
  "#{prefix}-#{digits}-#{check}"
51
87
  end
52
88
 
89
+ ##
90
+ # Produces a random valid South African ID Number.
91
+ #
92
+ # @return [String]
93
+ #
94
+ # @example
95
+ # Faker::IDNumber.south_african_id_number #=> "8105128870184"
96
+ # Faker::IDNumber.valid_south_african_id_number #=> "8105128870184"
97
+ #
98
+ # @faker.version 1.9.2
53
99
  def valid_south_african_id_number
54
100
  id_number = [
55
101
  Faker::Date.birthday.strftime('%y%m%d'),
@@ -63,6 +109,15 @@ module Faker
63
109
 
64
110
  alias south_african_id_number valid_south_african_id_number
65
111
 
112
+ ##
113
+ # Produces a random invalid South African ID Number.
114
+ #
115
+ # @return [String]
116
+ #
117
+ # @example
118
+ # Faker::IDNumber.invalid_south_african_id_number #=> "1642972065088"
119
+ #
120
+ # @faker.version 1.9.2
66
121
  def invalid_south_african_id_number
67
122
  invalid_date_of_birth = [
68
123
  Faker::Number.number(digits: 2),
@@ -80,6 +135,17 @@ module Faker
80
135
  [id_number, south_african_id_checksum_digit(id_number)].join
81
136
  end
82
137
 
138
+ ##
139
+ # Produces a random Brazilian Citizen Number (CPF).
140
+ #
141
+ # @param formatted [Boolean] Specifies if the number is formatted with dividers.
142
+ # @return [String]
143
+ #
144
+ # @example
145
+ # Faker::IDNumber.brazilian_citizen_number #=> "53540542221"
146
+ # Faker::IDNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21"
147
+ #
148
+ # @faker.version 1.9.2
83
149
  def brazilian_citizen_number(legacy_formatted = NOT_GIVEN, formatted: false)
84
150
  warn_for_deprecated_arguments do |keywords|
85
151
  keywords << :formatted if legacy_formatted != NOT_GIVEN
@@ -94,6 +160,17 @@ module Faker
94
160
 
95
161
  alias brazilian_cpf brazilian_citizen_number
96
162
 
163
+ ##
164
+ # Produces a random Brazilian ID Number (RG).
165
+ #
166
+ # @param formatted [Boolean] Specifies if the number is formatted with dividers.
167
+ # @return [String]
168
+ #
169
+ # @example
170
+ # Faker::IDNumber.brazilian_id #=> "493054029"
171
+ # Faker::IDNumber.brazilian_id(formatted: true) #=> "49.305.402-9"
172
+ #
173
+ # @faker.version 2.1.2
97
174
  def brazilian_id(legacy_formatted = NOT_GIVEN, formatted: false)
98
175
  warn_for_deprecated_arguments do |keywords|
99
176
  keywords << :formatted if legacy_formatted != NOT_GIVEN
@@ -107,15 +184,58 @@ module Faker
107
184
 
108
185
  alias brazilian_rg brazilian_id
109
186
 
187
+ ##
188
+ # Produces a random Chilean ID (Rut with 8 digits).
189
+ #
190
+ # @return [String]
191
+ #
192
+ # @example
193
+ # Faker::IDNumber.chilean_id #=> "15620613-K"
194
+ #
195
+ # @faker.version 2.1.2
110
196
  def chilean_id
111
197
  digits = Faker::Number.number(digits: 8)
112
198
  verification_code = chilean_verification_code(digits)
113
199
 
114
- digits.to_s + '-' + verification_code.to_s
200
+ "#{digits}-#{verification_code}"
201
+ end
202
+
203
+ ##
204
+ # Produces a random Croatian ID number (OIB).
205
+ #
206
+ # @param international [Boolean] Specifies whether to add international prefix.
207
+ # @return [String]
208
+ #
209
+ # @example
210
+ # Faker::IDNumber.croatian_id #=> "88467617508"
211
+ # Faker::IDNumber.croatian_id(international: true) #=> "HR88467617508"
212
+ #
213
+ # @faker.version next
214
+ def croatian_id(international: false)
215
+ prefix = international ? 'HR' : ''
216
+ digits = Faker::Number.number(digits: 10).to_s
217
+ checksum_digit = croatian_id_checksum_digit(digits)
218
+
219
+ "#{prefix}#{digits}#{checksum_digit}"
115
220
  end
116
221
 
117
222
  private
118
223
 
224
+ def croatian_id_checksum_digit(digits)
225
+ control_sum = 10
226
+
227
+ digits.chars.map(&:to_i).each do |digit|
228
+ control_sum += digit
229
+ control_sum %= 10
230
+ control_sum = 10 if control_sum.zero?
231
+ control_sum *= 2
232
+ control_sum %= 11
233
+ end
234
+
235
+ control_sum = 11 - control_sum
236
+ control_sum % 10
237
+ end
238
+
119
239
  def chilean_verification_code(digits)
120
240
  # First digit is multiplied by 3, second by 2, and so on
121
241
  multiplication_rule = [3, 2, 7, 6, 5, 4, 3, 2]
@@ -170,7 +290,7 @@ module Faker
170
290
  end * 10
171
291
  end
172
292
 
173
- def brazilian_document_digit(checksum, id = false)
293
+ def brazilian_document_digit(checksum, id: false)
174
294
  remainder = checksum % 11
175
295
  id ? brazilian_id_digit(remainder) : brazilian_citizen_number_digit(remainder)
176
296
  end