ffaker 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (320) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +34 -0
  3. data/README.md +4 -0
  4. data/REFERENCE.md +1153 -800
  5. data/Rakefile +23 -24
  6. data/ffaker.gemspec +12 -420
  7. data/lib/ffaker.rb +47 -7
  8. data/lib/ffaker/address.rb +11 -11
  9. data/lib/ffaker/address_au.rb +60 -60
  10. data/lib/ffaker/address_br.rb +5 -5
  11. data/lib/ffaker/address_ca.rb +7 -7
  12. data/lib/ffaker/address_ch.rb +1 -2
  13. data/lib/ffaker/address_ch_de.rb +1 -1
  14. data/lib/ffaker/address_ch_fr.rb +1 -1
  15. data/lib/ffaker/address_ch_it.rb +1 -1
  16. data/lib/ffaker/address_da.rb +5 -5
  17. data/lib/ffaker/address_de.rb +16 -12
  18. data/lib/ffaker/address_fi.rb +7 -8
  19. data/lib/ffaker/address_fr.rb +13 -13
  20. data/lib/ffaker/address_gr.rb +40 -0
  21. data/lib/ffaker/address_in.rb +12 -12
  22. data/lib/ffaker/address_kr.rb +87 -0
  23. data/lib/ffaker/address_mx.rb +409 -409
  24. data/lib/ffaker/address_nl.rb +17 -13
  25. data/lib/ffaker/address_ru.rb +6 -6
  26. data/lib/ffaker/address_se.rb +7 -8
  27. data/lib/ffaker/address_sn.rb +3 -3
  28. data/lib/ffaker/address_ua.rb +8 -8
  29. data/lib/ffaker/address_uk.rb +5 -5
  30. data/lib/ffaker/address_us.rb +9 -9
  31. data/lib/ffaker/airline.rb +16 -0
  32. data/lib/ffaker/avatar.rb +3 -3
  33. data/lib/ffaker/aws.rb +24 -0
  34. data/lib/ffaker/bacon_ipsum.rb +2 -2
  35. data/lib/ffaker/book.rb +45 -0
  36. data/lib/ffaker/boolean.rb +2 -2
  37. data/lib/ffaker/cheesy_lingo.rb +15 -12
  38. data/lib/ffaker/color.rb +54 -1
  39. data/lib/ffaker/color_ua.rb +1 -1
  40. data/lib/ffaker/company.rb +13 -11
  41. data/lib/ffaker/company_cn.rb +23 -0
  42. data/lib/ffaker/company_it.rb +4 -4
  43. data/lib/ffaker/company_se.rb +2 -2
  44. data/lib/ffaker/conference.rb +1 -1
  45. data/lib/ffaker/courses.rb +2 -3
  46. data/lib/ffaker/currency.rb +2 -2
  47. data/lib/ffaker/data/address_gr/city +79 -0
  48. data/lib/ffaker/data/address_gr/region +13 -0
  49. data/lib/ffaker/data/address_gr/street +100 -0
  50. data/lib/ffaker/data/address_kr/boroughs +29 -0
  51. data/lib/ffaker/data/address_kr/cities +51 -0
  52. data/lib/ffaker/data/airline/codes_list +209 -0
  53. data/lib/ffaker/data/airline/names_list +206 -0
  54. data/lib/ffaker/data/aws/ec2_instance_type +59 -0
  55. data/lib/ffaker/data/aws/ec2_reserved_instance_tenancy +3 -0
  56. data/lib/ffaker/data/aws/ec2_reserved_offering_type +6 -0
  57. data/lib/ffaker/data/aws/ec2_reserved_product_description +14 -0
  58. data/lib/ffaker/data/book/adj_and_adv +20 -0
  59. data/lib/ffaker/data/book/genres +369 -0
  60. data/lib/ffaker/data/book/nouns +36 -0
  61. data/lib/ffaker/data/book/prefixes +17 -0
  62. data/lib/ffaker/data/color/names_list +128 -0
  63. data/lib/ffaker/data/education/degree_prefix +274 -0
  64. data/lib/ffaker/data/education/degree_short_prefix +19 -0
  65. data/lib/ffaker/data/job_br/job_nouns +52 -0
  66. data/lib/ffaker/data/job_vn/job_nouns +191 -0
  67. data/lib/ffaker/data/lorem_ja/characters +101 -0
  68. data/lib/ffaker/data/lorem_ja/sentences +30 -0
  69. data/lib/ffaker/data/lorem_ja/sentences_end +21 -0
  70. data/lib/ffaker/data/lorem_ja/words +81 -0
  71. data/lib/ffaker/data/name/first_names_female +4275 -0
  72. data/lib/ffaker/data/name/first_names_male +1219 -0
  73. data/lib/ffaker/data/name_br/first_names_female +1068 -0
  74. data/lib/ffaker/data/name_br/first_names_male +607 -0
  75. data/lib/ffaker/data/name_br/last_names +52 -0
  76. data/lib/ffaker/data/name_gr/female_first_names +80 -0
  77. data/lib/ffaker/data/name_gr/female_last_names +45 -0
  78. data/lib/ffaker/data/name_gr/male_first_names +90 -0
  79. data/lib/ffaker/data/name_gr/male_last_names +57 -0
  80. data/lib/ffaker/data/name_kh/first_names +64 -0
  81. data/lib/ffaker/data/name_kh/last_names +71 -0
  82. data/lib/ffaker/data/name_kh/nick_names +30 -0
  83. data/lib/ffaker/data/name_then/first_names +292 -0
  84. data/lib/ffaker/data/name_then/last_names +63 -0
  85. data/lib/ffaker/data/name_then/nick_names +30 -0
  86. data/lib/ffaker/data/phone_number/phone_calling_code +205 -0
  87. data/lib/ffaker/data/sport/names +57 -24
  88. data/lib/ffaker/data/tweet/hashtag +58 -0
  89. data/lib/ffaker/data/youtube/video_ids +50 -0
  90. data/lib/ffaker/dizzle_ipsum.rb +2 -2
  91. data/lib/ffaker/education.rb +17 -16
  92. data/lib/ffaker/food.rb +5 -6
  93. data/lib/ffaker/gender.rb +4 -4
  94. data/lib/ffaker/gender_br.rb +17 -0
  95. data/lib/ffaker/gender_cn.rb +4 -4
  96. data/lib/ffaker/gender_kr.rb +4 -4
  97. data/lib/ffaker/geolocation.rb +26 -26
  98. data/lib/ffaker/healthcare_ipsum.rb +2 -2
  99. data/lib/ffaker/hipster_ipsum.rb +2 -2
  100. data/lib/ffaker/html_ipsum.rb +101 -81
  101. data/lib/ffaker/identification.rb +4 -4
  102. data/lib/ffaker/identification_br.rb +84 -0
  103. data/lib/ffaker/identification_es.rb +2 -2
  104. data/lib/ffaker/identification_es_cl.rb +7 -5
  105. data/lib/ffaker/identification_es_co.rb +9 -10
  106. data/lib/ffaker/identification_kr.rb +3 -4
  107. data/lib/ffaker/identification_mx.rb +27 -11
  108. data/lib/ffaker/internet.rb +26 -23
  109. data/lib/ffaker/internet_se.rb +21 -21
  110. data/lib/ffaker/job.rb +1 -1
  111. data/lib/ffaker/job_br.rb +12 -0
  112. data/lib/ffaker/job_cn.rb +1 -1
  113. data/lib/ffaker/job_fr.rb +3 -3
  114. data/lib/ffaker/job_ja.rb +2 -1
  115. data/lib/ffaker/job_kr.rb +1 -1
  116. data/lib/ffaker/job_vn.rb +13 -0
  117. data/lib/ffaker/locale.rb +2 -3
  118. data/lib/ffaker/lorem.rb +5 -5
  119. data/lib/ffaker/lorem_ar.rb +4 -4
  120. data/lib/ffaker/lorem_cn.rb +3 -3
  121. data/lib/ffaker/lorem_fr.rb +4 -4
  122. data/lib/ffaker/lorem_ja.rb +40 -0
  123. data/lib/ffaker/lorem_kr.rb +4 -4
  124. data/lib/ffaker/lorem_ua.rb +8 -11
  125. data/lib/ffaker/movie.rb +18 -20
  126. data/lib/ffaker/music.rb +4 -4
  127. data/lib/ffaker/name.rb +100 -11
  128. data/lib/ffaker/name_br.rb +37 -6
  129. data/lib/ffaker/name_cn.rb +2 -2
  130. data/lib/ffaker/name_cs.rb +10 -10
  131. data/lib/ffaker/name_da.rb +6 -6
  132. data/lib/ffaker/name_de.rb +5 -5
  133. data/lib/ffaker/name_fr.rb +4 -4
  134. data/lib/ffaker/name_ga.rb +4 -5
  135. data/lib/ffaker/name_gr.rb +60 -0
  136. data/lib/ffaker/name_it.rb +4 -4
  137. data/lib/ffaker/name_ja.rb +3 -3
  138. data/lib/ffaker/name_kh.rb +22 -0
  139. data/lib/ffaker/name_kr.rb +3 -3
  140. data/lib/ffaker/name_mx.rb +14 -14
  141. data/lib/ffaker/name_nb.rb +5 -5
  142. data/lib/ffaker/name_nl.rb +7 -7
  143. data/lib/ffaker/name_ph.rb +2 -2
  144. data/lib/ffaker/name_ru.rb +7 -8
  145. data/lib/ffaker/name_se.rb +5 -5
  146. data/lib/ffaker/name_sn.rb +23 -23
  147. data/lib/ffaker/name_th.rb +3 -3
  148. data/lib/ffaker/name_th_en.rb +26 -0
  149. data/lib/ffaker/name_ua.rb +8 -8
  150. data/lib/ffaker/name_vn.rb +4 -4
  151. data/lib/ffaker/nato_alphabet.rb +10 -10
  152. data/lib/ffaker/phone_number.rb +31 -21
  153. data/lib/ffaker/phone_number_au.rb +3 -3
  154. data/lib/ffaker/phone_number_br.rb +9 -8
  155. data/lib/ffaker/phone_number_ch.rb +7 -7
  156. data/lib/ffaker/phone_number_cu.rb +5 -5
  157. data/lib/ffaker/phone_number_de.rb +1 -1
  158. data/lib/ffaker/phone_number_fr.rb +4 -4
  159. data/lib/ffaker/phone_number_it.rb +2 -2
  160. data/lib/ffaker/phone_number_kr.rb +4 -4
  161. data/lib/ffaker/phone_number_mx.rb +4 -5
  162. data/lib/ffaker/phone_number_nl.rb +13 -13
  163. data/lib/ffaker/phone_number_se.rb +18 -19
  164. data/lib/ffaker/phone_number_sg.rb +8 -8
  165. data/lib/ffaker/phone_number_sn.rb +2 -2
  166. data/lib/ffaker/product.rb +18 -14
  167. data/lib/ffaker/skill.rb +3 -3
  168. data/lib/ffaker/sport.rb +1 -1
  169. data/lib/ffaker/ssn_se.rb +19 -20
  170. data/lib/ffaker/string.rb +21 -23
  171. data/lib/ffaker/time.rb +19 -7
  172. data/lib/ffaker/tweet.rb +59 -0
  173. data/lib/ffaker/unit.rb +12 -12
  174. data/lib/ffaker/unit_english.rb +34 -35
  175. data/lib/ffaker/unit_metric.rb +25 -25
  176. data/lib/ffaker/utils/array_utils.rb +12 -9
  177. data/lib/ffaker/utils/module_utils.rb +9 -6
  178. data/lib/ffaker/utils/random_utils.rb +33 -0
  179. data/lib/ffaker/vehicle.rb +21 -21
  180. data/lib/ffaker/venue.rb +1 -1
  181. data/lib/ffaker/youtube.rb +24 -0
  182. data/scripts/benchmark.rb +3 -3
  183. data/scripts/reference.rb +26 -23
  184. data/test/helper.rb +50 -0
  185. data/test/test_address.rb +40 -21
  186. data/test/test_address_au.rb +19 -9
  187. data/test/test_address_br.rb +9 -2
  188. data/test/test_address_ca.rb +7 -0
  189. data/test/test_address_ch.rb +6 -2
  190. data/test/test_address_ch_de.rb +7 -3
  191. data/test/test_address_ch_fr.rb +7 -3
  192. data/test/test_address_ch_it.rb +5 -1
  193. data/test/test_address_da.rb +18 -9
  194. data/test/test_address_de.rb +12 -5
  195. data/test/test_address_fi.rb +10 -3
  196. data/test/test_address_fr.rb +13 -0
  197. data/test/test_address_gr.rb +43 -0
  198. data/test/test_address_in.rb +20 -12
  199. data/test/test_address_kr.rb +14 -0
  200. data/test/test_address_mx.rb +12 -5
  201. data/test/test_address_nl.rb +11 -5
  202. data/test/test_address_ru.rb +11 -5
  203. data/test/test_address_se.rb +9 -3
  204. data/test/test_address_sn.rb +7 -1
  205. data/test/test_address_ua.rb +17 -10
  206. data/test/test_address_uk.rb +11 -3
  207. data/test/test_address_us.rb +15 -6
  208. data/test/test_airline.rb +17 -0
  209. data/test/test_array_utils.rb +51 -3
  210. data/test/test_avatar.rb +5 -1
  211. data/test/test_aws.rb +25 -0
  212. data/test/test_bacon_ipsum.rb +12 -6
  213. data/test/test_book.rb +41 -0
  214. data/test/test_boolean.rb +4 -0
  215. data/test/test_cheesy_lingo.rb +14 -10
  216. data/test/test_color.rb +126 -1
  217. data/test/test_color_ua.rb +5 -1
  218. data/test/test_company.rb +7 -0
  219. data/test/test_company_cn.rb +24 -0
  220. data/test/test_company_it.rb +7 -1
  221. data/test/test_company_se.rb +6 -0
  222. data/test/test_conference.rb +5 -2
  223. data/test/test_course_mathematiques.rb +5 -1
  224. data/test/test_course_philosophie.rb +5 -1
  225. data/test/test_currency.rb +12 -0
  226. data/test/test_dizzle_ipsum.rb +12 -6
  227. data/test/test_education.rb +9 -2
  228. data/test/test_faker.rb +8 -1
  229. data/test/test_food.rb +11 -4
  230. data/test/test_gender.rb +5 -1
  231. data/test/test_gender_br.rb +18 -0
  232. data/test/test_gender_cn.rb +5 -2
  233. data/test/test_gender_kr.rb +7 -3
  234. data/test/test_geolocation.rb +11 -8
  235. data/test/test_guid.rb +6 -1
  236. data/test/test_healthcare_ipsum.rb +13 -6
  237. data/test/test_hipster_ipsum.rb +13 -6
  238. data/test/test_html_ipsum.rb +28 -20
  239. data/test/test_identification.rb +9 -2
  240. data/test/test_identification_br.rb +46 -0
  241. data/test/test_identification_co.rb +7 -0
  242. data/test/test_identification_es.rb +5 -1
  243. data/test/test_identification_es_cl.rb +5 -1
  244. data/test/test_identification_es_mx.rb +7 -2
  245. data/test/test_identification_kr.rb +4 -0
  246. data/test/test_internet.rb +36 -5
  247. data/test/test_internet_se.rb +12 -4
  248. data/test/test_job.rb +4 -0
  249. data/test/test_job_br.rb +17 -0
  250. data/test/test_job_cn.rb +4 -0
  251. data/test/test_job_fr.rb +4 -0
  252. data/test/test_job_ja.rb +4 -0
  253. data/test/test_job_kr.rb +4 -0
  254. data/test/test_job_vn.rb +22 -0
  255. data/test/test_locale.rb +10 -4
  256. data/test/test_lorem.rb +18 -11
  257. data/test/test_lorem_ar.rb +16 -8
  258. data/test/test_lorem_cn.rb +9 -2
  259. data/test/test_lorem_fr.rb +16 -8
  260. data/test/test_lorem_ja.rb +81 -0
  261. data/test/test_lorem_kr.rb +17 -8
  262. data/test/test_lorem_ua.rb +15 -8
  263. data/test/test_module_utils.rb +2 -2
  264. data/test/test_movie.rb +5 -1
  265. data/test/test_music.rb +11 -4
  266. data/test/test_name.rb +114 -1
  267. data/test/test_name_br.rb +41 -2
  268. data/test/test_name_cn.rb +7 -0
  269. data/test/test_name_cs.rb +7 -0
  270. data/test/test_name_da.rb +13 -6
  271. data/test/test_name_de.rb +4 -0
  272. data/test/test_name_fr.rb +7 -0
  273. data/test/test_name_ga.rb +7 -0
  274. data/test/test_name_gr.rb +70 -0
  275. data/test/test_name_it.rb +7 -0
  276. data/test/test_name_ja.rb +7 -0
  277. data/test/test_name_kh.rb +32 -0
  278. data/test/test_name_kr.rb +7 -0
  279. data/test/test_name_mx.rb +9 -0
  280. data/test/test_name_nb.rb +8 -0
  281. data/test/test_name_nl.rb +4 -0
  282. data/test/test_name_ph.rb +7 -0
  283. data/test/test_name_ru.rb +10 -3
  284. data/test/test_name_se.rb +12 -4
  285. data/test/test_name_sn.rb +8 -0
  286. data/test/test_name_th.rb +7 -0
  287. data/test/test_name_th_en.rb +35 -0
  288. data/test/test_name_ua.rb +26 -17
  289. data/test/test_name_vn.rb +42 -0
  290. data/test/test_nato_alphabet.rb +15 -4
  291. data/test/test_phone_number.rb +24 -6
  292. data/test/test_phone_number_au.rb +17 -6
  293. data/test/test_phone_number_br.rb +22 -13
  294. data/test/test_phone_number_cu.rb +29 -18
  295. data/test/test_phone_number_da.rb +16 -7
  296. data/test/test_phone_number_de.rb +17 -9
  297. data/test/test_phone_number_kr.rb +9 -0
  298. data/test/test_phone_number_mx.rb +16 -8
  299. data/test/test_phone_number_nl.rb +9 -2
  300. data/test/test_phone_number_se.rb +12 -7
  301. data/test/test_phone_number_sg.rb +17 -9
  302. data/test/test_phone_number_sn.rb +12 -4
  303. data/test/test_products.rb +22 -0
  304. data/test/test_skill.rb +8 -2
  305. data/test/test_sports.rb +4 -0
  306. data/test/test_ssn.rb +3 -1
  307. data/test/test_ssn_mx.rb +6 -1
  308. data/test/test_ssn_se.rb +3 -0
  309. data/test/test_string.rb +28 -1
  310. data/test/test_time.rb +33 -2
  311. data/test/test_tweet.rb +59 -0
  312. data/test/test_units.rb +7 -0
  313. data/test/test_units_english.rb +9 -0
  314. data/test/test_units_metric.rb +9 -0
  315. data/test/test_vehicle.rb +24 -15
  316. data/test/test_venue.rb +5 -1
  317. data/test/test_youtube.rb +28 -0
  318. metadata +101 -5
  319. data/lib/ffaker/data/name/first_names +0 -3008
  320. data/lib/ffaker/data/name_br/first_names +0 -91
