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
@@ -4,9 +4,8 @@ module Faker
4
4
  class String < Base
5
5
  class << self
6
6
  def random(legacy_length = NOT_GIVEN, length: 32)
7
- if legacy_length != NOT_GIVEN
8
- warn_with_uplevel 'Passing `length` with the 1st argument of `String.random` is deprecated. Use keyword argument like `String.random(length: ...)` instead.', uplevel: 1
9
- length = legacy_length
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :length if legacy_length != NOT_GIVEN
10
9
  end
11
10
 
12
11
  utf8string select_a length
@@ -4,9 +4,8 @@ module Faker
4
4
  class Stripe < Base
5
5
  class << self
6
6
  def valid_card(legacy_card_type = NOT_GIVEN, card_type: nil)
7
- if legacy_card_type != NOT_GIVEN
8
- warn_with_uplevel 'Passing `card_type` with the 1st argument of `Stripe.valid_card` is deprecated. Use keyword argument like `Stripe.valid_card(card_type: ...)` instead.', uplevel: 1
9
- card_type = legacy_card_type
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :card_type if legacy_card_type != NOT_GIVEN
10
9
  end
11
10
 
12
11
  valid_cards = translate('faker.stripe.valid_cards').keys
@@ -24,9 +23,8 @@ module Faker
24
23
  end
25
24
 
26
25
  def valid_token(legacy_card_type = NOT_GIVEN, card_type: nil)
27
- if legacy_card_type != NOT_GIVEN
28
- warn_with_uplevel 'Passing `card_type` with the 1st argument of `Stripe.valid_token` is deprecated. Use keyword argument like `Stripe.valid_token(card_type: ...)` instead.', uplevel: 1
29
- card_type = legacy_card_type
26
+ warn_for_deprecated_arguments do |keywords|
27
+ keywords << :card_type if legacy_card_type != NOT_GIVEN
30
28
  end
31
29
 
32
30
  valid_tokens = translate('faker.stripe.valid_tokens').keys
@@ -44,9 +42,8 @@ module Faker
44
42
  end
45
43
 
46
44
  def invalid_card(legacy_card_error = NOT_GIVEN, card_error: nil)
47
- if legacy_card_error != NOT_GIVEN
48
- warn_with_uplevel 'Passing `card_error` with the 1st argument of `Stripe.invalid_card` is deprecated. Use keyword argument like `Stripe.invalid_card(card_error: ...)` instead.', uplevel: 1
49
- card_error = legacy_card_error
45
+ warn_for_deprecated_arguments do |keywords|
46
+ keywords << :card_error if legacy_card_error != NOT_GIVEN
50
47
  end
51
48
 
52
49
  invalid_cards = translate('faker.stripe.invalid_cards').keys
@@ -73,9 +70,8 @@ module Faker
73
70
  end
74
71
 
75
72
  def ccv(legacy_card_type = NOT_GIVEN, card_type: nil)
76
- if legacy_card_type != NOT_GIVEN
77
- warn_with_uplevel 'Passing `card_type` with the 1st argument of `Stripe.ccv` is deprecated. Use keyword argument like `Stripe.ccv(card_type: ...)` instead.', uplevel: 1
78
- card_type = legacy_card_type
73
+ warn_for_deprecated_arguments do |keywords|
74
+ keywords << :card_type if legacy_card_type != NOT_GIVEN
79
75
  end
80
76
 
