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
@@ -18,17 +18,10 @@ module Faker
18
18
  # rubocop:disable Metrics/ParameterLists
19
19
  def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 9).to_s)
20
20
  # rubocop:enable Metrics/ParameterLists
21
- if legacy_name != NOT_GIVEN
22
- warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.google` is deprecated. Use keyword argument like `Omniauth.google(name: ...)` instead.', uplevel: 1
23
- name = legacy_name
24
- end
25
- if legacy_email != NOT_GIVEN
26
- warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.google` is deprecated. Use keyword argument like `Omniauth.google(email: ...)` instead.', uplevel: 1
27
- email = legacy_email
28
- end
29
- if legacy_uid != NOT_GIVEN
30
- warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.google` is deprecated. Use keyword argument like `Omniauth.google(uid: ...)` instead.', uplevel: 1
31
- uid = legacy_uid
21
+ warn_for_deprecated_arguments do |keywords|
22
+ keywords << :name if legacy_name != NOT_GIVEN
23
+ keywords << :email if legacy_email != NOT_GIVEN
24
+ keywords << :uid if legacy_uid != NOT_GIVEN
32
25
  end
33
26
 
34
27
  auth = Omniauth.new(name: name, email: email)
@@ -42,7 +35,7 @@ module Faker
42
35
  email: auth.email,
43
36
  image: image
44
37
  },
45
- credentials: {
38
+ credentials: {
46
39
  token: Crypto.md5,
47
40
  refresh_token: Crypto.md5,
48
41
  expires_at: Time.forward.to_i,
@@ -50,7 +43,7 @@ module Faker
50
43
  },
51
44
  extra: {
52
45
  raw_info: {
53
- sub: uid,
46
+ sub: uid,
54
47
  email: auth.email,
55
48
  email_verified: random_boolean.to_s,
56
49
  name: auth.name,
@@ -82,21 +75,11 @@ module Faker
82
75
  # rubocop:disable Metrics/ParameterLists
83
76
  def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
84
77
  # rubocop:enable Metrics/ParameterLists
85
- if legacy_name != NOT_GIVEN
86
- warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(name: ...)` instead.', uplevel: 1
87
- name = legacy_name
88
- end
89
- if legacy_email != NOT_GIVEN
90
- warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(email: ...)` instead.', uplevel: 1
91
- email = legacy_email
92
- end
93
- if legacy_username != NOT_GIVEN
94
- warn_with_uplevel 'Passing `username` with the 3rd argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(username: ...)` instead.', uplevel: 1
95
- username = legacy_username
96
- end
97
- if legacy_uid != NOT_GIVEN
98
- warn_with_uplevel 'Passing `uid` with the 4th argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(uid: ...)` instead.', uplevel: 1
99
- uid = legacy_uid
78
+ warn_for_deprecated_arguments do |keywords|
79
+ keywords << :name if legacy_name != NOT_GIVEN
80
+ keywords << :email if legacy_email != NOT_GIVEN
81
+ keywords << :username if legacy_username != NOT_GIVEN
82
+ keywords << :uid if legacy_uid != NOT_GIVEN
100
83
  end
101
84
 
102
85
  auth = Omniauth.new(name: name, email: email)
@@ -143,17 +126,10 @@ module Faker
143
126
  # rubocop:disable Metrics/ParameterLists
144
127
  def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
145
128
  # rubocop:enable Metrics/ParameterLists
146
- if legacy_name != NOT_GIVEN
147
- warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.twitter` is deprecated. Use keyword argument like `Omniauth.twitter(name: ...)` instead.', uplevel: 1
148
- name = legacy_name
149
- end
150
- if legacy_nickname != NOT_GIVEN
151
- warn_with_uplevel 'Passing `nickname` with the 2nd argument of `Omniauth.twitter` is deprecated. Use keyword argument like `Omniauth.twitter(nickname: ...)` instead.', uplevel: 1
152
- nickname = legacy_nickname
153
- end
154
- if legacy_uid != NOT_GIVEN
155
- warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.twitter` is deprecated. Use keyword argument like `Omniauth.twitter(uid: ...)` instead.', uplevel: 1
156
- uid = legacy_uid
129
+ warn_for_deprecated_arguments do |keywords|
130
+ keywords << :name if legacy_name != NOT_GIVEN
131
+ keywords << :nickname if legacy_nickname != NOT_GIVEN
132
+ keywords << :uid if legacy_uid != NOT_GIVEN
157
133
  end
