ffaker 2.16.0 → 2.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +32 -0
  3. data/README.md +6 -4
  4. data/REFERENCE.md +1484 -1257
  5. data/Rakefile +3 -3
  6. data/ffaker.gemspec +4 -7
  7. data/lib/ffaker/address_au.rb +1 -1
  8. data/lib/ffaker/address_br.rb +1 -1
  9. data/lib/ffaker/address_ca.rb +1 -1
  10. data/lib/ffaker/address_ch.rb +0 -2
  11. data/lib/ffaker/address_ch_de.rb +0 -2
  12. data/lib/ffaker/address_ch_fr.rb +0 -2
  13. data/lib/ffaker/address_ch_it.rb +0 -2
  14. data/lib/ffaker/address_da.rb +0 -2
  15. data/lib/ffaker/address_de.rb +0 -2
  16. data/lib/ffaker/address_fi.rb +0 -2
  17. data/lib/ffaker/address_fr.rb +0 -2
  18. data/lib/ffaker/address_gr.rb +0 -2
  19. data/lib/ffaker/address_id.rb +0 -2
  20. data/lib/ffaker/address_in.rb +0 -2
  21. data/lib/ffaker/address_it.rb +37 -0
  22. data/lib/ffaker/address_ja.rb +0 -2
  23. data/lib/ffaker/address_mx.rb +2 -8
  24. data/lib/ffaker/address_nl.rb +0 -2
  25. data/lib/ffaker/address_ru.rb +0 -2
  26. data/lib/ffaker/address_se.rb +0 -2
  27. data/lib/ffaker/address_sn.rb +0 -2
  28. data/lib/ffaker/address_ua.rb +0 -2
  29. data/lib/ffaker/address_uk.rb +0 -2
  30. data/lib/ffaker/address_us.rb +0 -2
  31. data/lib/ffaker/animal.rb +1 -1
  32. data/lib/ffaker/bacon_ipsum.rb +0 -2
  33. data/lib/ffaker/company_fr.rb +35 -0
  34. data/lib/ffaker/{courses.rb → courses_fr.rb} +2 -0
  35. data/lib/ffaker/data/address_br/city +0 -1
  36. data/lib/ffaker/data/address_br/state +1 -1
  37. data/lib/ffaker/data/address_it/city +111 -0
  38. data/lib/ffaker/data/address_it/region +20 -0
  39. data/lib/ffaker/data/filesystem/extension +31 -31
  40. data/lib/ffaker/data/food_pl/diary +14 -0
  41. data/lib/ffaker/data/food_pl/fermented +13 -0
  42. data/lib/ffaker/data/food_pl/fruits +34 -0
  43. data/lib/ffaker/data/food_pl/herbs +20 -0
  44. data/lib/ffaker/data/food_pl/meats +9 -0
  45. data/lib/ffaker/data/food_pl/preserves +10 -0
  46. data/lib/ffaker/data/food_pl/spices +26 -0
  47. data/lib/ffaker/data/food_pl/vegetables +45 -0
  48. data/lib/ffaker/data/freedom_ipsum/freedom_words +161 -0
  49. data/lib/ffaker/data/game/adj_and_adv +18 -0
  50. data/lib/ffaker/data/game/category +84 -0
  51. data/lib/ffaker/data/game/mechanic +182 -0
  52. data/lib/ffaker/data/game/nouns +37 -0
  53. data/lib/ffaker/data/game/prefixes +17 -0
  54. data/lib/ffaker/data/job_it/job_adj +37 -0
  55. data/lib/ffaker/data/job_it/job_noun +25 -0
  56. data/lib/ffaker/data/job_it/job_prefix +22 -0
  57. data/lib/ffaker/data/lorem/words +0 -67
  58. data/lib/ffaker/data/lorem_br/characters +36 -0
  59. data/lib/ffaker/data/lorem_br/words +183 -0
  60. data/lib/ffaker/data/lorem_it/words +321 -0
  61. data/lib/ffaker/data/name/pronouns +1 -1
  62. data/lib/ffaker/data/name_ga/first_names_male +286 -286
  63. data/lib/ffaker/data/phone_number_ja/four_disit_area_codes +41 -0
  64. data/lib/ffaker/data/phone_number_ja/one_disit_area_codes +3 -0
  65. data/lib/ffaker/data/phone_number_ja/three_disit_area_codes +296 -0
  66. data/lib/ffaker/data/phone_number_ja/two_disit_area_codes +48 -0
  67. data/lib/ffaker/data/sport_ru/summer +68 -0
  68. data/lib/ffaker/data/sport_ru/winter +20 -0
  69. data/lib/ffaker/dizzle_ipsum.rb +0 -2
  70. data/lib/ffaker/filesystem.rb +7 -7
  71. data/lib/ffaker/food_pl.rb +65 -0
  72. data/lib/ffaker/freedom_ipsum.rb +20 -0
  73. data/lib/ffaker/game.rb +33 -0
  74. data/lib/ffaker/gender_it.rb +17 -0
  75. data/lib/ffaker/gender_ru.rb +22 -0
  76. data/lib/ffaker/healthcare_ipsum.rb +0 -2
  77. data/lib/ffaker/hipster_ipsum.rb +0 -2
  78. data/lib/ffaker/identification_es_cl.rb +0 -2
  79. data/lib/ffaker/identification_es_co.rb +0 -1
  80. data/lib/ffaker/identification_it.rb +30 -0
  81. data/lib/ffaker/identification_kr.rb +1 -1
  82. data/lib/ffaker/identification_mx.rb +1 -3
  83. data/lib/ffaker/image.rb +8 -11
  84. data/lib/ffaker/internet.rb +1 -1
  85. data/lib/ffaker/internet_se.rb +1 -3
  86. data/lib/ffaker/job_it.rb +12 -0
  87. data/lib/ffaker/lorem_br.rb +45 -0
  88. data/lib/ffaker/lorem_cn.rb +0 -1
  89. data/lib/ffaker/lorem_it.rb +39 -0
  90. data/lib/ffaker/name_cs.rb +0 -2
  91. data/lib/ffaker/name_da.rb +0 -2
  92. data/lib/ffaker/name_de.rb +0 -2
  93. data/lib/ffaker/name_mx.rb +0 -2
  94. data/lib/ffaker/name_nb.rb +0 -2
  95. data/lib/ffaker/name_nl.rb +0 -2
  96. data/lib/ffaker/name_ph.rb +0 -2
  97. data/lib/ffaker/name_ru.rb +0 -2
  98. data/lib/ffaker/name_se.rb +0 -2
  99. data/lib/ffaker/name_th_en.rb +1 -1
  100. data/lib/ffaker/name_ua.rb +0 -2
  101. data/lib/ffaker/number.rb +26 -0
  102. data/lib/ffaker/phone_number_br.rb +2 -2
  103. data/lib/ffaker/phone_number_da.rb +0 -1
  104. data/lib/ffaker/phone_number_it.rb +8 -6
  105. data/lib/ffaker/phone_number_ja.rb +88 -0
  106. data/lib/ffaker/sport_ru.rb +25 -0
  107. data/lib/ffaker/ssn.rb +1 -3
  108. data/lib/ffaker/ssn_se.rb +0 -19
  109. data/lib/ffaker/string.rb +4 -4
  110. data/lib/ffaker/unit.rb +9 -10
  111. data/lib/ffaker/unit_english.rb +18 -21
  112. data/lib/ffaker/unit_metric.rb +15 -18
  113. data/lib/ffaker/utils/array_utils.rb +1 -1
  114. data/lib/ffaker/utils/module_utils.rb +23 -3
  115. data/lib/ffaker/vehicle.rb +1 -1
  116. data/lib/ffaker.rb +19 -4
  117. data/lib/version.rb +1 -1
  118. data/scripts/profiling.rb +1 -1
  119. data/scripts/reference.rb +2 -3
  120. data/test/helper.rb +4 -4
  121. data/test/test_address.rb +1 -1
  122. data/test/test_address_au.rb +3 -3
  123. data/test/test_address_br.rb +2 -2
  124. data/test/test_address_ca.rb +1 -1
  125. data/test/test_address_ch.rb +1 -1
  126. data/test/test_address_ch_de.rb +1 -1
  127. data/test/test_address_ch_fr.rb +1 -1
  128. data/test/test_address_ch_it.rb +1 -1
  129. data/test/test_address_da.rb +1 -1
  130. data/test/test_address_de.rb +1 -1
  131. data/test/test_address_fi.rb +3 -3
  132. data/test/test_address_fr.rb +1 -1
  133. data/test/test_address_gr.rb +1 -1
  134. data/test/test_address_id.rb +2 -2
  135. data/test/test_address_in.rb +1 -1
  136. data/test/test_address_it.rb +12 -0
  137. data/test/test_address_ja.rb +2 -2
  138. data/test/test_address_kr.rb +1 -1
  139. data/test/test_address_mx.rb +1 -1
  140. data/test/test_address_nl.rb +1 -1
  141. data/test/test_address_pl.rb +1 -1
  142. data/test/test_address_ru.rb +1 -1
  143. data/test/test_address_se.rb +3 -3
  144. data/test/test_address_sn.rb +1 -1
  145. data/test/test_address_ua.rb +1 -1
  146. data/test/test_address_uk.rb +1 -1
  147. data/test/test_address_us.rb +1 -1
  148. data/test/test_airline.rb +1 -1
  149. data/test/test_animal.rb +1 -1
  150. data/test/test_animal_cn.rb +1 -1
  151. data/test/test_animal_es.rb +1 -1
  152. data/test/test_animal_pl.rb +1 -1
  153. data/test/test_animal_us.rb +1 -1
  154. data/test/test_array_utils.rb +2 -1
  155. data/test/test_avatar.rb +1 -1
  156. data/test/test_aws.rb +2 -2
  157. data/test/test_bacon_ipsum.rb +1 -1
  158. data/test/test_bank.rb +3 -4
  159. data/test/test_book.rb +5 -5
  160. data/test/test_boolean.rb +1 -1
  161. data/test/test_cheesy_lingo.rb +1 -1
  162. data/test/test_code.rb +1 -1
  163. data/test/test_color.rb +1 -1
  164. data/test/test_color_pl.rb +1 -1
  165. data/test/test_color_ua.rb +1 -1
  166. data/test/test_company.rb +1 -1
  167. data/test/test_company_cn.rb +1 -1
  168. data/test/test_company_fr.rb +33 -0
  169. data/test/test_company_it.rb +1 -1
  170. data/test/test_company_ja.rb +1 -1
  171. data/test/test_company_se.rb +1 -1
  172. data/test/test_conference.rb +1 -1
  173. data/test/test_course_mathematiques.rb +1 -1
  174. data/test/test_course_philosophie.rb +1 -1
  175. data/test/test_currency.rb +1 -1
  176. data/test/test_dizzle_ipsum.rb +1 -1
  177. data/test/test_education.rb +1 -1
  178. data/test/test_education_cn.rb +1 -1
  179. data/test/{test_faker.rb → test_ffaker.rb} +6 -2
  180. data/test/test_filesystem.rb +12 -4
  181. data/test/test_food.rb +1 -1
  182. data/test/test_food_pl.rb +61 -0
  183. data/test/test_freedom_ipsum.rb +21 -0
  184. data/test/test_game.rb +28 -0
  185. data/test/test_gender.rb +2 -2
  186. data/test/test_gender_br.rb +1 -1
  187. data/test/test_gender_cn.rb +1 -1
  188. data/test/test_gender_id.rb +1 -1
  189. data/test/test_gender_it.rb +27 -0
  190. data/test/test_gender_ja.rb +1 -1
  191. data/test/test_gender_jp.rb +1 -1
  192. data/test/test_gender_kr.rb +1 -1
  193. data/test/test_gender_pl.rb +1 -1
  194. data/test/test_gender_ru.rb +23 -0
  195. data/test/test_geolocation.rb +1 -1
  196. data/test/test_guid.rb +1 -1
  197. data/test/test_healthcare_ipsum.rb +1 -1
  198. data/test/test_healthcare_ru.rb +2 -2
  199. data/test/test_hipster_ipsum.rb +1 -1
  200. data/test/test_html_ipsum.rb +2 -2
  201. data/test/test_identification.rb +1 -1
  202. data/test/test_identification_br.rb +1 -1
  203. data/test/test_identification_co.rb +2 -2
  204. data/test/test_identification_es.rb +1 -1
  205. data/test/test_identification_es_cl.rb +2 -2
  206. data/test/test_identification_es_mx.rb +1 -1
  207. data/test/test_identification_in.rb +1 -1
  208. data/test/test_identification_it.rb +34 -0
  209. data/test/test_identification_kr.rb +1 -1
  210. data/test/test_identification_tw.rb +1 -1
  211. data/test/test_image.rb +5 -5
  212. data/test/test_internet.rb +1 -1
  213. data/test/test_internet_se.rb +2 -2
  214. data/test/test_job.rb +1 -1
  215. data/test/test_job_br.rb +1 -1
  216. data/test/test_job_cn.rb +1 -1
  217. data/test/test_job_fr.rb +1 -1
  218. data/test/test_job_it.rb +17 -0
  219. data/test/test_job_ja.rb +1 -1
  220. data/test/test_job_kr.rb +1 -1
  221. data/test/test_job_vn.rb +1 -1
  222. data/test/test_locale.rb +1 -1
  223. data/test/test_lorem.rb +5 -1
  224. data/test/test_lorem_ar.rb +1 -1
  225. data/test/test_lorem_br.rb +62 -0
  226. data/test/test_lorem_cn.rb +1 -1
  227. data/test/test_lorem_fr.rb +10 -8
  228. data/test/test_lorem_ie.rb +1 -1
  229. data/test/test_lorem_it.rb +51 -0
  230. data/test/test_lorem_ja.rb +1 -1
  231. data/test/test_lorem_kr.rb +1 -1
  232. data/test/test_lorem_pl.rb +2 -2
  233. data/test/test_lorem_ru.rb +2 -2
  234. data/test/test_lorem_ua.rb +2 -2
  235. data/test/test_module_utils.rb +1 -1
  236. data/test/test_movie.rb +1 -1
  237. data/test/test_music.rb +5 -5
  238. data/test/test_name.rb +1 -1
  239. data/test/test_name_ar.rb +1 -1
  240. data/test/test_name_br.rb +1 -1
  241. data/test/test_name_cn.rb +1 -1
  242. data/test/test_name_cs.rb +1 -1
  243. data/test/test_name_da.rb +1 -1
  244. data/test/test_name_de.rb +1 -1
  245. data/test/test_name_es.rb +1 -1
  246. data/test/test_name_fr.rb +1 -1
  247. data/test/test_name_ga.rb +1 -1
  248. data/test/test_name_gr.rb +1 -1
  249. data/test/test_name_id.rb +1 -1
  250. data/test/test_name_it.rb +1 -1
  251. data/test/test_name_ja.rb +1 -1
  252. data/test/test_name_kh.rb +1 -1
  253. data/test/test_name_kr.rb +1 -1
  254. data/test/test_name_mx.rb +1 -1
  255. data/test/test_name_nb.rb +1 -1
  256. data/test/test_name_nl.rb +1 -1
  257. data/test/test_name_ph.rb +1 -1
  258. data/test/test_name_pl.rb +1 -1
  259. data/test/test_name_ru.rb +1 -1
  260. data/test/test_name_se.rb +1 -1
  261. data/test/test_name_sn.rb +1 -1
  262. data/test/test_name_th.rb +1 -1
  263. data/test/test_name_th_en.rb +1 -1
  264. data/test/test_name_tw.rb +1 -1
  265. data/test/test_name_ua.rb +1 -1
  266. data/test/test_name_vn.rb +1 -1
  267. data/test/test_nato_alphabet.rb +1 -1
  268. data/test/test_number.rb +45 -0
  269. data/test/test_phone_number.rb +1 -1
  270. data/test/test_phone_number_au.rb +1 -1
  271. data/test/test_phone_number_br.rb +1 -1
  272. data/test/test_phone_number_cu.rb +1 -1
  273. data/test/test_phone_number_da.rb +1 -1
  274. data/test/test_phone_number_de.rb +1 -1
  275. data/test/test_phone_number_fr.rb +1 -1
  276. data/test/test_phone_number_id.rb +1 -1
  277. data/test/test_phone_number_it.rb +12 -0
  278. data/test/test_phone_number_ja.rb +63 -0
  279. data/test/test_phone_number_kr.rb +1 -1
  280. data/test/test_phone_number_mx.rb +1 -1
  281. data/test/test_phone_number_nl.rb +1 -1
  282. data/test/test_phone_number_pl.rb +1 -1
  283. data/test/test_phone_number_se.rb +1 -1
  284. data/test/test_phone_number_sg.rb +1 -1
  285. data/test/test_phone_number_sn.rb +1 -1
  286. data/test/test_phone_number_tw.rb +1 -1
  287. data/test/test_phone_number_ua.rb +1 -1
  288. data/test/test_products.rb +1 -1
  289. data/test/test_sem_ver.rb +1 -1
  290. data/test/test_skill.rb +1 -1
  291. data/test/test_sport_pl.rb +1 -1
  292. data/test/test_sport_ru.rb +30 -0
  293. data/test/test_sport_us.rb +1 -1
  294. data/test/test_sports.rb +1 -1
  295. data/test/test_ssn.rb +1 -1
  296. data/test/test_ssn_mx.rb +1 -1
  297. data/test/test_ssn_se.rb +2 -2
  298. data/test/test_string.rb +4 -4
  299. data/test/test_time.rb +3 -4
  300. data/test/test_tweet.rb +5 -5
  301. data/test/test_unique_utils.rb +1 -1
  302. data/test/test_units.rb +2 -1
  303. data/test/test_units_english.rb +1 -1
  304. data/test/test_units_metric.rb +1 -1
  305. data/test/test_vehicle.rb +3 -3
  306. data/test/test_venue.rb +1 -1
  307. data/test/test_youtube.rb +1 -1
  308. metadata +232 -160
