faker 2.1.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -7
  3. data/README.md +2 -3
  4. data/lib/faker.rb +56 -1
  5. data/lib/faker/blockchain/bitcoin.rb +26 -0
  6. data/lib/faker/blockchain/ethereum.rb +10 -0
  7. data/lib/faker/blockchain/tezos.rb +62 -6
  8. data/lib/faker/books/book.rb +36 -0
  9. data/lib/faker/books/culture_series.rb +49 -0
  10. data/lib/faker/books/dune.rb +66 -5
  11. data/lib/faker/books/lovecraft.rb +210 -7
  12. data/lib/faker/creature/animal.rb +9 -0
  13. data/lib/faker/creature/cat.rb +27 -0
  14. data/lib/faker/creature/dog.rb +72 -0
  15. data/lib/faker/creature/horse.rb +18 -0
  16. data/lib/faker/default/address.rb +25 -5
  17. data/lib/faker/default/alphanumeric.rb +56 -7
  18. data/lib/faker/default/app.rb +54 -1
  19. data/lib/faker/default/artist.rb +9 -0
  20. data/lib/faker/default/avatar.rb +42 -1
  21. data/lib/faker/default/bank.rb +10 -2
  22. data/lib/faker/default/boolean.rb +16 -1
  23. data/lib/faker/default/chile_rut.rb +12 -2
  24. data/lib/faker/default/code.rb +16 -3
  25. data/lib/faker/default/commerce.rb +17 -3
  26. data/lib/faker/default/company.rb +10 -2
  27. data/lib/faker/default/crypto_coin.rb +15 -3
  28. data/lib/faker/default/date.rb +37 -5
  29. data/lib/faker/default/demographic.rb +5 -1
  30. data/lib/faker/default/driving_licence.rb +10 -4
  31. data/lib/faker/default/file.rb +19 -2
  32. data/lib/faker/default/fillmurray.rb +9 -1
  33. data/lib/faker/default/finance.rb +5 -1
  34. data/lib/faker/default/gender.rb +18 -0
  35. data/lib/faker/default/hacker.rb +59 -1
  36. data/lib/faker/default/hipster.rb +45 -6
  37. data/lib/faker/default/house.rb +18 -0
  38. data/lib/faker/default/id_number.rb +11 -3
  39. data/lib/faker/default/internet.rb +94 -13
  40. data/lib/faker/default/invoice.rb +16 -3
  41. data/lib/faker/default/json.rb +19 -2
  42. data/lib/faker/default/lorem.rb +81 -10
  43. data/lib/faker/default/lorem_flickr.rb +38 -5
  44. data/lib/faker/default/lorem_pixel.rb +10 -1
  45. data/lib/faker/default/markdown.rb +6 -1
  46. data/lib/faker/default/measurement.rb +40 -8
  47. data/lib/faker/default/name.rb +5 -1
  48. data/lib/faker/default/nhs.rb +5 -1
  49. data/lib/faker/default/number.rb +56 -11
  50. data/lib/faker/default/omniauth.rb +92 -9
  51. data/lib/faker/default/phone_number.rb +5 -1
  52. data/lib/faker/default/placeholdit.rb +11 -1
  53. data/lib/faker/default/programming_language.rb +18 -0
  54. data/lib/faker/default/relationship.rb +5 -1
  55. data/lib/faker/default/source.rb +59 -3
  56. data/lib/faker/default/string.rb +5 -1
  57. data/lib/faker/default/stripe.rb +20 -4
  58. data/lib/faker/default/time.rb +37 -4
  59. data/lib/faker/default/twitter.rb +32 -18
  60. data/lib/faker/default/types.rb +27 -5
  61. data/lib/faker/default/vehicle.rb +17 -4
  62. data/lib/faker/default/world_cup.rb +11 -2
  63. data/lib/faker/games/dota.rb +5 -1
  64. data/lib/faker/games/elder_scrolls.rb +72 -0
  65. data/lib/faker/games/fallout.rb +37 -0
  66. data/lib/faker/games/game.rb +27 -0
  67. data/lib/faker/games/half_life.rb +27 -0
  68. data/lib/faker/games/overwatch.rb +27 -0
  69. data/lib/faker/games/super_smash_bros.rb +18 -0
  70. data/lib/faker/games/zelda.rb +36 -0
  71. data/lib/faker/movies/star_wars.rb +6 -4
  72. data/lib/faker/tv_shows/breaking_bad.rb +18 -0
  73. data/lib/faker/version.rb +1 -1
  74. data/lib/locales/en-CA.yml +1 -1
  75. data/lib/locales/en/science.yml +1 -1
  76. data/lib/locales/ja.yml +1 -1
  77. metadata +31 -15
@@ -40,7 +40,11 @@ module Faker
40
40
  # US and Canada only
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
- def subscriber_number(length: 4)
43
+ def subscriber_number(legacy_length = NOT_GIVEN, length: 4)
44
+ warn_for_deprecated_arguments do |keywords|
45
+ keywords << :length if legacy_length != NOT_GIVEN
46
+ end
47
+
44
48
  rand.to_s[2..(1 + length)]
