faker 1.9.6 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +386 -6
  3. data/README.md +12 -5
  4. data/lib/faker.rb +56 -1
  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 +66 -5
  12. data/lib/faker/books/lovecraft.rb +221 -18
  13. data/lib/faker/creature/animal.rb +10 -1
  14. data/lib/faker/creature/cat.rb +28 -1
  15. data/lib/faker/creature/dog.rb +73 -1
  16. data/lib/faker/creature/horse.rb +19 -1
  17. data/lib/faker/default/address.rb +25 -5
  18. data/lib/faker/default/alphanumeric.rb +58 -9
  19. data/lib/faker/default/app.rb +55 -1
  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 +43 -1
  23. data/lib/faker/default/bank.rb +10 -2
  24. data/lib/faker/default/boolean.rb +16 -1
  25. data/lib/faker/default/cannabis.rb +4 -0
  26. data/lib/faker/default/chile_rut.rb +13 -3
  27. data/lib/faker/default/chuck_norris.rb +1 -1
  28. data/lib/faker/default/code.rb +18 -5
  29. data/lib/faker/default/commerce.rb +18 -4
  30. data/lib/faker/default/company.rb +11 -3
  31. data/lib/faker/default/crypto_coin.rb +21 -4
  32. data/lib/faker/default/date.rb +122 -9
  33. data/lib/faker/default/demographic.rb +5 -1
  34. data/lib/faker/default/dessert.rb +27 -0
  35. data/lib/faker/default/device.rb +56 -2
  36. data/lib/faker/default/driving_licence.rb +13 -7
  37. data/lib/faker/default/educator.rb +0 -3
  38. data/lib/faker/default/electrical_components.rb +27 -0
  39. data/lib/faker/default/file.rb +20 -3
  40. data/lib/faker/default/fillmurray.rb +10 -2
  41. data/lib/faker/default/finance.rb +5 -1
  42. data/lib/faker/default/gender.rb +18 -0
  43. data/lib/faker/default/greek_philosophers.rb +18 -0
  44. data/lib/faker/default/hacker.rb +59 -1
  45. data/lib/faker/default/hipster.rb +55 -16
  46. data/lib/faker/default/house.rb +18 -0
  47. data/lib/faker/default/id_number.rb +85 -11
  48. data/lib/faker/default/industry_segments.rb +36 -0
  49. data/lib/faker/default/internet.rb +107 -22
  50. data/lib/faker/default/invoice.rb +16 -3
  51. data/lib/faker/default/json.rb +19 -2
  52. data/lib/faker/default/lorem.rb +91 -20
  53. data/lib/faker/default/lorem_flickr.rb +38 -5
  54. data/lib/faker/default/lorem_pixel.rb +10 -1
  55. data/lib/faker/default/markdown.rb +12 -7
  56. data/lib/faker/default/marketing.rb +9 -0
  57. data/lib/faker/default/measurement.rb +40 -8
  58. data/lib/faker/default/military.rb +45 -0
  59. data/lib/faker/default/name.rb +6 -4
  60. data/lib/faker/default/nation.rb +48 -5
  61. data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
  62. data/lib/faker/default/nhs.rb +11 -7
  63. data/lib/faker/default/number.rb +202 -30
  64. data/lib/faker/default/omniauth.rb +98 -15
  65. data/lib/faker/default/phone_number.rb +5 -1
  66. data/lib/faker/default/placeholdit.rb +11 -1
  67. data/lib/faker/default/programming_language.rb +18 -0
  68. data/lib/faker/default/relationship.rb +5 -1
  69. data/lib/faker/default/restaurant.rb +54 -2
  70. data/lib/faker/default/science.rb +27 -0
  71. data/lib/faker/default/source.rb +59 -3
  72. data/lib/faker/default/south_africa.rb +1 -1
  73. data/lib/faker/default/space.rb +2 -2
  74. data/lib/faker/default/string.rb +5 -1
  75. data/lib/faker/default/stripe.rb +20 -4
  76. data/lib/faker/default/subscription.rb +45 -0
  77. data/lib/faker/default/superhero.rb +45 -0
  78. data/lib/faker/default/time.rb +133 -8
  79. data/lib/faker/default/twitter.rb +62 -48
  80. data/lib/faker/default/types.rb +29 -7
  81. data/lib/faker/default/vehicle.rb +19 -6
  82. data/lib/faker/default/world_cup.rb +61 -2
  83. data/lib/faker/games/dota.rb +53 -2
  84. data/lib/faker/games/elder_scrolls.rb +73 -1
  85. data/lib/faker/games/fallout.rb +38 -1
  86. data/lib/faker/games/game.rb +27 -0
  87. data/lib/faker/games/half_life.rb +28 -1
  88. data/lib/faker/games/heroes.rb +28 -1
  89. data/lib/faker/games/heroes_of_the_storm.rb +37 -1
  90. data/lib/faker/games/league_of_legends.rb +55 -1
  91. data/lib/faker/games/myst.rb +46 -1
  92. data/lib/faker/games/overwatch.rb +28 -1
  93. data/lib/faker/games/pokemon.rb +28 -1
  94. data/lib/faker/games/sonic_the_hedgehog.rb +28 -1
  95. data/lib/faker/games/super_smash_bros.rb +19 -1
  96. data/lib/faker/games/witcher.rb +55 -1
  97. data/lib/faker/games/world_of_warcraft.rb +19 -1
  98. data/lib/faker/games/zelda.rb +38 -2
  99. data/lib/faker/japanese_media/dragon_ball.rb +10 -1
  100. data/lib/faker/japanese_media/one_piece.rb +55 -1
  101. data/lib/faker/japanese_media/sword_art_online.rb +37 -1
  102. data/lib/faker/movies/back_to_the_future.rb +29 -1
  103. data/lib/faker/movies/ghostbusters.rb +29 -1
  104. data/lib/faker/movies/harry_potter.rb +55 -1
  105. data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +70 -1
  106. data/lib/faker/movies/hobbit.rb +38 -1
  107. data/lib/faker/movies/lebowski.rb +28 -1
  108. data/lib/faker/movies/lord_of_the_rings.rb +29 -1
  109. data/lib/faker/movies/movie.rb +9 -0
  110. data/lib/faker/movies/princess_bride.rb +20 -1
  111. data/lib/faker/movies/star_wars.rb +101 -5
  112. data/lib/faker/movies/v_for_vendetta.rb +30 -1
  113. data/lib/faker/music/grateful_dead.rb +18 -0
  114. data/lib/faker/music/phish.rb +9 -0
  115. data/lib/faker/music/rock_band.rb +9 -0
  116. data/lib/faker/music/umphreys_mcgee.rb +9 -0
  117. data/lib/faker/sports/basketball.rb +36 -0
  118. data/lib/faker/sports/football.rb +45 -0
  119. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +10 -1
  120. data/lib/faker/tv_shows/bojack_horseman.rb +29 -1
  121. data/lib/faker/tv_shows/breaking_bad.rb +19 -1
  122. data/lib/faker/tv_shows/buffy.rb +46 -1
  123. data/lib/faker/tv_shows/community.rb +20 -1
  124. data/lib/faker/tv_shows/dr_who.rb +79 -3
  125. data/lib/faker/tv_shows/dumb_and_dumber.rb +29 -1
  126. data/lib/faker/tv_shows/family_guy.rb +29 -1
  127. data/lib/faker/tv_shows/friends.rb +28 -1
  128. data/lib/faker/tv_shows/game_of_thrones.rb +47 -1
  129. data/lib/faker/tv_shows/hey_arnold.rb +28 -1
  130. data/lib/faker/tv_shows/how_i_met_your_mother.rb +38 -1
  131. data/lib/faker/tv_shows/michael_scott.rb +14 -1
  132. data/lib/faker/tv_shows/new_girl.rb +20 -1
  133. data/lib/faker/tv_shows/parks_and_rec.rb +19 -1
  134. data/lib/faker/tv_shows/rick_and_morty.rb +29 -1
  135. data/lib/faker/tv_shows/ru_paul.rb +19 -1
  136. data/lib/faker/tv_shows/seinfeld.rb +29 -1
  137. data/lib/faker/tv_shows/silicon_valley.rb +76 -1
  138. data/lib/faker/tv_shows/simpsons.rb +29 -1
  139. data/lib/faker/tv_shows/south_park.rb +20 -1
  140. data/lib/faker/tv_shows/star_trek.rb +37 -1
  141. data/lib/faker/tv_shows/stargate.rb +29 -1
  142. data/lib/faker/tv_shows/stranger_things.rb +20 -1
  143. data/lib/faker/tv_shows/the_expanse.rb +37 -1
  144. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +29 -1
  145. data/lib/faker/tv_shows/the_it_crowd.rb +38 -1
  146. data/lib/faker/tv_shows/the_thick_of_it.rb +29 -1
  147. data/lib/faker/tv_shows/twin_peaks.rb +29 -1
  148. data/lib/faker/tv_shows/venture_bros.rb +39 -1
  149. data/lib/faker/version.rb +1 -1
  150. data/lib/locales/en-CA.yml +2 -1
  151. data/lib/locales/en-IND.yml +1 -1
  152. data/lib/locales/en-TH.yml +360 -0
  153. data/lib/locales/en.yml +4 -1
  154. data/lib/locales/en/address.yml +1 -4
  155. data/lib/locales/en/animal.yml +2 -2
  156. data/lib/locales/en/cannabis.yml +1 -0
  157. data/lib/locales/en/color.yml +1 -1
  158. data/lib/locales/en/dr_who.yml +1 -1
  159. data/lib/locales/en/science.yml +1 -1
  160. data/lib/locales/en/space.yml +1 -1
  161. data/lib/locales/en/super_smash_bros.yml +5 -0
  162. data/lib/locales/fr-CA.yml +1 -1
  163. data/lib/locales/ja.yml +12 -9
  164. data/lib/locales/th.yml +380 -0
  165. data/lib/locales/vi.yml +1 -1
  166. metadata +44 -27
  167. data/lib/faker/default/creature.rb +0 -6
  168. data/lib/faker/default/games.rb +0 -6
  169. data/lib/faker/default/japanese_media.rb +0 -6
  170. data/lib/faker/default/movies.rb +0 -6
  171. data/lib/faker/default/tv_shows.rb +0 -6
  172. data/lib/faker/deprecate/unreleased/football.rb +0 -35
  173. data/lib/faker/deprecate/unreleased/movies/grateful_dead.rb +0 -22
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faker
4
- class Time < Faker::Date
4
+ class Time < Base
5
5
  TIME_RANGES = {
6
6
  all: (0..23),
7
7
  day: (9..17),
@@ -13,19 +13,138 @@ module Faker
13
13
  }.freeze
