phony 2.20.14 → 2.20.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/lib/phony/config.rb +25 -26
  3. data/lib/phony/countries/argentina.rb +311 -314
  4. data/lib/phony/countries/austria.rb +71 -72
  5. data/lib/phony/countries/bangladesh.rb +27 -28
  6. data/lib/phony/countries/belarus.rb +110 -111
  7. data/lib/phony/countries/brazil.rb +92 -92
  8. data/lib/phony/countries/cambodia.rb +9 -9
  9. data/lib/phony/countries/china.rb +22 -21
  10. data/lib/phony/countries/croatia.rb +6 -5
  11. data/lib/phony/countries/georgia.rb +84 -84
  12. data/lib/phony/countries/germany.rb +4067 -4068
  13. data/lib/phony/countries/guinea.rb +8 -8
  14. data/lib/phony/countries/india.rb +31 -34
  15. data/lib/phony/countries/indonesia.rb +57 -46
  16. data/lib/phony/countries/ireland.rb +4 -5
  17. data/lib/phony/countries/italy.rb +54 -53
  18. data/lib/phony/countries/japan.rb +456 -456
  19. data/lib/phony/countries/kyrgyzstan.rb +109 -109
  20. data/lib/phony/countries/latvia.rb +34 -34
  21. data/lib/phony/countries/libya.rb +106 -106
  22. data/lib/phony/countries/malaysia.rb +12 -12
  23. data/lib/phony/countries/moldova.rb +42 -42
  24. data/lib/phony/countries/montenegro.rb +24 -20
  25. data/lib/phony/countries/myanmar.rb +39 -39
  26. data/lib/phony/countries/namibia.rb +35 -29
  27. data/lib/phony/countries/nepal.rb +60 -62
  28. data/lib/phony/countries/netherlands.rb +13 -13
  29. data/lib/phony/countries/pakistan.rb +134 -110
  30. data/lib/phony/countries/paraguay.rb +135 -135
  31. data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +125 -128
  32. data/lib/phony/countries/saudi_arabia.rb +5 -5
  33. data/lib/phony/countries/serbia.rb +47 -39
  34. data/lib/phony/countries/somalia.rb +18 -18
  35. data/lib/phony/countries/south_korea.rb +16 -13
  36. data/lib/phony/countries/sweden.rb +28 -28
  37. data/lib/phony/countries/taiwan.rb +20 -19
  38. data/lib/phony/countries/tajikistan.rb +70 -70
  39. data/lib/phony/countries/turkmenistan.rb +65 -65
  40. data/lib/phony/countries/ukraine.rb +607 -607
  41. data/lib/phony/countries/united_kingdom.rb +66 -66
  42. data/lib/phony/countries/uruguay.rb +40 -41
  43. data/lib/phony/countries/vietnam.rb +18 -17
  44. data/lib/phony/countries/zimbabwe.rb +31 -31
  45. data/lib/phony/countries.rb +440 -443
  46. data/lib/phony/country.rb +42 -44
  47. data/lib/phony/country_codes.rb +61 -60
  48. data/lib/phony/dsl.rb +23 -26
  49. data/lib/phony/local_splitters/fixed.rb +20 -29
  50. data/lib/phony/local_splitters/regex.rb +28 -31
  51. data/lib/phony/national_code.rb +7 -10
  52. data/lib/phony/national_splitters/default.rb +9 -11
  53. data/lib/phony/national_splitters/dsl.rb +8 -18
  54. data/lib/phony/national_splitters/fixed.rb +11 -14
  55. data/lib/phony/national_splitters/none.rb +7 -11
  56. data/lib/phony/national_splitters/regex.rb +13 -17
  57. data/lib/phony/national_splitters/variable.rb +36 -38
  58. data/lib/phony/trunk_code.rb +16 -18
  59. data/lib/phony/vanity.rb +12 -13
  60. data/lib/phony.rb +84 -84
  61. metadata +5 -39
  62. data/spec/functional/config_spec.rb +0 -44
  63. data/spec/functional/plausibility_spec.rb +0 -689
  64. data/spec/lib/phony/countries_spec.rb +0 -1460
  65. data/spec/lib/phony/country_codes_spec.rb +0 -227
  66. data/spec/lib/phony/country_spec.rb +0 -104
  67. data/spec/lib/phony/dsl_spec.rb +0 -28
  68. data/spec/lib/phony/local_splitters/fixed_spec.rb +0 -56
  69. data/spec/lib/phony/local_splitters/regex_spec.rb +0 -94
  70. data/spec/lib/phony/national_code_spec.rb +0 -61
  71. data/spec/lib/phony/national_splitters/default_spec.rb +0 -34
  72. data/spec/lib/phony/national_splitters/fixed_spec.rb +0 -45
  73. data/spec/lib/phony/national_splitters/none_spec.rb +0 -28
  74. data/spec/lib/phony/national_splitters/regex_spec.rb +0 -23
  75. data/spec/lib/phony/national_splitters/variable_spec.rb +0 -35
  76. data/spec/lib/phony/trunk_code_spec.rb +0 -85
  77. data/spec/lib/phony/vanity_spec.rb +0 -30
  78. data/spec/lib/phony_spec.rb +0 -70
