faker 2.11.0 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -0
  3. data/README.md +8 -2
  4. data/lib/faker.rb +14 -9
  5. data/lib/faker/default/address.rb +1 -1
  6. data/lib/faker/default/bank.rb +79 -0
  7. data/lib/faker/default/blood.rb +48 -0
  8. data/lib/faker/default/business.rb +1 -1
  9. data/lib/faker/default/commerce.rb +73 -10
  10. data/lib/faker/default/company.rb +39 -0
  11. data/lib/faker/default/compass.rb +135 -0
  12. data/lib/faker/default/computer.rb +63 -0
  13. data/lib/faker/default/construction.rb +54 -0
  14. data/lib/faker/default/cosmere.rb +90 -0
  15. data/lib/faker/default/crypto_coin.rb +45 -0
  16. data/lib/faker/default/driving_licence.rb +42 -0
  17. data/lib/faker/default/file.rb +49 -0
  18. data/lib/faker/default/finance.rb +24 -0
  19. data/lib/faker/default/hipster.rb +94 -0
  20. data/lib/faker/default/invoice.rb +32 -5
  21. data/lib/faker/default/json.rb +55 -0
  22. data/lib/faker/default/measurement.rb +90 -0
  23. data/lib/faker/default/name.rb +83 -0
  24. data/lib/faker/default/phone_number.rb +88 -5
  25. data/lib/faker/default/placeholdit.rb +21 -0
  26. data/lib/faker/default/slack_emoji.rb +81 -0
  27. data/lib/faker/default/south_africa.rb +90 -0
  28. data/lib/faker/default/string.rb +19 -3
  29. data/lib/faker/default/stripe.rb +61 -0
  30. data/lib/faker/default/twitter.rb +35 -0
  31. data/lib/faker/default/types.rb +80 -0
  32. data/lib/faker/default/university.rb +45 -0
  33. data/lib/faker/default/vehicle.rb +184 -4
  34. data/lib/faker/default/verb.rb +45 -0
  35. data/lib/faker/games/control.rb +113 -0
  36. data/lib/faker/games/dnd.rb +61 -0
  37. data/lib/faker/games/warhammer_fantasy.rb +74 -0
  38. data/lib/faker/movies/departed.rb +49 -0
  39. data/lib/faker/music/pearl_jam.rb +50 -0
  40. data/lib/faker/music/phish.rb +27 -1
  41. data/lib/faker/music/show.rb +49 -0
  42. data/lib/faker/quotes/quote.rb +54 -1
  43. data/lib/faker/quotes/shakespeare.rb +36 -0
  44. data/lib/faker/tv_shows/suits.rb +37 -0
  45. data/lib/faker/version.rb +1 -1
  46. data/lib/helpers/char.rb +2 -1
  47. data/lib/locales/de-CH.yml +1693 -0
  48. data/lib/locales/en-AU.yml +44 -10
  49. data/lib/locales/en-CA.yml +2 -0
  50. data/lib/locales/en-US.yml +29 -3
  51. data/lib/locales/en/address.yml +2 -0
  52. data/lib/locales/en/blood.yml +13 -0
  53. data/lib/locales/en/computer.yml +36 -0
  54. data/lib/locales/en/control.yml +247 -0
  55. data/lib/locales/en/departed.yml +50 -0
  56. data/lib/locales/en/dnd.yml +54 -0
  57. data/lib/locales/en/heroes_of_the_storm.yml +1 -1
  58. data/lib/locales/en/house.yml +1 -1
  59. data/lib/locales/en/one_piece.yml +2 -2
  60. data/lib/locales/en/pearl_jam.yml +213 -0
  61. data/lib/locales/en/phish.yml +392 -1
  62. data/lib/locales/en/show.yml +597 -0
  63. data/lib/locales/en/star_wars.yml +568 -221
  64. data/lib/locales/en/suits.yml +45 -0
  65. data/lib/locales/en/warhammer_fantasy.yml +582 -0
  66. data/lib/locales/fr-CA.yml +2 -0
  67. data/lib/locales/ko.yml +82 -0
  68. data/lib/locales/pt-BR.yml +1 -0
  69. metadata +29 -11
@@ -3,46 +3,136 @@
3
3
  module Faker
4
4
  class SouthAfrica < Base
5
5
  class << self
6
+ ##
7
+ # Produces a South African ID number.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::SouthAfrica.id_number #=> "6110311856083"
13
+ #
14
+ # @faker.version 1.9.2
6
15
  def id_number
