phony 1.2.11 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README.textile +1 -1
  2. data/lib/countries.rb +385 -0
  3. data/lib/phony.rb +11 -9
  4. data/lib/phony/countries.rb +1 -0
  5. data/lib/phony/countries/austria.rb +68 -67
  6. data/lib/phony/countries/belgium.rb +29 -57
  7. data/lib/phony/countries/chile.rb +5 -12
  8. data/lib/phony/countries/china.rb +21 -20
  9. data/lib/phony/countries/egypt.rb +12 -37
  10. data/lib/phony/countries/germany.rb +39 -36
  11. data/lib/phony/countries/greece.rb +21 -25
  12. data/lib/phony/countries/hungary.rb +6 -19
  13. data/lib/phony/countries/italy.rb +174 -152
  14. data/lib/phony/countries/malaysia.rb +17 -17
  15. data/lib/phony/countries/netherlands.rb +50 -52
  16. data/lib/phony/countries/romania.rb +28 -27
  17. data/lib/phony/countries/south_korea.rb +11 -11
  18. data/lib/phony/countries/sweden.rb +49 -49
  19. data/lib/phony/countries/united_kingdom.rb +4 -4
  20. data/lib/phony/country.rb +14 -80
  21. data/lib/phony/country_codes.rb +23 -3
  22. data/lib/phony/dsl.rb +78 -0
  23. data/lib/phony/national_code.rb +2 -5
  24. data/lib/phony/national_splitters/dsl.rb +20 -0
  25. data/lib/phony/national_splitters/fixed.rb +1 -1
  26. data/lib/phony/national_splitters/none.rb +1 -1
  27. data/lib/phony/national_splitters/regex.rb +49 -0
  28. data/lib/phony/national_splitters/variable.rb +6 -6
  29. data/lib/phony/vanity.rb +3 -0
  30. data/spec/lib/phony/country_codes_spec.rb +1 -1
  31. data/spec/lib/phony/country_spec.rb +12 -45
  32. data/spec/lib/phony/local_splitters/fixed_spec.rb +8 -0
  33. data/spec/lib/phony/national_code_spec.rb +13 -0
  34. data/spec/lib/phony/national_splitters/regex_spec.rb +23 -0
  35. data/spec/lib/phony/national_splitters/variable_spec.rb +2 -4
  36. data/spec/lib/phony_spec.rb +44 -4
  37. metadata +9 -21
  38. data/lib/phony/countries/all_other.rb +0 -455
  39. data/lib/phony/countries/norway.rb +0 -11
  40. data/lib/phony/countries/peru.rb +0 -19
  41. data/lib/phony/countries/portugal.rb +0 -16
  42. data/lib/phony/national_splitters/experimental.rb +0 -17
  43. data/spec/lib/phony/countries/austria_spec.rb +0 -24
  44. data/spec/lib/phony/countries/belgium_spec.rb +0 -33
  45. data/spec/lib/phony/countries/egypt_spec.rb +0 -18
  46. data/spec/lib/phony/countries/greece_spec.rb +0 -18
  47. data/spec/lib/phony/countries/portugal_spec.rb +0 -21
  48. data/spec/lib/phony/countries/switzerland_spec.rb +0 -18
  49. data/spec/lib/phony/countries/united_kingdom_spec.rb +0 -50
data/README.textile CHANGED
@@ -7,7 +7,7 @@ This gem can normalize, format and split E164 numbers.
7
7
 
8
8
  The (admittedly crazy) *goal* of this Gem is to be able to format/split all phone numbers in the world.
9
9
 
10
- Currently handles Afghan, Austrian, Australian, Belgian, Brazilian, Chilean, Chinese, Czech, Danish, Dutch, Egyptian, French, German, Greek, Hungarian, Italian, Malaysian, (The) Netherlands, New Zealand, Norwegian, Peruvian, Polish, Russian, Romanian, South African, South Korean, Spanish, Swedish, Swiss, Turkish, Liechtenstein, UK, US, and Venezuelan numbers.
10
+ Currently handles Afghan, Algerian, Austrian, Australian, Belgian, Brazilian, Chilean, Chinese, Cuban, Czech, Danish, Dutch, Egyptian, French, German, Greek, Hungarian, Italian, Malaysian, Mexican, (The) Netherlands, New Zealand, Norwegian, Peruvian, Polish, Russian, Romanian, South African, South Korean, Spanish, Swedish, Swiss, Tunisian, Turkish, Liechtenstein, UK, US, and Venezuelan numbers.
11
11
  And to some extent, all others. Just try if it works for you.