14
14
 
15
15
  class << self
16
- def between(from, to, period = :all, format = nil)
17
- time = period == :between ? rand(from..to) : date_with_random_time(super(from, to), period)
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
41
+ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, format: nil)
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
46
+ end
47
+
48
+ from = get_time_object(from)
49
+ to = get_time_object(to)
50
+
51
+ time = Faker::Base.rand_in_range(from, to)
18
52
  time_with_format(time, format)
19
53
  end
54
+ # rubocop:enable Style/AsciiComments
20
55
 
21
- def forward(days = 365, period = :all, format = nil)
22
- time_with_format(date_with_random_time(super(days), period), format)
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
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)
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
90
+ end
91
+
92
+ date = Faker::Date.between(from: from, to: to)
93
+ time = date_with_random_time(date, period)
94
+ time_with_format(time, format)
23
95
  end
24
96
 
25
- def backward(days = 365, period = :all, format = nil)
26
- time_with_format(date_with_random_time(super(days), period), format)
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
112
+ def forward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
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
117
+ end
118
+
119
+ time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format)
27
120
  end
28
121
 
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
137
+ def backward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
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
142
+ end
143
+
144
+ time_with_format(date_with_random_time(Faker::Date.backward(days: days), period), format)
145
+ end
146
+ # rubocop:enable Metrics/ParameterLists
147
+
29
148
  private