7
16
  Faker::IDNumber.south_african_id_number
8
17
  end
9
18
 
19
+ ##
20
+ # Produces a valid South African ID number
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::SouthAfrica.valid_id_number #=> "6110311856083"
26
+ #
27
+ # @faker.version 1.9.2
10
28
  def valid_id_number
11
29
  Faker::IDNumber.valid_south_african_id_number
12
30
  end
13
31
 
32
+ ##
33
+ # Produces an invalid South African ID number
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::SouthAfrica.invalid_id_number #=> "7018356904081"
39
+ #
40
+ # @faker.version 1.9.2
14
41
  def invalid_id_number
15
42
  Faker::IDNumber.invalid_south_african_id_number
16
43
  end
17
44
 
45
+ ##
46
+ # Produces a South African phone number.
47
+ #
48
+ # @return [String]
49
+ #
50
+ # @example
51
+ # Faker::SouthAfrica.phone_number #=> "010 788 5009"
52
+ #
53
+ # @faker.version 1.9.2
18
54
  def phone_number
19
55
  with_locale 'en-ZA' do
20
56
  Faker::PhoneNumber.phone_number
21
57
  end
22
58
  end
23
59
 
60
+ ##
61
+ # Produces a South African cell phone number.
62
+ #
63
+ # @return [String]
64
+ #
65
+ # @example
66
+ # Faker::SouthAfrica.cell_phone #=> "082 946 7470"
67
+ #
68
+ # @faker.version 1.9.2
24
69
  def cell_phone
25
70
  with_locale 'en-ZA' do
26
71
  Faker::PhoneNumber.cell_phone
27
72
  end
28
73
  end
29
74
 
75
+ ##
76
+ # Produces a South African private company registration number.
77
+ #
78
+ # @return [String]
79
+ #
80
+ # @example
81
+ # Faker::SouthAfrica.pty_ltd_registration_number #=> "5301/714689/07"
82
+ #
83
+ # @faker.version 1.9.2
30
84
  def pty_ltd_registration_number
31
85
  Faker::Company.south_african_pty_ltd_registration_number
32
86
  end
33
87
 
88
+ ##
89
+ # Produces a South African close corporation registration number.
90
+ #
91
+ # @return [String]
92
+ #
93
+ # @example
94
+ # Faker::SouthAfrica.close_corporation_registration_number #=> "CK74/7585/23"
95
+ #
96
+ # @faker.version 1.9.2
34
97
  def close_corporation_registration_number
35
98
  Faker::Company.south_african_close_corporation_registration_number
36
99
  end
37
100
 
101
+ ##
102
+ # Produces a South African listed company registration number.
103
+ #
104
+ # @return [String]
105
+ #
106
+ # @example
107
+ # Faker::SouthAfrica.listed_company_registration_number #=> "7039/3135/06"
108
+ #
109
+ # @faker.version 1.9.2
38
110
  def listed_company_registration_number
39
111
  Faker::Company.south_african_listed_company_registration_number
40
112
  end
41
113
 
114
+ ##
115
+ # Produces a South African trust registration number.
116
+ #
117
+ # @return [String]
118
+ #
119
+ # @example
120
+ # Faker::SouthAfrica.trust_registration_number #=> "IT38/6489900"
121
+ #
122
+ # @faker.version 1.9.2
42
123
  def trust_registration_number
43
124
  Faker::Company.south_african_trust_registration_number
44
125
  end
45
126
 
127
+ ##
128
+ # Produces a South African VAT number.
129
+ #
130
+ # @return [String]
131
+ #
132
+ # @example
133
+ # Faker::SouthAfrica.vat_number #=> "ZA79494416181"
134
+ #
135
+ # @faker.version 1.9.2
46
136
  def vat_number
47
137
  Faker::Finance.vat_number(country: 'ZA')
48
138
  end
@@ -3,6 +3,22 @@
3
3
  module Faker
4
4
  class String < Base
5
5
  class << self