81
77
  (card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s
@@ -2,22 +2,67 @@
2
2
 
3
3
  module Faker
4
4
  class Subscription < Base
5
+ ##
6
+ # Produces the name of a subscription plan.
7
+ #
8
+ # @return [String]
9
+ #
10
+ # @example
11
+ # Faker::Subscription.plan #=> "Platinum"
12
+ #
13
+ # @faker.version 1.9.2
5
14
  def self.plan
6
15
  fetch('subscription.plans')
7
16
  end
8
17
 
18
+ ##
19
+ # Produces a subscription status.
20
+ #
21
+ # @return [String]
22
+ #
23
+ # @example
24
+ # Faker::Subscription.status #=> "Active"
25
+ #
26
+ # @faker.version 1.9.2
9
27
  def self.status
10
28
  fetch('subscription.statuses')
11
29
  end
12
30
 
31
+ ##
32
+ # Produces the name of a payment method.
33
+ #
34
+ # @return [String]
35
+ #
36
+ # @example
37
+ # Faker::Subscription.payment_method #=> "PayPal"
38
+ #
39
+ # @faker.version 1.9.2
13
40
  def self.payment_method
14
41
  fetch('subscription.payment_methods')
15
42
  end
16
43
 
44
+ ##
45
+ # Produces the name of a subscription term.
46
+ #
47
+ # @return [String]
48
+ #
49
+ # @example
50
+ # Faker::Subscription.subscription_term #=> "Annual"
51
+ #
52
+ # @faker.version 1.9.2
17
53
  def self.subscription_term
18
54
  fetch('subscription.subscription_terms')
19
55
  end
20
56
 
57
+ ##
58
+ # Produces the name of a payment term.
59
+ #
60
+ # @return [String]
61
+ #
62
+ # @example
63
+ # Faker::Subscription.payment_term #=> "Monthly"
64
+ #
65
+ # @faker.version 1.9.2
21
66
  def self.payment_term
22
67
  fetch('subscription.payment_terms')
23
68
  end
@@ -3,22 +3,67 @@
3
3
  module Faker
4
4
  class Superhero < Base
5
5
  class << self
6
+ ##
7
+ # Produces a superpower.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Superhero.power #=> "Photokinesis"
13
+ #
14
+ # @faker.version 1.6.2
6
15
  def power
7
16
  fetch('superhero.power')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces a superhero name prefix.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Superhero.prefix #=> "the Fated"
26
+ #
27
+ # @faker.version 1.6.2
10
28
  def prefix
11
29
  fetch('superhero.prefix')
12
30
  end
13
31
 
32
+ ##
33
+ # Produces a superhero name suffix.
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::Superhero.suffix #=> "Captain"
39
+ #
40
+ # @faker.version 1.6.2
14
41
  def suffix
15
42
  fetch('superhero.suffix')
16
43
  end
17
44
 
45
+ ##
46
+ # Produces a superhero descriptor.
47
+ #
48
+ # @return [String]
49
+ #
50
+ # @example
51
+ # Faker::Superhero.descriptor #=> "Bizarro"
52
+ #
53
+ # @faker.version 1.6.2
18
54
  def descriptor
19
55
  fetch('superhero.descriptor')
20
56
  end
21
57
 
58
+ ##
59
+ # Produces a random superhero name.
60
+ #
61
+ # @return [String]
62
+ #
63
+ # @example
64
+ # Faker::Superhero.name #=> "Magnificent Shatterstar"
65
+ #
66
+ # @faker.version 1.6.2
22
67
  def name
23
68
  parse('superhero.name')
24
69
  end
@@ -14,19 +14,35 @@ module Faker
14
14
 
15
15
  class << self
16
16
  # rubocop:disable Metrics/ParameterLists
17
+ # rubocop:disable Style/AsciiComments
18
+
19
+ ##
20
+ # Produce a random time between two times.
21
+ #
22
+ # @param from [Time, Date, DateTime] The start of the usable time range.
23
+ # @param to [Time, Date, DateTime] The end of the usable time range.
24
+ # @param format [Symbol] The name of a DateTime format to use.
25
+ # @return [Time]
26
+ #
27
+ # @example
28
+ # # Random Stringified time between two times, formatted to the specified I18n format
29
+ # # (Examples are from a Rails console with rails-i18n 5.1.1 defaults loaded)
30
+ # I18n.locale = 'en-US'
31
+ # Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :default) #=> "Tue, 16 Oct 2018 10:48:27 AM -05:00"
32
+ # Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :short) #=> "15 Oct 10:48 AM"
33
+ # Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :long) #=> "October 15, 2018 10:48 AM"
34
+ #
35
+ # I18n.locale = 'ja'
36
+ # Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :default) #=> "2018/10/15 10:48:27"
37
+ # Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :short) #=> "18/10/15 10:48"
38
+ # Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :long) #=> "2018年10月16日(火) 10時48分27秒 -0500"
39
+ #
40
+ # @faker.version 1.5.0
17
41
  def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, format: nil)
