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/image.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'cgi'
|
3
4
|
require 'tempfile'
|
4
5
|
require 'open-uri'
|
5
6
|
|
@@ -18,11 +19,16 @@ module FFaker
|
|
18
19
|
text_color = FFaker::Color.hex_code if text_color == :random
|
19
20
|
text = CGI.escape(text.to_s)
|
20
21
|
|
21
|
-
"https://
|
22
|
+
"https://dummyimage.com/#{size}/#{bg_color}/#{text_color}.#{format}?text=#{text}"
|
22
23
|
end
|
23
24
|
|
24
25
|
def file(size = '300x300', format = 'png', bg_color = :random, text_color = :random, text = nil)
|
25
|
-
|
26
|
+
uri = URI.parse(url(size, format, bg_color, text_color, text))
|
27
|
+
file = Tempfile.new('ffaker_image')
|
28
|
+
file.binmode
|
29
|
+
file << uri.open.read
|
30
|
+
file.close
|
31
|
+
File.new(file.path)
|
26
32
|
end
|
27
33
|
|
28
34
|
private
|
@@ -38,14 +44,5 @@ module FFaker
|
|
38
44
|
|
39
45
|
raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}"
|
40
46
|
end
|
41
|
-
|
42
|
-
def download_file(url)
|
43
|
-
file = Tempfile.new('ffaker_image')
|
44
|
-
file.binmode
|
45
|
-
file << Kernel.open(url).read
|
46
|
-
file.close
|
47
|
-
|
48
|
-
File.new(file.path)
|
49
|
-
end
|
50
47
|
end
|
51
48
|
end
|
data/lib/ffaker/internet.rb
CHANGED
@@ -5,7 +5,7 @@ module FFaker
|
|
5
5
|
extend ModuleUtils
|
6
6
|
extend self
|
7
7
|
|
8
|
-
BYTE =
|
8
|
+
BYTE = Array('0'..'255').freeze
|
9
9
|
HOSTS = %w[gmail.com yahoo.com hotmail.com].freeze
|
10
10
|
DISPOSABLE_HOSTS = %w[
|
11
11
|
mailinator.com suremail.info spamherelots.com binkmail.com safetymail.info
|
data/lib/ffaker/internet_se.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ffaker/internet'
|
4
|
-
|
5
3
|
module FFaker
|
6
4
|
module InternetSE
|
7
5
|
include Internet
|
@@ -9,7 +7,7 @@ module FFaker
|
|
9
7
|
extend ModuleUtils
|
10
8
|
extend self
|
11
9
|
|
12
|
-
BYTE =
|
10
|
+
BYTE = Array('0'..'255').freeze
|
13
11
|
HOSTS = %w[gmail.com yahoo.com hotmail.com spray.se passagen.se].freeze
|
14
12
|
DOMAIN_SUFFIXES = %w[se nu com].freeze
|
15
13
|
DISPOSABLE_HOSTS = %w[
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FFaker
|
4
|
+
# Based on Perl's Text::Lorem
|
5
|
+
module LoremBR
|
6
|
+
extend ModuleUtils
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def characters(character_count = 255)
|
10
|
+
character_count = 0 if character_count.negative?
|
11
|
+
Array.new(character_count).map { fetch_sample(CHARACTERS) }.join
|
12
|
+
end
|
13
|
+
|
14
|
+
def word
|
15
|
+
fetch_sample(WORDS)
|
16
|
+
end
|
17
|
+
|
18
|
+
def words(num = 3)
|
19
|
+
fetch_sample(WORDS, count: num)
|
20
|
+
end
|
21
|
+
|
22
|
+
def sentence(word_count = 4)
|
23
|
+
first_word, *last_words = words(word_count + rand(1..5))
|
24
|
+
return "#{first_word.capitalize} #{last_words.join(' ')}." if last_words
|
25
|
+
|
26
|
+
first_word.capitalize
|
27
|
+
end
|
28
|
+
|
29
|
+
alias phrase sentence
|
30
|
+
|
31
|
+
def sentences(sentence_count = 3)
|
32
|
+
(1..sentence_count).map { sentence }
|
33
|
+
end
|
34
|
+
|
35
|
+
alias phrases sentences
|
36
|
+
|
37
|
+
def paragraph(sentence_count = 3)
|
38
|
+
sentences(sentence_count + rand(0..2)).join(' ')
|
39
|
+
end
|
40
|
+
|
41
|
+
def paragraphs(paragraph_count = 3)
|
42
|
+
(1..paragraph_count).map { paragraph }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/ffaker/lorem_cn.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FFaker
|
4
|
+
module LoremIT
|
5
|
+
extend ModuleUtils
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def word
|
9
|
+
fetch_sample(WORDS)
|
10
|
+
end
|
11
|
+
|
12
|
+
def words(num = 3)
|
13
|
+
fetch_sample(WORDS, count: num)
|
14
|
+
end
|
15
|
+
|
16
|
+
def sentence(word_count = 4)
|
17
|
+
s = words(word_count + rand(0..5))
|
18
|
+
s = s.join(' ')
|
19
|
+
s.capitalize!
|
20
|
+
"#{s}."
|
21
|
+
end
|
22
|
+
|
23
|
+
alias phrase sentence
|
24
|
+
|
25
|
+
def sentences(sentence_count = 3)
|
26
|
+
(1..sentence_count).map { sentence }
|
27
|
+
end
|
28
|
+
|
29
|
+
alias phrases sentences
|
30
|
+
|
31
|
+
def paragraph(sentence_count = 3)
|
32
|
+
sentences(sentence_count + rand(0..2)).join(' ')
|
33
|
+
end
|
34
|
+
|
35
|
+
def paragraphs(paragraph_count = 3)
|
36
|
+
(1..paragraph_count).map { paragraph }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/ffaker/name_cs.rb
CHANGED
data/lib/ffaker/name_da.rb
CHANGED
data/lib/ffaker/name_de.rb
CHANGED
data/lib/ffaker/name_mx.rb
CHANGED
data/lib/ffaker/name_nb.rb
CHANGED
data/lib/ffaker/name_nl.rb
CHANGED
data/lib/ffaker/name_ph.rb
CHANGED
data/lib/ffaker/name_ru.rb
CHANGED
data/lib/ffaker/name_se.rb
CHANGED
data/lib/ffaker/name_th_en.rb
CHANGED
data/lib/ffaker/name_ua.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FFaker
|
4
|
+
module Number
|
5
|
+
extend ModuleUtils
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def number(digits: 1)
|
9
|
+
FFaker.numerify(generate_pattern(digits)).to_i
|
10
|
+
end
|
11
|
+
|
12
|
+
def decimal(whole_digits: 1, fractional_digits: 1)
|
13
|
+
whole_part_pattern = generate_pattern(whole_digits)
|
14
|
+
fractional_part_pattern = generate_pattern(fractional_digits).reverse
|
15
|
+
FFaker.numerify("#{whole_part_pattern}.#{fractional_part_pattern}").to_f
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def generate_pattern(digits)
|
21
|
+
raise ArgumentError.new('Digits cannot be less than 1') if digits < 1
|
22
|
+
|
23
|
+
"#{fetch_sample(1..9)}#{"#" * (digits - 1)}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -14,8 +14,8 @@ module FFaker
|
|
14
14
|
|
15
15
|
COUNTRY_PREFIX = '+55'
|
16
16
|
AREA_CODE = [
|
17
|
-
|
18
|
-
51
|
17
|
+
11..19, 21..22, 24, 27..28, 31..35, 37..38, 41..49,
|
18
|
+
51, 53..55, 61..69, 71, 73..75, 77, 79, 81..89, 91..99
|
19
19
|
].flat_map { |x| Array(x) }.map(&:to_s).freeze
|
20
20
|
|
21
21
|
HOME_WORK_PHONE_PREFIX = %w[2 3 4 5].freeze
|
@@ -24,15 +24,17 @@ module FFaker
|
|
24
24
|
number MOBILE_PHONE_PREFIXES
|
25
25
|
end
|
26
26
|
|
27
|
+
private
|
28
|
+
|
27
29
|
def number(prefixes)
|
28
|
-
|
29
|
-
COUNTRY_PREFIX
|
30
|
-
prefixes
|
30
|
+
pattern = [
|
31
|
+
fetch_sample(COUNTRY_PREFIX),
|
32
|
+
fetch_sample(prefixes),
|
31
33
|
random_space,
|
32
|
-
PHONE_NUMBER
|
33
|
-
].join
|
34
|
+
fetch_sample(PHONE_NUMBER)
|
35
|
+
].join
|
34
36
|
|
35
|
-
FFaker.numerify
|
37
|
+
FFaker.numerify(pattern)
|
36
38
|
end
|
37
39
|
|
38
40
|
def random_space
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# sourse: https://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html#kotei-denwa
|
4
|
+
|
5
|
+
module FFaker
|
6
|
+
module PhoneNumberJA
|
7
|
+
extend ModuleUtils
|
8
|
+
extend self
|
9
|
+
|
10
|
+
JAPAN_PREFIX = '0'
|
11
|
+
JAPAN_COUNTRY_CODE = '+81'
|
12
|
+
|
13
|
+
ONE_DISIT_FORMAT = '%s #### ####'
|
14
|
+
TWO_DISIT_FORMAT = '%s ### ####'
|
15
|
+
THREE_DISIT_FORMAT = '%s ## ####'
|
16
|
+
FOUR_DISIT_FORMAT = '%s # ####'
|
17
|
+
|
18
|
+
MOBILE_PHONE_PREFIXES = %w[90 80 70].freeze
|
19
|
+
IP_PHONE_PREFIX = '50'
|
20
|
+
MOBILE_NUMBER_FORMAT = '%s #### ####'
|
21
|
+
|
22
|
+
def home_phone_number
|
23
|
+
disit = rand(1..4)
|
24
|
+
FFaker.numerify("#{JAPAN_PREFIX}#{home_phone_number_format(disit)}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def mobile_phone_number
|
28
|
+
FFaker.numerify("#{JAPAN_PREFIX}#{mobile_phone_number_format}")
|
29
|
+
end
|
30
|
+
|
31
|
+
def phone_number
|
32
|
+
case rand(0..1)
|
33
|
+
when 0 then home_phone_number
|
34
|
+
when 1 then mobile_phone_number
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def international_home_phone_number
|
39
|
+
disit = rand(1..4)
|
40
|
+
FFaker.numerify("#{JAPAN_COUNTRY_CODE} #{home_phone_number_format(disit)}")
|
41
|
+
end
|
42
|
+
|
43
|
+
def international_mobile_phone_number
|
44
|
+
FFaker.numerify("#{JAPAN_COUNTRY_CODE} #{mobile_phone_number_format}")
|
45
|
+
end
|
46
|
+
|
47
|
+
def international_phone_number
|
48
|
+
case rand(0..1)
|
49
|
+
when 0 then international_mobile_phone_number
|
50
|
+
when 1 then international_home_phone_number
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def home_phone_prefix(disit = nil)
|
55
|
+
case disit
|
56
|
+
when 1 then fetch_sample(ONE_DISIT_AREA_CODES)
|
57
|
+
when 2 then fetch_sample(TWO_DISIT_AREA_CODES)
|
58
|
+
when 3 then fetch_sample(THREE_DISIT_AREA_CODES)
|
59
|
+
when 4 then fetch_sample(FOUR_DISIT_AREA_CODES)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def home_phone_number_format(disit)
|
64
|
+
prefix = home_phone_prefix(disit)
|
65
|
+
select_home_phone_format(disit) % prefix
|
66
|
+
end
|
67
|
+
|
68
|
+
def mobile_prefix
|
69
|
+
fetch_sample(MOBILE_PHONE_PREFIXES)
|
70
|
+
end
|
71
|
+
|
72
|
+
def mobile_phone_number_format
|
73
|
+
prefix = mobile_prefix
|
74
|
+
MOBILE_NUMBER_FORMAT % prefix
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def select_home_phone_format(disit)
|
80
|
+
case disit
|
81
|
+
when 1 then ONE_DISIT_FORMAT
|
82
|
+
when 2 then TWO_DISIT_FORMAT
|
83
|
+
when 3 then THREE_DISIT_FORMAT
|
84
|
+
when 4 then FOUR_DISIT_FORMAT
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FFaker
|
4
|
+
# Inspirations:
|
5
|
+
# https://olympic.ru/team/sport/
|
6
|
+
# http://ru.sport-wiki.org/vidy-sporta/
|
7
|
+
module SportRU
|
8
|
+
extend ModuleUtils
|
9
|
+
extend self
|
10
|
+
|
11
|
+
ALL = SUMMER + WINTER
|
12
|
+
|
13
|
+
def name
|
14
|
+
fetch_sample(ALL)
|
15
|
+
end
|
16
|
+
|
17
|
+
def summer
|
18
|
+
fetch_sample(SUMMER)
|
19
|
+
end
|
20
|
+
|
21
|
+
def winter
|
22
|
+
fetch_sample(WINTER)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/ffaker/ssn.rb
CHANGED
data/lib/ffaker/ssn_se.rb
CHANGED
@@ -76,24 +76,5 @@ module FFaker
|
|
76
76
|
def three_character_string(number)
|
77
77
|
format('%03d', number)
|
78
78
|
end
|
79
|
-
|
80
|
-
# http://en.wikipedia.org/wiki/Luhn_algorithm
|
81
|
-
def luhn_check(number)
|
82
|
-
multiplications = []
|
83
|
-
|
84
|
-
number.split(//).each_with_index do |digit, i|
|
85
|
-
multiplications << i.even? ? digit.to_i * 2 : digit.to_i
|
86
|
-
end
|
87
|
-
|
88
|
-
sum = 0
|
89
|
-
multiplications.each do |num|
|
90
|
-
num.to_s.each_byte do |character|
|
91
|
-
sum += character.chr.to_i
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
control_digit = (sum % 10).zero? ? 0 : (sum / 10 + 1) * 10 - sum
|
96
|
-
control_digit.to_s
|
97
|
-
end
|
98
79
|
end
|
99
80
|
end
|
data/lib/ffaker/string.rb
CHANGED
@@ -8,10 +8,10 @@ module FFaker
|
|
8
8
|
BACKSLASH = '\\'
|
9
9
|
DASH = '-'
|
10
10
|
|
11
|
-
LOWERS =
|
12
|
-
UPPERS =
|
11
|
+
LOWERS = Array('a'..'z').freeze
|
12
|
+
UPPERS = Array('A'..'Z').freeze
|
13
13
|
LETTERS = LOWERS + UPPERS
|
14
|
-
NUMBERS =
|
14
|
+
NUMBERS = Array('0'..'9').freeze
|
15
15
|
WORD_CHARS = LETTERS + NUMBERS + ['_']
|
16
16
|
SPACES = [' ', "\t"].freeze
|
17
17
|
ESCAPEABLE_CHARS = ['\\', '/', '.', '(', ')', '[', ']', '{', '}'].freeze
|
@@ -34,7 +34,7 @@ module FFaker
|
|
34
34
|
while tokens.any?
|
35
35
|
token = tokens.shift
|
36
36
|
if token == DASH && tokens.first && result.last
|
37
|
-
result +=
|
37
|
+
result += Array(result.pop..tokens.shift)
|
38
38
|
elsif token == BACKSLASH
|
39
39
|
result << special(tokens.shift)
|
40
40
|
else
|
data/lib/ffaker/unit.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
3
|
module FFaker
|
6
4
|
module Unit
|
7
5
|
extend ModuleUtils
|
@@ -10,9 +8,10 @@ module FFaker
|
|
10
8
|
TIME_UNITS = [
|
11
9
|
{ name: 'Years', abbreviation: 'yr' },
|
12
10
|
{ name: 'Days', abbreviation: 'd' },
|
13
|
-
{ name: 'Hours', abbreviation: '
|
11
|
+
{ name: 'Hours', abbreviation: 'h' },
|
12
|
+
{ name: 'Minutes', abbreviation: 'm' },
|
14
13
|
{ name: 'Seconds', abbreviation: 's' },
|
15
|
-
{ name: 'Milliseconds', abbreviation: '
|
14
|
+
{ name: 'Milliseconds', abbreviation: 'ms' }
|
16
15
|
].freeze
|
17
16
|
TEMPERATURE_UNITS = [
|
18
17
|
{ name: 'Kelvin', abbreviation: 'K' },
|
@@ -21,29 +20,29 @@ module FFaker
|
|
21
20
|
].freeze
|
22
21
|
|
23
22
|
def time_name
|
24
|
-
time
|
23
|
+
time[:name]
|
25
24
|
end
|
26
25
|
|
27
26
|
def time_abbr
|
28
|
-
time
|
27
|
+
time[:abbreviation]
|
29
28
|
end
|
30
29
|
|
31
30
|
def temperature_name
|
32
|
-
temperature
|
31
|
+
temperature[:name]
|
33
32
|
end
|
34
33
|
|
35
34
|
def temperature_abbr
|
36
|
-
temperature
|
35
|
+
temperature[:abbreviation]
|
37
36
|
end
|
38
37
|
|
39
38
|
private
|
40
39
|
|
41
40
|
def time
|
42
|
-
|
41
|
+
fetch_sample(TIME_UNITS)
|
43
42
|
end
|
44
43
|
|
45
44
|
def temperature
|
46
|
-
|
45
|
+
fetch_sample(TEMPERATURE_UNITS)
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|