6
+ ##
7
+ # Produces a random UTF-8 string with optional nested length selectors.
8
+ #
9
+ # @param length [Integer, Range, Array<Integer, Range, nil>] The length of produced string and/or specific UTF-8 characters to use.
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # rubocop:disable Style/AsciiComments
14
+ # Faker::String.random #=> "3 뇦\u0017&y\u{3A109}$8^4* 녹豿4좘툢ꔾ쉙6ɉ\uA6 8TN畀챵|\"3쇤Ŵ"
15
+ # Faker::String.random(length: 4) #=> "⼨%0*"
16
+ # Faker::String.random(length: 3..12) #=> "\u{69FDC};秨툫"
17
+ # Faker::String.random(length: [0, 6]) #=> "I轤𣴒P溟L"
18
+ # Faker::String.random(length: [1, (2..5), [3, 6], nil]) #=> "葓L#ћ"
19
+ # rubocop:enable Style/AsciiComments
20
+ #
21
+ # @faker.version 1.9.0
6
22
  def random(legacy_length = NOT_GIVEN, length: 32)
7
23
  warn_for_deprecated_arguments do |keywords|
8
24
  keywords << :length if legacy_length != NOT_GIVEN
@@ -38,9 +54,9 @@ module Faker
38
54
 
39
55
  def utf8character
40
56
  sample([
41
- rand(32..90), # latin alphabet
42
- rand(128), # 7-bit ASCII
43
- rand(0xd800), # utf-8 codepoints below utf-16 surrogate halves
57
+ rand(32..90), # latin alphabet
58
+ rand(128), # 7-bit ASCII
59
+ rand(0xd800), # utf-8 codepoints below utf-16 surrogate halves
44
60
  rand(57_344..1_114_111) # utf-8 codepoints above utf-16 surrogate halves
45
61
  ]).chr(Encoding::UTF_8)
46
62
  end
@@ -3,6 +3,17 @@
3
3
  module Faker
4
4
  class Stripe < Base
5
5
  class << self
6
+ ##
7
+ # Produces a random valid card number.
8
+ #
9
+ # @param card_type [String] Specific valid card type.
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # Faker::Stripe.valid_card #=> "4242424242424242"
14
+ # Faker::Stripe.valid_card(card_type: "visa_debit") #=> "4000056655665556"
15
+ #
16
+ # @faker.version 1.9.0
6
17
  def valid_card(legacy_card_type = NOT_GIVEN, card_type: nil)
7
18
  warn_for_deprecated_arguments do |keywords|
8
19
  keywords << :card_type if legacy_card_type != NOT_GIVEN
@@ -22,6 +33,17 @@ module Faker
22
33
  fetch('stripe.valid_cards.' + card_type)
23
34
  end
24
35
 
36
+ ##
37
+ # Produces a random valid Stripe token.
38
+ #
39
+ # @param card_type [String] Specific valid card type.
40
+ # @return [String]
41
+ #
42
+ # @example
43
+ # Faker::Stripe.valid_token #=> "tok_visa"
44
+ # Faker::Stripe.valid_token(card_type: "mc_debit") #=> "tok_mastercard_debit"
45
+ #
46
+ # @faker.version 1.9.0
25
47
  def valid_token(legacy_card_type = NOT_GIVEN, card_type: nil)
26
48
  warn_for_deprecated_arguments do |keywords|
27
49
  keywords << :card_type if legacy_card_type != NOT_GIVEN
@@ -41,6 +63,16 @@ module Faker
41
63
  fetch('stripe.valid_tokens.' + card_type)
42
64
  end
43
65
 
66
+ ##
67
+ # Produces a random invalid card number.
68
+ #
69
+ # @return [String]
70
+ #
71
+ # @example
72
+ # Faker::Stripe.invalid_card #=> "4000000000000002"
73
+ # Faker::Stripe.invalid_card(card_error: "addressZipFail") #=> "4000000000000010"
74
+ #
75
+ # @faker.version 1.9.0
44
76
  def invalid_card(legacy_card_error = NOT_GIVEN, card_error: nil)
45
77
  warn_for_deprecated_arguments do |keywords|
46
78
  keywords << :card_error if legacy_card_error != NOT_GIVEN
@@ -60,15 +92,44 @@ module Faker
60
92
  fetch('stripe.invalid_cards.' + card_error)
61
93
  end
62
94
 
95
+ ##
96
+ # Produces a random month in two digits format.
97
+ #
98
+ # @return [String]
99
+ #
100
+ # @example
101
+ # Faker::Stripe.month #=> "10"
102
+ #
103
+ # @faker.version 1.9.0
63
104
  def month
64
105
  format('%02d', rand_in_range(1, 12))
65
106
  end
66
107
 
108
+ ##
109
+ # Produces a random year that is always in the future.
110
+ #
111
+ # @return [String]
112
+ #
113
+ # @example
114
+ # Faker::Stripe.year #=> "2018" # This will always be a year in the future
115
+ #
116
+ # @faker.version 1.9.0
67
117
  def year