18
- # rubocop:enable Metrics/ParameterLists
19
- if legacy_from != NOT_GIVEN
20
- warn_with_uplevel 'Passing `from` with the 1st argument of `Time.between` is deprecated. Use keyword argument like `Time.between(from: ...)` instead.', uplevel: 1
21
- from = legacy_from
22
- end
23
- if legacy_to != NOT_GIVEN
24
- warn_with_uplevel 'Passing `to` with the 2nd argument of `Time.between` is deprecated. Use keyword argument like `Time.between(to: ...)` instead.', uplevel: 1
25
- to = legacy_to
26
- end
27
- if legacy_format != NOT_GIVEN
28
- warn_with_uplevel 'Passing `format` with the 3rd argument of `Time.between` is deprecated. Use keyword argument like `Time.between(format: ...)` instead.', uplevel: 1
29
- format = legacy_format
42
+ warn_for_deprecated_arguments do |keywords|
43
+ keywords << :from if legacy_from != NOT_GIVEN
44
+ keywords << :to if legacy_to != NOT_GIVEN
45
+ keywords << :format if legacy_format != NOT_GIVEN
30
46
  end
31
47
 
32
48
  from = get_time_object(from)
@@ -35,25 +51,42 @@ module Faker
35
51
  time = Faker::Base.rand_in_range(from, to)
36
52
  time_with_format(time, format)
37
53
  end
38
-
39
- # rubocop:disable Metrics/ParameterLists
54
+ # rubocop:enable Style/AsciiComments
55
+
56
+ ##
57
+ # Produce a random time between two dates.
58
+ #
59
+ # @param from [Date] The start of the usable time range.
60
+ # @param to [Date] The end of the usable time range.
61
+ # @param period [Symbol] The time of day, if any. See {TIME_RANGES}.
62
+ # @param format [Symbol] The name of a DateTime format to use.
63
+ # @return [Time]
64
+ #
65
+ # @example
66
+ # Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :all)
67
+ # #=> "2014-09-19 07:03:30 -0700"
68
+ # Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :day)
69
+ # #=> "2014-09-18 16:28:13 -0700"
70
+ # Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :night)
71
+ # #=> "2014-09-20 19:39:38 -0700"
72
+ # Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :morning)
73
+ # #=> "2014-09-19 08:07:52 -0700"
74
+ # Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :afternoon)
75
+ # #=> "2014-09-18 12:10:34 -0700"
76
+ # Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :evening)
77
+ # #=> "2014-09-19 20:21:03 -0700"
78
+ # Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :midnight)
79
+ # #=> "2014-09-20 00:40:14 -0700"
80
+ # Faker::Time.between_dates(from: Date.today - 5, to: Date.today + 5, period: :afternoon, format: :default)
81
+ # #=> "Fri, 19 Oct 2018 15:17:46 -0500"
82
+ #
83
+ # @faker.version 1.0.0
40
84
  def between_dates(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, period: :all, format: nil)