12
12
 
13
13
  If it doesn't, please "enter an issue":http://github.com/floere/phony/issues.
data/lib/countries.rb ADDED
@@ -0,0 +1,385 @@
1
+ include Phony::DSL
2
+
3
+ # All countries, ordered by country code.
4
+ #
5
+ # Available matching/splitting methods:
6
+ # * fixed: Always splits off a fixed length ndc. (Always use last in a | chain)
7
+ # * none: Does not have a national destination code, e.g. Denmark, Iceland.
8
+ # * one_of: Matches one of the following numbers. Splits if it does.
9
+ # Options:
10
+ # * max_length: Will try to match up to length max_length, then stop.
11
+ # (Only use one_of with this option when last in a | chain)
12
+ # * match: Try to match the regex, and if it matches, splits it off.
13
+ # Options:
14
+ # * on_fail_take: If it does not match, take n digits, then stop.
15
+ # (When you use this option, match must be last in a | chain)
16
+ #
17
+ # For the national number part, there are two:
18
+ # * split: Use this number group splitting.
19
+ # * matched_split: Give a hash of regex => format array, with a :fallback => format option.
20
+ # (See Norway how it looks.)
21
+ #
22
+
23
+ country '0', fixed(1) >> split(10) # Reserved.
24
+ country '1', fixed(3) >> split(3,4) # USA, Canada, etc.
25
+ country '7', fixed(3) >> split(3,2,2) # Kazakhstan (Republic of) & Russian Federation
26
+
27
+ country '20', one_of('800') >> split(7) | # Egypt
28
+ one_of('2', '3', :max_length => 2) >> split(8) # Cairo/Giza, Alexandria
29
+ # :mobile? => /^10|11|12|14|16|17|18|19*$/, :service? => /^800.*$/
30
+ country '27', fixed(2) >> split(3,4) # South Africa
31
+
32
+ country '30', Phony::Countries::Greece
33
+ country '31', Phony::Countries::Netherlands
34
+ country '32', Phony::Countries::Belgium
35
+ country '33', fixed(1) >> split(2,2,2,2) # :service? => /^8.*$/, :mobile? => /^[67].*$/ # France
36
+ country '34', fixed(2) >> split(3,4) # Spain
37
+ country '36', Phony::Countries::Hungary
38
+ country '39', Phony::Countries::Italy
39
+
40
+ country '40', Phony::Countries::Romania
41
+ # :service => %w{800 840 842 844 848}, :mobile => %w{74 76 77 78 79}
42
+ swiss_service_regex = /^(800|840|842|844|848)\d+$/
43
+ country '41', match(swiss_service_regex) >> split(3,3) | # Switzerland
44
+ fixed(2) >> split(3,2,2)
45
+ country '43', Phony::Countries::Austria
46
+ country '44', Phony::Countries::UnitedKingdom
47
+ country '45', none >> split(2,2,2,2) # Denmark
48
+ country '46', Phony::Countries::Sweden
49
+ country '47', # Norway
50
+ none >> matched_split(/^[1].*$/ => [3], /^[489].*$/ => [3,2,3], :fallback => [2,2,2,2])
51
+ # Poland (Republic of)
52
+ # Although the NDCs are 2 digits, the representation is 3 digits.
53
+ # Note: http://wapedia.mobi/en/Telephone_numbers_in_Poland, mobile not yet correct
54
+ #
55
+ country '48', fixed(3) >> split(3,3) # Poland
56
+ country '49', Phony::Countries::Germany
57
+
58
+ country '51', one_of('103', '105') >> split(3,3) | # Peru
59
+ one_of('1', '9', :max_length => 2) >> split(4,4) # Lima and mobile.
60
+ country '52', match(/^(0\d{2})\d+$/) >> split(2,2,2,2) | # Mexico
61
+ match(/^(33|55|81)\d+$/) >> split(2,2,2,2) |
62
+ match(/^(\d{3})\d+$/) >> split(3,2,2)
63
+ country '53', match(/^(5\d{3})\d+$/) >> split(4) | # Cuba. Mobile.
64
+ match(/^(7|21|22|23|4[1-8]|3[1-3])/, :on_fail_take => 3) >> split(7)
65
+ country '54', fixed(2) >> split(3,2,2) # TODO Argentine Republic
66
+ brazilian_service = /^(100|128|190|191|192|193|194|197|198|199)\d+$/
67
+ country '55', match(brazilian_service) >> split(3,3) | # Brazil (Federative Republic of)
68
+ fixed(2) >> split(4,4)
69
+ # :service? => brazilian_service, :mobile? => ?
70
+ # http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
71
+ country '56', Phony::Countries::Chile
72
+ country '57', fixed(2) >> split(3,2,2) # TODO Colombia
73
+ country '58', fixed(3) >> split(7) # Venezuela (Bolivarian Republic of)
74
+
75
+ country '60', Phony::Countries::Malaysia
76
+ country '61', fixed(1) >> split(4,4) # Australia
77
+ country '62', fixed(2) >> split(3,2,2) # TODO Indonesia (Republic of)
78
+ country '63', fixed(2) >> split(3,2,2) # TODO Philippines (Republic of the)
79
+ country '64', fixed(1) >> split(3,4) # New Zealand
80
+ country '65', fixed(2) >> split(3,2,2) # TODO Singapore (Republic of)
81
+ country '66', fixed(2) >> split(3,2,2) # TODO Thailand
82
+
83
+ country '81', fixed(2) >> split(3,2,2) # TODO Japan
84
+ country '82', Phony::Countries::SouthKorea
85
+ country '84', fixed(2) >> split(3,2,2) # TODO Viet Nam (Socialist Republic of)
86
+ country '86', Phony::Countries::China
87
+
88
+ country '90', fixed(3) >> split(3,4) # Turkey. Wiki says 7, but the examples say 3, 4.
89
+ country '91', fixed(2) >> split(3,2,2) # TODO India (Republic of)
90
+ country '92', fixed(2) >> split(3,2,2) # TODO Pakistan (Islamic Republic of), http://en.wikipedia.org/wiki/Telephone_numbers_in_Pakistan, NDC 2-5
91
+ country '93', fixed(2) >> split(7) # Afghanistan. Note: the document says 6, but the examples use 7. http://www.wtng.info/wtng-93-af.html
92
+
93
+ country '94', fixed(2) >> split(3,2,2) # TODO Sri Lanka (Democratic Socialist Republic of)
94
+ country '95', fixed(2) >> split(3,2,2) # TODO Myanmar (Union of)
95
+ country '98', fixed(2) >> split(3,2,2) # TODO Iran (Islamic Republic of)
96
+
97
+ country '210', fixed(2) >> split(3,2,2) # -
98
+ country '211', fixed(2) >> split(3,2,2) # -
99
+ country '212', fixed(2) >> split(3,2,2) # Morocco
100
+ country '213', fixed(2) >> split(3,4) # Algeria
101
+ country '214', fixed(2) >> split(3,2,2) # -
102
+ country '215', fixed(2) >> split(3,2,2) # -
103
+ country '216', fixed(1) >> split(3,4) # Tunisia
104
+ country '217', fixed(2) >> split(3,2,2) # -
105
+ country '218', fixed(2) >> split(3,2,2) # Lybia
106
+ country '219', fixed(2) >> split(3,2,2) # -
107
+
108
+ # TODO From here on.
109
+
110
+ country '220', fixed(2) >> split(3,2,2) # Gambia
111
+ country '221', fixed(2) >> split(3,2,2) # Senegal
112
+ country '222', fixed(2) >> split(3,2,2) # Mauritania
113
+ country '223', fixed(2) >> split(3,2,2) # Mali
114
+ country '224', fixed(2) >> split(3,2,2) # Guinea
115
+ country '225', fixed(2) >> split(3,2,2) # Côte d'Ivoire
116
+ country '226', fixed(2) >> split(3,2,2) # Burkina Faso
117
+ country '227', fixed(2) >> split(3,2,2) # Niger
118
+ country '228', fixed(2) >> split(3,2,2) # Togolese Republic
119
+ country '229', fixed(2) >> split(3,2,2) # Benin
120
+
121
+ country '230', fixed(2) >> split(3,2,2) # Mauritius
122
+ country '231', fixed(2) >> split(3,2,2) # Liberia
123
+ country '232', fixed(2) >> split(3,2,2) # Sierra Leone
124
+ country '233', fixed(2) >> split(3,2,2) # Ghana
125
+ country '234', fixed(2) >> split(3,2,2) # Nigeria
126
+ country '235', fixed(2) >> split(3,2,2) # Chad
127
+ country '236', fixed(2) >> split(3,2,2) # Central African Republic
128
+ country '237', fixed(2) >> split(3,2,2) # Cameroon
129
+ country '238', fixed(2) >> split(3,2,2) # Cape Verde
130
+ country '239', fixed(2) >> split(3,2,2) # Sao Tome and Principe
131
+
132
+ country '240', fixed(2) >> split(3,2,2) # Equatorial Guinea
133
+ country '241', fixed(2) >> split(3,2,2) # Gabonese Republic
134
+ country '242', fixed(2) >> split(3,2,2) # Congo
135
+ country '243', fixed(2) >> split(3,2,2) # Democratic Republic of the Congo
136
+ country '244', fixed(2) >> split(3,2,2) # Angola
137
+ country '245', fixed(2) >> split(3,2,2) # Guinea-Bissau
138
+ country '246', fixed(2) >> split(3,2,2) # Diego Garcia
139
+ country '247', fixed(2) >> split(3,2,2) # Ascension
140
+ country '248', fixed(2) >> split(3,2,2) # Seychelles
141
+ country '249', fixed(2) >> split(3,2,2) # Sudan
142
+
143
+ country '250', fixed(2) >> split(3,2,2) # Rwanda
144
+ country '251', fixed(2) >> split(3,2,2) # Ethiopia
145
+ country '252', fixed(2) >> split(3,2,2) # Somali Democratic Republic
146
+ country '253', fixed(2) >> split(3,2,2) # Djibouti
147
+ country '254', fixed(2) >> split(3,2,2) # Kenya
148
+ country '255', fixed(2) >> split(3,2,2) # Tanzania
149
+ country '256', fixed(2) >> split(3,2,2) # Uganda
150
+ country '257', fixed(2) >> split(3,2,2) # Burundi
151
+ country '258', fixed(2) >> split(3,2,2) # Mozambique
152
+ country '259', fixed(2) >> split(3,2,2) # -
153
+
154
+ country '260', fixed(2) >> split(3,2,2) # Zambia
155
+ country '261', fixed(2) >> split(3,2,2) # Madagascar
156
+ country '262', fixed(3) >> split(3,2,2) # Reunion / Mayotte (new)
157
+ country '263', fixed(2) >> split(3,2,2) # Zimbabwe
158
+ country '264', fixed(2) >> split(3,2,2) # Namibia
159
+ country '265', fixed(2) >> split(3,2,2) # Malawi
160
+ country '266', fixed(2) >> split(3,2,2) # Lesotho
161
+ country '267', fixed(2) >> split(3,2,2) # Botswana
162
+ country '268', fixed(2) >> split(3,2,2) # Swaziland
163
+ country '269', fixed(2) >> split(3,2,2) # Comoros
164
+
165
+ country '280', fixed(2) >> split(3,2,2) # -
166
+ country '281', fixed(2) >> split(3,2,2) # -
167
+ country '282', fixed(2) >> split(3,2,2) # -
168
+ country '283', fixed(2) >> split(3,2,2) # -
169
+ country '284', fixed(2) >> split(3,2,2) # -
170
+ country '285', fixed(2) >> split(3,2,2) # -
171
+ country '286', fixed(2) >> split(3,2,2) # -
172
+ country '287', fixed(2) >> split(3,2,2) # -
173
+ country '288', fixed(2) >> split(3,2,2) # -
174
+ country '289', fixed(2) >> split(3,2,2) # -
175
+ country '290', fixed(2) >> split(3,2,2) # Saint Helena
176
+
177
+ country '291', fixed(2) >> split(3,2,2) # Eritrea
178
+ country '292', fixed(2) >> split(3,2,2) # -
179
+ country '293', fixed(2) >> split(3,2,2) # -
180
+ country '294', fixed(2) >> split(3,2,2) # -
181
+ country '295', fixed(2) >> split(3,2,2) # -
182
+ country '296', fixed(2) >> split(3,2,2) # -
183
+ country '297', fixed(2) >> split(3,2,2) # Aruba
184
+ country '298', fixed(2) >> split(3,2,2) # Faroe Islands
185
+ country '299', fixed(2) >> split(3,2,2) # Greenland
186
+
187
+ country '350', fixed(2) >> split(3,2,2) # Gibraltar
188
+ country '351', one_of('700', '800') >> split(3,3) | # Portugal
189
+ match(/^(9\d)\d+$/) >> split(3,4) | # mobile
190
+ one_of('21', '22', :max_length => 3) >> split(3,4) # Lisboa & Porto
191
+ country '352', fixed(2) >> split(3,2,2) # Luxembourg
192
+ country '353', fixed(2) >> split(3,2,2) # Ireland (0-3-4)
193
+ country '354', none >> split(3,4) # Iceland
194
+ country '355', fixed(2) >> split(3,2,2) # Albania
195
+ country '356', fixed(2) >> split(3,2,2) # Malta
196
+ country '357', fixed(2) >> split(3,2,2) # Cyprus
197
+ country '358', fixed(2) >> split(3,2,2) # Finland
198
+ country '359', fixed(2) >> split(3,2,2) # Bulgaria
199
+
200
+ country '370', fixed(2) >> split(3,2,2) # Lithuania
201
+ country '371', fixed(2) >> split(3,2,2) # Latvia
202
+ country '372', fixed(2) >> split(3,2,2) # Estonia
203
+ country '373', fixed(2) >> split(3,2,2) # Moldova
204
+ country '374', fixed(2) >> split(3,2,2) # Armenia
205
+ country '375', fixed(2) >> split(3,2,2) # Belarus
206
+ country '376', fixed(2) >> split(3,2,2) # Andorra
207
+ country '377', fixed(2) >> split(3,2,2) # Monaco
208
+ country '378', fixed(2) >> split(3,2,2) # San Marino
209
+ country '379', fixed(2) >> split(3,2,2) # Vatican City State
210
+
211
+ country '380', fixed(2) >> split(3,2,2) # Ukraine
212
+ country '381', fixed(2) >> split(3,2,2) # Serbia and Montenegro
213
+ country '382', fixed(2) >> split(3,2,2) # -
214
+ country '383', fixed(2) >> split(3,2,2) # -
215
+ country '384', fixed(2) >> split(3,2,2) # -
216
+ country '385', fixed(2) >> split(3,2,2) # Croatia
217
+ country '386', fixed(2) >> split(3,2,2) # Slovenia
218
+ country '387', fixed(2) >> split(3,2,2) # Bosnia and Herzegovina
219
+ country '388', fixed(2) >> split(3,2,2) # Group of countries, shared code
220
+ country '389', fixed(2) >> split(3,2,2) # The Former Yugoslav Republic of Macedonia
221
+
222
+ country '420', fixed(3) >> split(3,3) # Czech Republic
223
+ country '421', fixed(2) >> split(3,2,2) # Slovak Republic
224
+ country '422', fixed(2) >> split(3,2,2) # Spare code
225
+ country '423', none >> split(3,2,2) # Liechtenstein (Principality of)
226
+ country '424', fixed(2) >> split(3,2,2) # -
227
+ country '425', fixed(2) >> split(3,2,2) # -
228
+ country '426', fixed(2) >> split(3,2,2) # -
229
+ country '427', fixed(2) >> split(3,2,2) # -
230
+ country '428', fixed(2) >> split(3,2,2) # -
231
+ country '429', fixed(2) >> split(3,2,2) # -
232
+
233
+ country '500', fixed(2) >> split(3,2,2) # Falkland Islands (Malvinas)
234
+ country '501', fixed(2) >> split(3,2,2) # Belize
235
+ country '502', fixed(2) >> split(3,2,2) # Guatemala (Republic of)
236
+ country '503', fixed(2) >> split(3,2,2) # El Salvador (Republic of)
237
+ country '504', fixed(2) >> split(3,2,2) # Honduras (Republic of)
238
+ country '505', fixed(2) >> split(3,2,2) # Nicaragua
239
+ country '506', fixed(2) >> split(3,2,2) # Costa Rica
240
+ country '507', fixed(2) >> split(3,2,2) # Panama (Republic of)
241
+ country '508', fixed(2) >> split(3,2,2) # Saint Pierre and Miquelon (Collectivité territoriale de la République française)
242
+ country '509', fixed(2) >> split(3,2,2) # Haiti (Republic of)
243
+
244
+ country '590', fixed(3) >> split(3,2,2) # Guadeloupe (French Department of)
245
+ country '591', fixed(2) >> split(3,2,2) # Bolivia (Republic of)
246
+ country '592', fixed(2) >> split(3,2,2) # Guyana
247
+ country '593', fixed(2) >> split(3,2,2) # Ecuador
248
+ country '594', fixed(3) >> split(3,2,2) # French Guiana (French Department of)
249
+ country '595', fixed(2) >> split(3,2,2) # Paraguay (Republic of)
250
+ country '596', fixed(3) >> split(3,2,2) # Martinique (French Department of)
251
+ country '597', fixed(2) >> split(3,2,2) # Suriname (Republic of)
252
+ country '598', fixed(2) >> split(3,2,2) # Uruguay (Eastern Republic of)
253
+ country '599', fixed(2) >> split(3,2,2) # Netherlands Antilles
254
+
255
+ country '670', fixed(2) >> split(3,2,2) # Democratic Republic of Timor-Leste
256
+ country '671', fixed(2) >> split(3,2,2) # Spare code
257
+ country '672', fixed(2) >> split(3,2,2) # Australian External Territories
258
+ country '673', fixed(2) >> split(3,2,2) # Brunei Darussalam
259
+ country '674', fixed(2) >> split(3,2,2) # Nauru (Republic of)
260
+ country '675', fixed(2) >> split(3,2,2) # Papua New Guinea
261
+ country '676', fixed(2) >> split(3,2,2) # Tonga (Kingdom of)
262
+ country '677', fixed(2) >> split(3,2,2) # Solomon Islands
263
+ country '678', fixed(2) >> split(3,2,2) # Vanuatu (Republic of)
264
+ country '679', fixed(2) >> split(3,2,2) # Fiji (Republic of)
265
+
266
+ country '680', fixed(2) >> split(3,2,2) # Palau (Republic of)
267
+ country '681', fixed(2) >> split(3,2,2) # Wallis and Futuna (Territoire français d'outre-mer)
268
+ country '682', fixed(2) >> split(3,2,2) # Cook Islands
269
+ country '683', fixed(2) >> split(3,2,2) # Niue
270
+ country '684', fixed(2) >> split(3,2,2) # -
271
+ country '685', fixed(2) >> split(3,2,2) # Samoa (Independent State of)
272
+ country '686', fixed(2) >> split(3,2,2) # Kiribati (Republic of)
273
+ country '687', fixed(2) >> split(3,2,2) # New Caledonia (Territoire français d'outre-mer)
274
+ country '688', fixed(2) >> split(3,2,2) # Tuvalu
275
+ country '689', fixed(2) >> split(3,2,2) # French Polynesia (Territoire français d'outre-mer)
276
+
277
+ country '690', fixed(2) >> split(3,2,2) # Tokelau
278
+ country '691', fixed(2) >> split(3,2,2) # Micronesia (Federated States of)
279
+ country '692', fixed(2) >> split(3,2,2) # Marshall Islands (Republic of the)
280
+ country '693', fixed(2) >> split(3,2,2) # -
281
+ country '694', fixed(2) >> split(3,2,2) # -
282
+ country '695', fixed(2) >> split(3,2,2) # -
283
+ country '696', fixed(2) >> split(3,2,2) # -
284
+ country '697', fixed(2) >> split(3,2,2) # -
285
+ country '698', fixed(2) >> split(3,2,2) # -
286
+ country '699', fixed(2) >> split(3,2,2) # -
287
+
288
+ country '800', fixed(2) >> split(3,2,2) # International Freephone Service
289
+ country '801', fixed(2) >> split(3,2,2) # -
290
+ country '802', fixed(2) >> split(3,2,2) # -
291
+ country '803', fixed(2) >> split(3,2,2) # -
292
+ country '804', fixed(2) >> split(3,2,2) # -
293
+ country '805', fixed(2) >> split(3,2,2) # -
294
+ country '806', fixed(2) >> split(3,2,2) # -
295
+ country '807', fixed(2) >> split(3,2,2) # -
296
+ country '808', fixed(2) >> split(3,2,2) # International Shared Cost Service (ISCS)
297
+ country '809', fixed(2) >> split(3,2,2) # -
298
+
299
+ country '830', fixed(2) >> split(3,2,2) # -
300
+ country '831', fixed(2) >> split(3,2,2) # -
301
+ country '832', fixed(2) >> split(3,2,2) # -
302
+ country '833', fixed(2) >> split(3,2,2) # -
303
+ country '834', fixed(2) >> split(3,2,2) # -
304
+ country '835', fixed(2) >> split(3,2,2) # -
305
+ country '836', fixed(2) >> split(3,2,2) # -
306
+ country '837', fixed(2) >> split(3,2,2) # -
307
+ country '838', fixed(2) >> split(3,2,2) # -
308
+ country '839', fixed(2) >> split(3,2,2) # -
309
+
310
+ country '850', fixed(2) >> split(3,2,2) # Democratic People's Republic of Korea
311
+ country '851', fixed(2) >> split(3,2,2) # Spare code
312
+ country '852', fixed(2) >> split(3,2,2) # Hong Kong, China
313
+ country '853', fixed(2) >> split(3,2,2) # Macao, China
314
+ country '854', fixed(2) >> split(3,2,2) # Spare code
315
+ country '855', fixed(2) >> split(3,2,2) # Cambodia (Kingdom of)
316
+ country '856', fixed(2) >> split(3,2,2) # Lao People's Democratic Republic
317
+ country '857', fixed(2) >> split(3,2,2) # Spare code
318
+ country '858', fixed(2) >> split(3,2,2) # Spare code
319
+ country '859', fixed(2) >> split(3,2,2) # Spare code
320
+
321
+ country '870', fixed(2) >> split(3,2,2) # Inmarsat SNAC
322
+ country '871', fixed(2) >> split(3,2,2) # Inmarsat (Atlantic Ocean-East)
323
+ country '872', fixed(2) >> split(3,2,2) # Inmarsat (Pacific Ocean)
324
+ country '873', fixed(2) >> split(3,2,2) # Inmarsat (Indian Ocean)
325
+ country '874', fixed(2) >> split(3,2,2) # Inmarsat (Atlantic Ocean-West)
326
+ country '875', fixed(2) >> split(3,2,2) # Reserved - Maritime Mobile Service Applications
327
+ country '876', fixed(2) >> split(3,2,2) # Reserved - Maritime Mobile Service Applications
328
+ country '877', fixed(2) >> split(3,2,2) # Reserved - Maritime Mobile Service Applications
329
+ country '878', fixed(2) >> split(3,2,2) # Universal Personal Telecommunication Service (UPT)
330
+ country '879', fixed(2) >> split(3,2,2) # Reserved for national non-commercial purposes
331
+
332
+ country '880', fixed(2) >> split(3,2,2) # Bangladesh (People's Republic of)
333
+ country '881', fixed(2) >> split(3,2,2) # International Mobile, shared code
334
+ country '882', fixed(2) >> split(3,2,2) # International Networks, shared code
335
+ country '883', fixed(2) >> split(3,2,2) # -
336
+ country '884', fixed(2) >> split(3,2,2) # -
337
+ country '885', fixed(2) >> split(3,2,2) # -
338
+ country '886', fixed(2) >> split(3,2,2) # Reserved
339
+ country '887', fixed(2) >> split(3,2,2) # -
340
+ country '888', fixed(2) >> split(3,2,2) # Reserved for future global service
341
+ country '889', fixed(2) >> split(3,2,2) # -
342
+
343
+ country '890', fixed(2) >> split(3,2,2) # -
344
+ country '891', fixed(2) >> split(3,2,2) # -
345
+ country '892', fixed(2) >> split(3,2,2) # -
346
+ country '893', fixed(2) >> split(3,2,2) # -
347
+ country '894', fixed(2) >> split(3,2,2) # -
348
+ country '895', fixed(2) >> split(3,2,2) # -
349
+ country '896', fixed(2) >> split(3,2,2) # -
350
+ country '897', fixed(2) >> split(3,2,2) # -
351
+ country '898', fixed(2) >> split(3,2,2) # -
352
+ country '899', fixed(2) >> split(3,2,2) # -
353
+
354
+ country '960', fixed(2) >> split(3,2,2) # Maldives (Republic of)
355
+ country '961', fixed(2) >> split(3,2,2) # Lebanon
356
+ country '962', fixed(2) >> split(3,2,2) # Jordan (Hashemite Kingdom of)
357
+ country '963', fixed(2) >> split(3,2,2) # Syrian Arab Republic
358
+ country '964', fixed(2) >> split(3,2,2) # Iraq (Republic of)
359
+ country '965', fixed(2) >> split(3,2,2) # Kuwait (State of)
360
+ country '966', fixed(2) >> split(3,2,2) # Saudi Arabia (Kingdom of)
361
+ country '967', fixed(2) >> split(3,2,2) # Yemen (Republic of)
362
+ country '968', fixed(2) >> split(3,2,2) # Oman (Sultanate of)
363
+ country '969', fixed(2) >> split(3,2,2) # Reserved - reservation currently under investigation
364
+
365
+ country '970', fixed(2) >> split(3,2,2) # Reserved
366
+ country '971', fixed(2) >> split(3,2,2) # United Arab Emirates
367
+ country '972', fixed(2) >> split(3,2,2) # Israel (State of)
368
+ country '973', fixed(2) >> split(3,2,2) # Bahrain (Kingdom of)
369
+ country '974', fixed(2) >> split(3,2,2) # Qatar (State of)
370
+ country '975', fixed(2) >> split(3,2,2) # Bhutan (Kingdom of)
371
+ country '976', fixed(2) >> split(3,2,2) # Mongolia
372
+ country '977', fixed(2) >> split(3,2,2) # Nepal
373
+ country '978', fixed(2) >> split(3,2,2) # -
374
+ country '979', fixed(2) >> split(3,2,2) # International Premium Rate Service (IPRS)
375
+
376
+ country '990', fixed(2) >> split(3,2,2) # Spare code
377
+ country '991', fixed(2) >> split(3,2,2) # Trial of a proposed new international telecommunication public correspondence service, shared code
378
+ country '992', fixed(2) >> split(3,2,2) # Tajikistan (Republic of)
379
+ country '993', fixed(2) >> split(3,2,2) # Turkmenistan
380
+ country '994', fixed(2) >> split(3,2,2) # Azerbaijani Republic
381
+ country '995', fixed(2) >> split(3,2,2) # Georgia
382
+ country '996', fixed(2) >> split(3,2,2) # Kyrgyz Republic
383
+ country '997', fixed(2) >> split(3,2,2) # Spare code
384
+ country '998', fixed(2) >> split(3,2,2) # Uzbekistan (Republic of)
385
+ country '999', fixed(2) >> split(3,2,2) # Reserved for possible future use within the Telecommunications for Disaster Relief (TDR) concept
data/lib/phony.rb CHANGED
@@ -3,18 +3,21 @@
3
3
  require File.expand_path '../phony/vanity', __FILE__