@@ -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: 'm' }
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. in' },
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: 'Twp' }
42
+ { name: 'township', abbreviation: 'twp' }
46
43
  ].freeze
47
44
 
48
45
  def mass_name
49
- mass.name
46
+ mass[:name]
50
47
  end
51
48
 
52
49
  def mass_abbr
53
- mass.abbreviation
50
+ mass[:abbreviation]
54
51
  end
55
52
 
56
53
  def length_name
57
- length.name
54
+ length[:name]
58
55
  end
59
56
 
60
57
  def length_abbr
61
- length.abbreviation
58
+ length[:abbreviation]
62
59
  end
63
60
 
64
61
  def liquid_name
65
- liquid.name
62
+ liquid[:name]
66
63
  end
67
64
 
68
65
  def liquid_abbr
69
- liquid.abbreviation
66
+ liquid[:abbreviation]
70
67
  end
71
68
 
72
69
  def volume_name
73
- volume.name
70
+ volume[:name]
74
71
  end
75
72
 
76
73
  def volume_abbr
77
- volume.abbreviation
74
+ volume[:abbreviation]
78
75
  end
79
76
 
80
77
  def area_name
81
- area.name
78
+ area[:name]
82
79
  end
83
80
 
84
81
  def area_abbr
85
- area.abbreviation
82
+ area[:abbreviation]
86
83
  end