41
- # rubocop:enable Metrics/ParameterLists
42
- if legacy_from != NOT_GIVEN
43
- warn_with_uplevel 'Passing `from` with the 1st argument of `Time.between_dates` is deprecated. Use keyword argument like `Time.between_dates(from: ...)` instead.', uplevel: 1
44
- from = legacy_from
45
- end
46
- if legacy_to != NOT_GIVEN
47
- warn_with_uplevel 'Passing `to` with the 2nd argument of `Time.between_dates` is deprecated. Use keyword argument like `Time.between_dates(to: ...)` instead.', uplevel: 1
48
- to = legacy_to
49
- end
50
- if legacy_period != NOT_GIVEN
51
- warn_with_uplevel 'Passing `period` with the 3rd argument of `Time.between_dates` is deprecated. Use keyword argument like `Time.between_dates(period: ...)` instead.', uplevel: 1
52
- period = legacy_period
53
- end
54
- if legacy_format != NOT_GIVEN
55
- warn_with_uplevel 'Passing `format` with the 4th argument of `Time.between_dates` is deprecated. Use keyword argument like `Time.between_dates(format: ...)` instead.', uplevel: 1
56
- format = legacy_format
85
+ warn_for_deprecated_arguments do |keywords|
86
+ keywords << :from if legacy_from != NOT_GIVEN
87
+ keywords << :to if legacy_to != NOT_GIVEN
88
+ keywords << :period if legacy_period != NOT_GIVEN
89
+ keywords << :format if legacy_format != NOT_GIVEN
57
90
  end
58
91
 
59
92
  date = Faker::Date.between(from: from, to: to)
@@ -61,43 +94,56 @@ module Faker
61
94
  time_with_format(time, format)
62
95
  end
63
96
 
64
- # rubocop:disable Metrics/ParameterLists
97
+ ##
98
+ # Produce a random time in the future (up to N days).
99
+ #
100
+ # @param days [Integer] The maximum number of days to go into the future.
101
+ # @param period [Symbol] The time of day, if any. See {TIME_RANGES}.
102
+ # @param format [Symbol] The name of a DateTime format to use.
103
+ # @return [Time]
104
+ #
105
+ # @example
106
+ # Faker::Time.forward(days: 23, period: :morning)
107
+ # # => "2014-09-26 06:54:47 -0700"
108
+ # Faker::Time.forward(days: 5, period: :evening, format: :long)
109
+ # #=> "October 21, 2018 20:47"
110
+ #
111
+ # @faker.version 1.5.0
65
112
  def forward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
66
- # rubocop:enable Metrics/ParameterLists
67
- if legacy_days != NOT_GIVEN
68
- warn_with_uplevel 'Passing `days` with the 1st argument of `Time.forward` is deprecated. Use keyword argument like `Time.forward(days: ...)` instead.', uplevel: 1
69
- days = legacy_days
70
- end
71
- if legacy_period != NOT_GIVEN
72
- warn_with_uplevel 'Passing `period` with the 2nd argument of `Time.forward` is deprecated. Use keyword argument like `Time.forward(period: ...)` instead.', uplevel: 1
73
- period = legacy_period
74
- end
75
- if legacy_format != NOT_GIVEN
76
- warn_with_uplevel 'Passing `format` with the 3rd argument of `Time.forward` is deprecated. Use keyword argument like `Time.forward(format: ...)` instead.', uplevel: 1
77
- format = legacy_format
113
+ warn_for_deprecated_arguments do |keywords|
114
+ keywords << :days if legacy_days != NOT_GIVEN
115
+ keywords << :period if legacy_period != NOT_GIVEN
116
+ keywords << :format if legacy_format != NOT_GIVEN
78
117
  end
79
118
 
80
119
  time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format)
81
120
  end
82
121
 
83
- # rubocop:disable Metrics/ParameterLists
122
+ ##
123
+ # Produce a random time in the past (up to N days).
124
+ #
125
+ # @param days [Integer] The maximum number of days to go into the past.
126
+ # @param period [Symbol] The time of day, if any. See {TIME_RANGES}.
127
+ # @param format [Symbol] The name of a DateTime format to use.
128
+ # @return [Time]
129
+ #
130
+ # @example
131
+ # Faker::Time.backward(days: 14, period: :evening)
132
+ # #=> "2014-09-17 19:56:33 -0700"
133
+ # Faker::Time.backward(days: 5, period: :morning, format: :short)
134
+ # #=> "14 Oct 07:44"
135
+ #
136
+ # @faker.version 1.5.0
84
137
  def backward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
