phony 1.9.0 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/README.textile +1 -1
  2. data/lib/phony.rb +28 -15
  3. data/lib/phony/countries.rb +609 -210
  4. data/lib/phony/countries/austria.rb +6 -1
  5. data/lib/phony/countries/bangladesh.rb +55 -0
  6. data/lib/phony/countries/belarus.rb +130 -0
  7. data/lib/phony/countries/georgia.rb +91 -0
  8. data/lib/phony/countries/germany.rb +20 -6
  9. data/lib/phony/countries/india.rb +50 -0
  10. data/lib/phony/countries/indonesia.rb +50 -0
  11. data/lib/phony/countries/italy.rb +38 -67
  12. data/lib/phony/countries/japan.rb +412 -0
  13. data/lib/phony/countries/kyrgyzstan.rb +118 -0
  14. data/lib/phony/countries/latvia.rb +40 -0
  15. data/lib/phony/countries/libya.rb +114 -0
  16. data/lib/phony/countries/malaysia.rb +7 -5
  17. data/lib/phony/countries/moldova.rb +50 -0
  18. data/lib/phony/countries/montenegro.rb +27 -0
  19. data/lib/phony/countries/namibia.rb +35 -0
  20. data/lib/phony/countries/nepal.rb +71 -0
  21. data/lib/phony/countries/netherlands.rb +3 -2
  22. data/lib/phony/countries/pakistan.rb +119 -0
  23. data/lib/phony/countries/paraguay.rb +145 -0
  24. data/lib/phony/countries/russia_kazakhstan_abhasia_south_osetia.rb +6 -6
  25. data/lib/phony/countries/serbia.rb +34 -0
  26. data/lib/phony/countries/somali.rb +22 -0
  27. data/lib/phony/countries/south_korea.rb +1 -1
  28. data/lib/phony/countries/sweden.rb +1 -1
  29. data/lib/phony/countries/taiwan.rb +51 -0
  30. data/lib/phony/countries/tajikistan.rb +76 -0
  31. data/lib/phony/countries/turkmenistan.rb +73 -0
  32. data/lib/phony/countries/ukraine.rb +614 -0
  33. data/lib/phony/countries/uruguay.rb +51 -0
  34. data/lib/phony/countries/zimbabwe.rb +37 -0
  35. data/lib/phony/country.rb +41 -0
  36. data/lib/phony/country_codes.rb +45 -18
  37. data/lib/phony/dsl.rb +33 -7
  38. data/lib/phony/local_splitters/fixed.rb +14 -1
  39. data/lib/phony/local_splitters/regex.rb +12 -1
  40. data/lib/phony/national_code.rb +7 -3
  41. data/lib/phony/national_splitters/default.rb +13 -1
  42. data/lib/phony/national_splitters/dsl.rb +9 -7
  43. data/lib/phony/national_splitters/fixed.rb +6 -0
  44. data/lib/phony/national_splitters/none.rb +6 -0
  45. data/lib/phony/national_splitters/regex.rb +6 -0
  46. data/lib/phony/national_splitters/variable.rb +7 -1
  47. data/spec/lib/phony/countries_spec.rb +684 -16
  48. data/spec/lib/phony/local_splitters/regex_spec.rb +41 -0
  49. data/spec/lib/phony/validations_spec.rb +542 -10
  50. data/spec/lib/phony_spec.rb +20 -6
  51. metadata +29 -9
  52. data/lib/phony/validator.rb +0 -26
  53. data/lib/phony/validators.rb +0 -88