45
49
  end
46
50
 
@@ -5,7 +5,17 @@ module Faker
5
5
  class << self
6
6
  SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
7
7
 
8
- def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
8
+ # rubocop:disable Metrics/ParameterLists
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
+ # rubocop:enable Metrics/ParameterLists
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
17
+ end
18
+
9
19
  background_color = generate_color if background_color == :random
10
20
  text_color = generate_color if text_color == :random
11
21
 
@@ -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
@@ -5,7 +5,11 @@ module Faker
5
5
  flexible :relationship
6
6
 
7
7
  class << self
8
- def familial(connection: nil)
8
+ def familial(legacy_connection = NOT_GIVEN, connection: nil)
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :connection if legacy_connection != NOT_GIVEN
11
+ end
12
+
9
13
  familial_connections = translate('faker.relationship.familial').keys
10
14
 
11
15
  if connection.nil?
@@ -3,16 +3,72 @@
3
3
  module Faker
4
4
  class Source < Base
5
5
  class << self
6
- def hello_world(lang: :ruby)
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
20
+ def hello_world(legacy_lang = NOT_GIVEN, lang: :ruby)
21
+ warn_for_deprecated_arguments do |keywords|
22
+ keywords << :lang if legacy_lang != NOT_GIVEN
23
+ end
24
+
7
25
  fetch("source.hello_world.#{lang}")
8
26
  end
9
27
 
10
- def print(str: 'some string', lang: :ruby)
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
42
+ def print(legacy_str = NOT_GIVEN, legacy_lang = NOT_GIVEN, str: 'some string', lang: :ruby)
43
+ warn_for_deprecated_arguments do |keywords|
44
+ keywords << :str if legacy_str != NOT_GIVEN
45
+ end
46
+ warn_for_deprecated_arguments do |keywords|
47
+ keywords << :lang if legacy_lang != NOT_GIVEN
48
+ end
11
49
  code = fetch("source.print.#{lang}")
12
50
  code.gsub('faker_string_to_print', str)
13
51
  end
14
52
 
15
- def print_1_to_10(lang: :ruby)
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
68
+ def print_1_to_10(legacy_lang = NOT_GIVEN, lang: :ruby)
69
+ warn_for_deprecated_arguments do |keywords|
70
+ keywords << :lang if legacy_lang != NOT_GIVEN
71
+ end
16
72
  fetch("source.print_1_to_10.#{lang}")
17
73
  end
18
74
  end
@@ -3,7 +3,11 @@
3
3
  module Faker
4
4
  class String < Base
5
5
  class << self
6
- def random(length: 32)
6
+ def random(legacy_length = NOT_GIVEN, length: 32)
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :length if legacy_length != NOT_GIVEN
9
+ end
10
+
7
11
  utf8string select_a length
8
12
  end
9
13
 
@@ -3,7 +3,11 @@
3
3
  module Faker
4
4
  class Stripe < Base
5
5
  class << self
6
- def valid_card(card_type: nil)
6
+ def valid_card(legacy_card_type = NOT_GIVEN, card_type: nil)
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :card_type if legacy_card_type != NOT_GIVEN
9
+ end
10
+
7
11
  valid_cards = translate('faker.stripe.valid_cards').keys
8
12
 
9
13
  if card_type.nil?
@@ -18,7 +22,11 @@ module Faker
18
22
  fetch('stripe.valid_cards.' + card_type)
19
23
  end
20
24
 
21
- def valid_token(card_type: nil)
25
+ def valid_token(legacy_card_type = NOT_GIVEN, card_type: nil)
26
+ warn_for_deprecated_arguments do |keywords|
27
+ keywords << :card_type if legacy_card_type != NOT_GIVEN
28
+ end
29
+
22
30
  valid_tokens = translate('faker.stripe.valid_tokens').keys
23
31
 
24
32
  if card_type.nil?
@@ -33,7 +41,11 @@ module Faker
33
41
  fetch('stripe.valid_tokens.' + card_type)
34
42
  end
35
43
 
36
- def invalid_card(card_error: nil)
44
+ def invalid_card(legacy_card_error = NOT_GIVEN, card_error: nil)
45
+ warn_for_deprecated_arguments do |keywords|
46
+ keywords << :card_error if legacy_card_error != NOT_GIVEN
47
+ end
48
+
37
49
  invalid_cards = translate('faker.stripe.invalid_cards').keys
38
50
 
39
51
  if card_error.nil?
@@ -57,7 +69,11 @@ module Faker
57
69
  rand_in_range(start_year, start_year + 5).to_s
58
70
  end
59
71
 
60
- def ccv(card_type: nil)
72
+ def ccv(legacy_card_type = NOT_GIVEN, card_type: nil)
73
+ warn_for_deprecated_arguments do |keywords|
74
+ keywords << :card_type if legacy_card_type != NOT_GIVEN
75
+ end
76
+
61
77
  (card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s
62
78
  end
63
79
  end
@@ -13,7 +13,15 @@ module Faker
13
13
  }.freeze
