ffaker 2.2.0 → 2.3.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 +34 -0
- data/README.md +4 -0
- data/REFERENCE.md +1153 -800
- data/Rakefile +23 -24
- data/ffaker.gemspec +12 -420
- data/lib/ffaker.rb +47 -7
- data/lib/ffaker/address.rb +11 -11
- data/lib/ffaker/address_au.rb +60 -60
- data/lib/ffaker/address_br.rb +5 -5
- data/lib/ffaker/address_ca.rb +7 -7
- data/lib/ffaker/address_ch.rb +1 -2
- data/lib/ffaker/address_ch_de.rb +1 -1
- data/lib/ffaker/address_ch_fr.rb +1 -1
- data/lib/ffaker/address_ch_it.rb +1 -1
- data/lib/ffaker/address_da.rb +5 -5
- data/lib/ffaker/address_de.rb +16 -12
- data/lib/ffaker/address_fi.rb +7 -8
- data/lib/ffaker/address_fr.rb +13 -13
- data/lib/ffaker/address_gr.rb +40 -0
- data/lib/ffaker/address_in.rb +12 -12
- data/lib/ffaker/address_kr.rb +87 -0
- data/lib/ffaker/address_mx.rb +409 -409
- data/lib/ffaker/address_nl.rb +17 -13
- data/lib/ffaker/address_ru.rb +6 -6
- data/lib/ffaker/address_se.rb +7 -8
- data/lib/ffaker/address_sn.rb +3 -3
- data/lib/ffaker/address_ua.rb +8 -8
- data/lib/ffaker/address_uk.rb +5 -5
- data/lib/ffaker/address_us.rb +9 -9
- data/lib/ffaker/airline.rb +16 -0
- data/lib/ffaker/avatar.rb +3 -3
- data/lib/ffaker/aws.rb +24 -0
- data/lib/ffaker/bacon_ipsum.rb +2 -2
- data/lib/ffaker/book.rb +45 -0
- data/lib/ffaker/boolean.rb +2 -2
- data/lib/ffaker/cheesy_lingo.rb +15 -12
- data/lib/ffaker/color.rb +54 -1
- data/lib/ffaker/color_ua.rb +1 -1
- data/lib/ffaker/company.rb +13 -11
- data/lib/ffaker/company_cn.rb +23 -0
- data/lib/ffaker/company_it.rb +4 -4
- data/lib/ffaker/company_se.rb +2 -2
- data/lib/ffaker/conference.rb +1 -1
- data/lib/ffaker/courses.rb +2 -3
- data/lib/ffaker/currency.rb +2 -2
- data/lib/ffaker/data/address_gr/city +79 -0
- data/lib/ffaker/data/address_gr/region +13 -0
- data/lib/ffaker/data/address_gr/street +100 -0
- data/lib/ffaker/data/address_kr/boroughs +29 -0
- data/lib/ffaker/data/address_kr/cities +51 -0
- data/lib/ffaker/data/airline/codes_list +209 -0
- data/lib/ffaker/data/airline/names_list +206 -0
- data/lib/ffaker/data/aws/ec2_instance_type +59 -0
- data/lib/ffaker/data/aws/ec2_reserved_instance_tenancy +3 -0
- data/lib/ffaker/data/aws/ec2_reserved_offering_type +6 -0
- data/lib/ffaker/data/aws/ec2_reserved_product_description +14 -0
- data/lib/ffaker/data/book/adj_and_adv +20 -0
- data/lib/ffaker/data/book/genres +369 -0
- data/lib/ffaker/data/book/nouns +36 -0
- data/lib/ffaker/data/book/prefixes +17 -0
- data/lib/ffaker/data/color/names_list +128 -0
- data/lib/ffaker/data/education/degree_prefix +274 -0
- data/lib/ffaker/data/education/degree_short_prefix +19 -0
- data/lib/ffaker/data/job_br/job_nouns +52 -0
- data/lib/ffaker/data/job_vn/job_nouns +191 -0
- data/lib/ffaker/data/lorem_ja/characters +101 -0
- data/lib/ffaker/data/lorem_ja/sentences +30 -0
- data/lib/ffaker/data/lorem_ja/sentences_end +21 -0
- data/lib/ffaker/data/lorem_ja/words +81 -0
- data/lib/ffaker/data/name/first_names_female +4275 -0
- data/lib/ffaker/data/name/first_names_male +1219 -0
- data/lib/ffaker/data/name_br/first_names_female +1068 -0
- data/lib/ffaker/data/name_br/first_names_male +607 -0
- data/lib/ffaker/data/name_br/last_names +52 -0
- data/lib/ffaker/data/name_gr/female_first_names +80 -0
- data/lib/ffaker/data/name_gr/female_last_names +45 -0
- data/lib/ffaker/data/name_gr/male_first_names +90 -0
- data/lib/ffaker/data/name_gr/male_last_names +57 -0
- data/lib/ffaker/data/name_kh/first_names +64 -0
- data/lib/ffaker/data/name_kh/last_names +71 -0
- data/lib/ffaker/data/name_kh/nick_names +30 -0
- data/lib/ffaker/data/name_then/first_names +292 -0
- data/lib/ffaker/data/name_then/last_names +63 -0
- data/lib/ffaker/data/name_then/nick_names +30 -0
- data/lib/ffaker/data/phone_number/phone_calling_code +205 -0
- data/lib/ffaker/data/sport/names +57 -24
- data/lib/ffaker/data/tweet/hashtag +58 -0
- data/lib/ffaker/data/youtube/video_ids +50 -0
- data/lib/ffaker/dizzle_ipsum.rb +2 -2
- data/lib/ffaker/education.rb +17 -16
- data/lib/ffaker/food.rb +5 -6
- data/lib/ffaker/gender.rb +4 -4
- data/lib/ffaker/gender_br.rb +17 -0
- data/lib/ffaker/gender_cn.rb +4 -4
- data/lib/ffaker/gender_kr.rb +4 -4
- data/lib/ffaker/geolocation.rb +26 -26
- data/lib/ffaker/healthcare_ipsum.rb +2 -2
- data/lib/ffaker/hipster_ipsum.rb +2 -2
- data/lib/ffaker/html_ipsum.rb +101 -81
- data/lib/ffaker/identification.rb +4 -4
- data/lib/ffaker/identification_br.rb +84 -0
- data/lib/ffaker/identification_es.rb +2 -2
- data/lib/ffaker/identification_es_cl.rb +7 -5
- data/lib/ffaker/identification_es_co.rb +9 -10
- data/lib/ffaker/identification_kr.rb +3 -4
- data/lib/ffaker/identification_mx.rb +27 -11
- data/lib/ffaker/internet.rb +26 -23
- data/lib/ffaker/internet_se.rb +21 -21
- data/lib/ffaker/job.rb +1 -1
- data/lib/ffaker/job_br.rb +12 -0
- data/lib/ffaker/job_cn.rb +1 -1
- data/lib/ffaker/job_fr.rb +3 -3
- data/lib/ffaker/job_ja.rb +2 -1
- data/lib/ffaker/job_kr.rb +1 -1
- data/lib/ffaker/job_vn.rb +13 -0
- data/lib/ffaker/locale.rb +2 -3
- data/lib/ffaker/lorem.rb +5 -5
- data/lib/ffaker/lorem_ar.rb +4 -4
- data/lib/ffaker/lorem_cn.rb +3 -3
- data/lib/ffaker/lorem_fr.rb +4 -4
- data/lib/ffaker/lorem_ja.rb +40 -0
- data/lib/ffaker/lorem_kr.rb +4 -4
- data/lib/ffaker/lorem_ua.rb +8 -11
- data/lib/ffaker/movie.rb +18 -20
- data/lib/ffaker/music.rb +4 -4
- data/lib/ffaker/name.rb +100 -11
- data/lib/ffaker/name_br.rb +37 -6
- data/lib/ffaker/name_cn.rb +2 -2
- data/lib/ffaker/name_cs.rb +10 -10
- data/lib/ffaker/name_da.rb +6 -6
- data/lib/ffaker/name_de.rb +5 -5
- data/lib/ffaker/name_fr.rb +4 -4
- data/lib/ffaker/name_ga.rb +4 -5
- data/lib/ffaker/name_gr.rb +60 -0
- data/lib/ffaker/name_it.rb +4 -4
- data/lib/ffaker/name_ja.rb +3 -3
- data/lib/ffaker/name_kh.rb +22 -0
- data/lib/ffaker/name_kr.rb +3 -3
- data/lib/ffaker/name_mx.rb +14 -14
- data/lib/ffaker/name_nb.rb +5 -5
- data/lib/ffaker/name_nl.rb +7 -7
- data/lib/ffaker/name_ph.rb +2 -2
- data/lib/ffaker/name_ru.rb +7 -8
- data/lib/ffaker/name_se.rb +5 -5
- data/lib/ffaker/name_sn.rb +23 -23
- data/lib/ffaker/name_th.rb +3 -3
- data/lib/ffaker/name_th_en.rb +26 -0
- data/lib/ffaker/name_ua.rb +8 -8
- data/lib/ffaker/name_vn.rb +4 -4
- data/lib/ffaker/nato_alphabet.rb +10 -10
- data/lib/ffaker/phone_number.rb +31 -21
- data/lib/ffaker/phone_number_au.rb +3 -3
- data/lib/ffaker/phone_number_br.rb +9 -8
- data/lib/ffaker/phone_number_ch.rb +7 -7
- data/lib/ffaker/phone_number_cu.rb +5 -5
- data/lib/ffaker/phone_number_de.rb +1 -1
- data/lib/ffaker/phone_number_fr.rb +4 -4
- data/lib/ffaker/phone_number_it.rb +2 -2
- data/lib/ffaker/phone_number_kr.rb +4 -4
- data/lib/ffaker/phone_number_mx.rb +4 -5
- data/lib/ffaker/phone_number_nl.rb +13 -13
- data/lib/ffaker/phone_number_se.rb +18 -19
- data/lib/ffaker/phone_number_sg.rb +8 -8
- data/lib/ffaker/phone_number_sn.rb +2 -2
- data/lib/ffaker/product.rb +18 -14
- data/lib/ffaker/skill.rb +3 -3
- data/lib/ffaker/sport.rb +1 -1
- data/lib/ffaker/ssn_se.rb +19 -20
- data/lib/ffaker/string.rb +21 -23
- data/lib/ffaker/time.rb +19 -7
- data/lib/ffaker/tweet.rb +59 -0
- data/lib/ffaker/unit.rb +12 -12
- data/lib/ffaker/unit_english.rb +34 -35
- data/lib/ffaker/unit_metric.rb +25 -25
- data/lib/ffaker/utils/array_utils.rb +12 -9
- data/lib/ffaker/utils/module_utils.rb +9 -6
- data/lib/ffaker/utils/random_utils.rb +33 -0
- data/lib/ffaker/vehicle.rb +21 -21
- data/lib/ffaker/venue.rb +1 -1
- data/lib/ffaker/youtube.rb +24 -0
- data/scripts/benchmark.rb +3 -3
- data/scripts/reference.rb +26 -23
- data/test/helper.rb +50 -0
- data/test/test_address.rb +40 -21
- data/test/test_address_au.rb +19 -9
- data/test/test_address_br.rb +9 -2
- data/test/test_address_ca.rb +7 -0
- data/test/test_address_ch.rb +6 -2
- data/test/test_address_ch_de.rb +7 -3
- data/test/test_address_ch_fr.rb +7 -3
- data/test/test_address_ch_it.rb +5 -1
- data/test/test_address_da.rb +18 -9
- data/test/test_address_de.rb +12 -5
- data/test/test_address_fi.rb +10 -3
- data/test/test_address_fr.rb +13 -0
- data/test/test_address_gr.rb +43 -0
- data/test/test_address_in.rb +20 -12
- data/test/test_address_kr.rb +14 -0
- data/test/test_address_mx.rb +12 -5
- data/test/test_address_nl.rb +11 -5
- data/test/test_address_ru.rb +11 -5
- data/test/test_address_se.rb +9 -3
- data/test/test_address_sn.rb +7 -1
- data/test/test_address_ua.rb +17 -10
- data/test/test_address_uk.rb +11 -3
- data/test/test_address_us.rb +15 -6
- data/test/test_airline.rb +17 -0
- data/test/test_array_utils.rb +51 -3
- data/test/test_avatar.rb +5 -1
- data/test/test_aws.rb +25 -0
- data/test/test_bacon_ipsum.rb +12 -6
- data/test/test_book.rb +41 -0
- data/test/test_boolean.rb +4 -0
- data/test/test_cheesy_lingo.rb +14 -10
- data/test/test_color.rb +126 -1
- data/test/test_color_ua.rb +5 -1
- data/test/test_company.rb +7 -0
- data/test/test_company_cn.rb +24 -0
- data/test/test_company_it.rb +7 -1
- data/test/test_company_se.rb +6 -0
- data/test/test_conference.rb +5 -2
- data/test/test_course_mathematiques.rb +5 -1
- data/test/test_course_philosophie.rb +5 -1
- data/test/test_currency.rb +12 -0
- data/test/test_dizzle_ipsum.rb +12 -6
- data/test/test_education.rb +9 -2
- data/test/test_faker.rb +8 -1
- data/test/test_food.rb +11 -4
- data/test/test_gender.rb +5 -1
- data/test/test_gender_br.rb +18 -0
- data/test/test_gender_cn.rb +5 -2
- data/test/test_gender_kr.rb +7 -3
- data/test/test_geolocation.rb +11 -8
- data/test/test_guid.rb +6 -1
- data/test/test_healthcare_ipsum.rb +13 -6
- data/test/test_hipster_ipsum.rb +13 -6
- data/test/test_html_ipsum.rb +28 -20
- data/test/test_identification.rb +9 -2
- data/test/test_identification_br.rb +46 -0
- data/test/test_identification_co.rb +7 -0
- data/test/test_identification_es.rb +5 -1
- data/test/test_identification_es_cl.rb +5 -1
- data/test/test_identification_es_mx.rb +7 -2
- data/test/test_identification_kr.rb +4 -0
- data/test/test_internet.rb +36 -5
- data/test/test_internet_se.rb +12 -4
- data/test/test_job.rb +4 -0
- data/test/test_job_br.rb +17 -0
- data/test/test_job_cn.rb +4 -0
- data/test/test_job_fr.rb +4 -0
- data/test/test_job_ja.rb +4 -0
- data/test/test_job_kr.rb +4 -0
- data/test/test_job_vn.rb +22 -0
- data/test/test_locale.rb +10 -4
- data/test/test_lorem.rb +18 -11
- data/test/test_lorem_ar.rb +16 -8
- data/test/test_lorem_cn.rb +9 -2
- data/test/test_lorem_fr.rb +16 -8
- data/test/test_lorem_ja.rb +81 -0
- data/test/test_lorem_kr.rb +17 -8
- data/test/test_lorem_ua.rb +15 -8
- data/test/test_module_utils.rb +2 -2
- data/test/test_movie.rb +5 -1
- data/test/test_music.rb +11 -4
- data/test/test_name.rb +114 -1
- data/test/test_name_br.rb +41 -2
- data/test/test_name_cn.rb +7 -0
- data/test/test_name_cs.rb +7 -0
- data/test/test_name_da.rb +13 -6
- data/test/test_name_de.rb +4 -0
- data/test/test_name_fr.rb +7 -0
- data/test/test_name_ga.rb +7 -0
- data/test/test_name_gr.rb +70 -0
- data/test/test_name_it.rb +7 -0
- data/test/test_name_ja.rb +7 -0
- data/test/test_name_kh.rb +32 -0
- data/test/test_name_kr.rb +7 -0
- data/test/test_name_mx.rb +9 -0
- data/test/test_name_nb.rb +8 -0
- data/test/test_name_nl.rb +4 -0
- data/test/test_name_ph.rb +7 -0
- data/test/test_name_ru.rb +10 -3
- data/test/test_name_se.rb +12 -4
- data/test/test_name_sn.rb +8 -0
- data/test/test_name_th.rb +7 -0
- data/test/test_name_th_en.rb +35 -0
- data/test/test_name_ua.rb +26 -17
- data/test/test_name_vn.rb +42 -0
- data/test/test_nato_alphabet.rb +15 -4
- data/test/test_phone_number.rb +24 -6
- data/test/test_phone_number_au.rb +17 -6
- data/test/test_phone_number_br.rb +22 -13
- data/test/test_phone_number_cu.rb +29 -18
- data/test/test_phone_number_da.rb +16 -7
- data/test/test_phone_number_de.rb +17 -9
- data/test/test_phone_number_kr.rb +9 -0
- data/test/test_phone_number_mx.rb +16 -8
- data/test/test_phone_number_nl.rb +9 -2
- data/test/test_phone_number_se.rb +12 -7
- data/test/test_phone_number_sg.rb +17 -9
- data/test/test_phone_number_sn.rb +12 -4
- data/test/test_products.rb +22 -0
- data/test/test_skill.rb +8 -2
- data/test/test_sports.rb +4 -0
- data/test/test_ssn.rb +3 -1
- data/test/test_ssn_mx.rb +6 -1
- data/test/test_ssn_se.rb +3 -0
- data/test/test_string.rb +28 -1
- data/test/test_time.rb +33 -2
- data/test/test_tweet.rb +59 -0
- data/test/test_units.rb +7 -0
- data/test/test_units_english.rb +9 -0
- data/test/test_units_metric.rb +9 -0
- data/test/test_vehicle.rb +24 -15
- data/test/test_venue.rb +5 -1
- data/test/test_youtube.rb +28 -0
- metadata +101 -5
- data/lib/ffaker/data/name/first_names +0 -3008
- data/lib/ffaker/data/name_br/first_names +0 -91
data/lib/ffaker/hipster_ipsum.rb
CHANGED
data/lib/ffaker/html_ipsum.rb
CHANGED
@@ -12,149 +12,169 @@ module FFaker
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def p(count = 3, options = {})
|
15
|
-
options = {fancy: false, include_breaks: false}.merge(options)
|
15
|
+
options = { fancy: false, include_breaks: false }.merge(options)
|
16
16
|
if options[:fancy]
|
17
17
|
s = fancy_string(count, options[:include_breaks])
|
18
18
|
else
|
19
|
-
mode = options[:include_breaks] ?
|
19
|
+
mode = options[:include_breaks] ? 'paragraphs' : 'paragraph'
|
20
20
|
s = send(mode.to_sym, count)
|
21
21
|
end
|
22
|
-
|
22
|
+
content_tag_for(:p, s)
|
23
23
|
end
|
24
24
|
|
25
25
|
def dl(definitions = 2)
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
content_tag_for :dl do |dl|
|
27
|
+
definitions.times do
|
28
|
+
dl << content_tag_for(:dt, words(1).capitalize!)
|
29
|
+
dl << content_tag_for(:dd, paragraph(2))
|
30
|
+
end
|
29
31
|
end
|
30
|
-
s << "</dl>"
|
31
32
|
end
|
32
33
|
|
33
34
|
def ul_short(items = 3)
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
content_tag_for :ul do |ul|
|
36
|
+
items.times do
|
37
|
+
ul << content_tag_for(:li, sentence(2))
|
38
|
+
end
|
37
39
|
end
|
38
|
-
s << "</ul>"
|
39
40
|
end
|
40
41
|
|
41
42
|
def ul_long(items = 3)
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
content_tag_for :ul do |ul|
|
44
|
+
items.times do
|
45
|
+
ul << content_tag_for(:li, paragraph(2))
|
46
|
+
end
|
45
47
|
end
|
46
|
-
s << "</ul>"
|
47
48
|
end
|
48
49
|
|
49
50
|
def ol_short(items = 3)
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
content_tag_for :ol do |ol|
|
52
|
+
items.times do
|
53
|
+
ol << content_tag_for(:li, sentence(2))
|
54
|
+
end
|
53
55
|
end
|
54
|
-
s << "</ol>"
|
55
56
|
end
|
56
57
|
|
57
58
|
def ol_long(items = 3)
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
content_tag_for :ol do |ol|
|
60
|
+
items.times do
|
61
|
+
ol << content_tag_for(:li, paragraph(2))
|
62
|
+
end
|
61
63
|
end
|
62
|
-
s << "</ol>"
|
63
64
|
end
|
64
65
|
|
65
66
|
def ul_links(items = 3)
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
content_tag_for :ul do |ul|
|
68
|
+
items.times do
|
69
|
+
ul << content_tag_for(:li, a(1))
|
70
|
+
end
|
69
71
|
end
|
70
|
-
s << "</ul>"
|
71
72
|
end
|
72
73
|
|
73
74
|
def table(rows = 3)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
75
|
+
content_tag_for(:table) do |table|
|
76
|
+
table << content_tag_for(:thead) do |thead|
|
77
|
+
thead << content_tag_for(:tr) do |tr|
|
78
|
+
tr << content_tag_for(:th, word.capitalize)
|
79
|
+
tr << content_tag_for(:th, word.capitalize)
|
80
|
+
tr << content_tag_for(:th, word.capitalize)
|
81
|
+
tr << content_tag_for(:th, word.capitalize)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
table << content_tag_for(:tbody) do |tbody|
|
85
|
+
rows.times do
|
86
|
+
tbody << content_tag_for(:tr) do |tr|
|
87
|
+
tr << content_tag_for(:td, words(1).capitalize)
|
88
|
+
tr << content_tag_for(:td, words(1).capitalize)
|
89
|
+
tr << content_tag_for(:td, words(1).capitalize)
|
90
|
+
tr << content_tag_for(:td, a)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
91
94
|
end
|
92
|
-
s << "</tbody>
|
93
|
-
</table>"
|
94
95
|
end
|
95
96
|
|
96
97
|
def body
|
97
|
-
|
98
|
+
body = content_tag_for(:h1, words(2).capitalize)
|
98
99
|
rand(4).times do
|
99
|
-
|
100
|
+
body << content_tag_for(:p, fancy_string)
|
100
101
|
end
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
102
|
+
body << table(rand(4))
|
103
|
+
body << content_tag_for(:h2, words(2).capitalize)
|
104
|
+
body << content_tag_for(:ol) do |ol|
|
105
|
+
rand(4).times do
|
106
|
+
ol << content_tag_for(:li, paragraph(1))
|
107
|
+
end
|
106
108
|
end
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
body << content_tag_for(:blockquote) do |bq|
|
110
|
+
bq << content_tag_for(:p, paragraphs(3))
|
111
|
+
end
|
112
|
+
body << content_tag_for(:h3, words(2).capitalize!)
|
113
|
+
body << content_tag_for(:ul) do |ul|
|
114
|
+
rand(4).times do
|
115
|
+
ul << content_tag_for(:li, paragraph(1))
|
116
|
+
end
|
117
|
+
end
|
118
|
+
body << content_tag_for(:pre) do |pre|
|
119
|
+
pre << content_tag_for(:code) do |code|
|
120
|
+
code << "
|
121
|
+
##{word} h1 a {
|
122
|
+
display: block;
|
123
|
+
width: 300px;
|
124
|
+
height: 80px;
|
125
|
+
}
|
126
|
+
"
|
127
|
+
end
|
113
128
|
end
|
114
|
-
|
115
|
-
<pre><code>
|
116
|
-
##{word} h1 a {
|
117
|
-
display: block;
|
118
|
-
width: 300px;
|
119
|
-
height: 80px;
|
120
|
-
}
|
121
|
-
</code></pre>"
|
129
|
+
body
|
122
130
|
end
|
123
131
|
|
124
132
|
def fancy_string(count = 3, include_breaks = false)
|
125
|
-
sep
|
133
|
+
sep = include_breaks ? '<br>' : ' '
|
126
134
|
a = k([
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
] + FFaker::Lorem
|
132
|
-
a
|
135
|
+
content_tag_for(:strong, words(2).capitalize!),
|
136
|
+
content_tag_for(:em, paragraph),
|
137
|
+
content_tag_for(:code, words(2)),
|
138
|
+
(a 2).to_s
|
139
|
+
] + FFaker::Lorem.paragraphs(count))
|
140
|
+
fetch_sample(a, count: count).join(sep)
|
141
|
+
end
|
142
|
+
|
143
|
+
private
|
144
|
+
|
145
|
+
def content_tag_for(element, content = nil)
|
146
|
+
element_content = if content
|
147
|
+
content
|
148
|
+
else
|
149
|
+
block_html = ''
|
150
|
+
yield(block_html)
|
151
|
+
block_html
|
152
|
+
end
|
153
|
+
"<#{element}>#{element_content}</#{element}>"
|
133
154
|
end
|
134
155
|
|
135
|
-
private
|
136
156
|
def word
|
137
|
-
FFaker::Lorem
|
157
|
+
FFaker::Lorem.word
|
138
158
|
end
|
139
159
|
|
140
160
|
def words(word_count = 3)
|
141
|
-
FFaker::Lorem
|
161
|
+
FFaker::Lorem.words(word_count).join(' ')
|
142
162
|
end
|
143
163
|
|
144
164
|
def sentence(word_count = 3)
|
145
|
-
FFaker::Lorem
|
165
|
+
FFaker::Lorem.sentence(word_count)
|
146
166
|
end
|
147
167
|
|
148
168
|
def sentences(sentence_count = 3)
|
149
|
-
FFaker::Lorem
|
169
|
+
FFaker::Lorem.sentences(sentence_count).join(' ')
|
150
170
|
end
|
151
171
|
|
152
172
|
def paragraph(sentence_count = 3)
|
153
|
-
FFaker::Lorem
|
173
|
+
FFaker::Lorem.paragraph(sentence_count)
|
154
174
|
end
|
155
175
|
|
156
176
|
def paragraphs(paragraph_count = 3)
|
157
|
-
FFaker::Lorem
|
177
|
+
FFaker::Lorem.paragraphs(paragraph_count).join('<br>')
|
158
178
|
end
|
159
179
|
end
|
160
180
|
end
|
@@ -5,8 +5,8 @@ module FFaker
|
|
5
5
|
extend ModuleUtils
|
6
6
|
extend self
|
7
7
|
|
8
|
-
ETHNICITIES = ['African American', 'Asian/Pacific Islander', 'Caucasian', 'Hispanic', 'Native American', 'Multiracial', 'Other', 'Prefer not to respond']
|
9
|
-
GENDERS = %w(Male Female)
|
8
|
+
ETHNICITIES = ['African American', 'Asian/Pacific Islander', 'Caucasian', 'Hispanic', 'Native American', 'Multiracial', 'Other', 'Prefer not to respond'].freeze
|
9
|
+
GENDERS = %w(Male Female).freeze
|
10
10
|
|
11
11
|
def drivers_license
|
12
12
|
FFaker.bothify('?###-###-##-###-#').upcase
|
@@ -17,11 +17,11 @@ module FFaker
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def ethnicity
|
20
|
-
ETHNICITIES
|
20
|
+
fetch_sample(ETHNICITIES)
|
21
21
|
end
|
22
22
|
|
23
23
|
def gender
|
24
|
-
GENDERS
|
24
|
+
fetch_sample(GENDERS)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module FFaker
|
4
|
+
module IdentificationBR
|
5
|
+
extend ModuleUtils
|
6
|
+
extend self
|
7
|
+
|
8
|
+
GENDERS = %w(Feminino Masculino).freeze
|
9
|
+
CPF_VERIFICATION_MULTIPLIERS = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2].freeze
|
10
|
+
CNPJ_VERIFICATION_MULTIPLIERS = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2].freeze
|
11
|
+
|
12
|
+
def cpf
|
13
|
+
cpf = FFaker.numerify('#########')
|
14
|
+
validators = cpf_verification_digits(cpf)
|
15
|
+
cpf + validators.join
|
16
|
+
end
|
17
|
+
|
18
|
+
def pretty_cpf
|
19
|
+
cpf_numbers = cpf
|
20
|
+
format('%s.%s.%s-%s',
|
21
|
+
cpf_numbers[0..2],
|
22
|
+
cpf_numbers[3..5],
|
23
|
+
cpf_numbers[6..8],
|
24
|
+
cpf_numbers[9..10])
|
25
|
+
end
|
26
|
+
|
27
|
+
def cnpj
|
28
|
+
cnpj = FFaker.numerify('############')
|
29
|
+
validators = cnpj_verification_digits(cnpj)
|
30
|
+
cnpj + validators.join
|
31
|
+
end
|
32
|
+
|
33
|
+
def pretty_cnpj
|
34
|
+
cnpj_numbers = cnpj.to_s.rjust(14, '0')
|
35
|
+
format('%s.%s.%s/%s-%s',
|
36
|
+
cnpj_numbers[0..1],
|
37
|
+
cnpj_numbers[2..4],
|
38
|
+
cnpj_numbers[5..7],
|
39
|
+
cnpj_numbers[8..11],
|
40
|
+
cnpj_numbers[12..14])
|
41
|
+
end
|
42
|
+
|
43
|
+
def rg
|
44
|
+
FFaker.numerify('#########')
|
45
|
+
end
|
46
|
+
|
47
|
+
def pretty_rg
|
48
|
+
FFaker.numerify('###.###.###')
|
49
|
+
end
|
50
|
+
|
51
|
+
def gender
|
52
|
+
fetch_sample(GENDERS)
|
53
|
+
end
|
54
|
+
|
55
|
+
def cpf_verification_digits(cpf)
|
56
|
+
document_verification_digits(CPF_VERIFICATION_MULTIPLIERS, cpf)
|
57
|
+
end
|
58
|
+
|
59
|
+
def cnpj_verification_digits(cnpj)
|
60
|
+
document_verification_digits(CNPJ_VERIFICATION_MULTIPLIERS, cnpj)
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def document_verification_digits(verification_multipliers, document = nil)
|
66
|
+
return false if document.nil?
|
67
|
+
|
68
|
+
document_digits = document.to_s.scan(/[0-9]/).map(&:to_i)
|
69
|
+
validation_digits = []
|
70
|
+
|
71
|
+
if document_digits.size + 1 == verification_multipliers.size && document_digits.uniq.size > 1
|
72
|
+
0.upto(1) do |i|
|
73
|
+
sum = verification_multipliers.drop(1 - i).each_with_index.inject(0) do |val, (value, j)|
|
74
|
+
val + document_digits[j] * value
|
75
|
+
end
|
76
|
+
validation_digits[i] = (sum %= 11) < 2 ? 0 : 11 - sum
|
77
|
+
document_digits.push(validation_digits[i])
|
78
|
+
end
|
79
|
+
return validation_digits
|
80
|
+
end
|
81
|
+
[]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -5,6 +5,7 @@ require 'ffaker/identification_es'
|
|
5
5
|
module FFaker
|
6
6
|
module IdentificationESCL
|
7
7
|
extend IdentificationES
|
8
|
+
extend ModuleUtils
|
8
9
|
extend self
|
9
10
|
|
10
11
|
# RUT is the Chilean ID, followed by format: XX.XXX.XXX - Y
|
@@ -13,14 +14,15 @@ module FFaker
|
|
13
14
|
# The last Y is a modulo 11 validation code. In the case the result is 10, it will be replaced by a 'K' character
|
14
15
|
def rut
|
15
16
|
# Rut is gonna be between 1.000.000 and 24.999.999
|
16
|
-
n =
|
17
|
+
n = rand(24_000_000) + 1_000_000
|
17
18
|
"#{n}-#{dv(n)}"
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
|
23
|
+
def dv(rut)
|
24
|
+
total = rut.to_s.rjust(8, '0').split(//).zip(%w(3 2 7 6 5 4 3 2)).collect { |a, b| a.to_i * b.to_i }.inject(:+)
|
25
|
+
(11 - total % 11).to_s.gsub(/10/, 'k').gsub(/11/, '0')
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'ffaker/identification_es'
|
4
|
-
require
|
4
|
+
require 'date'
|
5
5
|
|
6
6
|
module FFaker
|
7
7
|
module IdentificationESCO
|
@@ -10,32 +10,31 @@ module FFaker
|
|
10
10
|
extend ModuleUtils
|
11
11
|
extend self
|
12
12
|
|
13
|
-
BLOOD_TYPE = %w(A B O AB)
|
14
|
-
LICENSE_CATEGORY = %w(A B C)
|
13
|
+
BLOOD_TYPE = %w(A B O AB).freeze
|
14
|
+
LICENSE_CATEGORY = %w(A B C).freeze
|
15
15
|
|
16
16
|
def drivers_license
|
17
17
|
how_many_numbers = 6 + rand(8)
|
18
|
-
FFaker.numerify(
|
18
|
+
FFaker.numerify('#' * how_many_numbers)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
alias id drivers_license
|
22
22
|
|
23
23
|
def driver_license_category
|
24
|
-
category = LICENSE_CATEGORY
|
24
|
+
category = fetch_sample(LICENSE_CATEGORY)
|
25
25
|
# the categories are A1 A2 B1 B2 B3 C1 C2 C3
|
26
26
|
num = category == 'A' ? 1 + rand(2) : 1 + rand(3)
|
27
27
|
"#{category}#{num}"
|
28
28
|
end
|
29
29
|
|
30
|
-
def blood_type #RH
|
31
|
-
sign = %w(+ -)
|
32
|
-
"#{BLOOD_TYPE
|
30
|
+
def blood_type # RH
|
31
|
+
sign = fetch_sample(%w(+ -))
|
32
|
+
"#{fetch_sample(BLOOD_TYPE)}#{sign}"
|
33
33
|
end
|
34
34
|
|
35
35
|
def expedition_date
|
36
36
|
today = Date.today
|
37
37
|
today - rand(today.year)
|
38
38
|
end
|
39
|
-
|
40
39
|
end
|
41
40
|
end
|