30
149
 
31
150
  def date_with_random_time(date, period)
@@ -33,7 +152,7 @@ module Faker
33
152
  end
34
153
 
35
154
  def time_with_format(time, format)
36
- format.nil? ? time : I18n.l(DateTime.parse(time.to_s), format: format)
155
+ format.nil? ? time : I18n.localize(time, format: format)
37
156
  end
38
157
 
39
158
  def hours(period)
@@ -49,6 +168,12 @@ module Faker
49
168
  def seconds
50
169
  sample((0..59).to_a)
51
170
  end
171
+
172
+ def get_time_object(time)
173
+ time = ::Time.parse(time) if time.is_a? String
174
+ time = time.to_time if time.respond_to?(:to_time)
175
+ time
176
+ end
52
177
  end
53
178
  end
54
179
  end
@@ -3,58 +3,68 @@
3
3
  module Faker
4
4
  class Twitter < Base
5
5
  class << self
6
- def user(include_status: true, include_email: false)
6
+ def user(legacy_include_status = NOT_GIVEN, legacy_include_email = NOT_GIVEN, include_status: true, include_email: false)
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
10
+ end
11
+
7
12
  user_id = id
8
- background_image_url = Faker::LoremPixel.image('600x400') # TODO: Make the dimensions change
9
- profile_image_url = Faker::Avatar.image(user_id, '48x48')
13
+ background_image_url = Faker::LoremPixel.image(size: '600x400') # TODO: Make the dimensions change
14
+ profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48')
10
15
  user = {
11
16
  id: user_id,
12
17
  id_str: user_id.to_s,
13
- contributors_enabled: Faker::Boolean.boolean(0.1),
18
+ contributors_enabled: Faker::Boolean.boolean(true_ratio: 0.1),
14
19
  created_at: created_at,
15
- default_profile_image: Faker::Boolean.boolean(0.1),
16
- default_profile: Faker::Boolean.boolean(0.1),
20
+ default_profile_image: Faker::Boolean.boolean(true_ratio: 0.1),
21
+ default_profile: Faker::Boolean.boolean(true_ratio: 0.1),
17
22
  description: Faker::Lorem.sentence,
18
- entities: user_entities,
19
- favourites_count: Faker::Number.between(1, 100_000),
23
+ entities: user_entities,
24
+ favourites_count: Faker::Number.between(to: 1, from: 100_000),
20
25
  follow_request_sent: false,
21
- followers_count: Faker::Number.between(1, 10_000_000),
26
+ followers_count: Faker::Number.between(to: 1, from: 10_000_000),
22
27
  following: false,
23
- friends_count: Faker::Number.between(1, 100_000),
24
- geo_enabled: Faker::Boolean.boolean(0.1),
25
- is_translation_enabled: Faker::Boolean.boolean(0.1),
26
- is_translator: Faker::Boolean.boolean(0.1),
28
+ friends_count: Faker::Number.between(to: 1, from: 100_000),
29
+ geo_enabled: Faker::Boolean.boolean(true_ratio: 0.1),
30
+ is_translation_enabled: Faker::Boolean.boolean(true_ratio: 0.1),
31
+ is_translator: Faker::Boolean.boolean(true_ratio: 0.1),
27
32
  lang: Faker::Address.country_code,
28
- listed_count: Faker::Number.between(1, 1000),
33
+ listed_count: Faker::Number.between(to: 1, from: 1000),
29
34
  location: "#{Faker::Address.city}, #{Faker::Address.state_abbr}, #{Faker::Address.country_code}",
30
35
  name: Faker::Name.name,
31
36
  notifications: false,
32
37
  profile_background_color: Faker::Color.hex_color,
33
38
  profile_background_image_url_https: background_image_url,
34
39
  profile_background_image_url: background_image_url.sub('https://', 'http://'),
35
- profile_background_tile: Faker::Boolean.boolean(0.1),
36
- profile_banner_url: Faker::LoremPixel.image('1500x500'),
40
+ profile_background_tile: Faker::Boolean.boolean(true_ratio: 0.1),
41
+ profile_banner_url: Faker::LoremPixel.image(size: '1500x500'),
37
42
  profile_image_url_https: profile_image_url,
38
43
  profile_image_url: profile_image_url.sub('https://', 'http://'),
39
44
  profile_link_color: Faker::Color.hex_color,
40
45
  profile_sidebar_border_color: Faker::Color.hex_color,
41
46
  profile_sidebar_fill_color: Faker::Color.hex_color,
42
47
  profile_text_color: Faker::Color.hex_color,
43
- profile_use_background_image: Faker::Boolean.boolean(0.4),
44
- protected: Faker::Boolean.boolean(0.1),
48
+ profile_use_background_image: Faker::Boolean.boolean(true_ratio: 0.4),
49
+ protected: Faker::Boolean.boolean(true_ratio: 0.1),
45
50
  screen_name: screen_name,
46
- statuses_count: Faker::Number.between(1, 100_000),
51
+ statuses_count: Faker::Number.between(to: 1, from: 100_000),
47
52
  time_zone: Faker::Address.time_zone,
48
- url: Faker::Internet.url('example.com'),
53
+ url: Faker::Internet.url(host: 'example.com'),
49
54
  utc_offset: utc_offset,
50
- verified: Faker::Boolean.boolean(0.1)
55
+ verified: Faker::Boolean.boolean(true_ratio: 0.1)
51
56
  }