14
14
 
15
15
  class << self
16
- def between(from:, to:, format: nil)
16
+ # rubocop:disable Metrics/ParameterLists
17
+ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, format: nil)
18
+ # rubocop:enable Metrics/ParameterLists
19
+ warn_for_deprecated_arguments do |keywords|
20
+ keywords << :from if legacy_from != NOT_GIVEN
21
+ keywords << :to if legacy_to != NOT_GIVEN
22
+ keywords << :format if legacy_format != NOT_GIVEN
23
+ end
24
+
17
25
  from = get_time_object(from)
18
26
  to = get_time_object(to)
19
27
 
@@ -21,17 +29,42 @@ module Faker
21
29
  time_with_format(time, format)
22
30
  end
23
31
 
24
- def between_dates(from:, to:, period: :all, format: nil)
32
+ # rubocop:disable Metrics/ParameterLists
33
+ 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)
34
+ # rubocop:enable Metrics/ParameterLists
35
+ warn_for_deprecated_arguments do |keywords|
36
+ keywords << :from if legacy_from != NOT_GIVEN
37
+ keywords << :to if legacy_to != NOT_GIVEN
38
+ keywords << :period if legacy_period != NOT_GIVEN
39
+ keywords << :format if legacy_format != NOT_GIVEN
40
+ end
41
+
25
42
  date = Faker::Date.between(from: from, to: to)
26
43
  time = date_with_random_time(date, period)
27
44
  time_with_format(time, format)
28
45
  end
29
46
 
30
- def forward(days: 365, period: :all, format: nil)
47
+ # rubocop:disable Metrics/ParameterLists
48
+ def forward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
49
+ # rubocop:enable Metrics/ParameterLists
50
+ warn_for_deprecated_arguments do |keywords|
51
+ keywords << :days if legacy_days != NOT_GIVEN
52
+ keywords << :period if legacy_period != NOT_GIVEN
53
+ keywords << :format if legacy_format != NOT_GIVEN
54
+ end
55
+
31
56
  time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format)
32
57
  end
33
58
 
34
- def backward(days: 365, period: :all, format: nil)
59
+ # rubocop:disable Metrics/ParameterLists
60
+ def backward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
61
+ # rubocop:enable Metrics/ParameterLists
62
+ warn_for_deprecated_arguments do |keywords|
63
+ keywords << :days if legacy_days != NOT_GIVEN
64
+ keywords << :period if legacy_period != NOT_GIVEN
65
+ keywords << :format if legacy_format != NOT_GIVEN
66
+ end
67
+
35
68
  time_with_format(date_with_random_time(Faker::Date.backward(days: days), period), format)
36
69
  end
37
70
 
@@ -3,7 +3,12 @@
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
13
  background_image_url = Faker::LoremPixel.image(size: '600x400') # TODO: Make the dimensions change
9
14
  profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48')
@@ -15,7 +20,7 @@ module Faker
15
20
  default_profile_image: Faker::Boolean.boolean(true_ratio: 0.1),
16
21
  default_profile: Faker::Boolean.boolean(true_ratio: 0.1),
17
22
  description: Faker::Lorem.sentence,
18
- entities: user_entities,
23
+ entities: user_entities,
19
24
  favourites_count: Faker::Number.between(to: 1, from: 100_000),
20
25
  follow_request_sent: false,
21
26
  followers_count: Faker::Number.between(to: 1, from: 10_000_000),
@@ -54,7 +59,12 @@ module Faker
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,7 +72,7 @@ module Faker
62
72
  contributors: nil,
63
73
  coordinates: nil,
64
74
  created_at: created_at,
65
- entities: status_entities(include_photo: include_photo),
75
+ entities: status_entities(include_photo: include_photo),
66
76
  favorite_count: Faker::Number.between(to: 1, from: 10_000),
67
77
  favorited: false,
68
78
  geo: nil,
@@ -76,7 +86,7 @@ module Faker
76
86
  place: nil,
77
87
  possibly_sensitive: Faker::Boolean.boolean(true_ratio: 0.1),
78
88
  retweet_count: Faker::Number.between(to: 1, from: 10_000),
79
- retweeted_status: nil,
89
+ retweeted_status: nil,
80
90
  retweeted: false,
81
91
  source: "<a href=\"#{Faker::Internet.url(host: 'example.com')}\" rel=\"nofollow\">#{Faker::Company.name}</a>",
82
92
  text: Faker::Lorem.sentence,
@@ -107,21 +117,25 @@ module Faker
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
@@ -135,7 +149,7 @@ module Faker
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
  ],
@@ -145,23 +159,23 @@ module Faker
145
159
  display_url: 'example.com',
146
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,11 +24,21 @@ 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(number: 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
43
  Lorem.words(number: number * 2).uniq.first(number).each do |s|
30
44
  hsh.merge!(s.to_sym => type)
@@ -32,11 +46,19 @@ module Faker
32
46
  end
33
47
  end
34
48
 
35
- def complex_rb_hash(number: 1)
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
+
36
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