faker 2.3.0 → 2.8.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 +158 -2
- data/README.md +5 -1
- data/lib/faker/blockchain/aeternity.rb +70 -0
- data/lib/faker/default/app.rb +2 -1
- data/lib/faker/default/appliance.rb +18 -0
- data/lib/faker/default/avatar.rb +2 -1
- data/lib/faker/default/bank.rb +13 -7
- data/lib/faker/default/chuck_norris.rb +1 -1
- data/lib/faker/default/coffee.rb +45 -0
- data/lib/faker/default/coin.rb +18 -0
- data/lib/faker/default/date.rb +83 -2
- data/lib/faker/default/dessert.rb +27 -0
- data/lib/faker/default/device.rb +54 -0
- data/lib/faker/default/driving_licence.rb +2 -2
- data/lib/faker/default/electrical_components.rb +27 -0
- data/lib/faker/default/greek_philosophers.rb +18 -0
- data/lib/faker/default/id_number.rb +29 -0
- data/lib/faker/default/industry_segments.rb +36 -0
- data/lib/faker/default/internet.rb +11 -7
- data/lib/faker/default/marketing.rb +9 -0
- data/lib/faker/default/military.rb +45 -0
- data/lib/faker/default/nation.rb +48 -5
- data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
- data/lib/faker/default/number.rb +124 -0
- data/lib/faker/default/relationship.rb +45 -0
- data/lib/faker/default/restaurant.rb +54 -2
- data/lib/faker/default/science.rb +27 -0
- data/lib/faker/default/subscription.rb +45 -0
- data/lib/faker/default/superhero.rb +45 -0
- data/lib/faker/default/time.rb +85 -8
- data/lib/faker/default/world_cup.rb +50 -0
- data/lib/faker/games/dota.rb +47 -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/pokemon.rb +27 -0
- data/lib/faker/games/sonic_the_hedgehog.rb +27 -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 +1 -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 +94 -0
- 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/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 -0
- 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/overwatch.yml +2617 -32
- data/lib/locales/en/science.yml +1 -1
- data/lib/locales/en/super_smash_bros.yml +1 -0
- data/lib/locales/fr-CA.yml +1 -1
- data/lib/locales/ja.yml +13 -10
- data/lib/locales/th.yml +380 -0
- metadata +26 -17
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/date.rb
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
module Faker
|
|
4
4
|
class Date < Base
|
|
5
5
|
class << self
|
|
6
|
+
##
|
|
7
|
+
# Produce a random date between two dates.
|
|
8
|
+
#
|
|
9
|
+
# @param from [Date] The start of the usable date range.
|
|
10
|
+
# @param to [Date] The end of the usable date range.
|
|
11
|
+
# @return [Date]
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# Faker::Date.between(from: 2.days.ago, to: Date.today)
|
|
15
|
+
# #=> #<Date: 2014-09-24>
|
|
16
|
+
#
|
|
17
|
+
# @faker.version 1.0.0
|
|
6
18
|
def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:)
|
|
7
19
|
warn_for_deprecated_arguments do |keywords|
|
|
8
20
|
keywords << :from if legacy_from != NOT_GIVEN
|
|
@@ -16,8 +28,21 @@ module Faker
|
|
|
16
28
|
end
|
|
17
29
|
|
|
18
30
|
# rubocop:disable Metrics/ParameterLists
|
|
31
|
+
|
|
32
|
+
##
|
|
33
|
+
# Produce a random date between two dates.
|
|
34
|
+
#
|
|
35
|
+
# @param from [Date] The start of the usable date range.
|
|
36
|
+
# @param to [Date] The end of the usable date range.
|
|
37
|
+
# @param excepted [Date] A date to exclude.
|
|
38
|
+
# @return [Date]
|
|
39
|
+
#
|
|
40
|
+
# @example
|
|
41
|
+
# Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today)
|
|
42
|
+
# #=> #<Date: 2014-10-03>
|
|
43
|
+
#
|
|
44
|
+
# @faker.version 1.6.2
|
|
19
45
|
def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_excepted = NOT_GIVEN, from:, to:, excepted:)
|
|
20
|
-
# rubocop:enable Metrics/ParameterLists
|
|
21
46
|
warn_for_deprecated_arguments do |keywords|
|
|
22
47
|
keywords << :from if legacy_from != NOT_GIVEN
|
|
23
48
|
end
|
|
@@ -37,7 +62,18 @@ module Faker
|
|
|
37
62
|
break date.to_date if date != excepted
|
|
38
63
|
end
|
|
39
64
|
end
|
|
40
|
-
|
|
65
|
+
# rubocop:enable Metrics/ParameterLists
|
|
66
|
+
|
|
67
|
+
##
|
|
68
|
+
# Produce a random date in the future (up to N days).
|
|
69
|
+
#
|
|
70
|
+
# @param days [Integer] The maximum number of days to go into the future.
|
|
71
|
+
# @return [Date]
|
|
72
|
+
#
|
|
73
|
+
# @example
|
|
74
|
+
# Faker::Date.forward(days: 23) #=> #<Date: 2014-10-03>
|
|
75
|
+
#
|
|
76
|
+
# @faker.version 1.0.0
|
|
41
77
|
def forward(legacy_days = NOT_GIVEN, days: 365)
|
|
42
78
|
warn_for_deprecated_arguments do |keywords|
|
|
43
79
|
keywords << :days if legacy_days != NOT_GIVEN
|
|
@@ -49,6 +85,16 @@ module Faker
|
|
|
49
85
|
between(from: from, to: to).to_date
|
|
50
86
|
end
|
|
51
87
|
|
|
88
|
+
##
|
|
89
|
+
# Produce a random date in the past (up to N days).
|
|
90
|
+
#
|
|
91
|
+
# @param days [Integer] The maximum number of days to go into the past.
|
|
92
|
+
# @return [Date]
|
|
93
|
+
#
|
|
94
|
+
# @example
|
|
95
|
+
# Faker::Date.backward(days: 14) #=> #<Date: 2019-09-12>
|
|
96
|
+
#
|
|
97
|
+
# @faker.version 1.0.0
|
|
52
98
|
def backward(legacy_days = NOT_GIVEN, days: 365)
|
|
53
99
|
warn_for_deprecated_arguments do |keywords|
|
|
54
100
|
keywords << :days if legacy_days != NOT_GIVEN
|
|
@@ -60,6 +106,17 @@ module Faker
|
|
|
60
106
|
between(from: from, to: to).to_date
|
|
61
107
|
end
|
|
62
108
|
|
|
109
|
+
##
|
|
110
|
+
# Produce a random date in the past (up to N days).
|
|
111
|
+
#
|
|
112
|
+
# @param min_age [Integer] The minimum age that the birthday would imply.
|
|
113
|
+
# @param max_age [Integer] The maximum age that the birthday would imply.
|
|
114
|
+
# @return [Date]
|
|
115
|
+
#
|
|
116
|
+
# @example
|
|
117
|
+
# Faker::Date.birthday(min_age: 18, max_age: 65) #=> #<Date: 1986-03-28>
|
|
118
|
+
#
|
|
119
|
+
# @faker.version 1.4.3
|
|
63
120
|
def birthday(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65)
|
|
64
121
|
warn_for_deprecated_arguments do |keywords|
|
|
65
122
|
keywords << :min_age if legacy_min_age != NOT_GIVEN
|
|
@@ -76,6 +133,30 @@ module Faker
|
|
|
76
133
|
between(from: from, to: to).to_date
|
|
77
134
|
end
|
|
78
135
|
|
|
136
|
+
##
|
|
137
|
+
# Produces a date in the year and/or month specified.
|
|
138
|
+
#
|
|
139
|
+
# @param month [Integer] represents the month of the date
|
|
140
|
+
# @param year [Integer] represents the year of the date
|
|
141
|
+
# @return [Date]
|
|
142
|
+
#
|
|
143
|
+
# @example
|
|
144
|
+
# Faker::Date.in_date_period #=> #<Date: 2019-09-01>
|
|
145
|
+
#
|
|
146
|
+
# @example
|
|
147
|
+
# Faker::Date.in_date_period(year: 2018, month: 2) #=> #<Date: 2018-02-26>
|
|
148
|
+
#
|
|
149
|
+
# @example
|
|
150
|
+
# Faker::Date.in_date_period(month: 2) #=> #<Date: 2019-02-26>
|
|
151
|
+
#
|
|
152
|
+
# @faker.version next
|
|
153
|
+
def in_date_period(month: nil, year: ::Date.today.year)
|
|
154
|
+
from = ::Date.new(year, month || 1, 1)
|
|
155
|
+
to = ::Date.new(year, month || 12, ::Date.civil(year, month || 12, -1).day)
|
|
156
|
+
|
|
157
|
+
between(from: from, to: to).to_date
|
|
158
|
+
end
|
|
159
|
+
|
|
79
160
|
private
|
|
80
161
|
|
|
81
162
|
def birthday_date(date, age)
|
|
@@ -5,14 +5,41 @@ module Faker
|
|
|
5
5
|
flexible :dessert
|
|
6
6
|
|
|
7
7
|
class << self
|
|
8
|
+
##
|
|
9
|
+
# Produces the name of a dessert variety.
|
|
10
|
+
#
|
|
11
|
+
# @return [String]
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# Faker::Dessert.variety #=> "Cake"
|
|
15
|
+
#
|
|
16
|
+
# @faker.version 1.8.0
|
|
8
17
|
def variety
|
|
9
18
|
fetch('dessert.variety')
|
|
10
19
|
end
|
|
11
20
|
|
|
21
|
+
##
|
|
22
|
+
# Produces the name of a dessert topping.
|
|
23
|
+
#
|
|
24
|
+
# @return [String]
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# Faker::Dessert.topping #=> "Gummy Bears"
|
|
28
|
+
#
|
|
29
|
+
# @faker.version 1.8.0
|
|
12
30
|
def topping
|
|
13
31
|
fetch('dessert.topping')
|
|
14
32
|
end
|
|
15
33
|
|
|
34
|
+
##
|
|
35
|
+
# Produces the name of a dessert flavor.
|
|
36
|
+
#
|
|
37
|
+
# @return [String]
|
|
38
|
+
#
|
|
39
|
+
# @example
|
|
40
|
+
# Faker::Dessert.flavor #=> "Salted Caramel"
|
|
41
|
+
#
|
|
42
|
+
# @faker.version 1.8.0
|
|
16
43
|
def flavor
|
|
17
44
|
fetch('dessert.flavor')
|
|
18
45
|
end
|
data/lib/faker/default/device.rb
CHANGED
|
@@ -3,26 +3,80 @@
|
|
|
3
3
|
module Faker
|
|
4
4
|
class Device < Base
|
|
5
5
|
class << self
|
|
6
|
+
##
|
|
7
|
+
# Produces a build number between 1 and 500.
|
|
8
|
+
#
|
|
9
|
+
# @return [Integer]
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# Faker::Device.build_number #=> 5
|
|
13
|
+
#
|
|
14
|
+
# @faker.version 1.9.0
|
|
6
15
|
def build_number
|
|
7
16
|
Faker::Number.between(from: 1, to: 500)
|
|
8
17
|
end
|
|
9
18
|
|
|
19
|
+
##
|
|
20
|
+
# Produces the name of a manufacturer for a device.
|
|
21
|
+
#
|
|
22
|
+
# @return [String]
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# Faker::Device.manufacturer #=> "Apple"
|
|
26
|
+
#
|
|
27
|
+
# @faker.version 1.9.0
|
|
10
28
|
def manufacturer
|
|
11
29
|
fetch('device.manufacturer')
|
|
12
30
|
end
|
|
13
31
|
|
|
32
|
+
##
|
|
33
|
+
# Produces a model name for a device.
|
|
34
|
+
#
|
|
35
|
+
# @return [String]
|
|
36
|
+
#
|
|
37
|
+
# @example
|
|
38
|
+
# Faker::Device.model_name #=> "iPhone 4"
|
|
39
|
+
#
|
|
40
|
+
# @faker.version 1.9.0
|
|
14
41
|
def model_name
|
|
15
42
|
fetch('device.model_name')
|
|
16
43
|
end
|
|
17
44
|
|
|
45
|
+
##
|
|
46
|
+
# Produces the name of a platform for a device.
|
|
47
|
+
#
|
|
48
|
+
# @return [String]
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# Faker::Device.platform #=> "webOS"
|
|
52
|
+
#
|
|
53
|
+
# @faker.version 1.9.0
|
|
18
54
|
def platform
|
|
19
55
|
fetch('device.platform')
|
|
20
56
|
end
|
|
21
57
|
|
|
58
|
+
##
|
|
59
|
+
# Produces a serial code for a device.
|
|
60
|
+
#
|
|
61
|
+
# @return [String]
|
|
62
|
+
#
|
|
63
|
+
# @example
|
|
64
|
+
# Faker::Device.serial #=> "ejfjnRNInxh0363JC2WM"
|
|
65
|
+
#
|
|
66
|
+
# @faker.version 1.9.0
|
|
22
67
|
def serial
|
|
23
68
|
fetch('device.serial')
|
|
24
69
|
end
|
|
25
70
|
|
|
71
|
+
##
|
|
72
|
+
# Produces a version number between 1 and 1000.
|
|
73
|
+
#
|
|
74
|
+
# @return [Integer]
|
|
75
|
+
#
|
|
76
|
+
# @example
|
|
77
|
+
# Faker::Device.version #=> 42
|
|
78
|
+
#
|
|
79
|
+
# @faker.version 1.9.0
|
|
26
80
|
def version
|
|
27
81
|
Faker::Number.between(from: 1, to: 1000)
|
|
28
82
|
end
|
|
@@ -52,9 +52,9 @@ module Faker
|
|
|
52
52
|
year = dob.year % 10
|
|
53
53
|
month = gender == :female ? dob.month + 50 : dob.month
|
|
54
54
|
# Rubocop's preferred formatting is pretty gory
|
|
55
|
-
# rubocop:disable FormatString
|
|
55
|
+
# rubocop:disable Style/FormatString
|
|
56
56
|
"#{decade}#{'%02d' % month}#{'%02d' % dob.day}#{year}"
|
|
57
|
-
# rubocop:enable FormatString
|
|
57
|
+
# rubocop:enable Style/FormatString
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def gb_licence_checksum
|
|
@@ -5,14 +5,41 @@ module Faker
|
|
|
5
5
|
flexible :electrical_components
|
|
6
6
|
|
|
7
7
|
class << self
|
|
8
|
+
##
|
|
9
|
+
# Produces an active electrical component.
|
|
10
|
+
#
|
|
11
|
+
# @return [String]
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# Faker::ElectricalComponents.active #=> "Transistor"
|
|
15
|
+
#
|
|
16
|
+
# @faker.version 1.9.0
|
|
8
17
|
def active
|
|
9
18
|
fetch('electrical_components.active')
|
|
10
19
|
end
|
|
11
20
|
|
|
21
|
+
##
|
|
22
|
+
# Produces a passive electrical component.
|
|
23
|
+
#
|
|
24
|
+
# @return [String]
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# Faker::ElectricalComponents.passive #=> "Resistor"
|
|
28
|
+
#
|
|
29
|
+
# @faker.version 1.9.0
|
|
12
30
|
def passive
|
|
13
31
|
fetch('electrical_components.passive')
|
|
14
32
|
end
|
|
15
33
|
|
|
34
|
+
##
|
|
35
|
+
# Produces an electromechanical electrical component.
|
|
36
|
+
#
|
|
37
|
+
# @return [String]
|
|
38
|
+
#
|
|
39
|
+
# @example
|
|
40
|
+
# Faker::ElectricalComponents.electromechanical #=> "Toggle Switch"
|
|
41
|
+
#
|
|
42
|
+
# @faker.version 1.9.0
|
|
16
43
|
def electromechanical
|
|
17
44
|
fetch('electrical_components.electromechanical')
|
|
18
45
|
end
|
|
@@ -3,10 +3,28 @@
|
|
|
3
3
|
module Faker
|
|
4
4
|
class GreekPhilosophers < Base
|
|
5
5
|
class << self
|
|
6
|
+
##
|
|
7
|
+
# Produces the name of a Greek philosopher.
|
|
8
|
+
#
|
|
9
|
+
# @return [String]
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# Faker::GreekPhilosophers.name #=> "Socrates"
|
|
13
|
+
#
|
|
14
|
+
# @faker.version 1.9.0
|
|
6
15
|
def name
|
|
7
16
|
fetch('greek_philosophers.names')
|
|
8
17
|
end
|
|
9
18
|
|
|
19
|
+
##
|
|
20
|
+
# Produces a quote from a Greek philosopher.
|
|
21
|
+
#
|
|
22
|
+
# @return [String]
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# Faker::GreekPhilosophers.quote #=> "Only the educated are free."
|
|
26
|
+
#
|
|
27
|
+
# @faker.version 1.9.0
|
|
10
28
|
def quote
|
|
11
29
|
fetch('greek_philosophers.quotes')
|
|
12
30
|
end
|
|
@@ -16,6 +16,8 @@ module Faker
|
|
|
16
16
|
BRAZILIAN_ID_FROM = 10_000_000
|
|
17
17
|
BRAZILIAN_ID_TO = 99_999_999
|
|
18
18
|
|
|
19
|
+
CHILEAN_MODULO = 11
|
|
20
|
+
|
|
19
21
|
class << self
|
|
20
22
|
def valid
|
|
21
23
|
_translate('valid')
|
|
@@ -105,8 +107,35 @@ module Faker
|
|
|
105
107
|
|
|
106
108
|
alias brazilian_rg brazilian_id
|
|
107
109
|
|
|
110
|
+
def chilean_id
|
|
111
|
+
digits = Faker::Number.number(digits: 8)
|
|
112
|
+
verification_code = chilean_verification_code(digits)
|
|
113
|
+
|
|
114
|
+
digits.to_s + '-' + verification_code.to_s
|
|
115
|
+
end
|
|
116
|
+
|
|
108
117
|
private
|
|
109
118
|
|
|
119
|
+
def chilean_verification_code(digits)
|
|
120
|
+
# First digit is multiplied by 3, second by 2, and so on
|
|
121
|
+
multiplication_rule = [3, 2, 7, 6, 5, 4, 3, 2]
|
|
122
|
+
digits_splitted = digits.to_s.chars.map(&:to_i)
|
|
123
|
+
|
|
124
|
+
sum = digits_splitted.map.with_index { |digit, index| digit * multiplication_rule[index] }.reduce(:+)
|
|
125
|
+
|
|
126
|
+
modulo = sum.modulo(CHILEAN_MODULO)
|
|
127
|
+
difference = CHILEAN_MODULO - modulo
|
|
128
|
+
|
|
129
|
+
case difference
|
|
130
|
+
when 0..9
|
|
131
|
+
difference
|
|
132
|
+
when 10
|
|
133
|
+
'K'
|
|
134
|
+
when 11
|
|
135
|
+
0
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
110
139
|
def south_african_id_checksum_digit(id_number)
|
|
111
140
|
value_parts = id_number.chars
|
|
112
141
|
even_digits = value_parts
|
|
@@ -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
|