@@ -7,24 +7,28 @@
7
7
  Phony.define do
8
8
  country '382',
9
9
  trunk('0') |
10
- one_of(%w(80)) >> split(3,3) | # freephone
11
- one_of(%w(20 30 31 40 52)) >> matched_split(
12
- /\A\d{5}\z/ => [3,2],
13
- /\A\d+\z/ => [3,3]) |
14
- one_of(%w(32 33 50 51)) >> split(3,3) |
15
- one_of(%w(77)) >> split(3,3) | # national geographic
16
- one_of(%w(78)) >> split(3,3) | # VoIP telephony
17
- one_of(%w(88)) >> split(3,3) | # shared cost
18
- one_of(%w(94 95)) >> split(3,3) | # premium rate
19
- one_of(%w(63 67 69 70)) >> matched_split(
20
- /\A\d{3}\z/ => [3],
21
- /\A\d{6}\z/ => [3,3],
22
- /\A\d+\z/ => [3,3,4]) | # mobile, voicemail (mobile
23
- one_of(%w(68)) >> matched_split(
24
- /\A\d{2}\z/ => [2],
25
- /\A\d{6}\z/ => [3,3],
26
- /\A\d+\z/ => [2,4,4]) | # voicemail (mobile)
27
- fixed(2) >> matched_split(
28
- /\A\d{5}\z/ => [3,2],
29
- /\A\d+\z/ => [3,3])
10
+ one_of(%w[80]) >> split(3, 3) | # freephone
11
+ one_of(%w[20 30 31 40 52]) >> matched_split(
12
+ /\A\d{5}\z/ => [3, 2],
13
+ /\A\d+\z/ => [3, 3]
14
+ ) |
15
+ one_of(%w[32 33 50 51]) >> split(3, 3) |
16
+ one_of(%w[77]) >> split(3, 3) | # national geographic
17
+ one_of(%w[78]) >> split(3, 3) | # VoIP telephony
18
+ one_of(%w[88]) >> split(3, 3) | # shared cost
19
+ one_of(%w[94 95]) >> split(3, 3) | # premium rate
20
+ one_of(%w[63 67 69 70]) >> matched_split(
21
+ /\A\d{3}\z/ => [3],
22
+ /\A\d{6}\z/ => [3, 3],
23
+ /\A\d+\z/ => [3, 3, 4]
24
+ ) | # mobile, voicemail (mobile
25
+ one_of(%w[68]) >> matched_split(
26
+ /\A\d{2}\z/ => [2],
27
+ /\A\d{6}\z/ => [3, 3],
28
+ /\A\d+\z/ => [2, 4, 4]
29
+ ) | # voicemail (mobile)
30
+ fixed(2) >> matched_split(
31
+ /\A\d{5}\z/ => [3, 2],
32
+ /\A\d+\z/ => [3, 3]
33
+ )
30
34
  end
@@ -6,50 +6,50 @@
6
6
  # except for ANEE SAKHAN area, Yangon ZTE GSM, MEC Tel CDMA 800 Mhz which are
7
7
  # not correctly handled by the google library