87
84
 
88
85
  private
89
86
 
90
87
  def length
91
- OpenStruct.new(fetch_sample(LENGTH_UNITS))
88
+ fetch_sample(LENGTH_UNITS)
92
89
  end
93
90
 
94
91
  def mass
95
- OpenStruct.new(fetch_sample(MASS_UNITS))
92
+ fetch_sample(MASS_UNITS)
96
93
  end
97
94
 
98
95
  def liquid
99
- OpenStruct.new(fetch_sample(LIQUID_UNITS))
96
+ fetch_sample(LIQUID_UNITS)
100
97
  end
101
98
 
102
99
  def volume
103
- OpenStruct.new(fetch_sample(VOLUME_UNITS))
100
+ fetch_sample(VOLUME_UNITS)
104
101
  end
105
102
 
106
103
  def area
107
- OpenStruct.new(fetch_sample(AREA_UNITS))
104
+ fetch_sample(AREA_UNITS)
108
105
  end
109
106
  end
110
107
  end
@@ -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.name
37
+ mass[:name]
41
38
  end
42
39
 
43
40
  def mass_abbr
44
- mass.abbreviation
41
+ mass[:abbreviation]
45
42
  end
46
43
 
47
44
  def length_name
48
- length.name
45
+ length[:name]
49
46
  end