52
57
  user[:status] = Faker::Twitter.status(include_user: false) if include_status
53
58
  user[:email] = Faker::Internet.safe_email if include_email
54
59
  user
55
60
  end
56
61
 
57
- def status(include_user: true, include_photo: false)
62
+ def status(legacy_include_user = NOT_GIVEN, legacy_include_photo = NOT_GIVEN, include_user: true, include_photo: false)
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
66
+ end
67
+
58
68
  status_id = id
59
69
  status = {
60
70
  id: status_id,
@@ -62,8 +72,8 @@ module Faker
62
72
  contributors: nil,
63
73
  coordinates: nil,
64
74
  created_at: created_at,
65
- entities: status_entities(include_photo: include_photo),
66
- favorite_count: Faker::Number.between(1, 10_000),
75
+ entities: status_entities(include_photo: include_photo),
76
+ favorite_count: Faker::Number.between(to: 1, from: 10_000),
67
77
  favorited: false,
68
78
  geo: nil,
69
79
  in_reply_to_screen_name: nil,
@@ -74,11 +84,11 @@ module Faker
74
84
  lang: Faker::Address.country_code,
75
85
  nil: nil,
76
86
  place: nil,
77
- possibly_sensitive: Faker::Boolean.boolean(0.1),
78
- retweet_count: Faker::Number.between(1, 10_000),
79
- retweeted_status: nil,
87
+ possibly_sensitive: Faker::Boolean.boolean(true_ratio: 0.1),
88
+ retweet_count: Faker::Number.between(to: 1, from: 10_000),
89
+ retweeted_status: nil,
80
90
  retweeted: false,
81
- source: "<a href=\"#{Faker::Internet.url('example.com')}\" rel=\"nofollow\">#{Faker::Company.name}</a>",
91
+ source: "<a href=\"#{Faker::Internet.url(host: 'example.com')}\" rel=\"nofollow\">#{Faker::Company.name}</a>",
82
92
  text: Faker::Lorem.sentence,
83
93
  truncated: false
84
94
  }