85
- # rubocop:enable Metrics/ParameterLists
86
- if legacy_days != NOT_GIVEN
87
- warn_with_uplevel 'Passing `days` with the 1st argument of `Time.backward` is deprecated. Use keyword argument like `Time.backward(days: ...)` instead.', uplevel: 1
88
- days = legacy_days
89
- end
90
- if legacy_period != NOT_GIVEN
91
- warn_with_uplevel 'Passing `period` with the 2nd argument of `Time.backward` is deprecated. Use keyword argument like `Time.backward(period: ...)` instead.', uplevel: 1
92
- period = legacy_period
93
- end
94
- if legacy_format != NOT_GIVEN
95
- warn_with_uplevel 'Passing `format` with the 3rd argument of `Time.backward` is deprecated. Use keyword argument like `Time.backward(format: ...)` instead.', uplevel: 1
96
- format = legacy_format
138
+ warn_for_deprecated_arguments do |keywords|
139
+ keywords << :days if legacy_days != NOT_GIVEN
140
+ keywords << :period if legacy_period != NOT_GIVEN
141
+ keywords << :format if legacy_format != NOT_GIVEN
97
142
  end
98
143
 
99
144
  time_with_format(date_with_random_time(Faker::Date.backward(days: days), period), format)
100
145
  end
146
+ # rubocop:enable Metrics/ParameterLists
101
147
 
102
148
  private
103
149
 
@@ -4,13 +4,9 @@ module Faker
4
4
  class Twitter < Base
5
5
  class << self
6
6
  def user(legacy_include_status = NOT_GIVEN, legacy_include_email = NOT_GIVEN, include_status: true, include_email: false)
7
- if legacy_include_status != NOT_GIVEN
8
- warn_with_uplevel 'Passing `include_status` with the 1st argument of `Twitter.user` is deprecated. Use keyword argument like `Twitter.user(include_status: ...)` instead.', uplevel: 1
9
- include_status = legacy_include_status
10
- end
11
- if legacy_include_email != NOT_GIVEN
12
- warn_with_uplevel 'Passing `include_email` with the 2nd argument of `Twitter.user` is deprecated. Use keyword argument like `Twitter.user(include_email: ...)` instead.', uplevel: 1
13
- include_email = legacy_include_email
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :include_status if legacy_include_status != NOT_GIVEN
9
+ keywords << :include_email if legacy_include_email != NOT_GIVEN
14
10
  end
15
11
 
16
12
  user_id = id
@@ -24,7 +20,7 @@ module Faker
24
20
  default_profile_image: Faker::Boolean.boolean(true_ratio: 0.1),
25
21
  default_profile: Faker::Boolean.boolean(true_ratio: 0.1),
26
22
  description: Faker::Lorem.sentence,
27
- entities: user_entities,
23
+ entities: user_entities,
28
24
  favourites_count: Faker::Number.between(to: 1, from: 100_000),
29
25
  follow_request_sent: false,
30
26
  followers_count: Faker::Number.between(to: 1, from: 10_000_000),
@@ -64,13 +60,9 @@ module Faker
64
60
  end
65
61
 
66
62
  def status(legacy_include_user = NOT_GIVEN, legacy_include_photo = NOT_GIVEN, include_user: true, include_photo: false)