4
4
  require File.expand_path '../phony/local_splitters/fixed', __FILE__
5
5
  require File.expand_path '../phony/local_splitters/regex', __FILE__
6
- require File.expand_path '../phony/national_splitters/experimental', __FILE__
6
+ require File.expand_path '../phony/national_splitters/dsl', __FILE__
7
7
  require File.expand_path '../phony/national_splitters/fixed', __FILE__
8
8
  require File.expand_path '../phony/national_splitters/variable', __FILE__
9
+ require File.expand_path '../phony/national_splitters/regex', __FILE__
9
10
  require File.expand_path '../phony/national_splitters/none', __FILE__
10
11
  require File.expand_path '../phony/national_code', __FILE__
11
12
  require File.expand_path '../phony/country', __FILE__
13
+ require File.expand_path '../phony/country_codes', __FILE__
14
+ require File.expand_path '../phony/dsl', __FILE__
12
15
 
13
16
  # Countries.
14
17
  #
15
- # Note: See country_codes.rb for a complete mapping.
18
+ # The ones that need more space to define.
16
19
  #
17
- require File.expand_path '../phony/countries/all_other', __FILE__
20
+ require File.expand_path '../phony/countries', __FILE__
18
21
  require File.expand_path '../phony/countries/austria', __FILE__