50
47
 
51
48
  def length_abbr
52
- length.abbreviation
49
+ length[:abbreviation]
53
50
  end
54
51
 
55
52
  def liquid_name
56
- liquid.name
53
+ liquid[:name]
57
54
  end
58
55
 
59
56
  def liquid_abbr
60
- liquid.abbreviation
57
+ liquid[:abbreviation]
61
58
  end
62
59
 
63
60
  def volume_name
64
- volume.name
61
+ volume[:name]
65
62
  end
66
63
 
67
64
  def volume_abbr
68
- volume.abbreviation
65
+ volume[:abbreviation]
69
66
  end
70
67
 
71
68
  def area_name
72
- area.name
69
+ area[:name]
73
70
  end
74
71
 
75
72
  def area_abbr
76
- area.abbreviation
73
+ area[:abbreviation]
77
74
  end
78
75
 
79
76
  private
80
77
 
81
78
  def length
82
- OpenStruct.new(fetch_sample(LENGTH_UNITS))
79
+ fetch_sample(LENGTH_UNITS)
83
80
  end
84
81
 
85
82
  def mass
86
- OpenStruct.new(fetch_sample(MASS_UNITS))
83
+ fetch_sample(MASS_UNITS)
87
84
  end
88
85
 
89
86
  def liquid
