faker 1.8.7 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +146 -6
- data/README.md +44 -4
- data/lib/extensions/array.rb +10 -10
- data/lib/extensions/symbol.rb +0 -1
- data/lib/faker.rb +42 -35
- data/lib/faker/address.rb +39 -13
- data/lib/faker/app.rb +1 -3
- data/lib/faker/appliance.rb +13 -0
- data/lib/faker/avatar.rb +2 -2
- data/lib/faker/bank.rb +72 -15
- data/lib/faker/beer.rb +0 -1
- data/lib/faker/bitcoin.rb +4 -5
- data/lib/faker/bojack_horseman.rb +17 -0
- data/lib/faker/breaking_bad.rb +0 -3
- data/lib/faker/business.rb +1 -2
- data/lib/faker/cannabis.rb +42 -0
- data/lib/faker/chuck_norris.rb +3 -2
- data/lib/faker/code.rb +59 -20
- data/lib/faker/coffee.rb +4 -0
- data/lib/faker/color.rb +2 -2
- data/lib/faker/commerce.rb +3 -4
- data/lib/faker/community.rb +13 -0
- data/lib/faker/company.rb +80 -24
- data/lib/faker/currency.rb +17 -0
- data/lib/faker/date.rb +13 -27
- data/lib/faker/demographic.rb +2 -2
- data/lib/faker/device.rb +29 -0
- data/lib/faker/dota.rb +25 -0
- data/lib/faker/dr_who.rb +7 -8
- data/lib/faker/dumb_and_dumber.rb +1 -1
- data/lib/faker/dune.rb +4 -4
- data/lib/faker/elder_scrolls.rb +16 -0
- data/lib/faker/electrical_components.rb +19 -0
- data/lib/faker/ethereum.rb +12 -0
- data/lib/faker/famous_last_words.rb +11 -0
- data/lib/faker/file.rb +2 -5
- data/lib/faker/fillmurray.rb +3 -4
- data/lib/faker/finance.rb +3 -4
- data/lib/faker/food.rb +21 -1
- data/lib/faker/football.rb +21 -0
- data/lib/faker/gender.rb +13 -0
- data/lib/faker/greek_philosophers.rb +13 -0
- data/lib/faker/hacker.rb +9 -11
- data/lib/faker/harry_potter.rb +4 -0
- data/lib/faker/hipster.rb +12 -4
- data/lib/faker/id_number.rb +24 -9
- data/lib/faker/internet.rb +69 -57
- data/lib/faker/invoice.rb +94 -0
- data/lib/faker/job.rb +10 -3
- data/lib/faker/lebowski.rb +2 -2
- data/lib/faker/lord_of_the_rings.rb +5 -1
- data/lib/faker/lorem.rb +32 -8
- data/lib/faker/lorem_flickr.rb +43 -0
- data/lib/faker/lorem_pixel.rb +20 -5
- data/lib/faker/lovecraft.rb +12 -5
- data/lib/faker/markdown.rb +12 -4
- data/lib/faker/measurement.rb +35 -80
- data/lib/faker/michael_scott.rb +9 -0
- data/lib/faker/military.rb +25 -0
- data/lib/faker/music.rb +13 -1
- data/lib/faker/myst.rb +25 -0
- data/lib/faker/name.rb +22 -8
- data/lib/faker/nation.rb +24 -0
- data/lib/faker/nato_phonetic_alphabet.rb +9 -0
- data/lib/faker/new_girl.rb +13 -0
- data/lib/faker/number.rb +12 -12
- data/lib/faker/omniauth.rb +110 -122
- data/lib/faker/parks_and_rec.rb +13 -0
- data/lib/faker/phone_number.rb +11 -19
- data/lib/faker/placeholdit.rb +11 -2
- data/lib/faker/princess_bride.rb +13 -0
- data/lib/faker/rick_and_morty.rb +1 -1
- data/lib/faker/science.rb +4 -2
- data/lib/faker/seinfeld.rb +1 -1
- data/lib/faker/shakespeare.rb +0 -3
- data/lib/faker/silicon_valley.rb +4 -0
- data/lib/faker/simpsons.rb +3 -8
- data/lib/faker/singular_siegler.rb +9 -0
- data/lib/faker/slack_emoji.rb +0 -2
- data/lib/faker/source.rb +18 -0
- data/lib/faker/space.rb +4 -0
- data/lib/faker/star_trek.rb +2 -2
- data/lib/faker/star_wars.rb +5 -6
- data/lib/faker/stranger_thing.rb +13 -0
- data/lib/faker/string.rb +45 -0
- data/lib/faker/stripe.rb +63 -0
- data/lib/faker/sword_art_online.rb +21 -0
- data/lib/faker/team.rb +4 -1
- data/lib/faker/the_it_crowd.rb +21 -0
- data/lib/faker/time.rb +10 -10
- data/lib/faker/twin_peaks.rb +2 -2
- data/lib/faker/twitter.rb +1 -1
- data/lib/faker/types.rb +36 -40
- data/lib/faker/university.rb +3 -3
- data/lib/faker/vehicle.rb +72 -10
- data/lib/faker/verb.rb +25 -0
- data/lib/faker/version.rb +1 -1
- data/lib/faker/world_cup.rb +25 -0
- data/lib/helpers/char.rb +19 -20
- data/lib/helpers/unique_generator.rb +7 -1
- data/lib/locales/ca-CAT.yml +1 -1
- data/lib/locales/da-DK.yml +1 -0
- data/lib/locales/de-AT.yml +3 -2
- data/lib/locales/de.yml +6 -5
- data/lib/locales/ee.yml +59 -0
- data/lib/locales/en-CA.yml +23 -1
- data/lib/locales/en-GB.yml +1 -0
- data/lib/locales/en-NZ.yml +4 -3
- data/lib/locales/en-US.yml +2 -0
- data/lib/locales/en.yml +2 -2
- data/lib/locales/en/appliance.yml +5 -0
- data/lib/locales/en/bank.yml +274 -59
- data/lib/locales/en/bojack_horseman.yml +6 -0
- data/lib/locales/en/cannabis.yml +12 -0
- data/lib/locales/en/community.yml +33 -0
- data/lib/locales/en/currency.yml +6 -0
- data/lib/locales/en/dessert.yml +3 -3
- data/lib/locales/en/device.yml +7 -0
- data/lib/locales/en/dota.yml +102 -0
- data/lib/locales/en/dr_who.yml +5 -1
- data/lib/locales/en/dumb_and_dumber.yml +1 -1
- data/lib/locales/en/elder_scrolls.yml +8 -5
- data/lib/locales/en/electrical_components.yml +6 -0
- data/lib/locales/en/famous_last_words.yml +4 -0
- data/lib/locales/en/food.yml +6 -3
- data/lib/locales/en/football.yml +7 -0
- data/lib/locales/en/gender.yml +5 -0
- data/lib/locales/en/greek_philosophers.yml +26 -0
- data/lib/locales/en/harry_potter.yml +2 -1
- data/lib/locales/en/invoice.yml +6 -0
- data/lib/locales/en/job.yml +2 -2
- data/lib/locales/en/lord_of_the_rings.yml +1 -0
- data/lib/locales/en/lorem.yml +4 -0
- data/lib/locales/en/michael_scott.yml +45 -0
- data/lib/locales/en/military.yml +8 -0
- data/lib/locales/en/music.yml +29 -1
- data/lib/locales/en/myst.yml +47 -0
- data/lib/locales/en/name.yml +13 -12
- data/lib/locales/en/nation.yml +8 -0
- data/lib/locales/en/nato_phonetic_alphabet.yml +4 -0
- data/lib/locales/en/new_girl.yml +40 -0
- data/lib/locales/en/overwatch.yml +3 -2
- data/lib/locales/en/parks_and_rec.yml +7 -0
- data/lib/locales/en/princess_bride.yml +5 -0
- data/lib/locales/en/programming_language.yml +2 -1
- data/lib/locales/en/science.yml +1 -0
- data/lib/locales/en/silicon_valley.yml +1 -0
- data/lib/locales/en/singular_siegler.yml +37 -0
- data/lib/locales/en/source.yml +16 -0
- data/lib/locales/en/space.yml +2 -1
- data/lib/locales/en/star_wars.yml +10 -0
- data/lib/locales/en/stranger_thing.yml +36 -0
- data/lib/locales/en/stripe.yml +42 -0
- data/lib/locales/en/sword_art_online.yml +334 -0
- data/lib/locales/en/team.yml +1 -1
- data/lib/locales/en/the_it_crowd.yml +155 -0
- data/lib/locales/en/vehicle.yml +24 -0
- data/lib/locales/en/verbs.yml +8 -0
- data/lib/locales/en/world_cup.yml +271 -0
- data/lib/locales/es.yml +6 -1
- data/lib/locales/fi-FI.yml +9 -4
- data/lib/locales/fr-CA.yml +90 -0
- data/lib/locales/fr-CH.yml +73 -0
- data/lib/locales/fr.yml +4 -2
- data/lib/locales/it.yml +1 -1
- data/lib/locales/ja.yml +11 -0
- data/lib/locales/lv.yml +53 -0
- data/lib/locales/nl.yml +1 -1
- data/lib/locales/no.yml +7 -0
- data/lib/locales/pl.yml +1 -0
- data/lib/locales/pt-BR.yml +21 -13
- data/lib/locales/pt.yml +1 -0
- data/lib/locales/sv.yml +4 -4
- data/lib/locales/tr.yml +8 -0
- data/lib/locales/uk.yml +9 -0
- metadata +167 -3
data/lib/faker/phone_number.rb
CHANGED
@@ -9,36 +9,28 @@ module Faker
|
|
9
9
|
parse('cell_phone.formats')
|
10
10
|
end
|
11
11
|
|
12
|
-
# US only
|
12
|
+
# US and Canada only
|
13
13
|
def area_code
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
nil
|
18
|
-
end
|
14
|
+
fetch('phone_number.area_code')
|
15
|
+
rescue I18n::MissingTranslationData
|
16
|
+
nil
|
19
17
|
end
|
20
18
|
|
21
|
-
# US only
|
19
|
+
# US and Canada only
|
22
20
|
def exchange_code
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
nil
|
27
|
-
end
|
21
|
+
fetch('phone_number.exchange_code')
|
22
|
+
rescue I18n::MissingTranslationData
|
23
|
+
nil
|
28
24
|
end
|
29
25
|
|
30
|
-
# US only
|
26
|
+
# US and Canada only
|
31
27
|
# Can be used for both extensions and last four digits of phone number.
|
32
28
|
# Since extensions can be of variable length, this method taks a length parameter
|
33
29
|
def subscriber_number(length = 4)
|
34
|
-
|
35
|
-
rand.to_s[2..(1 + length)]
|
36
|
-
rescue I18n::MissingTranslationData
|
37
|
-
nil
|
38
|
-
end
|
30
|
+
rand.to_s[2..(1 + length)]
|
39
31
|
end
|
40
32
|
|
41
|
-
|
33
|
+
alias extension subscriber_number
|
42
34
|
end
|
43
35
|
end
|
44
36
|
end
|
data/lib/faker/placeholdit.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
module Faker
|
2
2
|
class Placeholdit < Base
|
3
3
|
class << self
|
4
|
-
SUPPORTED_FORMATS = %w
|
4
|
+
SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
|
5
5
|
|
6
6
|
def image(size = '300x300', format = 'png', background_color = nil, text_color = nil, text = nil)
|
7
|
-
|
7
|
+
background_color = generate_color if background_color == :random
|
8
|
+
text_color = generate_color if text_color == :random
|
9
|
+
|
10
|
+
raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
|
8
11
|
raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format)
|
9
12
|
raise ArgumentError, "background_color must be a hex value without '#'" unless background_color.nil? || background_color.match(/((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/)
|
10
13
|
raise ArgumentError, "text_color must be a hex value without '#'" unless text_color.nil? || text_color.match(/((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/)
|
@@ -15,6 +18,12 @@ module Faker
|
|
15
18
|
image_url += "?text=#{text}" if text
|
16
19
|
image_url
|
17
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def generate_color
|
25
|
+
format('%06x', (rand * 0xffffff))
|
26
|
+
end
|
18
27
|
end
|
19
28
|
end
|
20
29
|
end
|
data/lib/faker/rick_and_morty.rb
CHANGED
data/lib/faker/science.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
module Faker
|
2
2
|
class Science < Base
|
3
3
|
class << self
|
4
|
-
|
5
4
|
def element
|
6
5
|
fetch('science.element')
|
7
6
|
end
|
8
7
|
|
8
|
+
def element_symbol
|
9
|
+
fetch('science.element_symbol')
|
10
|
+
end
|
11
|
+
|
9
12
|
def scientist
|
10
13
|
fetch('science.scientist')
|
11
14
|
end
|
12
|
-
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/faker/seinfeld.rb
CHANGED
data/lib/faker/shakespeare.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Faker
|
2
2
|
class Shakespeare < Base
|
3
3
|
class << self
|
4
|
-
|
5
4
|
def hamlet_quote
|
6
5
|
sample(hamlet)
|
7
6
|
end
|
@@ -26,7 +25,6 @@ module Faker
|
|
26
25
|
fetch('shakespeare.as_you_like_it')
|
27
26
|
end
|
28
27
|
|
29
|
-
|
30
28
|
def king_richard_iii
|
31
29
|
fetch('shakespeare.king_richard_iii')
|
32
30
|
end
|
@@ -34,7 +32,6 @@ module Faker
|
|
34
32
|
def romeo_and_juliet
|
35
33
|
fetch('shakespeare.romeo_and_juliet')
|
36
34
|
end
|
37
|
-
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
data/lib/faker/silicon_valley.rb
CHANGED
data/lib/faker/simpsons.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
#
|
2
|
-
#frozen_string_literal: true
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module Faker
|
5
|
-
|
6
4
|
class Simpsons < Base
|
7
|
-
|
8
5
|
def self.character
|
9
6
|
fetch('simpsons.characters')
|
10
7
|
end
|
@@ -16,7 +13,5 @@ module Faker
|
|
16
13
|
def self.quote
|
17
14
|
fetch('simpsons.quotes')
|
18
15
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end #module Faker
|
16
|
+
end
|
17
|
+
end
|
data/lib/faker/slack_emoji.rb
CHANGED
data/lib/faker/source.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Faker
|
2
|
+
class Source < Base
|
3
|
+
class << self
|
4
|
+
def hello_world(lang = :ruby)
|
5
|
+
fetch("source.hello_world.#{lang}")
|
6
|
+
end
|
7
|
+
|
8
|
+
def print(str: 'some string', lang: :ruby)
|
9
|
+
code = fetch("source.print.#{lang}")
|
10
|
+
code.gsub('faker_string_to_print', str)
|
11
|
+
end
|
12
|
+
|
13
|
+
def print_1_to_10(lang = :ruby)
|
14
|
+
fetch("source.print_1_to_10.#{lang}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/faker/space.rb
CHANGED
data/lib/faker/star_trek.rb
CHANGED
data/lib/faker/star_wars.rb
CHANGED
@@ -36,9 +36,9 @@ module Faker
|
|
36
36
|
def wookiee_sentence
|
37
37
|
sentence = sample(wookiee_words).capitalize
|
38
38
|
|
39
|
-
rand(0..10).times { sentence +=
|
39
|
+
rand(0..10).times { sentence += ' ' + sample(wookiee_words) }
|
40
40
|
|
41
|
-
sentence + sample(['.','?','!'])
|
41
|
+
sentence + sample(['.', '?', '!'])
|
42
42
|
end
|
43
43
|
|
44
44
|
def call_numbers
|
@@ -74,7 +74,7 @@ module Faker
|
|
74
74
|
character = k.to_s if v.include?(character)
|
75
75
|
end
|
76
76
|
|
77
|
-
unless quoted_characters.
|
77
|
+
unless quoted_characters.key?(character.to_sym)
|
78
78
|
raise ArgumentError, "Character for quotes can be left blank or #{quoted_characters.keys.join(', ')}"
|
79
79
|
end
|
80
80
|
end
|
@@ -94,9 +94,8 @@ module Faker
|
|
94
94
|
fetch_all('star_wars.wookiee_words')
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
alias wookie_sentence wookiee_sentence
|
98
|
+
alias wookie_words wookiee_words
|
100
99
|
end
|
101
100
|
end
|
102
101
|
end
|
data/lib/faker/string.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class String < Base
|
5
|
+
class << self
|
6
|
+
def random(length = 32)
|
7
|
+
utf8string select_a length
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def select_a(length)
|
13
|
+
if length.class.included_modules.include? Enumerable
|
14
|
+
select_a sample(length.to_enum.to_a)
|
15
|
+
else
|
16
|
+
length # recursive base case
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def utf8string(length)
|
21
|
+
ratio = char_space_ratio
|
22
|
+
(1..length.to_i).map do
|
23
|
+
space_or_utf8_char ratio
|
24
|
+
end.join
|
25
|
+
end
|
26
|
+
|
27
|
+
def space_or_utf8_char(ratio)
|
28
|
+
sample [32.chr(Encoding::UTF_8), [utf8character] * ratio].flatten
|
29
|
+
end
|
30
|
+
|
31
|
+
def char_space_ratio
|
32
|
+
sample [2, [3] * 5, [5] * 17, [7] * 11, 11, 191].flatten
|
33
|
+
end
|
34
|
+
|
35
|
+
def utf8character
|
36
|
+
sample([
|
37
|
+
rand(32..90), # latin alphabet
|
38
|
+
rand(128), # 7-bit ASCII
|
39
|
+
rand(0xd800), # utf-8 codepoints below utf-16 surrogate halves
|
40
|
+
rand(57_344..1_114_111) # utf-8 codepoints above utf-16 surrogate halves
|
41
|
+
]).chr(Encoding::UTF_8)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/faker/stripe.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
module Faker
|
2
|
+
class Stripe < Base
|
3
|
+
class << self
|
4
|
+
def valid_card(card_type = nil)
|
5
|
+
valid_cards = translate('faker.stripe.valid_cards').keys
|
6
|
+
|
7
|
+
if card_type.nil?
|
8
|
+
card_type = sample(valid_cards).to_s
|
9
|
+
else
|
10
|
+
unless valid_cards.include?(card_type.to_sym)
|
11
|
+
raise ArgumentError,
|
12
|
+
"Valid credit cards argument can be left blank or include #{valid_cards.join(', ')}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
fetch('stripe.valid_cards.' + card_type)
|
17
|
+
end
|
18
|
+
|
19
|
+
def valid_token(card_type = nil)
|
20
|
+
valid_tokens = translate('faker.stripe.valid_tokens').keys
|
21
|
+
|
22
|
+
if card_type.nil?
|
23
|
+
card_type = sample(valid_tokens).to_s
|
24
|
+
else
|
25
|
+
unless valid_tokens.include?(card_type.to_sym)
|
26
|
+
raise ArgumentError,
|
27
|
+
"Valid credit cards argument can be left blank or include #{valid_tokens.join(', ')}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
fetch('stripe.valid_tokens.' + card_type)
|
32
|
+
end
|
33
|
+
|
34
|
+
def invalid_card(card_error = nil)
|
35
|
+
invalid_cards = translate('faker.stripe.invalid_cards').keys
|
36
|
+
|
37
|
+
if card_error.nil?
|
38
|
+
card_error = sample(invalid_cards).to_s
|
39
|
+
else
|
40
|
+
unless invalid_cards.include?(card_error.to_sym)
|
41
|
+
raise ArgumentError,
|
42
|
+
"Invalid credit cards argument can be left blank or include #{invalid_cards.join(', ')}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
fetch('stripe.invalid_cards.' + card_error)
|
47
|
+
end
|
48
|
+
|
49
|
+
def month
|
50
|
+
format('%02d', rand_in_range(1, 12))
|
51
|
+
end
|
52
|
+
|
53
|
+
def year
|
54
|
+
start_year = ::Time.new.year + 1
|
55
|
+
rand_in_range(start_year, start_year + 5).to_s
|
56
|
+
end
|
57
|
+
|
58
|
+
def ccv(card_type = nil)
|
59
|
+
(card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Faker
|
2
|
+
class SwordArtOnline < Base
|
3
|
+
class << self
|
4
|
+
def real_name
|
5
|
+
fetch('sword_art_online.real_name')
|
6
|
+
end
|
7
|
+
|
8
|
+
def game_name
|
9
|
+
fetch('sword_art_online.game_name')
|
10
|
+
end
|
11
|
+
|
12
|
+
def location
|
13
|
+
fetch('sword_art_online.location')
|
14
|
+
end
|
15
|
+
|
16
|
+
def item
|
17
|
+
fetch('sword_art_online.item')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|