67
- if legacy_include_user != NOT_GIVEN
68
- warn_with_uplevel 'Passing `include_user` with the 1st argument of `Twitter.status` is deprecated. Use keyword argument like `Twitter.status(include_user: ...)` instead.', uplevel: 1
69
- include_user = legacy_include_user
70
- end
71
- if legacy_include_photo != NOT_GIVEN
72
- warn_with_uplevel 'Passing `include_photo` with the 2nd argument of `Twitter.status` is deprecated. Use keyword argument like `Twitter.status(include_photo: ...)` instead.', uplevel: 1
73
- include_photo = legacy_include_photo
63
+ warn_for_deprecated_arguments do |keywords|
64
+ keywords << :include_user if legacy_include_user != NOT_GIVEN
65
+ keywords << :include_photo if legacy_include_photo != NOT_GIVEN
74
66
  end
75
67
 
76
68
  status_id = id
@@ -80,7 +72,7 @@ module Faker
80
72
  contributors: nil,
81
73
  coordinates: nil,
82
74
  created_at: created_at,
83
- entities: status_entities(include_photo: include_photo),
75
+ entities: status_entities(include_photo: include_photo),
84
76
  favorite_count: Faker::Number.between(to: 1, from: 10_000),
85
77
  favorited: false,
86
78
  geo: nil,
@@ -94,7 +86,7 @@ module Faker
94
86
  place: nil,
95
87
  possibly_sensitive: Faker::Boolean.boolean(true_ratio: 0.1),
96
88
  retweet_count: Faker::Number.between(to: 1, from: 10_000),
97
- retweeted_status: nil,
89
+ retweeted_status: nil,
98
90
  retweeted: false,
99
91
  source: "<a href=\"#{Faker::Internet.url(host: 'example.com')}\" rel=\"nofollow\">#{Faker::Company.name}</a>",
100
92
  text: Faker::Lorem.sentence,
@@ -125,26 +117,25 @@ module Faker
125
117
 
126
118
  def user_entities
127
119
  {
128
- url: {
120
+ url: {
129
121
  urls: []
130
122
  },
131
- description: {
123
+ description: {
132
124
  urls: []
133
125
  }
134
126
  }
135
127
  end
136
128
 
137
129
  def status_entities(legacy_include_photo = NOT_GIVEN, include_photo: false)
138
- if legacy_include_photo != NOT_GIVEN
139
- warn_with_uplevel 'Passing `include_photo` with the 1st argument of `Twitter.status_entities` is deprecated. Use keyword argument like `Twitter.status_entities(include_photo: ...)` instead.', uplevel: 1
140
- include_photo = legacy_include_photo
130
+ warn_for_deprecated_arguments do |keywords|
131
+ keywords << :include_photo if legacy_include_photo != NOT_GIVEN
141
132
  end
142
133
 
143
134
  entities = {
144
- hashtags: [],
145
- symbols: [],
146
- user_mentions: [],
147
- urls: []
135
+ hashtags: [],
136
+ symbols: [],
137
+ user_mentions: [],
138
+ urls: []
148
139
  }
149
140
  entities[:media] = [photo_entity] if include_photo
150
141
  entities
@@ -158,7 +149,7 @@ module Faker
158
149
  {
159
150
  id: media_id,
160
151
  id_str: media_id.to_s,
161
- indices: [
152
+ indices: [
162
153
  103,
163
154
  126
164
155
  ],
@@ -168,23 +159,23 @@ module Faker
168
159
  display_url: 'example.com',
169
160
  expanded_url: Faker::Internet.url(host: 'example.com'),
170
161
  type: 'photo',
171
- sizes: {
172
- medium: {
162
+ sizes: {
163
+ medium: {
173
164
  w: 1064,
174
165
  h: 600,
175
166
  resize: 'fit'
176
167
  },
177
- large: {
168
+ large: {
178
169
  w: 1064,
179
170
  h: 600,
180
171
  resize: 'fit'
181
172
  },
182
- small: {
173
+ small: {
183
174
  w: 680,
184
175
  h: 383,
185
176
  resize: 'fit'
186
177
  },
187
- thumb: {
178
+ thumb: {
188
179
  w: 150,
189
180
  h: 150,
190
181
  resize: 'crop'