68
118
  start_year = ::Time.new.year + 1
69
119
  rand_in_range(start_year, start_year + 5).to_s
70
120
  end
71
121
 
122
+ ##
123
+ # Produces a random ccv number.
124
+ #
125
+ # @param card_type [String] Specific valid card type.
126
+ # @return [String]
127
+ #
128
+ # @example
129
+ # Faker::Stripe.ccv #=> "123"
130
+ # Faker::Stripe.ccv(card_type: "amex") #=> "1234"
131
+ #
132
+ # @faker.version 1.9.0
72
133
  def ccv(legacy_card_type = NOT_GIVEN, card_type: nil)
73
134
  warn_for_deprecated_arguments do |keywords|
74
135
  keywords << :card_type if legacy_card_type != NOT_GIVEN
@@ -3,6 +3,19 @@
3
3
  module Faker
4
4
  class Twitter < Base
5
5
  class << self
6
+ ##
7
+ # Produces a random Twitter user.
8
+ #
9
+ # @param include_status [Boolean] Include or exclude user status details
10
+ # @param include_email [Boolean] Include or exclude user email details
11
+ # @return [Hash]
12
+ #
13
+ # @example
14
+ # Faker::Twitter.user #=> {:id=>8821452687517076614, :name=>"Lincoln Paucek", :screen_name=>"cody"...
15
+ # Faker::Twitter.user(include_status: false) # Just get a user object with no embed status
16
+ # Faker::Twitter.user(include_email: true) # Simulate an authenticated user with the email permission
17
+ #
18
+ # @faker.version 1.7.3
6
19
  def user(legacy_include_status = NOT_GIVEN, legacy_include_email = NOT_GIVEN, include_status: true, include_email: false)
7
20
  warn_for_deprecated_arguments do |keywords|
8
21
  keywords << :include_status if legacy_include_status != NOT_GIVEN
@@ -59,6 +72,19 @@ module Faker
59
72
  user
60
73
  end
61
74
 
75
+ ##
76
+ # Produces a random Twitter user.
77
+ #
78
+ # @param include_user [Boolean] Include or exclude user details
79
+ # @param include_photo [Boolean] Include or exclude user photo
80
+ # @return [Hash]
81
+ #
82
+ # @example
83
+ # Faker::Twitter.status #=> {:id=>8821452687517076614, :text=>"Ea et laboriosam vel non."...
84
+ # Faker::Twitter.status(include_user: false) # Just get a status object with no embed user
85
+ # Faker::Twitter.status(include_photo: true) # Includes entities for an attached image
86
+ #
87
+ # @faker.version 1.7.3
62
88
  def status(legacy_include_user = NOT_GIVEN, legacy_include_photo = NOT_GIVEN, include_user: true, include_photo: false)
63
89
  warn_for_deprecated_arguments do |keywords|
64
90
  keywords << :include_user if legacy_include_user != NOT_GIVEN
@@ -97,6 +123,15 @@ module Faker
97
123
  status
98
124
  end
99
125
 
126
+ ##
127
+ # Produces a random screen name.
128
+ #
129
+ # @return [String]
130
+ #
131
+ # @example
132
+ # Faker::Twitter.screen_name #=> "audreanne_hackett"
133
+ #
134
+ # @faker.version 1.7.3
100
135
  def screen_name
101
136
  Faker::Internet.username(specifier: nil, separators: ['_'])[0...20]
102
137
  end
@@ -7,6 +7,15 @@ module Faker
7
7
  COMPLEX_TYPES = %i[hash array].freeze
8
8
 
9
9
  class << self
10
+ ##
11
+ # Produces a random String created from word (Faker::Lorem.word)
12
+ #
13
+ # @return [String]
14
+ #
15
+ # @example
16
+ # Faker::Types.rb_string #=> "foobar"
17
+ #
18
+ # @faker.version 1.8.6
10
19
  def rb_string(legacy_words = NOT_GIVEN, words: 1)
11
20
  warn_for_deprecated_arguments do |keywords|
12
21
  keywords << :words if legacy_words != NOT_GIVEN
@@ -20,10 +29,28 @@ module Faker
20
29
  shuffle(word_list)[0, resolved_num].join(' ')
21
30
  end
22
31
 
32
+ ##
33
+ # Produces a random character from the a-z, 0-9 ranges.
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::Types.character #=> "n"
39
+ #
40
+ # @faker.version 1.8.6
23
41
  def character