90
- OpenStruct.new(fetch_sample(LIQUID_UNITS))
87
+ fetch_sample(LIQUID_UNITS)
91
88
  end
92
89
 
93
90
  def volume
94
- OpenStruct.new(fetch_sample(VOLUME_UNITS))
91
+ fetch_sample(VOLUME_UNITS)
95
92
  end
96
93
 
97
94
  def area
98
- OpenStruct.new(fetch_sample(AREA_UNITS))
95
+ fetch_sample(AREA_UNITS)
99
96
  end
100
97
  end
101
98
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ffaker/utils/random_utils'
3
+ require_relative 'random_utils'
4
4
 
5
5
  module FFaker
6
6
  module ArrayUtils
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ffaker/utils/array_utils'
4
- require 'ffaker/utils/random_utils'
5
- require 'ffaker/utils/unique_utils'
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
@@ -6,7 +6,7 @@ module FFaker
6
6
  extend self
7
7
 
8
8
  DRIVETRAINS = %w[4WD 4X4 AWD FWD RWD].freeze
9
- YEARS = [*'1900'..(::Time.now.year + 1).to_s].freeze
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
- require 'ffaker/utils/array_utils'
5
- require 'ffaker/utils/module_utils'
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 = [*'a'..'z'].freeze
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/courses'
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FFaker
4
- VERSION = '2.16.0'
4
+ VERSION = '2.20.0'
5
5
  end