@@ -88,40 +98,44 @@ module Faker
88
98
  end
89
99
 
90
100
  def screen_name
91
- Faker::Internet.username(nil, ['_'])[0...20]
101
+ Faker::Internet.username(specifier: nil, separators: ['_'])[0...20]
92
102
  end
93
103
 
94
104
  private
95
105
 
96
106
  def id
97
- Faker::Number.between(1, 9_223_372_036_854_775_807)
107
+ Faker::Number.between(from: 1, to: 9_223_372_036_854_775_807)
98
108
  end
99
109
 
100
110
  def created_at
101
- Faker::Date.between('2006-03-21', ::Date.today).strftime('%a %b %d %H:%M:%S %z %Y')
111
+ Faker::Date.between(from: '2006-03-21', to: ::Date.today).strftime('%a %b %d %H:%M:%S %z %Y')
102
112
  end
103
113
 
104
114
  def utc_offset
105
- Faker::Number.between(-43_200, 50_400)
115
+ Faker::Number.between(to: -43_200, from: 50_400)
106
116
  end
107
117
 
108
118
  def user_entities
109
119
  {
110
- url: {
120
+ url: {
111
121
  urls: []
112
122
  },
113
- description: {
123
+ description: {
114
124
  urls: []
115
125
  }
116
126
  }
117
127
  end
118
128
 
119
- def status_entities(include_photo: false)
129
+ def status_entities(legacy_include_photo = NOT_GIVEN, include_photo: false)
130
+ warn_for_deprecated_arguments do |keywords|
131
+ keywords << :include_photo if legacy_include_photo != NOT_GIVEN
132
+ end
133
+
120
134
  entities = {
121
- hashtags: [],
122
- symbols: [],
123
- user_mentions: [],
124
- urls: []
135
+ hashtags: [],
136
+ symbols: [],
137
+ user_mentions: [],
138
+ urls: []
125
139
  }
126
140
  entities[:media] = [photo_entity] if include_photo
127
141
  entities
@@ -130,38 +144,38 @@ module Faker
130
144
  def photo_entity
131
145
  # TODO: Dynamic image sizes
132
146
  # TODO: Return accurate indices
133
- media_url = Faker::LoremPixel.image('1064x600')
147
+ media_url = Faker::LoremPixel.image(size: '1064x600')
134
148
  media_id = id
135
149
  {
136
150
  id: media_id,
137
151
  id_str: media_id.to_s,
138
- indices: [
152
+ indices: [
139
153
  103,
140
154
  126
141
155
  ],
142
156
  media_url: media_url.sub('https://', 'http://'),
143
157
  media_url_https: media_url,
144
- url: Faker::Internet.url('example.com'),
158
+ url: Faker::Internet.url(host: 'example.com'),
145
159
  display_url: 'example.com',
146
- expanded_url: Faker::Internet.url('example.com'),
160
+ expanded_url: Faker::Internet.url(host: 'example.com'),
147
161
  type: 'photo',
148
- sizes: {
149
- medium: {
162
+ sizes: {
163
+ medium: {
150
164
  w: 1064,
151
165
  h: 600,
152
166
  resize: 'fit'
153
167
  },
154
- large: {
168
+ large: {
155
169
  w: 1064,
156
170
  h: 600,
157
171
  resize: 'fit'
158
172
  },
159
- small: {
173
+ small: {
160
174
  w: 680,
161
175
  h: 383,
162
176
  resize: 'fit'
163
177
  },
164
- thumb: {
178
+ thumb: {
165
179
  w: 150,
166
180
  h: 150,
167
181
  resize: 'crop'
@@ -7,7 +7,11 @@ module Faker
7
7
  COMPLEX_TYPES = %i[hash array].freeze
8
8
 
9
9
  class << self
10
- def rb_string(words = 1)
10
+ def rb_string(legacy_words = NOT_GIVEN, words: 1)
11
+ warn_for_deprecated_arguments do |keywords|
12
+ keywords << :words if legacy_words != NOT_GIVEN
13
+ end
14
+
11
15
  resolved_num = resolve(words)
12
16
  word_list =
13
17
  translate('faker.lorem.words')
@@ -20,23 +24,41 @@ module Faker
20
24
  sample(CHARACTERS)
21
25
  end
22
26
 
23
- def rb_integer(from = 0, to = 100)
27
+ def rb_integer(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 100)
28
+ warn_for_deprecated_arguments do |keywords|
29
+ keywords << :from if legacy_from != NOT_GIVEN
30
+ keywords << :to if legacy_to != NOT_GIVEN
31
+ end
32
+
24
33
  rand(from..to).to_i
25
34
  end
26
35
 
27
- def rb_hash(key_count = 1, type = random_type)
36
+ def rb_hash(legacy_number = NOT_GIVEN, legacy_type = NOT_GIVEN, number: 1, type: random_type)
37
+ warn_for_deprecated_arguments do |keywords|
38
+ keywords << :number if legacy_number != NOT_GIVEN
39
+ keywords << :type if legacy_type != NOT_GIVEN
40
+ end
41
+
28
42
  {}.tap do |hsh|
29
- Lorem.words(key_count * 2).uniq.first(key_count).each do |s|
43
+ Lorem.words(number: number * 2).uniq.first(number).each do |s|
30
44
  hsh.merge!(s.to_sym => type)
31
45
  end
32
46
  end
33
47
  end
34
48
 
35
- def complex_rb_hash(key_count = 1)
36
- rb_hash(key_count, random_complex_type)
49
+ def complex_rb_hash(legacy_number = NOT_GIVEN, number: 1)
50
+ warn_for_deprecated_arguments do |keywords|
51
+ keywords << :number if legacy_number != NOT_GIVEN
52
+ end
53
+
54
+ rb_hash(number: number, type: random_complex_type)
37
55
  end
38
56
 
39
- def rb_array(len = 1)
57
+ def rb_array(legacy_len = NOT_GIVEN, len: 1)
58
+ warn_for_deprecated_arguments do |keywords|
59
+ keywords << :len if legacy_len != NOT_GIVEN
60
+ end
61
+
40
62
  [].tap do |ar|
41
63
  len.times do
42
64
  ar.push random_type