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/team.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Faker
|
2
|
+
class TheITCrowd < Base
|
3
|
+
class << self
|
4
|
+
def actor
|
5
|
+
fetch('the_it_crowd.actors')
|
6
|
+
end
|
7
|
+
|
8
|
+
def character
|
9
|
+
fetch('the_it_crowd.characters')
|
10
|
+
end
|
11
|
+
|
12
|
+
def email
|
13
|
+
fetch('the_it_crowd.emails')
|
14
|
+
end
|
15
|
+
|
16
|
+
def quote
|
17
|
+
fetch('the_it_crowd.quotes')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/faker/time.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Faker
|
2
2
|
class Time < Faker::Date
|
3
3
|
TIME_RANGES = {
|
4
|
-
:
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
}
|
4
|
+
all: (0..23),
|
5
|
+
day: (9..17),
|
6
|
+
night: (18..23),
|
7
|
+
morning: (6..11),
|
8
|
+
afternoon: (12..17),
|
9
|
+
evening: (17..21),
|
10
|
+
midnight: (0..4)
|
11
|
+
}.freeze
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def between(from, to, period = :all, format = nil)
|
@@ -31,11 +31,11 @@ module Faker
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def time_with_format(time, format)
|
34
|
-
format.nil? ? time : I18n.l(
|
34
|
+
format.nil? ? time : I18n.l(DateTime.parse(time.to_s), format: format)
|
35
35
|
end
|
36
36
|
|
37
37
|
def hours(period)
|
38
|
-
raise ArgumentError, 'invalid period' unless TIME_RANGES.
|
38
|
+
raise ArgumentError, 'invalid period' unless TIME_RANGES.key? period
|
39
39
|
sample(TIME_RANGES[period].to_a)
|
40
40
|
end
|
41
41
|
|
data/lib/faker/twin_peaks.rb
CHANGED
data/lib/faker/twitter.rb
CHANGED
data/lib/faker/types.rb
CHANGED
@@ -1,86 +1,82 @@
|
|
1
1
|
module Faker
|
2
2
|
class Types < Base
|
3
3
|
CHARACTERS = ('0'..'9').to_a + ('a'..'z').to_a
|
4
|
-
SIMPLE_TYPES = [
|
5
|
-
COMPLEX_TYPES = [
|
6
|
-
|
4
|
+
SIMPLE_TYPES = %i[string fixnum].freeze
|
5
|
+
COMPLEX_TYPES = %i[hash array].freeze
|
6
|
+
|
7
7
|
class << self
|
8
|
-
def
|
8
|
+
def rb_string(words = 1)
|
9
9
|
resolved_num = resolve(words)
|
10
|
-
word_list =
|
10
|
+
word_list =
|
11
11
|
translate('faker.lorem.words')
|
12
|
-
|
13
|
-
word_list
|
14
|
-
shuffle(word_list)[0, resolved_num].join(
|
12
|
+
|
13
|
+
word_list *= ((resolved_num / word_list.length) + 1)
|
14
|
+
shuffle(word_list)[0, resolved_num].join(' ')
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def character
|
18
18
|
sample(CHARACTERS)
|
19
19
|
end
|
20
|
-
|
21
|
-
def
|
20
|
+
|
21
|
+
def rb_integer(from = 0, to = 100)
|
22
22
|
rand(from..to).to_i
|
23
23
|
end
|
24
|
-
|
25
|
-
def
|
26
|
-
|
27
|
-
key_count.
|
28
|
-
hsh.merge!(
|
24
|
+
|
25
|
+
def rb_hash(key_count = 1)
|
26
|
+
{}.tap do |hsh|
|
27
|
+
Lorem.words(key_count * 2).uniq.first(key_count).each do |s|
|
28
|
+
hsh.merge!(s.to_sym => random_type)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
33
|
-
def
|
34
|
-
|
35
|
-
key_count.
|
36
|
-
hsh.merge!(
|
32
|
+
|
33
|
+
def complex_rb_hash(key_count = 1)
|
34
|
+
{}.tap do |hsh|
|
35
|
+
Lorem.words(key_count * 2).uniq.first(key_count).each do |s|
|
36
|
+
hsh.merge!(s.to_sym => random_complex_type)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
41
|
-
def
|
42
|
-
|
40
|
+
|
41
|
+
def rb_array(len = 1)
|
42
|
+
[].tap do |ar|
|
43
43
|
len.times do
|
44
|
-
ar.push
|
44
|
+
ar.push random_type
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def random_type
|
50
50
|
type_to_use = SIMPLE_TYPES[rand(0..SIMPLE_TYPES.length - 1)]
|
51
51
|
case type_to_use
|
52
52
|
when :string
|
53
|
-
|
53
|
+
rb_string
|
54
54
|
when :fixnum
|
55
|
-
|
56
|
-
else
|
57
|
-
self.integer
|
55
|
+
rb_integer
|
58
56
|
end
|
59
57
|
end
|
60
|
-
|
58
|
+
|
61
59
|
def random_complex_type
|
62
60
|
types = SIMPLE_TYPES + COMPLEX_TYPES
|
63
61
|
type_to_use = types[rand(0..types.length - 1)]
|
64
62
|
case type_to_use
|
65
63
|
when :string
|
66
|
-
|
64
|
+
rb_string
|
67
65
|
when :fixnum
|
68
|
-
|
66
|
+
rb_integer
|
69
67
|
when :hash
|
70
|
-
|
68
|
+
rb_hash
|
71
69
|
when :array
|
72
|
-
|
73
|
-
else
|
74
|
-
self.integer
|
70
|
+
rb_array
|
75
71
|
end
|
76
72
|
end
|
77
|
-
|
73
|
+
|
78
74
|
private
|
79
|
-
|
75
|
+
|
80
76
|
def titleize(word)
|
81
77
|
word.split(/(\W)/).map(&:capitalize).join
|
82
78
|
end
|
83
|
-
|
79
|
+
|
84
80
|
def resolve(value)
|
85
81
|
case value
|
86
82
|
when Array then sample(value)
|
data/lib/faker/university.rb
CHANGED
@@ -16,12 +16,12 @@ module Faker
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def greek_organization
|
19
|
-
3
|
19
|
+
Array.new(3) { |_| sample(greek_alphabet) }.join
|
20
20
|
end
|
21
21
|
|
22
22
|
def greek_alphabet
|
23
|
-
[
|
24
|
-
|
23
|
+
%w[Α B Γ Δ E Z H Θ I K Λ M N Ξ
|
24
|
+
O Π P Σ T Y Φ X Ψ Ω]
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/faker/vehicle.rb
CHANGED
@@ -2,17 +2,17 @@ module Faker
|
|
2
2
|
class Vehicle < Base
|
3
3
|
flexible :vehicle
|
4
4
|
|
5
|
-
VIN_CHARS = '0123456789.ABCDEFGH..JKLMN.P.R..STUVWXYZ'
|
6
|
-
VIN_MAP = '0123456789X'
|
7
|
-
VIN_WEIGHTS = '8765432X098765432'
|
5
|
+
VIN_CHARS = '0123456789.ABCDEFGH..JKLMN.P.R..STUVWXYZ'.freeze
|
6
|
+
VIN_MAP = '0123456789X'.freeze
|
7
|
+
VIN_WEIGHTS = '8765432X098765432'.freeze
|
8
8
|
|
9
9
|
class << self
|
10
|
-
#ISO 3779
|
10
|
+
# ISO 3779
|
11
11
|
def vin
|
12
12
|
_, wmi, wmi_ext = sample(fetch_all('vehicle.manufacture'))
|
13
13
|
|
14
|
-
c = VIN_CHARS.split('').reject{ |n| n == '.'}
|
15
|
-
vehicle_identification_number = wmi.split('').concat(
|
14
|
+
c = VIN_CHARS.split('').reject { |n| n == '.' }
|
15
|
+
vehicle_identification_number = wmi.split('').concat(Array.new(14) { sample(c) })
|
16
16
|
(12..14).to_a.each_with_index { |n, i| vehicle_identification_number[n] = wmi_ext[i] } unless wmi_ext.nil?
|
17
17
|
vehicle_identification_number[10] = fetch('vehicle.year')
|
18
18
|
vehicle_identification_number[8] = vin_checksum(vehicle_identification_number)
|
@@ -24,16 +24,78 @@ module Faker
|
|
24
24
|
sample(fetch_all('vehicle.manufacture')).first
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
def mileage
|
28
|
+
rand_in_range(10_000, 90_000)
|
29
|
+
end
|
30
|
+
|
31
|
+
def year
|
32
|
+
rand_in_range(2005, ::Time.now.year)
|
33
|
+
end
|
34
|
+
|
35
|
+
def make
|
36
|
+
fetch('vehicle.makes')
|
37
|
+
end
|
38
|
+
|
39
|
+
def model(make_of_model = '')
|
40
|
+
return fetch("vehicle.models_by_make.#{make}") if make_of_model.empty?
|
41
|
+
fetch("vehicle.models_by_make.#{make_of_model}")
|
42
|
+
end
|
43
|
+
|
44
|
+
def make_and_model
|
45
|
+
m = make
|
46
|
+
"#{m} #{model(m)}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def style
|
50
|
+
fetch('vehicle.styles')
|
51
|
+
end
|
52
|
+
|
53
|
+
def color
|
54
|
+
fetch('vehicle.colors')
|
55
|
+
end
|
56
|
+
|
57
|
+
def transmission
|
58
|
+
fetch('vehicle.transmissions')
|
59
|
+
end
|
28
60
|
|
29
|
-
def
|
30
|
-
(
|
61
|
+
def drive_type
|
62
|
+
fetch('vehicle.drive_types')
|
63
|
+
end
|
64
|
+
|
65
|
+
def fuel_type
|
66
|
+
fetch('vehicle.fuel_types')
|
67
|
+
end
|
68
|
+
|
69
|
+
def door_count
|
70
|
+
"#{fetch('vehicle.door_count')} #{fetch('vehicle.door')}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def car_type
|
74
|
+
fetch('vehicle.car_types')
|
75
|
+
end
|
76
|
+
|
77
|
+
def engine
|
78
|
+
"#{fetch('vehicle.engine_size')} #{fetch('vehicle.cylinder_engine')}"
|
79
|
+
end
|
80
|
+
alias engine_size engine
|
81
|
+
|
82
|
+
def car_options
|
83
|
+
Array.new(rand(5...10)) { fetch('vehicle.car_options') }
|
84
|
+
end
|
85
|
+
|
86
|
+
def standard_specs
|
87
|
+
Array.new(rand(5...10)) { fetch('vehicle.standard_specs') }
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def calculate_vin_weight(character, idx)
|
93
|
+
(VIN_CHARS.index(character) % 10) * VIN_MAP.index(VIN_WEIGHTS[idx])
|
31
94
|
end
|
32
95
|
|
33
96
|
def vin_checksum(vehicle_identification_number)
|
34
97
|
VIN_MAP[vehicle_identification_number.each_with_index.map(&method(:calculate_vin_weight)).inject(:+) % 11]
|
35
98
|
end
|
36
|
-
|
37
99
|
end
|
38
100
|
end
|
39
101
|
end
|
data/lib/faker/verb.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Faker
|
2
|
+
class Verb < Base
|
3
|
+
class << self
|
4
|
+
def base
|
5
|
+
fetch('verbs.base')
|
6
|
+
end
|
7
|
+
|
8
|
+
def past
|
9
|
+
fetch('verbs.past')
|
10
|
+
end
|
11
|
+
|
12
|
+
def past_participle
|
13
|
+
fetch('verbs.past_participle')
|
14
|
+
end
|
15
|
+
|
16
|
+
def simple_present
|
17
|
+
fetch('verbs.simple_present')
|
18
|
+
end
|
19
|
+
|
20
|
+
def ing_form
|
21
|
+
fetch('verbs.ing_form')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/faker/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Faker
|
2
|
+
class WorldCup < Base
|
3
|
+
class << self
|
4
|
+
def team
|
5
|
+
fetch('world_cup.teams')
|
6
|
+
end
|
7
|
+
|
8
|
+
def city
|
9
|
+
fetch('world_cup.cities')
|
10
|
+
end
|
11
|
+
|
12
|
+
def stadium
|
13
|
+
fetch('world_cup.stadiums')
|
14
|
+
end
|
15
|
+
|
16
|
+
def group(group = 'group_A')
|
17
|
+
fetch("world_cup.groups.#{group}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def roster(country = 'Egypt', type = 'coach')
|
21
|
+
fetch("world_cup.rosters.#{country}.#{type}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/helpers/char.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
module Faker
|
3
2
|
module Char
|
4
3
|
def self.prepare(string)
|
@@ -10,16 +9,16 @@ module Faker
|
|
10
9
|
def self.fix_umlauts(string)
|
11
10
|
string.gsub(/[äöüß]/i) do |match|
|
12
11
|
case match.downcase
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
when 'ä' then 'ae'
|
13
|
+
when 'ö' then 'oe'
|
14
|
+
when 'ü' then 'ue'
|
15
|
+
when 'ß' then 'ss'
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
20
|
def self.romanize_cyrillic(string)
|
22
|
-
if Faker::Config.locale ==
|
21
|
+
if Faker::Config.locale == 'uk'
|
23
22
|
# Based on conventions abopted by BGN/PCGN for Ukrainian
|
24
23
|
uk_chars = {
|
25
24
|
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'h', 'ґ' => 'g', 'д' => 'd',
|
@@ -39,22 +38,22 @@ module Faker
|
|
39
38
|
return string.gsub(/[а-яА-ЯіїєґІЇЄҐ]/, uk_chars)
|
40
39
|
end
|
41
40
|
|
42
|
-
if Faker::Config.locale ==
|
41
|
+
if Faker::Config.locale == 'ru'
|
43
42
|
# Based on conventions abopted by BGN/PCGN for Russian
|
44
43
|
ru_chars = {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
44
|
+
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'h', 'д' => 'd', 'е' => 'e',
|
45
|
+
'ё' => 'ye', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k',
|
46
|
+
'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r',
|
47
|
+
'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'kh', 'ц' => 'ts',
|
48
|
+
'ч' => 'ch', 'ш' => 'sh', 'щ' => 'shch', 'ы' => 'у', 'э' => 'e', 'ю' => 'yu',
|
49
|
+
'я' => 'ya',
|
50
|
+
'А' => 'a', 'Б' => 'b', 'В' => 'v', 'Г' => 'h', 'Д' => 'd', 'Е' => 'e',
|
51
|
+
'Ё' => 'ye', 'Ж' => 'zh', 'З' => 'z', 'И' => 'i', 'Й' => 'y', 'К' => 'k',
|
52
|
+
'Л' => 'l', 'М' => 'm', 'Н' => 'n', 'О' => 'o', 'П' => 'p', 'Р' => 'r',
|
53
|
+
'С' => 's', 'Т' => 't', 'У' => 'u', 'Ф' => 'f', 'Х' => 'kh', 'Ц' => 'ts',
|
54
|
+
'Ч' => 'ch', 'Ш' => 'sh', 'Щ' => 'shch', 'Ы' => 'у', 'Э' => 'e', 'Ю' => 'yu',
|
55
|
+
'Я' => 'ya',
|
56
|
+
'ь' => '', 'ъ' => '' # Ignore symbols, because its standard presentation is not allowed in URLs
|
58
57
|
}
|
59
58
|
return string.gsub(/[а-яА-Я]/, ru_chars)
|
60
59
|
end
|