@@ -0,0 +1,412 @@
1
+ # Japan
2
+ # http://www.itu.int/oth/T020200006D/en
3
+
4
+ ndcs_with_8_subscriber_numbers = %w(3 6)
5
+
6
+ ndcs_with_7_subscriber_numbers = %w(
7
+ 11
8
+ 15
9
+ 17
10
+ 18
11
+ 19
12
+ 22
13
+ 23
14
+ 24
15
+ 25
16
+ 26
17
+ 27
18
+ 28
19
+ 29
20
+ 42
21
+ 43
22
+ 44
23
+ 45
24
+ 46
25
+ 47
26
+ 48
27
+ 49
28
+ 52
29
+ 53
30
+ 54
31
+ 55
32
+ 58
33
+ 59
34
+ 72
35
+ 73
36
+ 75
37
+ 76
38
+ 77
39
+ 78
40
+ 79
41
+ 82
42
+ 83
43
+ 84
44
+ 86
45
+ 87
46
+ 88
47
+ 89
48
+ 92
49
+ 93
50
+ 95
51
+ 96
52
+ 97
53
+ 98
54
+ 99
55
+ )
56
+
57
+ ndcs_with_6_subscriber_numbers = %w(
58
+ 123
59
+ 124
60
+ 125
61
+ 126
62
+ 133
63
+ 134
64
+ 135
65
+ 136
66
+ 137
67
+ 138
68
+ 139
69
+ 142
70
+ 143
71
+ 144
72
+ 145
73
+ 146
74
+ 152
75
+ 153
76
+ 154
77
+ 155
78
+ 156
79
+ 157
80
+ 158
81
+ 162
82
+ 163
83
+ 164
84
+ 165
85
+ 166
86
+ 167
87
+ 172
88
+ 173
89
+ 174
90
+ 175
91
+ 176
92
+ 178
93
+ 179
94
+ 182
95
+ 183
96
+ 184
97
+ 185
98
+ 186
99
+ 187
100
+ 191
101
+ 192
102
+ 193
103
+ 194
104
+ 195
105
+ 197
106
+ 198
107
+ 220
108
+ 223
109
+ 224
110
+ 225
111
+ 226
112
+ 228
113
+ 229
114
+ 233
115
+ 234
116
+ 235
117
+ 237
118
+ 238
119
+ 240
120
+ 241
121
+ 242
122
+ 243
123
+ 244
124
+ 246
125
+ 247
126
+ 248
127
+ 250
128
+ 254
129
+ 255
130
+ 256
131
+ 257
132
+ 258
133
+ 259
134
+ 260
135
+ 261
136
+ 263
137
+ 264
138
+ 265
139
+ 266
140
+ 267
141
+ 268
142
+ 269
143
+ 270
144
+ 274
145
+ 276
146
+ 277
147
+ 278
148
+ 279
149
+ 280
150
+ 282
151
+ 283
152
+ 284
153
+ 285
154
+ 287
155
+ 288
156
+ 289
157
+ 291
158
+ 293
159
+ 294
160
+ 295
161
+ 296
162
+ 297
163
+ 299
164
+ 422
165
+ 428
166
+ 436
167
+ 439
168
+ 460
169
+ 463
170
+ 465
171
+ 466
172
+ 467
173
+ 470
174
+ 475
175
+ 476
176
+ 478
177
+ 479
178
+ 480
179
+ 493
180
+ 494
181
+ 495
182
+ 531
183
+ 532
184
+ 533
185
+ 536
186
+ 537
187
+ 538
188
+ 539
189
+ 544
190
+ 545
191
+ 547
192
+ 548
193
+ 550
194
+ 551
195
+ 553
196
+ 554
197
+ 555
198
+ 556
199
+ 557
200
+ 558
201
+ 561
202
+ 562
203
+ 563
204
+ 564
205
+ 565
206
+ 566
207
+ 567
208
+ 568
209
+ 569
210
+ 572
211
+ 573
212
+ 574
213
+ 575
214
+ 576
215
+ 577
216
+ 578
217
+ 581
218
+ 584
219
+ 585
220
+ 586
221
+ 587
222
+ 594
223
+ 595
224
+ 596
225
+ 597
226
+ 598
227
+ 599
228
+ 721
229
+ 725
230
+ 735
231
+ 736
232
+ 737
233
+ 738
234
+ 739
235
+ 740
236
+ 742
237
+ 743
238
+ 744
239
+ 745
240
+ 746
241
+ 747
242
+ 748
243
+ 749
244
+ 761
245
+ 763
246
+ 765
247
+ 766
248
+ 767
249
+ 768
250
+ 770
251
+ 771
252
+ 772
253
+ 773
254
+ 774
255
+ 776
256
+ 778
257
+ 779
258
+ 790
259
+ 791
260
+ 794
261
+ 795
262
+ 796
263
+ 797
264
+ 798
265
+ 799
266
+ 820
267
+ 823
268
+ 824
269
+ 826
270
+ 827
271
+ 829
272
+ 833
273
+ 834
274
+ 835
275
+ 836
276
+ 837
277
+ 838
278
+ 845
279
+ 846
280
+ 847
281
+ 848
282
+ 849
283
+ 852
284
+ 853
285
+ 854
286
+ 855
287
+ 856
288
+ 857
289
+ 858
290
+ 859
291
+ 863
292
+ 865
293
+ 866
294
+ 867
295
+ 868
296
+ 869
297
+ 875
298
+ 877
299
+ 879
300
+ 880
301
+ 883
302
+ 884
303
+ 885
304
+ 887
305
+ 889
306
+ 892
307
+ 893
308
+ 894
309
+ 895
310
+ 896
311
+ 897
312
+ 898
313
+ 920
314
+ 930
315
+ 940
316
+ 942
317
+ 943
318
+ 944
319
+ 946
320
+ 947
321
+ 948
322
+ 949
323
+ 950
324
+ 952
325
+ 954
326
+ 955
327
+ 956
328
+ 957
329
+ 959
330
+ 964
331
+ 965
332
+ 966
333
+ 967
334
+ 968
335
+ 969
336
+ 972
337
+ 973
338
+ 974
339
+ 977
340
+ 978
341
+ 979
342
+ 980
343
+ 982
344
+ 983
345
+ 984
346
+ 985
347
+ 986
348
+ 987
349
+ 993
350
+ 994
351
+ 995
352
+ 996
353
+ 997
354
+ )
355
+
356
+ ndcs_with_5_subscriber_numbers = %w(
357
+ 1267
358
+ 1372
359
+ 1374
360
+ 1377
361
+ 1392
362
+ 1394
363
+ 1397
364
+ 1398
365
+ 1456
366
+ 1457
367
+ 1466
368
+ 1547
369
+ 1558
370
+ 1564
371
+ 1586
372
+ 1587
373
+ 1632
374
+ 1634
375
+ 1635
376
+ 1648
377
+ 1654
378
+ 1655
379
+ 1656
380
+ 1658
381
+ 4992
382
+ 4994
383
+ 4996
384
+ 4998
385
+ 5769
386
+ 5979
387
+ 7468
388
+ 8387
389
+ 8388
390
+ 8396
391
+ 8477
392
+ 8512
393
+ 8514
394
+ 8636
395
+ 9496
396
+ 9802
397
+ 9912
398
+ 9913
399
+ 9969
400
+ )
401
+
402
+ Phony.define do
403
+ country '81',
404
+ one_of(ndcs_with_5_subscriber_numbers) >> split(3,2) |
405
+ one_of(ndcs_with_6_subscriber_numbers) >> split(3,3) |
406
+ one_of(%w(120 800)) >> split(3,3) | # freephone
407
+ one_of(ndcs_with_7_subscriber_numbers) >> split(4,3) |
408
+ one_of(ndcs_with_8_subscriber_numbers) >> split(4,4) |
409
+ one_of('20', '50', '60', '70', '90') >> split(4,4) | # mobile, VoIP telephony
410
+ # TODO: 91(NDC) N(S)N length: 5-13 - Non-geographic number (Direct subscriber telephone service (legacy))
411
+ fixed(2) >> split(4,4)
412
+ end
@@ -0,0 +1,118 @@
1
+ # Kyrgyz Republic
2
+ # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
+ # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=KG
4
+
5
+ ndcs_with_6_subscriber_digits = %w(312 315)
6
+
7
+ ndcs_with_5_subscriber_digits = %w(
8
+ 3131
9
+ 3132
10
+ 3133
11
+ 3134
12
+ 3135
13
+ 3137
14
+ 3138
15
+ 3147
16
+ 3161
17
+ 3162
18
+ 3163
19
+ 3164
20
+ 3165
21
+ 3166
22
+ 3167
23
+ 3168
24
+ 3222
25
+ 3230
26
+ 3231
27
+ 3232
28
+ 3233
29
+ 3234
30
+ 3237
31
+ 3239
32
+ 3261
33
+ 3262
34
+ 3263
35
+ 3264
36
+ 3265
37
+ 3266
38
+ 3267
39
+ 3422
40
+ 3456
41
+ 3457
42
+ 3458
43
+ 3459
44
+ 3461
45
+ 3462
46
+ 3463
47
+ 3464
48
+ 3522
49
+ 3534
50
+ 3535
51
+ 3536
52
+ 3537
53
+ 3559
54
+ 3561
55
+ 3562
56
+ 3563
57
+ 3564
58
+ 3565
59
+ 3622
60
+ 3653
61
+ 3655
62
+ 3656
63
+ 3657
64
+ 3661
65
+ 3662
66
+ 3663
67
+ 3722
68
+ 3734
69
+ 3736
70
+ 3738
71
+ 3741
72
+ 3742
73
+ 3743
74
+ 3744
75
+ 3745
76
+ 3746
77
+ 3747
78
+ 3748
79
+ 3759
80
+ 3761
81
+ 3762
82
+ 3763
83
+ 3764
84
+ 3765
85
+ 3766
86
+ 3767
87
+ 3768
88
+ 3769
89
+ 3775
90
+ 3776
91
+ 3777
92
+ 3922
93
+ 3941
94
+ 3942
95
+ 3943
96
+ 3944
97
+ 3945
98
+ 3946
99
+ 3947
100
+ 3961
101
+ 3962
102
+ 3963
103
+ 3964
104
+ 3965
105
+ 3966
106
+ 3967
107
+ 3968
108
+ )
109
+
110
+ Phony.define do
111
+ country '996',
112
+ one_of(ndcs_with_5_subscriber_digits) >> split(3,2) |
113
+ one_of(ndcs_with_6_subscriber_digits) >> split(3,3) |
114
+ one_of(%w(800)) >> split(3,3) | # freephone
115
+ one_of(%w(50 51 54 55 56 57 58 60 61 62 70 77)) >> split(3,4) | # mobile
116
+ one_of(%w(52)) >> split(3,4) | # satellite
117
+ fixed(3) >> split(3,3)
118
+ end