158
134
 
159
135
  auth = Omniauth.new(name: name)
@@ -231,17 +207,10 @@ module Faker
231
207
  # rubocop:disable Metrics/ParameterLists
232
208
  def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 6).to_s)
233
209
  # rubocop:enable Metrics/ParameterLists
234
- if legacy_name != NOT_GIVEN
235
- warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.linkedin` is deprecated. Use keyword argument like `Omniauth.linkedin(name: ...)` instead.', uplevel: 1
236
- name = legacy_name
237
- end
238
- if legacy_email != NOT_GIVEN
239
- warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.linkedin` is deprecated. Use keyword argument like `Omniauth.linkedin(email: ...)` instead.', uplevel: 1
240
- email = legacy_email
241
- end
242
- if legacy_uid != NOT_GIVEN
243
- warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.linkedin` is deprecated. Use keyword argument like `Omniauth.linkedin(uid: ...)` instead.', uplevel: 1
244
- uid = legacy_uid
210
+ warn_for_deprecated_arguments do |keywords|
211
+ keywords << :name if legacy_name != NOT_GIVEN
212
+ keywords << :email if legacy_email != NOT_GIVEN
213
+ keywords << :uid if legacy_uid != NOT_GIVEN
245
214
  end
246
215
 
247
216
  auth = Omniauth.new(name: name, email: email)
@@ -309,17 +278,10 @@ module Faker
309
278
  # rubocop:disable Metrics/ParameterLists
310
279
  def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 8).to_s)
311
280
  # rubocop:enable Metrics/ParameterLists
312
- if legacy_name != NOT_GIVEN
313
- warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.github` is deprecated. Use keyword argument like `Omniauth.github(name: ...)` instead.', uplevel: 1
314
- name = legacy_name
315
- end
316
- if legacy_email != NOT_GIVEN
317
- warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.github` is deprecated. Use keyword argument like `Omniauth.github(email: ...)` instead.', uplevel: 1
318
- email = legacy_email
319
- end
320
- if legacy_uid != NOT_GIVEN
321
- warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.github` is deprecated. Use keyword argument like `Omniauth.github(uid: ...)` instead.', uplevel: 1
322
- uid = legacy_uid
281
+ warn_for_deprecated_arguments do |keywords|
282
+ keywords << :name if legacy_name != NOT_GIVEN
283
+ keywords << :email if legacy_email != NOT_GIVEN
284
+ keywords << :uid if legacy_uid != NOT_GIVEN
323
285
  end
324
286
 
325
287
  auth = Omniauth.new(name: name, email: email)
@@ -340,7 +302,7 @@ module Faker
340
302
  },
341
303
  credentials: {
342
304
  token: Crypto.md5,
343
- expires: false
305
+ expires: false
344
306
  },
