ffaker 2.16.0 → 2.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +32 -0
- data/README.md +6 -4
- data/REFERENCE.md +1484 -1257
- data/Rakefile +3 -3
- data/ffaker.gemspec +4 -7
- data/lib/ffaker/address_au.rb +1 -1
- data/lib/ffaker/address_br.rb +1 -1
- data/lib/ffaker/address_ca.rb +1 -1
- data/lib/ffaker/address_ch.rb +0 -2
- data/lib/ffaker/address_ch_de.rb +0 -2
- data/lib/ffaker/address_ch_fr.rb +0 -2
- data/lib/ffaker/address_ch_it.rb +0 -2
- data/lib/ffaker/address_da.rb +0 -2
- data/lib/ffaker/address_de.rb +0 -2
- data/lib/ffaker/address_fi.rb +0 -2
- data/lib/ffaker/address_fr.rb +0 -2
- data/lib/ffaker/address_gr.rb +0 -2
- data/lib/ffaker/address_id.rb +0 -2
- data/lib/ffaker/address_in.rb +0 -2
- data/lib/ffaker/address_it.rb +37 -0
- data/lib/ffaker/address_ja.rb +0 -2
- data/lib/ffaker/address_mx.rb +2 -8
- data/lib/ffaker/address_nl.rb +0 -2
- data/lib/ffaker/address_ru.rb +0 -2
- data/lib/ffaker/address_se.rb +0 -2
- data/lib/ffaker/address_sn.rb +0 -2
- data/lib/ffaker/address_ua.rb +0 -2
- data/lib/ffaker/address_uk.rb +0 -2
- data/lib/ffaker/address_us.rb +0 -2
- data/lib/ffaker/animal.rb +1 -1
- data/lib/ffaker/bacon_ipsum.rb +0 -2
- data/lib/ffaker/company_fr.rb +35 -0
- data/lib/ffaker/{courses.rb → courses_fr.rb} +2 -0
- data/lib/ffaker/data/address_br/city +0 -1
- data/lib/ffaker/data/address_br/state +1 -1
- data/lib/ffaker/data/address_it/city +111 -0
- data/lib/ffaker/data/address_it/region +20 -0
- data/lib/ffaker/data/filesystem/extension +31 -31
- data/lib/ffaker/data/food_pl/diary +14 -0
- data/lib/ffaker/data/food_pl/fermented +13 -0
- data/lib/ffaker/data/food_pl/fruits +34 -0
- data/lib/ffaker/data/food_pl/herbs +20 -0
- data/lib/ffaker/data/food_pl/meats +9 -0
- data/lib/ffaker/data/food_pl/preserves +10 -0
- data/lib/ffaker/data/food_pl/spices +26 -0
- data/lib/ffaker/data/food_pl/vegetables +45 -0
- data/lib/ffaker/data/freedom_ipsum/freedom_words +161 -0
- data/lib/ffaker/data/game/adj_and_adv +18 -0
- data/lib/ffaker/data/game/category +84 -0
- data/lib/ffaker/data/game/mechanic +182 -0
- data/lib/ffaker/data/game/nouns +37 -0
- data/lib/ffaker/data/game/prefixes +17 -0
- data/lib/ffaker/data/job_it/job_adj +37 -0
- data/lib/ffaker/data/job_it/job_noun +25 -0
- data/lib/ffaker/data/job_it/job_prefix +22 -0
- data/lib/ffaker/data/lorem/words +0 -67
- data/lib/ffaker/data/lorem_br/characters +36 -0
- data/lib/ffaker/data/lorem_br/words +183 -0
- data/lib/ffaker/data/lorem_it/words +321 -0
- data/lib/ffaker/data/name/pronouns +1 -1
- data/lib/ffaker/data/name_ga/first_names_male +286 -286
- data/lib/ffaker/data/phone_number_ja/four_disit_area_codes +41 -0
- data/lib/ffaker/data/phone_number_ja/one_disit_area_codes +3 -0
- data/lib/ffaker/data/phone_number_ja/three_disit_area_codes +296 -0
- data/lib/ffaker/data/phone_number_ja/two_disit_area_codes +48 -0
- data/lib/ffaker/data/sport_ru/summer +68 -0
- data/lib/ffaker/data/sport_ru/winter +20 -0
- data/lib/ffaker/dizzle_ipsum.rb +0 -2
- data/lib/ffaker/filesystem.rb +7 -7
- data/lib/ffaker/food_pl.rb +65 -0
- data/lib/ffaker/freedom_ipsum.rb +20 -0
- data/lib/ffaker/game.rb +33 -0
- data/lib/ffaker/gender_it.rb +17 -0
- data/lib/ffaker/gender_ru.rb +22 -0
- data/lib/ffaker/healthcare_ipsum.rb +0 -2
- data/lib/ffaker/hipster_ipsum.rb +0 -2
- data/lib/ffaker/identification_es_cl.rb +0 -2
- data/lib/ffaker/identification_es_co.rb +0 -1
- data/lib/ffaker/identification_it.rb +30 -0
- data/lib/ffaker/identification_kr.rb +1 -1
- data/lib/ffaker/identification_mx.rb +1 -3
- data/lib/ffaker/image.rb +8 -11
- data/lib/ffaker/internet.rb +1 -1
- data/lib/ffaker/internet_se.rb +1 -3
- data/lib/ffaker/job_it.rb +12 -0
- data/lib/ffaker/lorem_br.rb +45 -0
- data/lib/ffaker/lorem_cn.rb +0 -1
- data/lib/ffaker/lorem_it.rb +39 -0
- data/lib/ffaker/name_cs.rb +0 -2
- data/lib/ffaker/name_da.rb +0 -2
- data/lib/ffaker/name_de.rb +0 -2
- data/lib/ffaker/name_mx.rb +0 -2
- data/lib/ffaker/name_nb.rb +0 -2
- data/lib/ffaker/name_nl.rb +0 -2
- data/lib/ffaker/name_ph.rb +0 -2
- data/lib/ffaker/name_ru.rb +0 -2
- data/lib/ffaker/name_se.rb +0 -2
- data/lib/ffaker/name_th_en.rb +1 -1
- data/lib/ffaker/name_ua.rb +0 -2
- data/lib/ffaker/number.rb +26 -0
- data/lib/ffaker/phone_number_br.rb +2 -2
- data/lib/ffaker/phone_number_da.rb +0 -1
- data/lib/ffaker/phone_number_it.rb +8 -6
- data/lib/ffaker/phone_number_ja.rb +88 -0
- data/lib/ffaker/sport_ru.rb +25 -0
- data/lib/ffaker/ssn.rb +1 -3
- data/lib/ffaker/ssn_se.rb +0 -19
- data/lib/ffaker/string.rb +4 -4
- data/lib/ffaker/unit.rb +9 -10
- data/lib/ffaker/unit_english.rb +18 -21
- data/lib/ffaker/unit_metric.rb +15 -18
- data/lib/ffaker/utils/array_utils.rb +1 -1
- data/lib/ffaker/utils/module_utils.rb +23 -3
- data/lib/ffaker/vehicle.rb +1 -1
- data/lib/ffaker.rb +19 -4
- data/lib/version.rb +1 -1
- data/scripts/profiling.rb +1 -1
- data/scripts/reference.rb +2 -3
- data/test/helper.rb +4 -4
- data/test/test_address.rb +1 -1
- data/test/test_address_au.rb +3 -3
- data/test/test_address_br.rb +2 -2
- data/test/test_address_ca.rb +1 -1
- data/test/test_address_ch.rb +1 -1
- data/test/test_address_ch_de.rb +1 -1
- data/test/test_address_ch_fr.rb +1 -1
- data/test/test_address_ch_it.rb +1 -1
- data/test/test_address_da.rb +1 -1
- data/test/test_address_de.rb +1 -1
- data/test/test_address_fi.rb +3 -3
- data/test/test_address_fr.rb +1 -1
- data/test/test_address_gr.rb +1 -1
- data/test/test_address_id.rb +2 -2
- data/test/test_address_in.rb +1 -1
- data/test/test_address_it.rb +12 -0
- data/test/test_address_ja.rb +2 -2
- data/test/test_address_kr.rb +1 -1
- data/test/test_address_mx.rb +1 -1
- data/test/test_address_nl.rb +1 -1
- data/test/test_address_pl.rb +1 -1
- data/test/test_address_ru.rb +1 -1
- data/test/test_address_se.rb +3 -3
- data/test/test_address_sn.rb +1 -1
- data/test/test_address_ua.rb +1 -1
- data/test/test_address_uk.rb +1 -1
- data/test/test_address_us.rb +1 -1
- data/test/test_airline.rb +1 -1
- data/test/test_animal.rb +1 -1
- data/test/test_animal_cn.rb +1 -1
- data/test/test_animal_es.rb +1 -1
- data/test/test_animal_pl.rb +1 -1
- data/test/test_animal_us.rb +1 -1
- data/test/test_array_utils.rb +2 -1
- data/test/test_avatar.rb +1 -1
- data/test/test_aws.rb +2 -2
- data/test/test_bacon_ipsum.rb +1 -1
- data/test/test_bank.rb +3 -4
- data/test/test_book.rb +5 -5
- data/test/test_boolean.rb +1 -1
- data/test/test_cheesy_lingo.rb +1 -1
- data/test/test_code.rb +1 -1
- data/test/test_color.rb +1 -1
- data/test/test_color_pl.rb +1 -1
- data/test/test_color_ua.rb +1 -1
- data/test/test_company.rb +1 -1
- data/test/test_company_cn.rb +1 -1
- data/test/test_company_fr.rb +33 -0
- data/test/test_company_it.rb +1 -1
- data/test/test_company_ja.rb +1 -1
- data/test/test_company_se.rb +1 -1
- data/test/test_conference.rb +1 -1
- data/test/test_course_mathematiques.rb +1 -1
- data/test/test_course_philosophie.rb +1 -1
- data/test/test_currency.rb +1 -1
- data/test/test_dizzle_ipsum.rb +1 -1
- data/test/test_education.rb +1 -1
- data/test/test_education_cn.rb +1 -1
- data/test/{test_faker.rb → test_ffaker.rb} +6 -2
- data/test/test_filesystem.rb +12 -4
- data/test/test_food.rb +1 -1
- data/test/test_food_pl.rb +61 -0
- data/test/test_freedom_ipsum.rb +21 -0
- data/test/test_game.rb +28 -0
- data/test/test_gender.rb +2 -2
- data/test/test_gender_br.rb +1 -1
- data/test/test_gender_cn.rb +1 -1
- data/test/test_gender_id.rb +1 -1
- data/test/test_gender_it.rb +27 -0
- data/test/test_gender_ja.rb +1 -1
- data/test/test_gender_jp.rb +1 -1
- data/test/test_gender_kr.rb +1 -1
- data/test/test_gender_pl.rb +1 -1
- data/test/test_gender_ru.rb +23 -0
- data/test/test_geolocation.rb +1 -1
- data/test/test_guid.rb +1 -1
- data/test/test_healthcare_ipsum.rb +1 -1
- data/test/test_healthcare_ru.rb +2 -2
- data/test/test_hipster_ipsum.rb +1 -1
- data/test/test_html_ipsum.rb +2 -2
- data/test/test_identification.rb +1 -1
- data/test/test_identification_br.rb +1 -1
- data/test/test_identification_co.rb +2 -2
- data/test/test_identification_es.rb +1 -1
- data/test/test_identification_es_cl.rb +2 -2
- data/test/test_identification_es_mx.rb +1 -1
- data/test/test_identification_in.rb +1 -1
- data/test/test_identification_it.rb +34 -0
- data/test/test_identification_kr.rb +1 -1
- data/test/test_identification_tw.rb +1 -1
- data/test/test_image.rb +5 -5
- data/test/test_internet.rb +1 -1
- data/test/test_internet_se.rb +2 -2
- data/test/test_job.rb +1 -1
- data/test/test_job_br.rb +1 -1
- data/test/test_job_cn.rb +1 -1
- data/test/test_job_fr.rb +1 -1
- data/test/test_job_it.rb +17 -0
- data/test/test_job_ja.rb +1 -1
- data/test/test_job_kr.rb +1 -1
- data/test/test_job_vn.rb +1 -1
- data/test/test_locale.rb +1 -1
- data/test/test_lorem.rb +5 -1
- data/test/test_lorem_ar.rb +1 -1
- data/test/test_lorem_br.rb +62 -0
- data/test/test_lorem_cn.rb +1 -1
- data/test/test_lorem_fr.rb +10 -8
- data/test/test_lorem_ie.rb +1 -1
- data/test/test_lorem_it.rb +51 -0
- data/test/test_lorem_ja.rb +1 -1
- data/test/test_lorem_kr.rb +1 -1
- data/test/test_lorem_pl.rb +2 -2
- data/test/test_lorem_ru.rb +2 -2
- data/test/test_lorem_ua.rb +2 -2
- data/test/test_module_utils.rb +1 -1
- data/test/test_movie.rb +1 -1
- data/test/test_music.rb +5 -5
- data/test/test_name.rb +1 -1
- data/test/test_name_ar.rb +1 -1
- data/test/test_name_br.rb +1 -1
- data/test/test_name_cn.rb +1 -1
- data/test/test_name_cs.rb +1 -1
- data/test/test_name_da.rb +1 -1
- data/test/test_name_de.rb +1 -1
- data/test/test_name_es.rb +1 -1
- data/test/test_name_fr.rb +1 -1
- data/test/test_name_ga.rb +1 -1
- data/test/test_name_gr.rb +1 -1
- data/test/test_name_id.rb +1 -1
- data/test/test_name_it.rb +1 -1
- data/test/test_name_ja.rb +1 -1
- data/test/test_name_kh.rb +1 -1
- data/test/test_name_kr.rb +1 -1
- data/test/test_name_mx.rb +1 -1
- data/test/test_name_nb.rb +1 -1
- data/test/test_name_nl.rb +1 -1
- data/test/test_name_ph.rb +1 -1
- data/test/test_name_pl.rb +1 -1
- data/test/test_name_ru.rb +1 -1
- data/test/test_name_se.rb +1 -1
- data/test/test_name_sn.rb +1 -1
- data/test/test_name_th.rb +1 -1
- data/test/test_name_th_en.rb +1 -1
- data/test/test_name_tw.rb +1 -1
- data/test/test_name_ua.rb +1 -1
- data/test/test_name_vn.rb +1 -1
- data/test/test_nato_alphabet.rb +1 -1
- data/test/test_number.rb +45 -0
- data/test/test_phone_number.rb +1 -1
- data/test/test_phone_number_au.rb +1 -1
- data/test/test_phone_number_br.rb +1 -1
- data/test/test_phone_number_cu.rb +1 -1
- data/test/test_phone_number_da.rb +1 -1
- data/test/test_phone_number_de.rb +1 -1
- data/test/test_phone_number_fr.rb +1 -1
- data/test/test_phone_number_id.rb +1 -1
- data/test/test_phone_number_it.rb +12 -0
- data/test/test_phone_number_ja.rb +63 -0
- data/test/test_phone_number_kr.rb +1 -1
- data/test/test_phone_number_mx.rb +1 -1
- data/test/test_phone_number_nl.rb +1 -1
- data/test/test_phone_number_pl.rb +1 -1
- data/test/test_phone_number_se.rb +1 -1
- data/test/test_phone_number_sg.rb +1 -1
- data/test/test_phone_number_sn.rb +1 -1
- data/test/test_phone_number_tw.rb +1 -1
- data/test/test_phone_number_ua.rb +1 -1
- data/test/test_products.rb +1 -1
- data/test/test_sem_ver.rb +1 -1
- data/test/test_skill.rb +1 -1
- data/test/test_sport_pl.rb +1 -1
- data/test/test_sport_ru.rb +30 -0
- data/test/test_sport_us.rb +1 -1
- data/test/test_sports.rb +1 -1
- data/test/test_ssn.rb +1 -1
- data/test/test_ssn_mx.rb +1 -1
- data/test/test_ssn_se.rb +2 -2
- data/test/test_string.rb +4 -4
- data/test/test_time.rb +3 -4
- data/test/test_tweet.rb +5 -5
- data/test/test_unique_utils.rb +1 -1
- data/test/test_units.rb +2 -1
- data/test/test_units_english.rb +1 -1
- data/test/test_units_metric.rb +1 -1
- data/test/test_vehicle.rb +3 -3
- data/test/test_venue.rb +1 -1
- data/test/test_youtube.rb +1 -1
- metadata +232 -160
data/lib/ffaker/unit_english.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ffaker/unit'
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
3
|
module FFaker
|
7
4
|
module UnitEnglish
|
8
5
|
include FFaker::Unit
|
@@ -15,7 +12,7 @@ module FFaker
|
|
15
12
|
{ name: 'foot', abbreviation: 'ft' },
|
16
13
|
{ name: 'yard', abbreviation: 'yd' },
|
17
14
|
{ name: 'furlong', abbreviation: 'fur' },
|
18
|
-
{ name: 'mile', abbreviation: '
|
15
|
+
{ name: 'mile', abbreviation: 'mi' }
|
19
16
|
].freeze
|
20
17
|
MASS_UNITS = [
|
21
18
|
{ name: 'grains', abbreviation: 'gr' },
|
@@ -36,75 +33,75 @@ module FFaker
|
|
36
33
|
{ name: 'cubic yard', abbreviation: 'CY' }
|
37
34
|
].freeze
|
38
35
|
AREA_UNITS = [
|
39
|
-
{ name: 'square inch', abbreviation: 'sq
|
36
|
+
{ name: 'square inch', abbreviation: 'sq in' },
|
40
37
|
{ name: 'square foot', abbreviation: 'sq ft' },
|
41
38
|
{ name: 'square yard', abbreviation: 'sq yd' },
|
42
39
|
{ name: 'acre', abbreviation: 'ac' },
|
43
40
|
{ name: 'section', abbreviation: 's' },
|
44
41
|
{ name: 'square mile', abbreviation: 'sq mi' },
|
45
|
-
{ name: 'township', abbreviation: '
|
42
|
+
{ name: 'township', abbreviation: 'twp' }
|
46
43
|
].freeze
|
47
44
|
|
48
45
|
def mass_name
|
49
|
-
mass
|
46
|
+
mass[:name]
|
50
47
|
end
|
51
48
|
|
52
49
|
def mass_abbr
|
53
|
-
mass
|
50
|
+
mass[:abbreviation]
|
54
51
|
end
|
55
52
|
|
56
53
|
def length_name
|
57
|
-
length
|
54
|
+
length[:name]
|
58
55
|
end
|
59
56
|
|
60
57
|
def length_abbr
|
61
|
-
length
|
58
|
+
length[:abbreviation]
|
62
59
|
end
|
63
60
|
|
64
61
|
def liquid_name
|
65
|
-
liquid
|
62
|
+
liquid[:name]
|
66
63
|
end
|
67
64
|
|
68
65
|
def liquid_abbr
|
69
|
-
liquid
|
66
|
+
liquid[:abbreviation]
|
70
67
|
end
|
71
68
|
|
72
69
|
def volume_name
|
73
|
-
volume
|
70
|
+
volume[:name]
|
74
71
|
end
|
75
72
|
|
76
73
|
def volume_abbr
|
77
|
-
volume
|
74
|
+
volume[:abbreviation]
|
78
75
|
end
|
79
76
|
|
80
77
|
def area_name
|
81
|
-
area
|
78
|
+
area[:name]
|
82
79
|
end
|
83
80
|
|
84
81
|
def area_abbr
|
85
|
-
area
|
82
|
+
area[:abbreviation]
|
86
83
|
end
|
87
84
|
|
88
85
|
private
|
89
86
|
|
90
87
|
def length
|
91
|
-
|
88
|
+
fetch_sample(LENGTH_UNITS)
|
92
89
|
end
|
93
90
|
|
94
91
|
def mass
|
95
|
-
|
92
|
+
fetch_sample(MASS_UNITS)
|
96
93
|
end
|
97
94
|
|
98
95
|
def liquid
|
99
|
-
|
96
|
+
fetch_sample(LIQUID_UNITS)
|
100
97
|
end
|
101
98
|
|
102
99
|
def volume
|
103
|
-
|
100
|
+
fetch_sample(VOLUME_UNITS)
|
104
101
|
end
|
105
102
|
|
106
103
|
def area
|
107
|
-
|
104
|
+
fetch_sample(AREA_UNITS)
|
108
105
|
end
|
109
106
|
end
|
110
107
|
end
|
data/lib/ffaker/unit_metric.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ffaker/unit'
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
3
|
module FFaker
|
7
4
|
module UnitMetric
|
8
5
|
include FFaker::Unit
|
@@ -37,65 +34,65 @@ module FFaker
|
|
37
34
|
].freeze
|
38
35
|
|
39
36
|
def mass_name
|
40
|
-
mass
|
37
|
+
mass[:name]
|
41
38
|
end
|
42
39
|
|
43
40
|
def mass_abbr
|
44
|
-
mass
|
41
|
+
mass[:abbreviation]
|
45
42
|
end
|
46
43
|
|
47
44
|
def length_name
|
48
|
-
length
|
45
|
+
length[:name]
|
49
46
|
end
|
50
47
|
|
51
48
|
def length_abbr
|
52
|
-
length
|
49
|
+
length[:abbreviation]
|
53
50
|
end
|
54
51
|
|
55
52
|
def liquid_name
|
56
|
-
liquid
|
53
|
+
liquid[:name]
|
57
54
|
end
|
58
55
|
|
59
56
|
def liquid_abbr
|
60
|
-
liquid
|
57
|
+
liquid[:abbreviation]
|
61
58
|
end
|
62
59
|
|
63
60
|
def volume_name
|
64
|
-
volume
|
61
|
+
volume[:name]
|
65
62
|
end
|
66
63
|
|
67
64
|
def volume_abbr
|
68
|
-
volume
|
65
|
+
volume[:abbreviation]
|
69
66
|
end
|
70
67
|
|
71
68
|
def area_name
|
72
|
-
area
|
69
|
+
area[:name]
|
73
70
|
end
|
74
71
|
|
75
72
|
def area_abbr
|
76
|
-
area
|
73
|
+
area[:abbreviation]
|
77
74
|
end
|
78
75
|
|
79
76
|
private
|
80
77
|
|
81
78
|
def length
|
82
|
-
|
79
|
+
fetch_sample(LENGTH_UNITS)
|
83
80
|
end
|
84
81
|
|
85
82
|
def mass
|
86
|
-
|
83
|
+
fetch_sample(MASS_UNITS)
|
87
84
|
end
|
88
85
|
|
89
86
|
def liquid
|
90
|
-
|
87
|
+
fetch_sample(LIQUID_UNITS)
|
91
88
|
end
|
92
89
|
|
93
90
|
def volume
|
94
|
-
|
91
|
+
fetch_sample(VOLUME_UNITS)
|
95
92
|
end
|
96
93
|
|
97
94
|
def area
|
98
|
-
|
95
|
+
fetch_sample(AREA_UNITS)
|
99
96
|
end
|
100
97
|
end
|
101
98
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative 'array_utils'
|
4
|
+
require_relative 'random_utils'
|
5
|
+
require_relative 'unique_utils'
|
6
6
|
|
7
7
|
module FFaker
|
8
8
|
module ModuleUtils
|
@@ -35,5 +35,25 @@ module FFaker
|
|
35
35
|
def unique(max_retries = 10_000)
|
36
36
|
@unique_generator ||= FFaker::UniqueUtils.new(self, max_retries)
|
37
37
|
end
|
38
|
+
|
39
|
+
# http://en.wikipedia.org/wiki/Luhn_algorithm
|
40
|
+
def luhn_check(number)
|
41
|
+
multiplications = []
|
42
|
+
|
43
|
+
number.split(//).each_with_index do |digit, i|
|
44
|
+
multiplications << i.even? ? digit.to_i * 2 : digit.to_i
|
45
|
+
end
|
46
|
+
|
47
|
+
sum = 0
|
48
|
+
multiplications.each do |num|
|
49
|
+
num.to_s.each_byte do |character|
|
50
|
+
sum += character.chr.to_i
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
control_digit = (sum % 10).zero? ? 0 : (sum / 10 + 1) * 10 - sum
|
55
|
+
control_digit.to_s
|
56
|
+
end
|
57
|
+
|
38
58
|
end
|
39
59
|
end
|
data/lib/ffaker/vehicle.rb
CHANGED
@@ -6,7 +6,7 @@ module FFaker
|
|
6
6
|
extend self
|
7
7
|
|
8
8
|
DRIVETRAINS = %w[4WD 4X4 AWD FWD RWD].freeze
|
9
|
-
YEARS =
|
9
|
+
YEARS = Array('1900'..(::Time.now.year + 1).to_s).freeze
|
10
10
|
TRANSMISSIONS_ABBR = %w[AT MT AM CVT].freeze
|
11
11
|
CYLINDERS = %w[2 5 6 8].freeze
|
12
12
|
|
data/lib/ffaker.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module FFaker
|
4
|
-
|
5
|
-
|
4
|
+
require_relative 'ffaker/utils/array_utils'
|
5
|
+
require_relative 'ffaker/utils/module_utils'
|
6
6
|
|
7
7
|
extend ModuleUtils
|
8
8
|
|
9
9
|
BASE_LIB_PATH = File.expand_path(__dir__)
|
10
10
|
|
11
|
-
LETTERS =
|
11
|
+
LETTERS = Array('a'..'z').freeze
|
12
12
|
|
13
13
|
HEX = %w[0 1 2 3 4 5 6 7 8 9 A B C D E F].freeze
|
14
14
|
|
@@ -43,6 +43,7 @@ module FFaker
|
|
43
43
|
autoload :AddressGR, 'ffaker/address_gr'
|
44
44
|
autoload :AddressID, 'ffaker/address_id'
|
45
45
|
autoload :AddressIN, 'ffaker/address_in'
|
46
|
+
autoload :AddressIT, 'ffaker/address_it'
|
46
47
|
autoload :AddressJA, 'ffaker/address_ja'
|
47
48
|
autoload :AddressKR, 'ffaker/address_kr'
|
48
49
|
autoload :AddressMX, 'ffaker/address_mx'
|
@@ -73,25 +74,31 @@ module FFaker
|
|
73
74
|
autoload :ColorUA, 'ffaker/color_ua'
|
74
75
|
autoload :Company, 'ffaker/company'
|
75
76
|
autoload :CompanyCN, 'ffaker/company_cn'
|
77
|
+
autoload :CompanyFR, 'ffaker/company_fr'
|
76
78
|
autoload :CompanyIT, 'ffaker/company_it'
|
77
79
|
autoload :CompanyJA, 'ffaker/company_ja'
|
78
80
|
autoload :CompanySE, 'ffaker/company_se'
|
79
81
|
autoload :Conference, 'ffaker/conference'
|
80
|
-
autoload :CoursesFR, 'ffaker/
|
82
|
+
autoload :CoursesFR, 'ffaker/courses_fr'
|
81
83
|
autoload :Currency, 'ffaker/currency'
|
82
84
|
autoload :DizzleIpsum, 'ffaker/dizzle_ipsum'
|
83
85
|
autoload :Education, 'ffaker/education'
|
84
86
|
autoload :EducationCN, 'ffaker/education_cn'
|
85
87
|
autoload :Filesystem, 'ffaker/filesystem'
|
86
88
|
autoload :Food, 'ffaker/food'
|
89
|
+
autoload :FoodPL, 'ffaker/food_pl'
|
90
|
+
autoload :FreedomIpsum, 'ffaker/freedom_ipsum'
|
91
|
+
autoload :Game, 'ffaker/game'
|
87
92
|
autoload :Gender, 'ffaker/gender'
|
88
93
|
autoload :GenderBR, 'ffaker/gender_br'
|
89
94
|
autoload :GenderCN, 'ffaker/gender_cn'
|
90
95
|
autoload :GenderID, 'ffaker/gender_id'
|
96
|
+
autoload :GenderIT, 'ffaker/gender_it'
|
91
97
|
autoload :GenderJA, 'ffaker/gender_ja'
|
92
98
|
autoload :GenderJP, 'ffaker/gender_jp'
|
93
99
|
autoload :GenderKR, 'ffaker/gender_kr'
|
94
100
|
autoload :GenderPL, 'ffaker/gender_pl'
|
101
|
+
autoload :GenderRU, 'ffaker/gender_ru'
|
95
102
|
autoload :Geolocation, 'ffaker/geolocation'
|
96
103
|
autoload :Guid, 'ffaker/guid'
|
97
104
|
autoload :HealthcareIpsum, 'ffaker/healthcare_ipsum'
|
@@ -104,6 +111,7 @@ module FFaker
|
|
104
111
|
autoload :IdentificationESCL, 'ffaker/identification_es_cl'
|
105
112
|
autoload :IdentificationESCO, 'ffaker/identification_es_co'
|
106
113
|
autoload :IdentificationIN, 'ffaker/identification_in'
|
114
|
+
autoload :IdentificationIT, 'ffaker/identification_it'
|
107
115
|
autoload :IdentificationKr, 'ffaker/identification_kr'
|
108
116
|
autoload :IdentificationMX, 'ffaker/identification_mx'
|
109
117
|
autoload :IdentificationPL, 'ffaker/identification_pl'
|
@@ -115,15 +123,18 @@ module FFaker
|
|
115
123
|
autoload :JobBR, 'ffaker/job_br'
|
116
124
|
autoload :JobCN, 'ffaker/job_cn'
|
117
125
|
autoload :JobFR, 'ffaker/job_fr'
|
126
|
+
autoload :JobIT, 'ffaker/job_it'
|
118
127
|
autoload :JobJA, 'ffaker/job_ja'
|
119
128
|
autoload :JobKR, 'ffaker/job_kr'
|
120
129
|
autoload :JobVN, 'ffaker/job_vn'
|
121
130
|
autoload :Locale, 'ffaker/locale'
|
122
131
|
autoload :Lorem, 'ffaker/lorem'
|
123
132
|
autoload :LoremAR, 'ffaker/lorem_ar'
|
133
|
+
autoload :LoremBR, 'ffaker/lorem_br'
|
124
134
|
autoload :LoremCN, 'ffaker/lorem_cn'
|
125
135
|
autoload :LoremFR, 'ffaker/lorem_fr'
|
126
136
|
autoload :LoremIE, 'ffaker/lorem_ie'
|
137
|
+
autoload :LoremIT, 'ffaker/lorem_it'
|
127
138
|
autoload :LoremJA, 'ffaker/lorem_ja'
|
128
139
|
autoload :LoremKR, 'ffaker/lorem_kr'
|
129
140
|
autoload :LoremPL, 'ffaker/lorem_pl'
|
@@ -162,6 +173,7 @@ module FFaker
|
|
162
173
|
autoload :NameUA, 'ffaker/name_ua'
|
163
174
|
autoload :NameVN, 'ffaker/name_vn'
|
164
175
|
autoload :NatoAlphabet, 'ffaker/nato_alphabet'
|
176
|
+
autoload :Number, 'ffaker/number'
|
165
177
|
autoload :PhoneNumber, 'ffaker/phone_number'
|
166
178
|
autoload :PhoneNumberAU, 'ffaker/phone_number_au'
|
167
179
|
autoload :PhoneNumberBR, 'ffaker/phone_number_br'
|
@@ -172,6 +184,7 @@ module FFaker
|
|
172
184
|
autoload :PhoneNumberFR, 'ffaker/phone_number_fr'
|
173
185
|
autoload :PhoneNumberID, 'ffaker/phone_number_id'
|
174
186
|
autoload :PhoneNumberIT, 'ffaker/phone_number_it'
|
187
|
+
autoload :PhoneNumberJA, 'ffaker/phone_number_ja'
|
175
188
|
autoload :PhoneNumberKR, 'ffaker/phone_number_kr'
|
176
189
|
autoload :PhoneNumberMX, 'ffaker/phone_number_mx'
|
177
190
|
autoload :PhoneNumberNL, 'ffaker/phone_number_nl'
|
@@ -188,6 +201,7 @@ module FFaker
|
|
188
201
|
autoload :Sport, 'ffaker/sport'
|
189
202
|
autoload :SportPL, 'ffaker/sport_pl'
|
190
203
|
autoload :SportUS, 'ffaker/sport_us'
|
204
|
+
autoload :SportRU, 'ffaker/sport_ru'
|
191
205
|
autoload :SSN, 'ffaker/ssn'
|
192
206
|
autoload :SSNMX, 'ffaker/ssn_mx'
|
193
207
|
autoload :SSNSE, 'ffaker/ssn_se'
|
@@ -197,6 +211,7 @@ module FFaker
|
|
197
211
|
autoload :Unit, 'ffaker/unit'
|
198
212
|
autoload :UnitEnglish, 'ffaker/unit_english'
|
199
213
|
autoload :UnitMetric, 'ffaker/unit_metric'
|
214
|
+
autoload :VERSION, 'version'
|
200
215
|
autoload :Vehicle, 'ffaker/vehicle'
|
201
216
|
autoload :Venue, 'ffaker/venue'
|
202
217
|
autoload :Youtube, 'ffaker/youtube'
|
data/lib/version.rb
CHANGED
data/scripts/profiling.rb
CHANGED
data/scripts/reference.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'ffaker'
|
3
|
+
require_relative '../lib/ffaker'
|
5
4
|
|
6
5
|
ICONS = {
|
7
6
|
error: '‼️',
|
@@ -25,7 +24,7 @@ end
|
|
25
24
|
# Returns faker methods for a given module
|
26
25
|
def faker_methods(mod)
|
27
26
|
methods = mod.methods - Module.methods -
|
28
|
-
%i[k underscore fetch_sample rand shuffle unique]
|
27
|
+
%i[k underscore fetch_sample rand shuffle unique luhn_check]
|
29
28
|
|
30
29
|
# For Company.name (et al), don't discard :name if it was reimplemented
|
31
30
|
methods << :name if mod.send(:name) != mod.to_s
|
data/test/helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
|
-
|
4
|
+
require_relative '../lib/ffaker'
|
5
5
|
|
6
6
|
# Helpers for checking if a method is deterministic -- e.g., that the Random
|
7
7
|
# results are repeatable given the same random seed.
|
@@ -45,9 +45,9 @@ module DeterministicHelper
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
def assert_between(got,
|
49
|
-
assert_greater_than_or_equal_to got,
|
50
|
-
public_send "assert_less_than#{'_or_equal_to' unless exclude_end}", got,
|
48
|
+
def assert_between(got, range)
|
49
|
+
assert_greater_than_or_equal_to got, range.begin
|
50
|
+
public_send "assert_less_than#{'_or_equal_to' unless range.exclude_end?}", got, range.end
|
51
51
|
end
|
52
52
|
|
53
53
|
def assert_random(original_block, *args)
|
data/test/test_address.rb
CHANGED
data/test/test_address_au.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'helper'
|
4
4
|
|
5
5
|
class TestAddressAU < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
@@ -33,7 +33,7 @@ class TestAddressAU < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_full_address
|
36
|
-
assert_match(/[
|
36
|
+
assert_match(/[, a-z]/, FFaker::AddressAU.full_address)
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_au_suburb_with_states
|
@@ -60,7 +60,7 @@ class TestAddressAU < Test::Unit::TestCase
|
|
60
60
|
|
61
61
|
def test_full_address_with_states
|
62
62
|
FFaker::AddressAU::STATE_ABBR.each do |st_abbr|
|
63
|
-
assert_match(/[
|
63
|
+
assert_match(/[, a-z]/, FFaker::AddressAU.full_address(st_abbr))
|
64
64
|
assert_deterministic { FFaker::AddressAU.full_address(st_abbr) }
|
65
65
|
end
|
66
66
|
end
|
data/test/test_address_br.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'helper'
|
4
4
|
|
5
5
|
class TestAddressBR < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
@@ -32,6 +32,6 @@ class TestAddressBR < Test::Unit::TestCase
|
|
32
32
|
|
33
33
|
def test_street
|
34
34
|
prefixes = FFaker::AddressBR::STREET_PREFIX
|
35
|
-
assert_match(/(#{prefixes.join('|')})(
|
35
|
+
assert_match(/(#{prefixes.join('|')})( \p{Alpha}+){1,2}/, FFaker::AddressBR.street)
|
36
36
|
end
|
37
37
|
end
|
data/test/test_address_ca.rb
CHANGED
data/test/test_address_ch.rb
CHANGED
data/test/test_address_ch_de.rb
CHANGED
data/test/test_address_ch_fr.rb
CHANGED
data/test/test_address_ch_it.rb
CHANGED
data/test/test_address_da.rb
CHANGED
data/test/test_address_de.rb
CHANGED
data/test/test_address_fi.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'helper'
|
4
4
|
|
5
5
|
class TestAddressFI < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
7
7
|
|
8
|
-
ALPHA = /\A
|
8
|
+
ALPHA = /\A\p{Alpha}+/.freeze
|
9
9
|
DIGIT = /\d{1}/.freeze
|
10
10
|
|
11
11
|
assert_methods_are_deterministic(
|
@@ -30,7 +30,7 @@ class TestAddressFI < Test::Unit::TestCase
|
|
30
30
|
assert_match(ALPHA, address)
|
31
31
|
assert_match(DIGIT, address)
|
32
32
|
assert_match(/SUOMI/, address)
|
33
|
-
assert_match(/[
|
33
|
+
assert_match(/[, a-z]/, address)
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_fi_zip_code_frozen
|
data/test/test_address_fr.rb
CHANGED
data/test/test_address_gr.rb
CHANGED
data/test/test_address_id.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'helper'
|
4
4
|
|
5
5
|
class TestAddressID < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
@@ -33,7 +33,7 @@ class TestAddressID < Test::Unit::TestCase
|
|
33
33
|
def test_street
|
34
34
|
prefixes = FFaker::AddressID::STREET_PREFIX
|
35
35
|
common_street_names = FFaker::AddressID::COMMON_STREET_NAMES
|
36
|
-
regex = /\A(#{prefixes.join('|')})\.(\s(#{common_street_names.join('|')}))
|
36
|
+
regex = /\A(#{prefixes.join('|')})\.(\s(#{common_street_names.join('|')})),\sNo\.\s\d+\z/
|
37
37
|
assert_match(regex, FFaker::AddressID.street)
|
38
38
|
end
|
39
39
|
end
|
data/test/test_address_in.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
class TestAddressIT < Test::Unit::TestCase
|
6
|
+
include DeterministicHelper
|
7
|
+
|
8
|
+
assert_methods_are_deterministic(
|
9
|
+
FFaker::AddressIT,
|
10
|
+
:city, :full_address, :street_address, :postal_code, :region
|
11
|
+
)
|
12
|
+
end
|
data/test/test_address_ja.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'helper'
|
4
4
|
|
5
5
|
class TestAddressJA < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
@@ -13,7 +13,7 @@ class TestAddressJA < Test::Unit::TestCase
|
|
13
13
|
)
|
14
14
|
|
15
15
|
def test_postal_code
|
16
|
-
assert_match(/^\d{3}
|
16
|
+
assert_match(/^\d{3}-\d{4}$/, FFaker::AddressJA.postal_code)
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_land_number
|
data/test/test_address_kr.rb
CHANGED