19
22
  require File.expand_path '../phony/countries/belgium', __FILE__
20
23
  require File.expand_path '../phony/countries/chile', __FILE__
@@ -25,22 +28,21 @@ require File.expand_path '../phony/countries/greece', __FILE__
25
28
  require File.expand_path '../phony/countries/hungary', __FILE__
26
29
  require File.expand_path '../phony/countries/italy', __FILE__
27
30
  require File.expand_path '../phony/countries/malaysia', __FILE__
28
- require File.expand_path '../phony/countries/norway', __FILE__
29
31
  require File.expand_path '../phony/countries/netherlands', __FILE__
30
- require File.expand_path '../phony/countries/peru', __FILE__
31
- require File.expand_path '../phony/countries/portugal', __FILE__
32
32
  require File.expand_path '../phony/countries/romania', __FILE__
33
33
  require File.expand_path '../phony/countries/south_korea', __FILE__
34
34
  require File.expand_path '../phony/countries/sweden', __FILE__
35
35
  require File.expand_path '../phony/countries/united_kingdom', __FILE__
36
-
37
- require File.expand_path '../phony/country_codes', __FILE__
36
+ #
37
+ # All other countries.
38
+ #
39
+ require File.expand_path '../countries', __FILE__
38
40
 
39
41
  module Phony
40
42
 
41
43
  # Phony uses a single country codes instance.
42
44
  #
43
- @codes = CountryCodes.new
45
+ @codes = CountryCodes.instance
44
46
 
45
47
  # Normalizes the given number.
46
48
  #
@@ -0,0 +1 @@
1
+ module Phony::Countries end