24
42
  sample(CHARACTERS)
25
43
  end
26
44
 
45
+ ##
46
+ # Produces a random integer.
47
+ #
48
+ # @return [Integer]
49
+ #
50
+ # @example
51
+ # Faker::Types.rb_integer #=> 1
52
+ #
53
+ # @faker.version 1.8.6
27
54
  def rb_integer(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 100)
28
55
  warn_for_deprecated_arguments do |keywords|
29
56
  keywords << :from if legacy_from != NOT_GIVEN
@@ -33,6 +60,18 @@ module Faker
33
60
  rand(from..to).to_i
34
61
  end
35
62
 
63
+ ##
64
+ # Produces a random hash with random keys and values.
65
+ #
66
+ # @param number [Integer] Specifies the number of key-value pairs.
67
+ # @return [Hash]
68
+ #
69
+ # @example
70
+ # Faker::Types.rb_hash #=> {name: "bob"}
71
+ # Faker::Types.rb_hash(number: 1) #=> {name: "bob"}
72
+ # Faker::Types.rb_hash(number: 2) #=> {name: "bob", last: "marley"}
73
+ #
74
+ # @faker.version 1.8.6
36
75
  def rb_hash(legacy_number = NOT_GIVEN, legacy_type = NOT_GIVEN, number: 1, type: random_type)
37
76
  warn_for_deprecated_arguments do |keywords|
38
77
  keywords << :number if legacy_number != NOT_GIVEN
@@ -46,6 +85,18 @@ module Faker
46
85
  end
47
86
  end
48
87
 
88
+ ##
89
+ # Produces a random complex hash with random keys and values where the values may include other hashes and arrays.
90
+ #
91
+ # @param number [Integer] Specifies the number of key-value pairs.
92
+ # @return [Hash]
93
+ #
94
+ # @example
95
+ # Faker::Types.complex_rb_hash #=> {user: {first: "bob", last: "marley"}}
96
+ # Faker::Types.complex_rb_hash(number: 1) #=> {user: {first: "bob", last: "marley"}}
97
+ # Faker::Types.complex_rb_hash(number: 2) #=> {user: {first: "bob", last: "marley"}, son: ["damien", "marley"]}
98
+ #
99
+ # @faker.version 1.8.6
49
100
  def complex_rb_hash(legacy_number = NOT_GIVEN, number: 1)
50
101
  warn_for_deprecated_arguments do |keywords|
51
102
  keywords << :number if legacy_number != NOT_GIVEN
@@ -54,6 +105,17 @@ module Faker
54
105
  rb_hash(number: number, type: random_complex_type)
55
106
  end
56
107
 
108
+ ##
109
+ # Produces a random array.
110
+ #
111
+ # @param len [Integer] Specifies the number of elements in the array.
112
+ # @return [Array]
113
+ #
114
+ # @example
115
+ # Faker::Types.rb_array #=> ["a"]
116
+ # Faker::Types.rb_array(len: 4) #=> ["a", 1, 2, "bob"]
117
+ #
118
+ # @faker.version 1.8.6
57
119
  def rb_array(legacy_len = NOT_GIVEN, len: 1)
58
120
  warn_for_deprecated_arguments do |keywords|
59
121
  keywords << :len if legacy_len != NOT_GIVEN
@@ -66,6 +128,15 @@ module Faker
66
128
  end
67
129
  end
68
130
 
131
+ ##
132
+ # Produces a random type that's either a String or an Integer.
133
+ #
134
+ # @return [String, Integer]
135
+ #
136
+ # @example
137
+ # Faker::Types.random_type #=> 1 or "a" or "bob"
138
+ #
139
+ # @faker.version 1.8.6
69
140
  def random_type
70
141
  type_to_use = SIMPLE_TYPES[rand(0..SIMPLE_TYPES.length - 1)]
71
142
  case type_to_use
@@ -76,6 +147,15 @@ module Faker
76
147
  end
77
148
  end
78
149
 
150
+ ##
151
+ # Produces a random complex type that's either a String, an Integer, an array or a hash.
152
+ #
153
+ # @return [String, Integer]
154
+ #
155
+ # @example
156
+ # Faker::Types.random_complex_type #=> 1 or "a" or "bob" or {foo: "bar"}
157
+ #
158
+ # @faker.version 1.8.6
79
159
  def random_complex_type
80
160
  types = SIMPLE_TYPES + COMPLEX_TYPES
81
161
  type_to_use = types[rand(0..types.length - 1)]