@@ -8,10 +8,10 @@ module FFaker
8
8
  extend self
9
9
 
10
10
  # Mobile prefixes
11
- MobileOperatorsPrefix = %w(04)
11
+ MobileOperatorsPrefix = %w(04).freeze
12
12
 
13
13
  # Home or Work Operator prefixes
14
- HomeWorkOperatorsPrefix = %w(02 03 05 07 08)
14
+ HomeWorkOperatorsPrefix = %w(02 03 05 07 08).freeze
15
15
 
16
16
  OperatorsPrefix = MobileOperatorsPrefix + HomeWorkOperatorsPrefix
17
17
 
@@ -56,7 +56,7 @@ module FFaker
56
56
  end
57
57
 
58
58
  def country_code
59
- "+61"
59
+ '+61'
60
60
  end
61
61
 
62
62
  def international_mobile_phone_number
@@ -8,11 +8,11 @@ module FFaker
8
8
  extend ModuleUtils
9
9
  extend self
10
10
 
11
- COUNTRY_PREFIX = '+55'
12
- AREA_CODE = %w[1# 2# 3# 4# 5# 6# 7# 8# 9#]
13
- HOME_WORK_PHONE_PREFIX = %w[2 3 4 5]
14
- MOBILE_PHONE_PREFIX = %w[6 7 8 9 96 97 98 99]
15
- PHONE_NUMBER = %w[####### ###-####]
11
+ COUNTRY_PREFIX = '+55'.freeze
12
+ AREA_CODE = %w(1# 2# 3# 4# 5# 6# 7# 8# 9#).freeze
13
+ HOME_WORK_PHONE_PREFIX = %w(2 3 4 5).freeze
14
+ MOBILE_PHONE_PREFIX = %w(6 7 8 9 96 97 98 99).freeze
15
+ PHONE_NUMBER = %w(####### ###-####).freeze
16
16
 
17
17
  # generate a random phone number
18
18
  #
@@ -53,15 +53,16 @@ module FFaker
53
53
  end
54
54
 
55
55
  private
56
+
56
57
  def number(prefixes, country_prefix = '')
57
58
  space = random_space
58
59
  p = [
59
60
  country_prefix,
60
61
  space,
61
- AREA_CODE.sample,
62
+ fetch_sample(AREA_CODE),
62
63
  space,
63
- prefixes.sample,
64
- PHONE_NUMBER.sample
64
+ fetch_sample(prefixes),
65
+ fetch_sample(PHONE_NUMBER)
65
66
  ].join('').strip
66
67
 
67
68
  FFaker.numerify p
@@ -5,13 +5,13 @@ module FFaker
5
5
  extend ModuleUtils
6
6
  extend self
7
7
 
8
- COUNTRY_PREFIX = %w[+41 0041 0]
9
- AREA_PREFIX = %w[21 22 24 26 27 31 32 33 34 41 43 44 51 52 56 58 61 62 71 81 91]
10
- MOBILE_PREFIX = %w[74 75 76 77 78 79]
11
- FREE_PHONE_PREFIX = %w[800]
12
- SHARED_COST_PREFIX = %w[840 842 844 848]
13
- PREMIUM_RATE_PREFIX = %w[900 901 906]
14
- PHONE_NUMBER = ['#######', ' ### ## ##']
8
+ COUNTRY_PREFIX = %w(+41 0041 0).freeze
9
+ AREA_PREFIX = %w(21 22 24 26 27 31 32 33 34 41 43 44 51 52 56 58 61 62 71 81 91).freeze
10
+ MOBILE_PREFIX = %w(74 75 76 77 78 79).freeze
11
+ FREE_PHONE_PREFIX = %w(800).freeze
12
+ SHARED_COST_PREFIX = %w(840 842 844 848).freeze
13
+ PREMIUM_RATE_PREFIX = %w(900 901 906).freeze
14
+ PHONE_NUMBER = ['#######', ' ### ## ##'].freeze
15
15
 
16
16
  def phone_number
17
17
  case rand(5)
@@ -6,10 +6,10 @@ module FFaker
6
6
  extend self
7
7
 
8
8
  # Mobile prefixes
9
- MobileOperatorsPrefix = %w(05)
9
+ MobileOperatorsPrefix = %w(05).freeze
10
10
 
11
11
  # Home or Work Operator prefixes
12
- HomeWorkOperatorsPrefix = %w(021 022 023 024 031 032 033 041 042 043 045 046 047 048 07)
12
+ HomeWorkOperatorsPrefix = %w(021 022 023 024 031 032 033 041 042 043 045 046 047 048 07).freeze
13
13
 
14
14
  OperatorsPrefix = MobileOperatorsPrefix + HomeWorkOperatorsPrefix
15
15
 
@@ -81,7 +81,7 @@ module FFaker
81
81
  phone_prefix = home_work_phone_prefix
82
82
  case phone_prefix.size
83
83
  when 2 then FFaker.numerify("#{international_country_code}#{phone_prefix[1]} ### ####")
84
- when 3 then FFaker.numerify("#{international_country_code}#{phone_prefix[1,2]} ## ####")
84
+ when 3 then FFaker.numerify("#{international_country_code}#{phone_prefix[1, 2]} ## ####")
85
85
  end
86
86
  end
87
87
 
@@ -96,7 +96,7 @@ module FFaker
96
96
  # Based on information from http://en.wikipedia.org/wiki/E.164
97
97
  #
98
98
  def e164_country_code
99
- "53"
99
+ '53'
100
100
  end
101
101
 
102
102
  def e164_mobile_phone_number
@@ -107,7 +107,7 @@ module FFaker
107
107
  phone_prefix = home_work_phone_prefix
108
108
  case phone_prefix.size
109
109
  when 2 then FFaker.numerify("#{e164_country_code}#{phone_prefix[1]}#######")
110
- when 3 then FFaker.numerify("#{e164_country_code}#{phone_prefix[1,2]}######")
110
+ when 3 then FFaker.numerify("#{e164_country_code}#{phone_prefix[1, 2]}######")
111
111
  end
112
112
  end
113
113
 
@@ -15,7 +15,7 @@ module FFaker
15
15
 
16
16
  # Region prefixes are in range 02..09 with length of 3 to 5 digits
17
17
  def region_prefix(leading_zero = true)
18
- region_prefix = (rand(8) + 2).to_s + FFaker.numerify( '#' * (rand(3) + 1) ).to_s
18
+ region_prefix = (rand(8) + 2).to_s + FFaker.numerify('#' * (rand(3) + 1)).to_s
19
19
  region_prefix = '0' + region_prefix if leading_zero
20
20
  region_prefix
21
21
  end
@@ -5,10 +5,10 @@ module FFaker
5
5
  extend ModuleUtils
6
6
  extend self
7
7
 
8
- COUNTRY_PREFIX = %w[+33 0033 0]
9
- AREA_PREFIX = %w[1 2 3 4 5]
10
- MOBILE_PREFIX = %w[6 7]
11
- PHONE_NUMBER = ['########', ' ## ## ## ##']
8
+ COUNTRY_PREFIX = %w(+33 0033 0).freeze
9
+ AREA_PREFIX = %w(1 2 3 4 5).freeze
10
+ MOBILE_PREFIX = %w(6 7).freeze
11
+ PHONE_NUMBER = ['########', ' ## ## ## ##'].freeze
12
12
 
13
13
  def phone_number
14
14
  case rand(2)
@@ -5,8 +5,8 @@ module FFaker
5
5
  extend ModuleUtils
6
6
  extend self
7
7
 
8
- COUNTRY_PREFIX = ['+39', '0039', '+39 ', '0039 ']
9
- PHONE_NUMBER = ['######', '########']
8
+ COUNTRY_PREFIX = ['+39', '0039', '+39 ', '0039 '].freeze
9
+ PHONE_NUMBER = ['######', '########'].freeze
10
10
 
11
11
  def phone_number
12
12
  if rand(0..1) == 1
@@ -6,8 +6,8 @@ module FFaker
6
6
  extend self
7
7
 
8
8
  HOME_PHONE_PREFIXES =
9
- %w(02 031 032 033 041 042 043 044 049 051 052 053 054 055 061 062 063 064)
10
- MOBILE_PHONE_PREFIXES = %w(010 011 016 019)
9
+ %w(02 031 032 033 041 042 043 044 049 051 052 053 054 055 061 062 063 064).freeze
10
+ MOBILE_PHONE_PREFIXES = %w(010 011 016 019).freeze
11
11
 
12
12
  def phone_number
13
13
  case rand(2)
@@ -17,11 +17,11 @@ module FFaker
17
17
  end
18
18
 
19
19
  def home_work_phone_number
20
- FFaker.numerify("#{HOME_PHONE_PREFIXES.sample} #### ####")
20
+ FFaker.numerify("#{fetch_sample(HOME_PHONE_PREFIXES)} #### ####")
21
21
  end
22
22
 
23
23
  def mobile_phone_number
24
- FFaker.numerify("#{MOBILE_PHONE_PREFIXES.sample} #### ####")
24
+ FFaker.numerify("#{fetch_sample(MOBILE_PHONE_PREFIXES)} #### ####")
25
25
  end
26
26
 
27
27
  def contry_code
@@ -10,14 +10,14 @@ module FFaker
10
10
  # xx xxxx xxxx
11
11
  #
12
12
  def home_work_phone_number
13
- FFaker.numerify("## #### ####")
13
+ FFaker.numerify('## #### ####')
14
14
  end
15
15
 
16
16
  # Generates a mobile phone number
17
17
  # 044 xx xxxx xxxx
18
18
  #
19
19
  def mobile_phone_number
20
- FFaker.numerify("044 ## #### ####")
20
+ FFaker.numerify('044 ## #### ####')
21
21
  end
22
22
 
23
23
  # generates mobile or home/work number
@@ -29,7 +29,7 @@ module FFaker
29
29
  end
30
30
 
31
31
  def country_code
32
- "+52"
32
+ '+52'
33
33
  end
34
34
 
35
35
  def international_mobile_phone_number
@@ -51,8 +51,7 @@ module FFaker
51
51
  # 01 800 xxx xxxx
52
52
  #
53
53
  def toll_free_number
54
- FFaker.numerify("01 800 ### ####")
54
+ FFaker.numerify('01 800 ### ####')
55
55
  end
56
-
57
56
  end
58
57
  end
@@ -5,14 +5,14 @@ module FFaker
5
5
  extend ModuleUtils
6
6
  extend self
7
7
 
8
- COUNTRY_CODE = "+31"
9
- AREA_CODE_PREFIX = "0"
8
+ COUNTRY_CODE = '+31'.freeze
9
+ AREA_CODE_PREFIX = '0'.freeze
10
10
  PHONE_NUMBER = {
11
- 2 => ["#######", "### ####", "#### ###"],
12
- 3 => ["######", "#### ##", "## ## ##"]
13
- }
14
- AREA_CODES = %w(10 111 113 114 115 117 118 13 14 15 161 162 164 165 166 167 168 172 174 180 181 182 183 184 186 187 20 222 223 224 226 227 228 229 23 24 251 252 255 26 294 297 299 30 313 314 315 316 317 318 320 321 33 341 342 343 344 345 346 347 348 35 36 38 40 411 412 413 416 418 43 45 46 475 478 481 485 486 487 488 492 493 495 497 499 50 511 512 513 514 515 516 517 518 519 521 522 523 524 525 527 528 529 53 541 543 544 545 546 547 548 55 561 562 566 570 571 572 573 575 577 578 58 591 592 593 594 595 596 597 598 599 70 71 72 73 74 75 76 77 78 79)
15
- MOBILE_PHONE_NUMBER = ['########', ' ## ## ## ##', ' ### ### ##', " #### ####"]
11
+ 2 => ['#######', '### ####', '#### ###'],
12
+ 3 => ['######', '#### ##', '## ## ##']
13
+ }.freeze
14
+ AREA_CODES = %w(10 111 113 114 115 117 118 13 14 15 161 162 164 165 166 167 168 172 174 180 181 182 183 184 186 187 20 222 223 224 226 227 228 229 23 24 251 252 255 26 294 297 299 30 313 314 315 316 317 318 320 321 33 341 342 343 344 345 346 347 348 35 36 38 40 411 412 413 416 418 43 45 46 475 478 481 485 486 487 488 492 493 495 497 499 50 511 512 513 514 515 516 517 518 519 521 522 523 524 525 527 528 529 53 541 543 544 545 546 547 548 55 561 562 566 570 571 572 573 575 577 578 58 591 592 593 594 595 596 597 598 599 70 71 72 73 74 75 76 77 78 79).freeze
15
+ MOBILE_PHONE_NUMBER = ['########', ' ## ## ## ##', ' ### ### ##', ' #### ####'].freeze
16
16
 
17
17
  def phone_number
18
18
  case rand(2)
@@ -22,12 +22,12 @@ module FFaker
22
22
  end
23
23
 
24
24
  def home_work_phone_number
25
- area = AREA_CODES.sample
26
- FFaker.numerify "#{AREA_CODE_PREFIX}#{area}-#{PHONE_NUMBER[area.size].sample}"
25
+ area = fetch_sample(AREA_CODES)
26
+ FFaker.numerify "#{AREA_CODE_PREFIX}#{area}-#{fetch_sample(PHONE_NUMBER[area.size])}"
27
27
  end
28
28
 
29
29
  def mobile_phone_number
30
- FFaker.numerify "#{AREA_CODE_PREFIX}6#{MOBILE_PHONE_NUMBER.sample}"
30
+ FFaker.numerify "#{AREA_CODE_PREFIX}6#{fetch_sample(MOBILE_PHONE_NUMBER)}"
31
31
  end
32
32
 
33
33
  def international_phone_number
@@ -38,12 +38,12 @@ module FFaker
38
38
  end
39
39
 
40
40
  def international_home_work_phone_number
41
- area = AREA_CODES.sample
42
- FFaker.numerify("#{COUNTRY_CODE} #{area}-#{PHONE_NUMBER[area.size].sample}")
41
+ area = fetch_sample(AREA_CODES)
42
+ FFaker.numerify("#{COUNTRY_CODE} #{area}-#{fetch_sample(PHONE_NUMBER[area.size])}")
43
43
  end
44
44
 
45
45
  def international_mobile_phone_number
46
- FFaker.numerify("#{COUNTRY_CODE} 6#{MOBILE_PHONE_NUMBER.sample}")
46
+ FFaker.numerify("#{COUNTRY_CODE} 6#{fetch_sample(MOBILE_PHONE_NUMBER)}")
47
47
  end
48
48
  end
49
49
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module FFaker
4
-
5
4
  # Format for swedish numbers, from here
6
5
  # from http://sv.wikipedia.org/wiki/Telefonnummer
7
6
  #
@@ -19,17 +18,17 @@ module FFaker
19
18
  extend ModuleUtils
20
19
  extend self
21
20
 
22
- PHONE_FORMAT_PREFIX_2 = ["%s-### ### ##",
23
- "%s-### ## ##",
24
- "%s-## ## ##"]
25
- PHONE_FORMAT_PREFIX_3 = ["%s-### ## ##",
26
- "%s-## ## ##",
27
- "%s-## ###"]
28
- PHONE_FORMAT_PREFIX_4 = ["%s-## ## ##",
29
- "%s-### ##"]
30
- MOBILE_PHONE_FORMAT = ["%s#-## ## ##", "%s#-######"]
31
- COUNTRY_PREFIX = ["+46", "0046"]
32
- MOBILE_PHONE_PREFIX = %w(70 72 73 76 74)
21
+ PHONE_FORMAT_PREFIX_2 = ['%s-### ### ##',
22
+ '%s-### ## ##',
23
+ '%s-## ## ##'].freeze
24
+ PHONE_FORMAT_PREFIX_3 = ['%s-### ## ##',
25
+ '%s-## ## ##',
26
+ '%s-## ###'].freeze
27
+ PHONE_FORMAT_PREFIX_4 = ['%s-## ## ##',
28
+ '%s-### ##'].freeze
29
+ MOBILE_PHONE_FORMAT = ['%s#-## ## ##', '%s#-######'].freeze
30
+ COUNTRY_PREFIX = ['+46', '0046'].freeze
31
+ MOBILE_PHONE_PREFIX = %w(70 72 73 76 74).freeze
33
32
 
34
33
  def phone_number
35
34
  case rand(2)
@@ -54,7 +53,7 @@ module FFaker
54
53
  end
55
54
 
56
55
  def country_prefix
57
- COUNTRY_PREFIX.sample
56
+ fetch_sample(COUNTRY_PREFIX)
58
57
  end
59
58
 
60
59
  def international_mobile_phone_number
@@ -66,24 +65,24 @@ module FFaker
66
65
  end
67
66
 
68
67
  def area_prefix
69
- PHONE_PREFIX.sample
68
+ fetch_sample(PHONE_PREFIX)
70
69
  end
71
70
 
72
71
  def phone_number_format
73
72
  prefix = area_prefix
74
73
  case prefix.length
75
- when 1 then PHONE_FORMAT_PREFIX_2.sample
76
- when 2 then PHONE_FORMAT_PREFIX_3.sample
77
- when 3 then PHONE_FORMAT_PREFIX_4.sample
74
+ when 1 then fetch_sample(PHONE_FORMAT_PREFIX_2)
75
+ when 2 then fetch_sample(PHONE_FORMAT_PREFIX_3)
76
+ when 3 then fetch_sample(PHONE_FORMAT_PREFIX_4)
78
77
  end % prefix
79
78
  end
80
79
 
81
80
  def mobile_prefix
82
- MOBILE_PHONE_PREFIX.sample
81
+ fetch_sample(MOBILE_PHONE_PREFIX)
83
82
  end
84
83
 
85
84
  def mobile_phone_number_format
86
- MOBILE_PHONE_FORMAT.sample % mobile_prefix
85
+ fetch_sample(MOBILE_PHONE_FORMAT) % mobile_prefix
87
86
  end
88
87
  end
89
88
  end
@@ -20,49 +20,49 @@ module FFaker
20
20
  # 3xxx xxxx
21
21
  #
22
22
  def voip_number
23
- FFaker.numerify("3### ####")
23
+ FFaker.numerify('3### ####')
24
24
  end
25
25
 
26
26
  # Generates a fixed line phone number
27
27
  # 6xxx xxxx
28
28
  #
29
29
  def fixed_line_number
30
- FFaker.numerify("6### ####")
30
+ FFaker.numerify('6### ####')
31
31
  end
32
32
 
33
33
  # Generates a fixed mobile phone number
34
34
  # 8xxx xxxx
35
35
  #
36
36
  def mobile_number
37
- FFaker.numerify("8### ####")
37
+ FFaker.numerify('8### ####')
38
38
  end
39
39
 
40
40
  # Generates a fixed mobile phone number or pager service number
41
41
  # 9xxx xxxx
42
42
  #
43
43
  def mobile_or_pager_number
44
- FFaker.numerify("9### ####")
44
+ FFaker.numerify('9### ####')
45
45
  end
46
46
 
47
47
  # Generates an international toll-free number
48
48
  # 800 xxx xxxx
49
49
  #
50
50
  def international_toll_free_number
51
- FFaker.numerify("800 ### ####")
51
+ FFaker.numerify('800 ### ####')
52
52
  end
53
53
 
54
54
  # Generates an toll-free number
55
55
  # 1800 xxx xxxx
56
56
  #
57
57
  def toll_free_number
58
- FFaker.numerify("1800 ### ####")
58
+ FFaker.numerify('1800 ### ####')
59
59
  end
60
60
 
61
61
  # Generates a premium service number
62
62
  # (1900) xxx xxxx
63
63
  #
64
64
  def premium_service_number
65
- FFaker.numerify("1900 ### ####")
65
+ FFaker.numerify('1900 ### ####')
66
66
  end
67
67
 
68
68
  # generates mobile or home/work number
@@ -75,7 +75,7 @@ module FFaker
75
75
  end
76
76
 
77
77
  def country_code
78
- "+65"
78
+ '+65'
79
79
  end
80
80
  end
81
81
  end
@@ -12,13 +12,13 @@ module FFaker
12
12
  # 76 => Tigo
13
13
  # 70 => Expresso
14
14
  #
15
- MobileOperatorsPrefix = %w(70 76 77)
15
+ MobileOperatorsPrefix = %w(70 76 77).freeze
16
16
 
17
17
  # Home or Work Operator prefixes
18
18
  #
19
19
  # 33 => Orange
20
20
  #
21
- HomeWorkOperatorsPrefix = %w(33)
21
+ HomeWorkOperatorsPrefix = %w(33).freeze
22
22
 
23
23
  # Return a prefix in MobileOperatorsPrefix
24
24
  # @see FFaker::PhoneNumberSN::MobileOperatorsPrefix
@@ -5,24 +5,28 @@ module FFaker
5
5
  extend ModuleUtils
6
6
  extend self
7
7
 
8
- B2 = %w(nix cell sync func balt sche pod)
9
- VOWELS = %w(a e i o u ou ie y io)
10
- START = %w(tr br p ph)
11
- SUFFIX = %w(ck ns nce nt st ne re ffe ph)
12
- ADDON = %w(wood forge func)
8
+ B2 = %w(nix cell sync func balt sche pod).freeze
9
+ VOWELS = %w(a e i o u ou ie y io).freeze
10
+ START = %w(tr br p ph).freeze
11
+ SUFFIX = %w(ck ns nce nt st ne re ffe ph).freeze
12
+ ADDON = %w(wood forge func).freeze
13
13
 
14
14
  def brand
15
15
  case rand(12)
16
- when (0..4) then B1.sample + B2.sample
17
- when (5..10) then "#{START.sample}#{VOWELS.sample}#{SUFFIX.sample}#{ADDON.sample if rand(2)==0}".capitalize
18
- when 11 then "#{letters(2..3)}"
16
+ when (0..4) then fetch_sample(B1) + fetch_sample(B2)
17
+ when (5..10) then
18
+ [
19
+ fetch_sample(START), fetch_sample(VOWELS), fetch_sample(SUFFIX),
20
+ rand(2).zero? ? fetch_sample(ADDON) : nil
21
+ ].join.capitalize
22
+ when 11 then letters(2..3).to_s
19
23
  end
20
24
  end
21
25
 
22
26
  def product_name
23
27
  case rand(2)
24
- when 0 then "#{ADJ.sample} #{NOUN.sample}"
25
- when 1 then "#{[ADJ.sample, ADJ.sample].uniq.join(" ")} #{NOUN.sample}"
28
+ when 0 then "#{fetch_sample(ADJ)} #{fetch_sample(NOUN)}"
29
+ when 1 then "#{[fetch_sample(ADJ), fetch_sample(ADJ)].uniq.join(' ')} #{fetch_sample(NOUN)}"
26
30
  end
27
31
  end
28
32
 
@@ -31,14 +35,14 @@ module FFaker
31
35
  end
32
36
 
33
37
  def letters(n)
34
- max = n.is_a?(Range) ? n.to_a.sample : n
35
- (0...max).map { LETTERS.sample.upcase }.join
38
+ max = n.is_a?(Range) ? fetch_sample(n.to_a) : n
39
+ (0...max).map { fetch_sample(LETTERS).upcase }.join
36
40
  end
37
41
 
38
42
  def model
39
43
  case rand(2)
40
- when 0 then "#{LETTERS.sample.upcase}#{rand(90)}" # N90
41
- when 1 then "#{letters(1..rand(1..2))}-#{rand(9900)}" # N-9400
44
+ when 0 then "#{fetch_sample(LETTERS).upcase}#{rand(90)}" # N90
45
+ when 1 then "#{letters(1..rand(1..2))}-#{rand(9900)}" # N-9400
42
46
  end
43
47
  end
44
48
  end