345
307
  extra: {
346
308
  raw_info: {
@@ -360,7 +322,7 @@ module Faker
360
322
  events_url: "#{api_url}/events{/privacy}",
361
323
  received_events_url: "#{api_url}/received_events",
362
324
  type: 'User',
363
- site_admin: random_boolean,
325
+ site_admin: random_boolean,
364
326
  name: auth.name,
365
327
  company: nil,
366
328
  blog: nil,
@@ -379,6 +341,48 @@ module Faker
379
341
  }
380
342
  end
381
343
 
344
+ ##
345
+ # Generate a mock Omniauth response from Apple
346
+ #
347
+ # @param name [String] A specific name to return in the response
348
+ # @param email [String] A specific email to return in the response
349
+ # @param uid [String] A specific UID to return in the response
350
+ #
351
+ # @return [Hash] An auth hash in the format provided by omniauth-apple
352
+ def apple(name: nil, email: nil, uid: nil)
353
+ uid ||= "#{Number.number(digits: 6)}.#{Number.hexadecimal(digits: 32)}.#{Number.number(digits: 4)}"
354
+ auth = Omniauth.new(name: name, email: email)
355
+ {
356
+ provider: 'apple',
357
+ uid: uid,
358
+ info: {
359
+ sub: uid,
360
+ email: auth.email,
361
+ first_name: auth.first_name,
362
+ last_name: auth.last_name
363
+ },
364
+ credentials: {
365
+ token: Crypto.md5,
366
+ refresh_token: Crypto.md5,
367
+ expires_at: Time.forward.to_i,
368
+ expires: true
369
+ },
370
+ extra: {
371
+ raw_info: {
372
+ iss: 'https://appleid.apple.com',
373
+ aud: 'CLIENT_ID',
374
+ exp: Time.forward.to_i,
375
+ iat: Time.forward.to_i,
376
+ sub: uid,
377
+ at_hash: Crypto.md5,
378
+ auth_time: Time.forward.to_i,
379
+ email: auth.email,
380
+ email_verified: true
381
+ }
382
+ }
383
+ }
384
+ end
385
+
382
386
  private
383
387
 
384
388
  def gender
@@ -41,9 +41,8 @@ module Faker
41
41
  # Can be used for both extensions and last four digits of phone number.
42
42
  # Since extensions can be of variable length, this method taks a length parameter
43
43
  def subscriber_number(legacy_length = NOT_GIVEN, length: 4)
44
- if legacy_length != NOT_GIVEN
45
- warn_with_uplevel 'Passing `length` with the 1st argument of `PhoneNumber.subscriber_number` is deprecated. Use keyword argument like `PhoneNumber.subscriber_number(length: ...)` instead.', uplevel: 1
46
- length = legacy_length
44
+ warn_for_deprecated_arguments do |keywords|
45
+ keywords << :length if legacy_length != NOT_GIVEN
47
46
  end
48
47
 
49
48
  rand.to_s[2..(1 + length)]
@@ -8,25 +8,12 @@ module Faker
8
8
  # rubocop:disable Metrics/ParameterLists
9
9
  def image(legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_background_color = NOT_GIVEN, legacy_text_color = NOT_GIVEN, legacy_text = NOT_GIVEN, size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
10
10
  # rubocop:enable Metrics/ParameterLists
11
- if legacy_size != NOT_GIVEN
12
- warn_with_uplevel 'Passing `size` with the 1st argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(size: ...)` instead.', uplevel: 1
13
- size = legacy_size
14
- end
15
- if legacy_format != NOT_GIVEN
16
- warn_with_uplevel 'Passing `format` with the 2nd argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(format: ...)` instead.', uplevel: 1
17
- format = legacy_format
18
- end
19
- if legacy_background_color != NOT_GIVEN
20
- warn_with_uplevel 'Passing `background_color` with the 3rd argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(background_color: ...)` instead.', uplevel: 1
21
- background_color = legacy_background_color
22
- end
23
- if legacy_text_color != NOT_GIVEN
24
- warn_with_uplevel 'Passing `text_color` with the 4th argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(text_color: ...)` instead.', uplevel: 1
25
- text_color = legacy_text_color
26
- end
27
- if legacy_text != NOT_GIVEN
28
- warn_with_uplevel 'Passing `text` with the 5th argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(text: ...)` instead.', uplevel: 1
29
- text = legacy_text
11
+ warn_for_deprecated_arguments do |keywords|
12
+ keywords << :size if legacy_size != NOT_GIVEN
13
+ keywords << :format if legacy_format != NOT_GIVEN
14
+ keywords << :background_color if legacy_background_color != NOT_GIVEN
15
+ keywords << :text_color if legacy_text_color != NOT_GIVEN
16
+ keywords << :text if legacy_text != NOT_GIVEN
30
17
  end
31
18
 
32
19
  background_color = generate_color if background_color == :random
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class ProgrammingLanguage < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of a programming language.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::ProgrammingLanguage.name #=> "Ruby"
13
+ #
14
+ # @faker.version 1.8.5
6
15
  def name
7
16
  fetch('programming_language.name')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces the name of a programming language's creator.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::ProgrammingLanguage.creator #=> "Yukihiro Matsumoto"
26
+ #
27
+ # @faker.version 1.8.5
10
28
  def creator
11
29
  fetch('programming_language.creator')
12
30
  end
@@ -6,9 +6,8 @@ module Faker
6
6
 
7
7
  class << self
8
8
  def familial(legacy_connection = NOT_GIVEN, connection: nil)
9
- if legacy_connection != NOT_GIVEN
10
- warn_with_uplevel 'Passing `connection` with the 1st argument of `Relationship.familial` is deprecated. Use keyword argument like `Relationship.familial(connection: ...)` instead.', uplevel: 1
11
- connection = legacy_connection
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :connection if legacy_connection != NOT_GIVEN
12
11
  end
13
12
 
14
13
  familial_connections = translate('faker.relationship.familial').keys
@@ -4,8 +4,60 @@ module Faker
4
4
  class Restaurant < Base
5
5
  flexible :restaurant
6
6
 
7
- def self.name
8
- bothify(parse('restaurant.name'))
7
+ class << self
8
+ ##
9
+ # Produces the name of a restaurant.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Restaurant.name #=> "Curry King"
15
+ #
16
+ # @faker.version 1.9.2
17
+ def name
18
+ bothify(parse('restaurant.name'))
19
+ end
20
+
21
+ ##
22
+ # Produces a type of restaurant.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Restaurant.type #=> "Comfort Food"
28
+ #
29
+ # @faker.version 1.9.2
30
+ def type
31
+ fetch('restaurant.type')
32
+ end
33
+
34
+ ##
35
+ # Produces a description of a restaurant.
36
+ #
37
+ # @return [String]
38
+ #
39
+ # @example
40
+ # Faker::Restaurant.description
41
+ # #=> "We are committed to using the finest ingredients in our recipes. No food leaves our kitchen that we ourselves would not eat."
42
+ #
43
+ # @faker.version 1.9.2
44
+ def description
45
+ fetch('restaurant.description')
46
+ end
47
+
48
+ ##
49
+ # Produces a review for a restaurant.
50
+ #
51
+ # @return [String]
52
+ #
53
+ # @example
54
+ # Faker::Restaurant.review
55
+ # #=> "Brand new. Great design. Odd to hear pop music in a Mexican establishment. Music is a bit loud. It should be background."
56
+ #
57
+ # @faker.version 1.9.2
58
+ def review
59
+ fetch('restaurant.review')
60
+ end
9
61
  end
10
62
  end
11
63
  end
@@ -3,14 +3,41 @@
3
3
  module Faker
4
4
  class Science < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of a element.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Science.element #=> "Carbon"
13
+ #
14
+ # @faker.version 1.8.5
6
15
  def element
7
16
  fetch('science.element')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces the symbol of an element.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Science.element_symbol #=> "Pb"
26
+ #
27
+ # @faker.version 1.9.0
10
28
  def element_symbol
11
29
  fetch('science.element_symbol')
12
30
  end
13
31
 
32
+ ##
33
+ # Produces the name of a scientist.
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::Science.scientist #=> "Isaac Newton"
39
+ #
40
+ # @faker.version 1.8.5
14
41
  def scientist
15
42
  fetch('science.scientist')
16
43
  end
@@ -3,35 +3,72 @@
3
3
  module Faker
4
4
  class Source < Base
5
5
  class << self
6
+ ##
7
+ # Produces source code for Hello World in a given language.
8
+ #
9
+ # @param lang [Symbol] The programming language to use
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # Faker::Source.hello_world #=> "puts 'Hello World!'"
14
+ #
15
+ # @example
16
+ # Faker::Source.hello_world(lang: :javascript)
17
+ # #=> "alert('Hello World!');"
18
+ #
19
+ # @faker.version 1.9.0
6
20
  def hello_world(legacy_lang = NOT_GIVEN, lang: :ruby)
7
- if legacy_lang != NOT_GIVEN
8
- warn_with_uplevel 'Passing `lang` with the 1st argument of `Source.hello_world` is deprecated. Use keyword argument like `Source.hello_world(lang: ...)` instead.', uplevel: 1
9
- lang = legacy_lang
21
+ warn_for_deprecated_arguments do |keywords|
22
+ keywords << :lang if legacy_lang != NOT_GIVEN
10
23
  end
11
24
 
12
25
  fetch("source.hello_world.#{lang}")
13
26
  end
14
27
 
28
+ ##
29
+ # Produces source code for printing a string in a given language.
30
+ #
31
+ # @param str [String] The string to print
32
+ # @param lang [Symbol] The programming language to use
33
+ # @return [String]
34
+ #
35
+ # @example
36
+ # Faker::Source.print #=> "puts 'faker_string_to_print'"
37
+ # @example
38
+ # Faker::Source.print(str: 'foo bar', lang: :javascript)
39
+ # #=> "console.log('foo bar');"
40
+ #
41
+ # @faker.version 1.9.0
15
42
  def print(legacy_str = NOT_GIVEN, legacy_lang = NOT_GIVEN, str: 'some string', lang: :ruby)
16
- if legacy_str != NOT_GIVEN
17
- warn_with_uplevel 'Passing `str` with the 1st argument of `Source.print` is deprecated. Use keyword argument like `Source.print(str: ...)` instead.', uplevel: 1
18
- str = legacy_str
43
+ warn_for_deprecated_arguments do |keywords|
44
+ keywords << :str if legacy_str != NOT_GIVEN
19
45
  end
20
- if legacy_lang != NOT_GIVEN
21
- warn_with_uplevel 'Passing `lang` with the 2nd argument of `Source.print` is deprecated. Use keyword argument like `Source.print(lang: ...)` instead.', uplevel: 1
22
- lang = legacy_lang
46
+ warn_for_deprecated_arguments do |keywords|
47
+ keywords << :lang if legacy_lang != NOT_GIVEN
23
48
  end
24
-
25
49
  code = fetch("source.print.#{lang}")
26
50
  code.gsub('faker_string_to_print', str)
27
51
  end
28
52
 
53
+ ##
54
+ # Produces source code for printing 1 through 10 in a given language.
55
+ #
56
+ # @param lang [Symbol] The programming language to use
57
+ # @return [String]
58
+ #
59
+ # @example
60
+ # Faker::Source.print_1_to_10 #=> "(1..10).each { |i| puts i }"
61
+ # @example
62
+ # Faker::Source.print_1_to_10(lang: :javascript)
63
+ # # => "for (let i=0; i<10; i++) {
64
+ # # console.log(i);
65
+ # # }"
66
+ #
67
+ # @faker.version 1.9.0
29
68
  def print_1_to_10(legacy_lang = NOT_GIVEN, lang: :ruby)
30
- if legacy_lang != NOT_GIVEN
31
- warn_with_uplevel 'Passing `lang` with the 1st argument of `Source.print_1_to_10` is deprecated. Use keyword argument like `Source.print_1_to_10(lang: ...)` instead.', uplevel: 1
32
- lang = legacy_lang
69
+ warn_for_deprecated_arguments do |keywords|
70
+ keywords << :lang if legacy_lang != NOT_GIVEN
33
71
  end
34
-
35
72
  fetch("source.print_1_to_10.#{lang}")
36
73
  end
37
74
  end