data/scripts/profiling.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.dirname(__FILE__) + '/../lib/faker'
3
+ require_relative '../lib/faker'
4
4
 
5
5
  N = 1_000_000
6
6
 
data/scripts/reference.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- $LOAD_PATH << File.dirname(__FILE__) + '/../lib'
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
- require 'ffaker'
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, from, to, exclude_end: false)
49
- assert_greater_than_or_equal_to got, from
50
- public_send "assert_less_than#{'_or_equal_to' unless exclude_end}", got, to
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddress < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
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(/[\, a-z]/, FFaker::AddressAU.full_address)
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(/[\, a-z]/, FFaker::AddressAU.full_address(st_abbr))
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
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('|')})( [\p{Alpha}]+){1,2}/, FFaker::AddressBR.street)
35
+ assert_match(/(#{prefixes.join('|')})( \p{Alpha}+){1,2}/, FFaker::AddressBR.street)
36
36
  end
37
37
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressCA < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressCHCH < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressCHDE < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressCHFR < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressCHIT < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressDA < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressDE < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressFI < Test::Unit::TestCase
6
6
  include DeterministicHelper
7
7
 
8
- ALPHA = /\A[\p{Alpha}]+/.freeze
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(/[\, a-z]/, address)
33
+ assert_match(/[, a-z]/, address)
34
34
  end
35
35
 
36
36
  def test_fi_zip_code_frozen
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressFR < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressGR < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
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('|')}))\,\sNo\.\s\d+\z/
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressININ < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
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}\-\d{4}$/, FFaker::AddressJA.postal_code)
16
+ assert_match(/^\d{3}-\d{4}$/, FFaker::AddressJA.postal_code)
17
17
  end
18
18
 
19
19
  def test_land_number
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressKR < Test::Unit::TestCase
6
6
  include DeterministicHelper
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'helper'
3
+ require_relative 'helper'
4
4
 
5
5
  class TestAddressMX < Test::Unit::TestCase
6
6
  include DeterministicHelper