faker 2.2.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +155 -15
- data/README.md +2 -2
- data/lib/faker.rb +34 -0
- data/lib/faker/blockchain/aeternity.rb +70 -0
- data/lib/faker/blockchain/bitcoin.rb +26 -0
- data/lib/faker/blockchain/ethereum.rb +10 -0
- data/lib/faker/blockchain/tezos.rb +62 -6
- data/lib/faker/books/book.rb +36 -0
- data/lib/faker/books/culture_series.rb +49 -0
- data/lib/faker/books/dune.rb +60 -9
- data/lib/faker/books/lovecraft.rb +189 -33
- data/lib/faker/creature/animal.rb +9 -0
- data/lib/faker/creature/cat.rb +27 -0
- data/lib/faker/creature/dog.rb +72 -0
- data/lib/faker/creature/horse.rb +18 -0
- data/lib/faker/default/address.rb +10 -15
- data/lib/faker/default/alphanumeric.rb +29 -18
- data/lib/faker/default/app.rb +50 -11
- data/lib/faker/default/appliance.rb +18 -0
- data/lib/faker/default/artist.rb +9 -0
- data/lib/faker/default/avatar.rb +38 -19
- data/lib/faker/default/bank.rb +4 -6
- data/lib/faker/default/boolean.rb +14 -4
- data/lib/faker/default/chile_rut.rb +6 -14
- data/lib/faker/default/chuck_norris.rb +1 -1
- data/lib/faker/default/code.rb +7 -13
- data/lib/faker/default/commerce.rb +8 -17
- data/lib/faker/default/company.rb +4 -6
- data/lib/faker/default/crypto_coin.rb +6 -9
- data/lib/faker/default/date.rb +100 -30
- data/lib/faker/default/demographic.rb +2 -3
- data/lib/faker/default/dessert.rb +27 -0
- data/lib/faker/default/device.rb +54 -0
- data/lib/faker/default/driving_licence.rb +7 -17
- data/lib/faker/default/electrical_components.rb +27 -0
- data/lib/faker/default/file.rb +9 -26
- data/lib/faker/default/fillmurray.rb +4 -11
- data/lib/faker/default/finance.rb +2 -3
- data/lib/faker/default/gender.rb +18 -0
- data/lib/faker/default/greek_philosophers.rb +18 -0
- data/lib/faker/default/hacker.rb +59 -1
- data/lib/faker/default/hipster.rb +21 -54
- data/lib/faker/default/house.rb +18 -0
- data/lib/faker/default/id_number.rb +5 -7
- data/lib/faker/default/industry_segments.rb +36 -0
- data/lib/faker/default/internet.rb +49 -76
- data/lib/faker/default/invoice.rb +7 -13
- data/lib/faker/default/json.rb +9 -16
- data/lib/faker/default/lorem.rb +38 -77
- data/lib/faker/default/lorem_flickr.rb +17 -48
- data/lib/faker/default/lorem_pixel.rb +7 -23
- data/lib/faker/default/markdown.rb +3 -7
- data/lib/faker/default/marketing.rb +9 -0
- data/lib/faker/default/measurement.rb +16 -24
- data/lib/faker/default/military.rb +45 -0
- data/lib/faker/default/name.rb +2 -3
- data/lib/faker/default/nation.rb +48 -5
- data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
- data/lib/faker/default/nhs.rb +2 -3
- data/lib/faker/default/number.rb +150 -51
- data/lib/faker/default/omniauth.rb +67 -63
- data/lib/faker/default/phone_number.rb +2 -3
- data/lib/faker/default/placeholdit.rb +6 -19
- data/lib/faker/default/programming_language.rb +18 -0
- data/lib/faker/default/relationship.rb +2 -3
- data/lib/faker/default/restaurant.rb +54 -2
- data/lib/faker/default/science.rb +27 -0
- data/lib/faker/default/source.rb +51 -14
- data/lib/faker/default/string.rb +2 -3
- data/lib/faker/default/stripe.rb +8 -12
- data/lib/faker/default/subscription.rb +45 -0
- data/lib/faker/default/superhero.rb +45 -0
- data/lib/faker/default/time.rb +102 -56
- data/lib/faker/default/twitter.rb +23 -32
- data/lib/faker/default/types.rb +12 -23
- data/lib/faker/default/vehicle.rb +8 -14
- data/lib/faker/default/world_cup.rb +55 -10
- data/lib/faker/games/dota.rb +49 -3
- data/lib/faker/games/elder_scrolls.rb +72 -0
- data/lib/faker/games/fallout.rb +37 -0
- data/lib/faker/games/game.rb +27 -0
- data/lib/faker/games/half_life.rb +27 -0
- data/lib/faker/games/heroes.rb +27 -0
- data/lib/faker/games/heroes_of_the_storm.rb +36 -0
- data/lib/faker/games/league_of_legends.rb +54 -0
- data/lib/faker/games/myst.rb +45 -0
- data/lib/faker/games/overwatch.rb +27 -0
- data/lib/faker/games/pokemon.rb +27 -0
- data/lib/faker/games/sonic_the_hedgehog.rb +27 -0
- data/lib/faker/games/super_smash_bros.rb +18 -0
- data/lib/faker/games/witcher.rb +54 -0
- data/lib/faker/games/world_of_warcraft.rb +18 -0
- data/lib/faker/games/zelda.rb +37 -1
- data/lib/faker/japanese_media/dragon_ball.rb +9 -0
- data/lib/faker/japanese_media/one_piece.rb +54 -0
- data/lib/faker/japanese_media/sword_art_online.rb +36 -0
- data/lib/faker/movies/back_to_the_future.rb +28 -0
- data/lib/faker/movies/ghostbusters.rb +28 -0
- data/lib/faker/movies/harry_potter.rb +54 -0
- data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +69 -0
- data/lib/faker/movies/hobbit.rb +37 -0
- data/lib/faker/movies/lebowski.rb +27 -0
- data/lib/faker/movies/lord_of_the_rings.rb +28 -0
- data/lib/faker/movies/movie.rb +9 -0
- data/lib/faker/movies/princess_bride.rb +19 -0
- data/lib/faker/movies/star_wars.rb +97 -6
- data/lib/faker/movies/v_for_vendetta.rb +29 -0
- data/lib/faker/music/grateful_dead.rb +18 -0
- data/lib/faker/music/phish.rb +9 -0
- data/lib/faker/music/rock_band.rb +9 -0
- data/lib/faker/music/umphreys_mcgee.rb +9 -0
- data/lib/faker/sports/basketball.rb +36 -0
- data/lib/faker/sports/football.rb +45 -0
- data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +9 -0
- data/lib/faker/tv_shows/bojack_horseman.rb +28 -0
- data/lib/faker/tv_shows/breaking_bad.rb +18 -0
- data/lib/faker/tv_shows/buffy.rb +45 -0
- data/lib/faker/tv_shows/community.rb +19 -0
- data/lib/faker/tv_shows/dr_who.rb +78 -2
- data/lib/faker/tv_shows/dumb_and_dumber.rb +28 -0
- data/lib/faker/tv_shows/family_guy.rb +28 -0
- data/lib/faker/tv_shows/friends.rb +27 -0
- data/lib/faker/tv_shows/game_of_thrones.rb +46 -0
- data/lib/faker/tv_shows/hey_arnold.rb +27 -0
- data/lib/faker/tv_shows/how_i_met_your_mother.rb +37 -0
- data/lib/faker/tv_shows/michael_scott.rb +13 -0
- data/lib/faker/tv_shows/new_girl.rb +19 -0
- data/lib/faker/tv_shows/parks_and_rec.rb +18 -0
- data/lib/faker/tv_shows/rick_and_morty.rb +28 -0
- data/lib/faker/tv_shows/ru_paul.rb +18 -0
- data/lib/faker/tv_shows/seinfeld.rb +28 -0
- data/lib/faker/tv_shows/silicon_valley.rb +75 -0
- data/lib/faker/tv_shows/simpsons.rb +28 -0
- data/lib/faker/tv_shows/south_park.rb +19 -0
- data/lib/faker/tv_shows/star_trek.rb +36 -0
- data/lib/faker/tv_shows/stargate.rb +28 -0
- data/lib/faker/tv_shows/stranger_things.rb +19 -0
- data/lib/faker/tv_shows/the_expanse.rb +36 -0
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +28 -0
- data/lib/faker/tv_shows/the_it_crowd.rb +37 -0
- data/lib/faker/tv_shows/the_thick_of_it.rb +28 -0
- data/lib/faker/tv_shows/twin_peaks.rb +28 -0
- data/lib/faker/tv_shows/venture_bros.rb +38 -0
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en-CA.yml +1 -1
- data/lib/locales/en-TH.yml +360 -0
- data/lib/locales/en/color.yml +1 -1
- data/lib/locales/en/dr_who.yml +1 -1
- data/lib/locales/en/science.yml +1 -1
- data/lib/locales/ja.yml +8 -9
- data/lib/locales/th.yml +380 -0
- metadata +39 -14
|
@@ -11,17 +11,10 @@ module Faker
|
|
|
11
11
|
# rubocop:disable Metrics/ParameterLists
|
|
12
12
|
def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
|
|
13
13
|
# rubocop:enable Metrics/ParameterLists
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if legacy_supplemental != NOT_GIVEN
|
|
19
|
-
warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.words` is deprecated. Use keyword argument like `Hipster.words(supplemental: ...)` instead.', uplevel: 1
|
|
20
|
-
supplemental = legacy_supplemental
|
|
21
|
-
end
|
|
22
|
-
if legacy_spaces_allowed != NOT_GIVEN
|
|
23
|
-
warn_with_uplevel 'Passing `spaces_allowed` with the 3rd argument of `Hipster.words` is deprecated. Use keyword argument like `Hipster.words(spaces_allowed: ...)` instead.', uplevel: 1
|
|
24
|
-
spaces_allowed = legacy_spaces_allowed
|
|
14
|
+
warn_for_deprecated_arguments do |keywords|
|
|
15
|
+
keywords << :number if legacy_number != NOT_GIVEN
|
|
16
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
|
17
|
+
keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN
|
|
25
18
|
end
|
|
26
19
|
|
|
27
20
|
resolved_num = resolve(number)
|
|
@@ -40,30 +33,19 @@ module Faker
|
|
|
40
33
|
# rubocop:disable Metrics/ParameterLists
|
|
41
34
|
def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6)
|
|
42
35
|
# rubocop:enable Metrics/ParameterLists
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if legacy_supplemental != NOT_GIVEN
|
|
48
|
-
warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.sentence` is deprecated. Use keyword argument like `Hipster.sentence(supplemental: ...)` instead.', uplevel: 1
|
|
49
|
-
supplemental = legacy_supplemental
|
|
50
|
-
end
|
|
51
|
-
if legacy_random_words_to_add != NOT_GIVEN
|
|
52
|
-
warn_with_uplevel 'Passing `random_words_to_add` with the 3rd argument of `Hipster.sentence` is deprecated. Use keyword argument like `Hipster.sentence(random_words_to_add: ...)` instead.', uplevel: 1
|
|
53
|
-
random_words_to_add = legacy_random_words_to_add
|
|
36
|
+
warn_for_deprecated_arguments do |keywords|
|
|
37
|
+
keywords << :word_count if legacy_word_count != NOT_GIVEN
|
|
38
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
|
39
|
+
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
|
|
54
40
|
end
|
|
55
41
|
|
|
56
42
|
words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
|
|
57
43
|
end
|
|
58
44
|
|
|
59
45
|
def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
end
|
|
64
|
-
if legacy_supplemental != NOT_GIVEN
|
|
65
|
-
warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.sentences` is deprecated. Use keyword argument like `Hipster.sentences(supplemental: ...)` instead.', uplevel: 1
|
|
66
|
-
supplemental = legacy_supplemental
|
|
46
|
+
warn_for_deprecated_arguments do |keywords|
|
|
47
|
+
keywords << :number if legacy_number != NOT_GIVEN
|
|
48
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
|
67
49
|
end
|
|
68
50
|
|
|
69
51
|
[].tap do |sentences|
|
|
@@ -76,30 +58,19 @@ module Faker
|
|
|
76
58
|
# rubocop:disable Metrics/ParameterLists
|
|
77
59
|
def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
|
|
78
60
|
# rubocop:enable Metrics/ParameterLists
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if legacy_supplemental != NOT_GIVEN
|
|
84
|
-
warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.paragraph` is deprecated. Use keyword argument like `Hipster.paragraph(supplemental: ...)` instead.', uplevel: 1
|
|
85
|
-
supplemental = legacy_supplemental
|
|
86
|
-
end
|
|
87
|
-
if legacy_random_sentences_to_add != NOT_GIVEN
|
|
88
|
-
warn_with_uplevel 'Passing `random_sentences_to_add` with the 3rd argument of `Hipster.paragraph` is deprecated. Use keyword argument like `Hipster.paragraph(random_sentences_to_add: ...)` instead.', uplevel: 1
|
|
89
|
-
random_sentences_to_add = legacy_random_sentences_to_add
|
|
61
|
+
warn_for_deprecated_arguments do |keywords|
|
|
62
|
+
keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
|
|
63
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
|
64
|
+
keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
|
|
90
65
|
end
|
|
91
66
|
|
|
92
67
|
sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
|
|
93
68
|
end
|
|
94
69
|
|
|
95
70
|
def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
end
|
|
100
|
-
if legacy_supplemental != NOT_GIVEN
|
|
101
|
-
warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.paragraphs` is deprecated. Use keyword argument like `Hipster.paragraphs(supplemental: ...)` instead.', uplevel: 1
|
|
102
|
-
supplemental = legacy_supplemental
|
|
71
|
+
warn_for_deprecated_arguments do |keywords|
|
|
72
|
+
keywords << :number if legacy_number != NOT_GIVEN
|
|
73
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
|
103
74
|
end
|
|
104
75
|
|
|
105
76
|
[].tap do |paragraphs|
|
|
@@ -110,13 +81,9 @@ module Faker
|
|
|
110
81
|
end
|
|
111
82
|
|
|
112
83
|
def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
end
|
|
117
|
-
if legacy_supplemental != NOT_GIVEN
|
|
118
|
-
warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.paragraph_by_chars` is deprecated. Use keyword argument like `Hipster.paragraph_by_chars(supplemental: ...)` instead.', uplevel: 1
|
|
119
|
-
supplemental = legacy_supplemental
|
|
84
|
+
warn_for_deprecated_arguments do |keywords|
|
|
85
|
+
keywords << :characters if legacy_characters != NOT_GIVEN
|
|
86
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
|
120
87
|
end
|
|
121
88
|
|
|
122
89
|
paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
|
data/lib/faker/default/house.rb
CHANGED
|
@@ -3,10 +3,28 @@
|
|
|
3
3
|
module Faker
|
|
4
4
|
class House < Base
|
|
5
5
|
class << self
|
|
6
|
+
##
|
|
7
|
+
# Produces the name of a piece of furniture.
|
|
8
|
+
#
|
|
9
|
+
# @return [String]
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# Faker::House.furniture #=> "chair"
|
|
13
|
+
#
|
|
14
|
+
# @faker.version 1.9.2
|
|
6
15
|
def furniture
|
|
7
16
|
fetch('house.furniture')
|
|
8
17
|
end
|
|
9
18
|
|
|
19
|
+
##
|
|
20
|
+
# Produces the name of a room in a house.
|
|
21
|
+
#
|
|
22
|
+
# @return [String]
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# Faker::House.room #=> "kitchen"
|
|
26
|
+
#
|
|
27
|
+
# @faker.version 1.9.2
|
|
10
28
|
def room
|
|
11
29
|
fetch('house.rooms')
|
|
12
30
|
end
|
|
@@ -12,7 +12,7 @@ module Faker
|
|
|
12
12
|
].freeze
|
|
13
13
|
ZA_RACE_DIGIT = '8'
|
|
14
14
|
ZA_CITIZENSHIP_DIGITS = %w[0 1].freeze
|
|
15
|
-
BRAZILIAN_ID_FORMAT = /(\d{1,2})(\d{3})(\d{3})([\dX])
|
|
15
|
+
BRAZILIAN_ID_FORMAT = /(\d{1,2})(\d{3})(\d{3})([\dX])/.freeze
|
|
16
16
|
BRAZILIAN_ID_FROM = 10_000_000
|
|
17
17
|
BRAZILIAN_ID_TO = 99_999_999
|
|
18
18
|
|
|
@@ -79,9 +79,8 @@ module Faker
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
def brazilian_citizen_number(legacy_formatted = NOT_GIVEN, formatted: false)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
formatted = legacy_formatted
|
|
82
|
+
warn_for_deprecated_arguments do |keywords|
|
|
83
|
+
keywords << :formatted if legacy_formatted != NOT_GIVEN
|
|
85
84
|
end
|
|
86
85
|
|
|
87
86
|
digits = Faker::Number.leading_zero_number(digits: 9) until digits&.match(/(\d)((?!\1)\d)+/)
|
|
@@ -94,9 +93,8 @@ module Faker
|
|
|
94
93
|
alias brazilian_cpf brazilian_citizen_number
|
|
95
94
|
|
|
96
95
|
def brazilian_id(legacy_formatted = NOT_GIVEN, formatted: false)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
formatted = legacy_formatted
|
|
96
|
+
warn_for_deprecated_arguments do |keywords|
|
|
97
|
+
keywords << :formatted if legacy_formatted != NOT_GIVEN
|
|
100
98
|
end
|
|
101
99
|
|
|
102
100
|
digits = Faker::Number.between(to: BRAZILIAN_ID_FROM, from: BRAZILIAN_ID_TO).to_s
|
|
@@ -5,18 +5,54 @@ module Faker
|
|
|
5
5
|
flexible :industry_segments
|
|
6
6
|
|
|
7
7
|
class << self
|
|
8
|
+
##
|
|
9
|
+
# Produces the name of an industry.
|
|
10
|
+
#
|
|
11
|
+
# @return [String]
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# Faker::IndustrySegments.industry #=> "Basic Materials"
|
|
15
|
+
#
|
|
16
|
+
# @faker.version 1.9.2
|
|
8
17
|
def industry
|
|
9
18
|
fetch('industry_segments.industry')
|
|
10
19
|
end
|
|
11
20
|
|
|
21
|
+
##
|
|
22
|
+
# Produces the name of a super-sector of an industry.
|
|
23
|
+
#
|
|
24
|
+
# @return [String]
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# Faker::IndustrySegments.super_sector #=> "Basic Resources"
|
|
28
|
+
#
|
|
29
|
+
# @faker.version 1.9.2
|
|
12
30
|
def super_sector
|
|
13
31
|
fetch('industry_segments.super_sector')
|
|
14
32
|
end
|
|
15
33
|
|
|
34
|
+
##
|
|
35
|
+
# Produces the name of a sector of an industry.
|
|
36
|
+
#
|
|
37
|
+
# @return [String]
|
|
38
|
+
#
|
|
39
|
+
# @example
|
|
40
|
+
# Faker::IndustrySegments.sector #=> "Industrial Metals & Mining"
|
|
41
|
+
#
|
|
42
|
+
# @faker.version 1.9.2
|
|
16
43
|
def sector
|
|
17
44
|
fetch('industry_segments.sector')
|
|
18
45
|
end
|
|
19
46
|
|
|
47
|
+
##
|
|
48
|
+
# Produces the name of a subsector of an industry.
|
|
49
|
+
#
|
|
50
|
+
# @return [String]
|
|
51
|
+
#
|
|
52
|
+
# @example
|
|
53
|
+
# Faker::IndustrySegments.industry #=> "Basic Materials"
|
|
54
|
+
#
|
|
55
|
+
# @faker.version 1.9.2
|
|
20
56
|
def sub_sector
|
|
21
57
|
fetch('industry_segments.sub_sector')
|
|
22
58
|
end
|
|
@@ -4,13 +4,9 @@ module Faker
|
|
|
4
4
|
class Internet < Base
|
|
5
5
|
class << self
|
|
6
6
|
def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, separators: nil)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
end
|
|
11
|
-
if legacy_separators != NOT_GIVEN
|
|
12
|
-
warn_with_uplevel 'Passing `separators` with the 2nd argument of `Internet.email` is deprecated. Use keyword argument like `Internet.email(separators: ...)` instead.', uplevel: 1
|
|
13
|
-
separators = legacy_separators
|
|
7
|
+
warn_for_deprecated_arguments do |keywords|
|
|
8
|
+
keywords << :name if legacy_name != NOT_GIVEN
|
|
9
|
+
keywords << :separators if legacy_separators != NOT_GIVEN
|
|
14
10
|
end
|
|
15
11
|
|
|
16
12
|
if separators
|
|
@@ -21,31 +17,25 @@ module Faker
|
|
|
21
17
|
end
|
|
22
18
|
|
|
23
19
|
def free_email(legacy_name = NOT_GIVEN, name: nil)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
name = legacy_name
|
|
20
|
+
warn_for_deprecated_arguments do |keywords|
|
|
21
|
+
keywords << :name if legacy_name != NOT_GIVEN
|
|
27
22
|
end
|
|
28
23
|
|
|
29
24
|
[username(specifier: name), fetch('internet.free_email')].join('@')
|
|
30
25
|
end
|
|
31
26
|
|
|
32
27
|
def safe_email(legacy_name = NOT_GIVEN, name: nil)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
name = legacy_name
|
|
28
|
+
warn_for_deprecated_arguments do |keywords|
|
|
29
|
+
keywords << :name if legacy_name != NOT_GIVEN
|
|
36
30
|
end
|
|
37
31
|
|
|
38
32
|
[username(specifier: name), 'example.' + sample(%w[org com net])].join('@')
|
|
39
33
|
end
|
|
40
34
|
|
|
41
35
|
def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specifier: nil, separators: %w[. _])
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
if legacy_separators != NOT_GIVEN
|
|
47
|
-
warn_with_uplevel 'Passing `separators` with the 2nd argument of `Internet.username` is deprecated. Use keyword argument like `Internet.username(separators: ...)` instead.', uplevel: 1
|
|
48
|
-
separators = legacy_separators
|
|
36
|
+
warn_for_deprecated_arguments do |keywords|
|
|
37
|
+
keywords << :specifier if legacy_specifier != NOT_GIVEN
|
|
38
|
+
keywords << :separators if legacy_separators != NOT_GIVEN
|
|
49
39
|
end
|
|
50
40
|
|
|
51
41
|
with_locale(:en) do
|
|
@@ -83,40 +73,37 @@ module Faker
|
|
|
83
73
|
end
|
|
84
74
|
end
|
|
85
75
|
|
|
76
|
+
# rubocop:disable Metrics/ParameterLists
|
|
77
|
+
|
|
86
78
|
##
|
|
87
|
-
# Produces a randomized string of characters
|
|
79
|
+
# Produces a randomized string of characters suitable for passwords
|
|
88
80
|
#
|
|
89
|
-
# @param [Integer]
|
|
90
|
-
# @param [Integer]
|
|
91
|
-
# @param [Boolean]
|
|
92
|
-
# @param [Boolean]
|
|
81
|
+
# @param min_length [Integer] The minimum length of the password
|
|
82
|
+
# @param max_length [Integer] The maximum length of the password
|
|
83
|
+
# @param mix_case [Boolean] Toggles if uppercased letters are allowed. If true, at least one will be added.
|
|
84
|
+
# @param special_characters [Boolean] Toggles if special characters are allowed. If true, at least one will be added.
|
|
93
85
|
#
|
|
94
86
|
# @return [String]
|
|
95
87
|
#
|
|
96
|
-
# @example
|
|
97
|
-
#
|
|
98
|
-
# @example
|
|
99
|
-
#
|
|
100
|
-
# @example
|
|
88
|
+
# @example
|
|
89
|
+
# Faker::Internet.password #=> "Vg5mSvY1UeRg7"
|
|
90
|
+
# @example
|
|
91
|
+
# Faker::Internet.password(min_length: 8) #=> "YfGjIk0hGzDqS0"
|
|
92
|
+
# @example
|
|
93
|
+
# Faker::Internet.password(min_length: 10, max_length: 20) #=> "EoC9ShWd1hWq4vBgFw"
|
|
94
|
+
# @example
|
|
95
|
+
# Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true) #=> "3k5qS15aNmG"
|
|
96
|
+
# @example
|
|
97
|
+
# Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4"
|
|
101
98
|
#
|
|
102
99
|
# @faker.version 2.1.3
|
|
103
|
-
# rubocop:disable Metrics/ParameterLists
|
|
104
100
|
def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legacy_mix_case = NOT_GIVEN, legacy_special_characters = NOT_GIVEN, min_length: 8, max_length: 16, mix_case: true, special_characters: false)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
min_length
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
max_length = legacy_max_length
|
|
112
|
-
end
|
|
113
|
-
if legacy_mix_case != NOT_GIVEN
|
|
114
|
-
warn_with_uplevel 'Passing `mix_case` with the 3rd argument of `Internet.password` is deprecated. Use keyword argument like `Internet.password(mix_case: ...)` instead.', uplevel: 1
|
|
115
|
-
mix_case = legacy_mix_case
|
|
116
|
-
end
|
|
117
|
-
if legacy_special_characters != NOT_GIVEN
|
|
118
|
-
warn_with_uplevel 'Passing `special_characters` with the 4th argument of `Internet.password` is deprecated. Use keyword argument like `Internet.password(special_characters: ...)` instead.', uplevel: 1
|
|
119
|
-
special_characters = legacy_special_characters
|
|
101
|
+
# rubocop:enable Metrics/ParameterLists
|
|
102
|
+
warn_for_deprecated_arguments do |keywords|
|
|
103
|
+
keywords << :min_length if legacy_min_length != NOT_GIVEN
|
|
104
|
+
keywords << :max_length if legacy_max_length != NOT_GIVEN
|
|
105
|
+
keywords << :mix_case if legacy_mix_case != NOT_GIVEN
|
|
106
|
+
keywords << :special_characters if legacy_special_characters != NOT_GIVEN
|
|
120
107
|
end
|
|
121
108
|
|
|
122
109
|
min_alpha = mix_case ? 2 : 0
|
|
@@ -149,9 +136,8 @@ module Faker
|
|
|
149
136
|
end
|
|
150
137
|
|
|
151
138
|
def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
subdomain = legacy_subdomain
|
|
139
|
+
warn_for_deprecated_arguments do |keywords|
|
|
140
|
+
keywords << :subdomain if legacy_subdomain != NOT_GIVEN
|
|
155
141
|
end
|
|
156
142
|
|
|
157
143
|
with_locale(:en) do
|
|
@@ -162,9 +148,8 @@ module Faker
|
|
|
162
148
|
end
|
|
163
149
|
|
|
164
150
|
def fix_umlauts(legacy_string = NOT_GIVEN, string: '')
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
string = legacy_string
|
|
151
|
+
warn_for_deprecated_arguments do |keywords|
|
|
152
|
+
keywords << :string if legacy_string != NOT_GIVEN
|
|
168
153
|
end
|
|
169
154
|
|
|
170
155
|
Char.fix_umlauts(string)
|
|
@@ -179,9 +164,8 @@ module Faker
|
|
|
179
164
|
end
|
|
180
165
|
|
|
181
166
|
def mac_address(legacy_prefix = NOT_GIVEN, prefix: '')
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
prefix = legacy_prefix
|
|
167
|
+
warn_for_deprecated_arguments do |keywords|
|
|
168
|
+
keywords << :prefix if legacy_prefix != NOT_GIVEN
|
|
185
169
|
end
|
|
186
170
|
|
|
187
171
|
prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
|
|
@@ -257,32 +241,22 @@ module Faker
|
|
|
257
241
|
"#{ip_v6_address}/#{rand(1..127)}"
|
|
258
242
|
end
|
|
259
243
|
|
|
244
|
+
# rubocop:disable Metrics/ParameterLists
|
|
260
245
|
def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http')
|
|
261
246
|
# rubocop:enable Metrics/ParameterLists
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
if legacy_path != NOT_GIVEN
|
|
267
|
-
warn_with_uplevel 'Passing `path` with the 2nd argument of `Internet.url` is deprecated. Use keyword argument like `Internet.url(path: ...)` instead.', uplevel: 1
|
|
268
|
-
path = legacy_path
|
|
269
|
-
end
|
|
270
|
-
if legacy_scheme != NOT_GIVEN
|
|
271
|
-
warn_with_uplevel 'Passing `scheme` with the 3rd argument of `Internet.url` is deprecated. Use keyword argument like `Internet.url(scheme: ...)` instead.', uplevel: 1
|
|
272
|
-
scheme = legacy_scheme
|
|
247
|
+
warn_for_deprecated_arguments do |keywords|
|
|
248
|
+
keywords << :host if legacy_host != NOT_GIVEN
|
|
249
|
+
keywords << :path if legacy_path != NOT_GIVEN
|
|
250
|
+
keywords << :scheme if legacy_scheme != NOT_GIVEN
|
|
273
251
|
end
|
|
274
252
|
|
|
275
253
|
"#{scheme}://#{host}#{path}"
|
|
276
254
|
end
|
|
277
255
|
|
|
278
256
|
def slug(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: nil)
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
end
|
|
283
|
-
if legacy_glue != NOT_GIVEN
|
|
284
|
-
warn_with_uplevel 'Passing `glue` with the 2nd argument of `Internet.slug` is deprecated. Use keyword argument like `Internet.slug(glue: ...)` instead.', uplevel: 1
|
|
285
|
-
glue = legacy_glue
|
|
257
|
+
warn_for_deprecated_arguments do |keywords|
|
|
258
|
+
keywords << :words if legacy_words != NOT_GIVEN
|
|
259
|
+
keywords << :glue if legacy_glue != NOT_GIVEN
|
|
286
260
|
end
|
|
287
261
|
|
|
288
262
|
glue ||= sample(%w[- _])
|
|
@@ -294,9 +268,8 @@ module Faker
|
|
|
294
268
|
end
|
|
295
269
|
|
|
296
270
|
def user_agent(legacy_vendor = NOT_GIVEN, vendor: nil)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
vendor = legacy_vendor
|
|
271
|
+
warn_for_deprecated_arguments do |keywords|
|
|
272
|
+
keywords << :vendor if legacy_vendor != NOT_GIVEN
|
|
300
273
|
end
|
|
301
274
|
|
|
302
275
|
agent_hash = translate('faker.internet.user_agent')
|
|
@@ -7,13 +7,9 @@ module Faker
|
|
|
7
7
|
class << self
|
|
8
8
|
# Generate random amount between values with 2 decimals
|
|
9
9
|
def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 0)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
if legacy_to != NOT_GIVEN
|
|
15
|
-
warn_with_uplevel 'Passing `to` with the 2nd argument of `Invoice.amount_between` is deprecated. Use keyword argument like `Invoice.amount_between(to: ...)` instead.', uplevel: 1
|
|
16
|
-
to = legacy_to
|
|
10
|
+
warn_for_deprecated_arguments do |keywords|
|
|
11
|
+
keywords << :from if legacy_from != NOT_GIVEN
|
|
12
|
+
keywords << :to if legacy_to != NOT_GIVEN
|
|
17
13
|
end
|
|
18
14
|
|
|
19
15
|
Faker::Base.rand_in_range(from, to).round(2)
|
|
@@ -22,9 +18,8 @@ module Faker
|
|
|
22
18
|
# International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
|
|
23
19
|
# ref is optional so that we can create unit tests
|
|
24
20
|
def creditor_reference(legacy_ref = NOT_GIVEN, ref: '')
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
ref = legacy_ref
|
|
21
|
+
warn_for_deprecated_arguments do |keywords|
|
|
22
|
+
keywords << :ref if legacy_ref != NOT_GIVEN
|
|
28
23
|
end
|
|
29
24
|
|
|
30
25
|
ref = reference if ref.empty?
|
|
@@ -35,9 +30,8 @@ module Faker
|
|
|
35
30
|
# Payment references have some rules in certain countries
|
|
36
31
|
# ref is optional so that we can create unit tests
|
|
37
32
|
def reference(legacy_ref = NOT_GIVEN, ref: '')
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ref = legacy_ref
|
|
33
|
+
warn_for_deprecated_arguments do |keywords|
|
|
34
|
+
keywords << :ref if legacy_ref != NOT_GIVEN
|
|
41
35
|
end
|
|
42
36
|
|
|
43
37
|
pattern = fetch('invoice.reference.pattern')
|