8
8
 
9
- area_codes = [
10
- '1',
11
- '2',
12
- '42',
13
- '43',
14
- '44',
15
- '45',
16
- '46',
17
- '52',
18
- '53',
19
- '54',
20
- '57',
21
- '58',
22
- '59',
23
- '61',
24
- '62',
25
- '64',
26
- '65',
27
- '66',
28
- '67',
29
- '69',
30
- '70',
31
- '71',
32
- '72',
33
- '73',
34
- '75',
35
- '81',
36
- '82',
37
- '83',
38
- '84',
39
- '85',
40
- '86'
9
+ area_codes = %w[
10
+ 1
11
+ 2
12
+ 42
13
+ 43
14
+ 44
15
+ 45
16
+ 46
17
+ 52
18
+ 53
19
+ 54
20
+ 57
21
+ 58
22
+ 59
23
+ 61
24
+ 62
25
+ 64
26
+ 65
27
+ 66
28
+ 67
29
+ 69
30
+ 70
31
+ 71
32
+ 72
33
+ 73
34
+ 75
35
+ 81
36
+ 82
37
+ 83
38
+ 84
39
+ 85
40
+ 86
41
41
  ]
42
42
 
43
43
  Phony.define do
44
44
  country '95',
45
45
  one_of(area_codes) >> matched_split(
46
- /\A\d{5}\z/ => [2,3],
47
- /\A\d{6}\z/ => [3,3],
48
- /\A\d{7}\z/ => [3,4]
46
+ /\A\d{5}\z/ => [2, 3],
47
+ /\A\d{6}\z/ => [3, 3],
48
+ /\A\d{7}\z/ => [3, 4]
49
49
  ) |
50
- one_of('9') >> matched_split( # mobile operators
51
- /\A\d{7}\z/ => [3,4],
52
- /\A\d{8}\z/ => [4,4],
53
- /\A\d{9}\z/ => [3,3,3]
50
+ one_of('9') >> matched_split( # mobile operators
51
+ /\A\d{7}\z/ => [3, 4],
52
+ /\A\d{8}\z/ => [4, 4],
53
+ /\A\d{9}\z/ => [3, 3, 3]
54
54
  )
55
55
  end
@@ -6,32 +6,38 @@
6
6
 
7
7
  Phony.define do
8
8
  country '264',
9
- one_of(%w(632532)) >> split(4) |
10
- one_of(%w(6342)) >> matched_split(
11
- /\A\d{3}\z/ => [3],
12
- /\A\d+\z/ => [3,3]) |
13
- one_of(%w(6362 6638)) >> split(4) |
14
- one_of(%w(6642)) >> matched_split(
15
- /\A\d{4}\z/ => [4],
16
- /\A\d+\z/ => [3,3]) |
17
- one_of(%w(6751)) >> split(3,2) |
18
- one_of(%w(628)) >> split(4) |
19
- one_of(%w(658)) >> split(5) |
20
- one_of(%w(668)) >> matched_split(
21
- /\A\d{4}\z/ => [4],
22
- /\A\d{5}\z/ => [3,2],
23
- /\A\d+\z/ => [3,3]) |
24
- one_of(%w(61 63 64 65 67)) >> matched_split(
25
- /\A\d{6}\z/ => [3,3],
26
- /\A\d+\z/ => [3,3,3]) |
27
- one_of(%w(66)) >> matched_split(
28
- /\A\d{4}\z/ => [4],
29
- /\A\d+\z/ => [3,3]) |
30
- one_of(%w(62)) >> split(3,3) |
31
- one_of(%w(67)) >> matched_split(
32
- /\A\d{6}\z/ => [3,3],
33
- /\A\d{7}\z/ => [4,3],
34
- /\A\d+\z/ => [3,3,3]) |
35
- one_of(%w(60 81 82 83 85)) >> split(4,3) |
36
- fixed(2) >> split(3,3)
37
- end
9
+ one_of(%w[632532]) >> split(4) |
10
+ one_of(%w[6342]) >> matched_split(
11
+ /\A\d{3}\z/ => [3],
12
+ /\A\d+\z/ => [3, 3]
13
+ ) |
14
+ one_of(%w[6362 6638]) >> split(4) |
15
+ one_of(%w[6642]) >> matched_split(
16
+ /\A\d{4}\z/ => [4],
17
+ /\A\d+\z/ => [3, 3]
18
+ ) |
19
+ one_of(%w[6751]) >> split(3, 2) |
20
+ one_of(%w[628]) >> split(4) |
21
+ one_of(%w[658]) >> split(5) |
22
+ one_of(%w[668]) >> matched_split(
23
+ /\A\d{4}\z/ => [4],
24
+ /\A\d{5}\z/ => [3, 2],
25
+ /\A\d+\z/ => [3, 3]
26
+ ) |
27
+ one_of(%w[61 63 64 65 67]) >> matched_split(
28
+ /\A\d{6}\z/ => [3, 3],
29
+ /\A\d+\z/ => [3, 3, 3]
30
+ ) |
31
+ one_of(%w[66]) >> matched_split(
32
+ /\A\d{4}\z/ => [4],
33
+ /\A\d+\z/ => [3, 3]
34
+ ) |
35
+ one_of(%w[62]) >> split(3, 3) |
36
+ one_of(%w[67]) >> matched_split(
37
+ /\A\d{6}\z/ => [3, 3],
38
+ /\A\d{7}\z/ => [4, 3],
39
+ /\A\d+\z/ => [3, 3, 3]
40
+ ) |
41
+ one_of(%w[60 81 82 83 85]) >> split(4, 3) |
42
+ fixed(2) >> split(3, 3)
43
+ end
@@ -4,70 +4,68 @@
4
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
5
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=NP
6
6
 
7
- ndcs_with_7_subscriber_digits = %w(1)
7
+ ndcs_with_7_subscriber_digits = %w[1]
8
8
 
9
- ndcs_with_6_subscriber_digits = %w(
10
- 10
11
- 11
12
- 21
13
- 23
14
- 24
15
- 25
16
- 26
17
- 27
18
- 29
19
- 31
20
- 33
21
- 35
22
- 36
23
- 37
24
- 38
25
- 41
26
- 44
27
- 46
28
- 47
29
- 49
30
- 51
31
- 53
32
- 55
33
- 56
34
- 57
35
- 61
36
- 63
37
- 64
38
- 66
39
- 67
40
- 68
41
- 69
42
- 71
43
- 75
44
- 76
45
- 77
46
- 78
47
- 79
48
- 81
49
- 82
50
- 83
51
- 84
52
- 86
53
- 87
54
- 89
55
- 91
56
- 92
57
- 93
58
- 94
59
- 95
60
- 96
61
- 97
62
- 99
63
- )
9
+ ndcs_with_6_subscriber_digits = %w[
10
+ 10
11
+ 11
12
+ 21
13
+ 23
14
+ 24
15
+ 25
16
+ 26
17
+ 27
18
+ 29
19
+ 31
20
+ 33
21
+ 35
22
+ 36
23
+ 37
24
+ 38
25
+ 41
26
+ 44
27
+ 46
28
+ 47
29
+ 49
30
+ 51
31
+ 53
32
+ 55
33
+ 56
34
+ 57
35
+ 61
36
+ 63
37
+ 64
38
+ 66
39
+ 67
40
+ 68
41
+ 69
42
+ 71
43
+ 75
44
+ 76
45
+ 77
46
+ 78
47
+ 79
48
+ 81
49
+ 82
50
+ 83
51
+ 84
52
+ 86
53
+ 87
54
+ 89
55
+ 91
56
+ 92
57
+ 93
58
+ 94
59
+ 95
60
+ 96
61
+ 97
62
+ 99
63
+ ]
64
64
 
65
65
  Phony.define do
66
66
  country '977',
67
- one_of(ndcs_with_6_subscriber_digits) >> split(3,3) |
68
- one_of(%w(98)) >> split(4,4) | # mobile
69
- one_of(ndcs_with_7_subscriber_digits) >> split(3,4) |
70
- fixed(2) >> split(3,3)
67
+ one_of(ndcs_with_6_subscriber_digits) >> split(3, 3) |
68
+ one_of(%w[98]) >> split(4, 4) | # mobile
69
+ one_of(ndcs_with_7_subscriber_digits) >> split(3, 4) |
70
+ fixed(2) >> split(3, 3)
71
71
  end
72
-
73
-
@@ -37,15 +37,15 @@ ndcs = [
37
37
  '76', # Breda
38
38
  '77', # Venlo
39
39
  '78', # Dordrecht
40
- '79', # Zoetermeer
41
- ]
40
+ '79' # Zoetermeer
41
+ ]
42
42
 
43
43
  service = [
44
44
  '84', # Persoonlijke-assistentdiensten, zoals voicemail en faxmail
45
45
  '85', # Plaatsonafhankelijk netnummer
46
46
  '87', # Both of the above.
47
47
  '88', # Bedrijfsnummers
48
- '91', # Plaatsonafhankelijk netnummer
48
+ '91' # Plaatsonafhankelijk netnummer
49
49
  ]
50
50
 
51
51
  service3 = [
@@ -53,17 +53,17 @@ service3 = [
53
53
  '800', # Gratis informatienummers
54
54
  '900', # Betaalde informatienummers
55
55
  '906', # Betaalde informatienummers
56
- '909', # Betaalde informatienummers
57
- ]
56
+ '909' # Betaalde informatienummers
57
+ ]
58
58
 
59
59
  Phony.define do
60
60
  country '31',
61
- trunk('0', :normalize => true) |
62
- match(/\A(97[0,9])\d{8}\z/) >> split(4,4) | # machine-to-machine
63
- one_of(service) >> split(4,3) |
64
- match(/\A(800|900)\d{4}\z/) >> split(4) |
65
- one_of(service3) >> split(4,3) |
66
- one_of('6') >> split(2,2,2,2) | # mobile
67
- one_of(ndcs) >> split(3,4) | # landline (geographic region)
68
- fixed(3) >> split(3,3) # 3 digit ndc
61
+ trunk('0', normalize: true) |
62
+ match(/\A(97[0,9])\d{8}\z/) >> split(4, 4) | # machine-to-machine
63
+ one_of(service) >> split(4, 3) |
64
+ match(/\A(800|900)\d{4}\z/) >> split(4) |
65
+ one_of(service3) >> split(4, 3) |
66
+ one_of('6') >> split(2, 2, 2, 2) | # mobile
67
+ one_of(ndcs) >> split(3, 4) | # landline (geographic region)
68
+ fixed(3) >> split(3, 3) # 3 digit ndc
69
69
  end
@@ -3,119 +3,143 @@
3
3
  # Pakistan (Islamic Republic of)
4
4
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=PK
5
5
 
6
- ndcs_with_8_subscriber_numbers = %w(21 42 58)
6
+ ndcs_mobile_plan = %w[30 31 32 33 34 35 36]
7
7
 
8
- ndcs_with_7_subscriber_numbers = %w(
9
- 22
10
- 25
11
- 40
12
- 41
13
- 44
14
- 46
15
- 47
16
- 48
17
- 49
18
- 51
19
- 52
20
- 53
21
- 55
22
- 56
23
- 57
24
- 61
25
- 62
26
- 63
27
- 64
28
- 65
29
- 66
30
- 67
31
- 68
32
- 71
33
- 74
34
- 81
35
- 86
36
- 91
37
- )
8
+ ndcs_with_8_subscriber_numbers = %w[21 42]
38
9
 
39
- ndcs_with_6_subscriber_numbers = %w(
40
- 232
41
- 233
42
- 235
43
- 238
44
- 242
45
- 243
46
- 244
47
- 297
48
- 298
49
- 453
50
- 454
51
- 457
52
- 459
53
- 542
54
- 543
55
- 544
56
- 546
57
- 547
58
- 604
59
- 606
60
- 608
61
- 722
62
- 723
63
- 726
64
- 822
65
- 823
66
- 824
67
- 825
68
- 826
69
- 828
70
- 829
71
- 832
72
- 833
73
- 835
74
- 837
75
- 838
76
- 843
77
- 844
78
- 847
79
- 848
80
- 852
81
- 853
82
- 855
83
- 856
84
- 922
85
- 923
86
- 924
87
- 925
88
- 926
89
- 927
90
- 928
91
- 932
92
- 937
93
- 938
94
- 939
95
- 942
96
- 943
97
- 944
98
- 945
99
- 946
100
- 963
101
- 965
102
- 966
103
- 969
104
- 992
105
- 995
106
- 996
107
- 997
108
- 998
109
- )
10
+ ndcs_with_7_subscriber_numbers = %w[
11
+ 22
12
+ 25
13
+ 40
14
+ 41
15
+ 44
16
+ 46
17
+ 47
18
+ 48
19
+ 49
20
+ 51
21
+ 52
22
+ 53
23
+ 55
24
+ 56
25
+ 57
26
+ 61
27
+ 62
28
+ 63
29
+ 64
30
+ 65
31
+ 66
32
+ 67
33
+ 68
34
+ 71
35
+ 74
36
+ 81
37
+ 86
38
+ 91
39
+ ]
110
40
 
111
- Phony.define do
41
+ ndcs_with_6_subscriber_numbers = %w[
42
+ 232
43
+ 233
44
+ 235
45
+ 238
46
+ 242
47
+ 243
48
+ 244
49
+ 297
50
+ 298
51
+ 453
52
+ 454
53
+ 457
54
+ 459
55
+ 542
56
+ 543
57
+ 544
58
+ 546
59
+ 547
60
+ 604
61
+ 606
62
+ 608
63
+ 722
64
+ 723
65
+ 726
66
+ 822
67
+ 823
68
+ 824
69
+ 825
70
+ 826
71
+ 828
72
+ 829
73
+ 832
74
+ 833
75
+ 835
76
+ 837
77
+ 838
78
+ 843
79
+ 844
80
+ 847
81
+ 848
82
+ 852
83
+ 853
84
+ 855
85
+ 856
86
+ 922
87
+ 923
88
+ 924
89
+ 925
90
+ 926
91
+ 927
92
+ 928
93
+ 932
94
+ 937
95
+ 938
96
+ 939
97
+ 942
98
+ 943
99
+ 944
100
+ 945
101
+ 946
102
+ 963
103
+ 965
104
+ 966
105
+ 969
106
+ 992
107
+ 995
108
+ 996
109
+ 997
110
+ 998
111
+ 5811
112
+ 5812
113
+ 5813
114
+ 5814
115
+ 5815
116
+ 5816
117
+ 5817
118
+ 5821
119
+ 5822
120
+ 5823
121
+ 5824
122
+ 5825
123
+ 5826
124
+ 2827
125
+ 5828
126
+ ]
112
127
 
128
+ Phony.define do
113
129
  country '92',
114
- one_of(ndcs_with_6_subscriber_numbers) >> split(3,3) |
115
- one_of('111') >> split(3,3) | # universal access number
116
- one_of(ndcs_with_7_subscriber_numbers) >> split(4,3) |
117
- one_of(ndcs_with_8_subscriber_numbers) >> split(4,4) |
118
- one_of(%w(30 31 32 33 34 35 36)) >> split(4,4) | # mobile
119
- fixed(2) >> split(4,4)
120
-
130
+ one_of('111') >> split(3, 3) | # UAN without NDC |
131
+ one_of(ndcs_with_6_subscriber_numbers) >> matched_split(
132
+ /^(111)\d{6}$/ => [3, 3, 3], # UAN - always 6 digits
133
+ /^\d{6}$/ => [3, 3]
134
+ ) |
135
+ one_of(ndcs_with_7_subscriber_numbers) >> matched_split(
136
+ /^(111)\d{6}$/ => [3, 3, 3], # UAN - always 6 digits
137
+ /^\d{7}$/ => [4, 3]
138
+ ) |
139
+ one_of(ndcs_with_8_subscriber_numbers) >> matched_split(
140
+ /^(111)\d{6}$/ => [3, 3, 3], # UAN - always 6 digits
141
+ /^\d{8}$/ => [4, 4]
142
+ ) |
143
+ one_of(ndcs_mobile_plan) >> split(4, 4) | # mobile
144
+ fixed(2) >> split(4, 4)
121
145
  end