faker 2.5.0 → 2.9.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 +163 -10
- data/README.md +3 -0
- data/lib/faker/default/address.rb +202 -0
- data/lib/faker/default/ancient.rb +36 -0
- data/lib/faker/default/bank.rb +13 -7
- data/lib/faker/default/beer.rb +72 -0
- data/lib/faker/default/bossa_nova.rb +18 -0
- data/lib/faker/default/business.rb +27 -0
- data/lib/faker/default/chuck_norris.rb +11 -1
- data/lib/faker/default/coffee.rb +45 -0
- data/lib/faker/default/coin.rb +18 -0
- data/lib/faker/default/color.rb +48 -1
- data/lib/faker/default/crypto.rb +27 -0
- data/lib/faker/default/currency.rb +27 -0
- data/lib/faker/default/date.rb +24 -0
- data/lib/faker/default/demographic.rb +57 -0
- data/lib/faker/default/driving_licence.rb +2 -2
- data/lib/faker/default/educator.rb +60 -6
- data/lib/faker/default/esport.rb +45 -0
- data/lib/faker/default/fillmurray.rb +23 -1
- data/lib/faker/default/food.rb +65 -1
- data/lib/faker/default/gender.rb +13 -0
- data/lib/faker/default/id_number.rb +29 -0
- data/lib/faker/default/internet.rb +17 -7
- data/lib/faker/default/job.rb +36 -0
- data/lib/faker/default/kpop.rb +54 -0
- data/lib/faker/default/relationship.rb +45 -0
- data/lib/faker/default/space.rb +127 -0
- data/lib/faker/default/team.rb +45 -0
- data/lib/faker/default/world_cup.rb +50 -0
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en-CA.yml +1 -0
- data/lib/locales/en/educator.yml +69 -6
- data/lib/locales/en/gender.yml +1 -0
- data/lib/locales/en/overwatch.yml +2617 -32
- data/lib/locales/en/super_smash_bros.yml +1 -0
- data/lib/locales/fa.yml +2 -0
- data/lib/locales/fr-CA.yml +1 -1
- data/lib/locales/ja.yml +6 -2
- data/lib/locales/pt-BR.yml +23 -2
- metadata +22 -15
@@ -3,18 +3,54 @@
|
|
3
3
|
module Faker
|
4
4
|
class Ancient < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a god from ancient mythology.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Ancient.god #=> "Zeus"
|
13
|
+
#
|
14
|
+
# @faker.version 1.7.0
|
6
15
|
def god
|
7
16
|
fetch('ancient.god')
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Produces a primordial from ancient mythology.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Ancient.primordial #=> "Gaia"
|
26
|
+
#
|
27
|
+
# @faker.version 1.7.0
|
10
28
|
def primordial
|
11
29
|
fetch('ancient.primordial')
|
12
30
|
end
|
13
31
|
|
32
|
+
##
|
33
|
+
# Produces a titan from ancient mythology.
|
34
|
+
#
|
35
|
+
# @return [String]
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# Faker::Ancient.titan #=> "Atlas"
|
39
|
+
#
|
40
|
+
# @faker.version 1.7.0
|
14
41
|
def titan
|
15
42
|
fetch('ancient.titan')
|
16
43
|
end
|
17
44
|
|
45
|
+
##
|
46
|
+
# Produces a hero from ancient mythology.
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# Faker::Ancient.hero #=> "Achilles"
|
52
|
+
#
|
53
|
+
# @faker.version 1.7.0
|
18
54
|
def hero
|
19
55
|
fetch('ancient.hero')
|
20
56
|
end
|
data/lib/faker/default/bank.rb
CHANGED
@@ -58,8 +58,11 @@ module Faker
|
|
58
58
|
|
59
59
|
def checksum(num_string)
|
60
60
|
num_array = num_string.split('').map(&:to_i)
|
61
|
-
|
62
|
-
|
61
|
+
(
|
62
|
+
7 * (num_array[0] + num_array[3] + num_array[6]) +
|
63
|
+
3 * (num_array[1] + num_array[4] + num_array[7]) +
|
64
|
+
9 * (num_array[2] + num_array[5])
|
65
|
+
) % 10
|
63
66
|
end
|
64
67
|
|
65
68
|
def compile_routing_number
|
@@ -85,12 +88,15 @@ module Faker
|
|
85
88
|
end
|
86
89
|
|
87
90
|
def valid_routing_number
|
88
|
-
|
89
|
-
|
91
|
+
routing_number = compile_routing_number
|
92
|
+
checksum = checksum(routing_number)
|
93
|
+
return routing_number if valid_checksum?(routing_number, checksum)
|
90
94
|
|
91
|
-
|
92
|
-
|
93
|
-
|
95
|
+
routing_number[0..7] + checksum.to_s
|
96
|
+
end
|
97
|
+
|
98
|
+
def valid_checksum?(routing_number, checksum)
|
99
|
+
routing_number[8].to_i == checksum
|
94
100
|
end
|
95
101
|
|
96
102
|
def compile_fraction(routing_num)
|
data/lib/faker/default/beer.rb
CHANGED
@@ -5,34 +5,106 @@ module Faker
|
|
5
5
|
flexible :beer
|
6
6
|
|
7
7
|
class << self
|
8
|
+
##
|
9
|
+
# Produces a random beer name.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Beer.name #=> "Pliny The Elder"
|
15
|
+
#
|
16
|
+
# @faker.version 1.6.2
|
8
17
|
def name
|
9
18
|
fetch('beer.name')
|
10
19
|
end
|
11
20
|
|
21
|
+
##
|
22
|
+
# Produces a random beer style.
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Faker::Beer.style #=> "Wood-aged Beer"
|
28
|
+
#
|
29
|
+
# @faker.version 1.6.2
|
12
30
|
def style
|
13
31
|
fetch('beer.style')
|
14
32
|
end
|
15
33
|
|
34
|
+
##
|
35
|
+
# Produces a random beer hops.
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# Faker::Beer.hop #=> "Sterling"
|
41
|
+
#
|
42
|
+
# @faker.version 1.6.2
|
16
43
|
def hop
|
17
44
|
fetch('beer.hop')
|
18
45
|
end
|
19
46
|
|
47
|
+
##
|
48
|
+
# Produces a random beer yeast.
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# Faker::Beer.yeast #=> "5335 - Lactobacillus"
|
54
|
+
#
|
55
|
+
# @faker.version 1.6.2
|
20
56
|
def yeast
|
21
57
|
fetch('beer.yeast')
|
22
58
|
end
|
23
59
|
|
60
|
+
##
|
61
|
+
# Produces a random beer malt.
|
62
|
+
#
|
63
|
+
# @return [String]
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# Faker::Beer.malts #=> "Munich"
|
67
|
+
#
|
68
|
+
# @faker.version 1.6.2
|
24
69
|
def malts
|
25
70
|
fetch('beer.malt')
|
26
71
|
end
|
27
72
|
|
73
|
+
##
|
74
|
+
# Produces a random beer IBU.
|
75
|
+
#
|
76
|
+
# @return [String]
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# Faker::Beer.ibu #=> "87 IBU"
|
80
|
+
#
|
81
|
+
# @faker.version 1.6.2
|
28
82
|
def ibu
|
29
83
|
rand(10..100).to_s + ' IBU'
|
30
84
|
end
|
31
85
|
|
86
|
+
##
|
87
|
+
# Produces a random beer alcohol percentage.
|
88
|
+
#
|
89
|
+
# @return [String]
|
90
|
+
#
|
91
|
+
# @example
|
92
|
+
# Faker::Beer.alcohol #=> "5.4%"
|
93
|
+
#
|
94
|
+
# @faker.version 1.6.2
|
32
95
|
def alcohol
|
33
96
|
rand(2.0..10.0).round(1).to_s + '%'
|
34
97
|
end
|
35
98
|
|
99
|
+
##
|
100
|
+
# Produces a random beer blg level.
|
101
|
+
#
|
102
|
+
# @return [String]
|
103
|
+
#
|
104
|
+
# @example
|
105
|
+
# Faker::Beer.blg #=> "5.1Blg"
|
106
|
+
#
|
107
|
+
# @faker.version 1.6.2
|
36
108
|
def blg
|
37
109
|
rand(5.0..20.0).round(1).to_s + '°Blg'
|
38
110
|
end
|
@@ -3,10 +3,28 @@
|
|
3
3
|
module Faker
|
4
4
|
class BossaNova < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces the name of a bossa nova artist.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::BossaNova.artist #=> "Tom Jobin"
|
13
|
+
#
|
14
|
+
# @faker.version 1.8.3
|
6
15
|
def artist
|
7
16
|
fetch('bossa_nova.artists')
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Produces a bossa nova song.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::BossaNova.song #=> "Chega de Saudade"
|
26
|
+
#
|
27
|
+
# @faker.version 1.8.3
|
10
28
|
def song
|
11
29
|
fetch('bossa_nova.songs')
|
12
30
|
end
|
@@ -7,14 +7,41 @@ module Faker
|
|
7
7
|
flexible :business
|
8
8
|
|
9
9
|
class << self
|
10
|
+
##
|
11
|
+
# Produces a credit card number.
|
12
|
+
#
|
13
|
+
# @return [String]
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# Faker::Business.credit_card_number #=> "1228-1221-1221-1431"
|
17
|
+
#
|
18
|
+
# @faker.version 1.2.0
|
10
19
|
def credit_card_number
|
11
20
|
fetch('business.credit_card_numbers')
|
12
21
|
end
|
13
22
|
|
23
|
+
##
|
24
|
+
# Produces a credit card expiration date.
|
25
|
+
#
|
26
|
+
# @return [Date]
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# Faker::Business.credit_card_number #=> <Date: 2015-11-11 ((2457338j,0s,0n),+0s,2299161j)>
|
30
|
+
#
|
31
|
+
# @faker.version 1.2.0
|
14
32
|
def credit_card_expiry_date
|
15
33
|
::Date.today + (365 * rand(1..4))
|
16
34
|
end
|
17
35
|
|
36
|
+
##
|
37
|
+
# Produces a type of credit card.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# Faker::Business.credit_card_type #=> "visa"
|
43
|
+
#
|
44
|
+
# @faker.version 1.2.0
|
18
45
|
def credit_card_type
|
19
46
|
fetch('business.credit_card_types')
|
20
47
|
end
|
@@ -5,7 +5,17 @@ module Faker
|
|
5
5
|
flexible :chuck_norris
|
6
6
|
|
7
7
|
class << self
|
8
|
-
#
|
8
|
+
# Produces a Chuck Norris Fact.
|
9
|
+
# Original list of facts:
|
10
|
+
# https://github.com/jenkinsci/chucknorris-plugin/blob/master/src/main/java/hudson/plugins/chucknorris/FactGenerator.java
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# Faker::ChuckNorris.fact
|
16
|
+
# #=> "Chuck Norris can solve the Towers of Hanoi in one move."
|
17
|
+
#
|
18
|
+
# @faker.version 1.6.4
|
9
19
|
def fact
|
10
20
|
fetch('chuck_norris.fact')
|
11
21
|
end
|
data/lib/faker/default/coffee.rb
CHANGED
@@ -5,24 +5,69 @@ module Faker
|
|
5
5
|
flexible :coffee
|
6
6
|
|
7
7
|
class << self
|
8
|
+
##
|
9
|
+
# Produces a random blend name.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Coffee.blend_name #=> "Major Java"
|
15
|
+
#
|
16
|
+
# @faker.version 1.9.0
|
8
17
|
def blend_name
|
9
18
|
parse('coffee.blend_name')
|
10
19
|
end
|
11
20
|
|
21
|
+
##
|
22
|
+
# Produces a random coffee origin place.
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Faker::Coffee.origin #=> "Oaxaca, Mexico"
|
28
|
+
#
|
29
|
+
# @faker.version 1.9.0
|
12
30
|
def origin
|
13
31
|
country = fetch('coffee.country')
|
14
32
|
region = fetch("coffee.regions.#{search_format(country)}")
|
15
33
|
"#{region}, #{country}"
|
16
34
|
end
|
17
35
|
|
36
|
+
##
|
37
|
+
# Produces a random coffee variety.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# Faker::Coffee.variety #=> "Red Bourbon"
|
43
|
+
#
|
44
|
+
# @faker.version 1.9.0
|
18
45
|
def variety
|
19
46
|
fetch('coffee.variety')
|
20
47
|
end
|
21
48
|
|
49
|
+
##
|
50
|
+
# Produces a string containing a random description of a coffee's taste.
|
51
|
+
#
|
52
|
+
# @return [String]
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# Faker::Coffee.notes #=> "dull, tea-like, cantaloupe, soy sauce, marshmallow"
|
56
|
+
#
|
57
|
+
# @faker.version 1.9.0
|
22
58
|
def notes
|
23
59
|
parse('coffee.notes')
|
24
60
|
end
|
25
61
|
|
62
|
+
##
|
63
|
+
# Produces a random coffee taste intensity.
|
64
|
+
#
|
65
|
+
# @return [String]
|
66
|
+
#
|
67
|
+
# @example
|
68
|
+
# Faker::Coffee.intensifier #=> "mild"
|
69
|
+
#
|
70
|
+
# @faker.version 1.9.0
|
26
71
|
def intensifier
|
27
72
|
fetch('coffee.intensifier')
|
28
73
|
end
|
data/lib/faker/default/coin.rb
CHANGED
@@ -3,10 +3,28 @@
|
|
3
3
|
module Faker
|
4
4
|
class Coin < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Retrieves a random coin from any country.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Coin.name #=> "Brazilian Real"
|
13
|
+
#
|
14
|
+
# @faker.version 1.9.2
|
6
15
|
def name
|
7
16
|
fetch('currency.name')
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Retrieves a face to a flipped coin
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Coin.flip #=> "Heads"
|
26
|
+
#
|
27
|
+
# @faker.version 1.9.2
|
10
28
|
def flip
|
11
29
|
fetch('coin.flip')
|
12
30
|
end
|
data/lib/faker/default/color.rb
CHANGED
@@ -3,27 +3,74 @@
|
|
3
3
|
module Faker
|
4
4
|
class Color < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a hex color code.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Color.hex_color #=> "#31a785"
|
13
|
+
#
|
14
|
+
# @faker.version 1.5.0
|
6
15
|
def hex_color
|
7
16
|
format('#%06x', (rand * 0xffffff))
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Produces the name of a color.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Color.color_name #=> "yellow"
|
26
|
+
#
|
27
|
+
# @faker.version 1.6.2
|
10
28
|
def color_name
|
11
29
|
fetch('color.name')
|
12
30
|
end
|
13
31
|
|
32
|
+
# @private
|
14
33
|
def single_rgb_color
|
15
34
|
sample((0..255).to_a)
|
16
35
|
end
|
17
36
|
|
37
|
+
##
|
38
|
+
# Produces an array of integers representing an RGB color.
|
39
|
+
#
|
40
|
+
# @return [Array(Integer, Integer, Integer)]
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# Faker::Color.rgb_color #=> [54, 233, 67]
|
44
|
+
#
|
45
|
+
# @faker.version 1.5.0
|
18
46
|
def rgb_color
|
19
47
|
Array.new(3) { single_rgb_color }
|
20
48
|
end
|
21
49
|
|
22
|
-
|
50
|
+
##
|
51
|
+
# Produces an array of floats representing an HSL color.
|
52
|
+
# The array is in the form of `[hue, saturation, lightness]`.
|
53
|
+
#
|
54
|
+
# @return [Array(Float, Float, Float)]
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# Faker::Color.hsl_color #=> [69.87, 0.66, 0.3]
|
58
|
+
#
|
59
|
+
# @faker.version 1.5.0
|
23
60
|
def hsl_color
|
24
61
|
[sample((0..360).to_a), rand.round(2), rand.round(2)]
|
25
62
|
end
|
26
63
|
|
64
|
+
##
|
65
|
+
# Produces an array of floats representing an HSLA color.
|
66
|
+
# The array is in the form of `[hue, saturation, lightness, alpha]`.
|
67
|
+
#
|
68
|
+
# @return [Array(Float, Float, Float, Float)]
|
69
|
+
#
|
70
|
+
# @example
|
71
|
+
# Faker::Color.hsla_color #=> [154.77, 0.36, 0.9, 0.2]
|
72
|
+
#
|
73
|
+
# @faker.version 1.5.0
|
27
74
|
def hsla_color
|
28
75
|
hsl_color << rand.round(1)
|
29
76
|
end
|