country_codes 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +14 -0
- data/country_codes.gemspec +19 -0
- data/lib/country_codes.rb +24 -0
- data/lib/country_codes/dictionary.yml +540 -0
- data/lib/country_codes/version.rb +3 -0
- data/test/phone_numbers_test.rb +20 -0
- data/test/test_helper.rb +6 -0
- metadata +75 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 adman65
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# CountryCodes
|
2
|
+
|
3
|
+
A library for looking up country codes and other meta data
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'country_codes'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install country_codes
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'country_codes'
|
23
|
+
|
24
|
+
# Phone number must only be this format: /^\+\d+$/
|
25
|
+
|
26
|
+
> CountryCodes.from_phone_number '+3585032139876'
|
27
|
+
=> <struct CountryCodes::Entry name="Finland", calling_code=358, code=:fi>
|
28
|
+
```
|
29
|
+
|
30
|
+
### Updating
|
31
|
+
|
32
|
+
All information is stored in `dictionary.yml`. If you see a simple
|
33
|
+
problem, please use Github's "Propose File Change" functionality to edit
|
34
|
+
the file inline and submit a pull request.
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
desc 'Run tests'
|
7
|
+
Rake::TestTask.new(:test) do |t|
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.libs << 'test'
|
10
|
+
t.pattern = 'test/**/*_test.rb'
|
11
|
+
t.verbose = true
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => :test
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/country_codes/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["adman65"]
|
6
|
+
gem.email = ["me@broadcastingadam.com"]
|
7
|
+
gem.description = %q{Lookup country related metadata}
|
8
|
+
gem.summary = %q{}
|
9
|
+
gem.homepage = "https://github.com/threadedlabs/country_codes"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "country_codes"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = CountryCodes::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rake"
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "country_codes/version"
|
3
|
+
|
4
|
+
module CountryCodes
|
5
|
+
extend self
|
6
|
+
|
7
|
+
DICTIONARY = YAML.load_file(File.expand_path(File.join("..", "country_codes", "dictionary.yml"), __FILE__)).freeze
|
8
|
+
|
9
|
+
class Entry < Struct.new(:name, :calling_code, :code) ; end
|
10
|
+
|
11
|
+
def from_phone_number(number)
|
12
|
+
entries = DICTIONARY.sort { |a, b| b['calling_code'] <=> a['calling_code'] }
|
13
|
+
|
14
|
+
entry = entries.select do |e|
|
15
|
+
number =~ /\+#{e['calling_code']}\d+$/
|
16
|
+
end.first
|
17
|
+
|
18
|
+
if entry
|
19
|
+
Entry.new(entry['name'], entry['calling_code'], entry['code'])
|
20
|
+
else
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,540 @@
|
|
1
|
+
- name: Abkhazia
|
2
|
+
calling_code: 7840
|
3
|
+
- name: Afghanistan
|
4
|
+
calling_code: 93
|
5
|
+
- name: Åland Islands
|
6
|
+
calling_code: 358
|
7
|
+
- name: Albania
|
8
|
+
calling_code: 355
|
9
|
+
- name: Algeria
|
10
|
+
calling_code: 213
|
11
|
+
- name: American Samoa
|
12
|
+
calling_code: 1684
|
13
|
+
- name: Andorra
|
14
|
+
calling_code: 376
|
15
|
+
- name: Angola
|
16
|
+
calling_code: 244
|
17
|
+
- name: Anguilla
|
18
|
+
calling_code: 1264
|
19
|
+
- name: Antigua and Barbuda
|
20
|
+
calling_code: 1268
|
21
|
+
- name: Argentina
|
22
|
+
calling_code: 54
|
23
|
+
- name: Armenia
|
24
|
+
calling_code: 374
|
25
|
+
- name: Aruba
|
26
|
+
calling_code: 297
|
27
|
+
- name: Ascension
|
28
|
+
calling_code: 247
|
29
|
+
- name: Australia
|
30
|
+
calling_code: 61
|
31
|
+
- name: Australian External Territories
|
32
|
+
calling_code: 672
|
33
|
+
- name: Austria
|
34
|
+
calling_code: 43
|
35
|
+
- name: Azerbaijan
|
36
|
+
calling_code: 994
|
37
|
+
- name: Bahamas
|
38
|
+
calling_code: 1242
|
39
|
+
- name: Bahrain
|
40
|
+
calling_code: 973
|
41
|
+
- name: Bangladesh
|
42
|
+
calling_code: 880
|
43
|
+
- name: Barbados
|
44
|
+
calling_code: 1246
|
45
|
+
- name: Barbuda
|
46
|
+
calling_code: 1268
|
47
|
+
- name: Belarus
|
48
|
+
calling_code: 375
|
49
|
+
- name: Belgium
|
50
|
+
calling_code: 32
|
51
|
+
- name: Belize
|
52
|
+
calling_code: 501
|
53
|
+
- name: Benin
|
54
|
+
calling_code: 229
|
55
|
+
- name: Bermuda
|
56
|
+
calling_code: 1441
|
57
|
+
- name: Bhutan
|
58
|
+
calling_code: 975
|
59
|
+
- name: Bolivia
|
60
|
+
calling_code: 591
|
61
|
+
- name: Bonaire
|
62
|
+
calling_code: 599
|
63
|
+
- name: Bosnia and Herzegovina
|
64
|
+
calling_code: 387
|
65
|
+
- name: Botswana
|
66
|
+
calling_code: 267
|
67
|
+
- name: Brazil
|
68
|
+
calling_code: 55
|
69
|
+
- name: British Indian Ocean Territory
|
70
|
+
calling_code: 246
|
71
|
+
- name: British Virgin Islands
|
72
|
+
calling_code: 1284
|
73
|
+
- name: Brunei Darussalam
|
74
|
+
calling_code: 673
|
75
|
+
- name: Bulgaria
|
76
|
+
calling_code: 359
|
77
|
+
- name: Burkina Faso
|
78
|
+
calling_code: 226
|
79
|
+
- name: Burundi
|
80
|
+
calling_code: 257
|
81
|
+
- name: Cambodia
|
82
|
+
calling_code: 855
|
83
|
+
- name: Cameroon
|
84
|
+
calling_code: 237
|
85
|
+
- name: Canada
|
86
|
+
calling_code: 1
|
87
|
+
- name: Cape Verde
|
88
|
+
calling_code: 238
|
89
|
+
- name: Caribbean Netherlands
|
90
|
+
calling_code: 599
|
91
|
+
- name: Cayman Islands
|
92
|
+
calling_code: 1345
|
93
|
+
- name: Central African Republic
|
94
|
+
calling_code: 236
|
95
|
+
- name: Chad
|
96
|
+
calling_code: 235
|
97
|
+
- name: Chatham Island (New Zealand)
|
98
|
+
calling_code: 64
|
99
|
+
- name: Chile
|
100
|
+
calling_code: 56
|
101
|
+
- name: China
|
102
|
+
calling_code: 86
|
103
|
+
- name: Christmas Island
|
104
|
+
calling_code: 61
|
105
|
+
- name: Cocos (Keeling) Islands
|
106
|
+
calling_code: 61
|
107
|
+
- name: Colombia
|
108
|
+
calling_code: 57
|
109
|
+
- name: Comoros
|
110
|
+
calling_code: 269
|
111
|
+
- name: Congo (Brazzaville)
|
112
|
+
calling_code: 242
|
113
|
+
- name: Congo (The Democratic Republic of the Zaire)
|
114
|
+
calling_code: 243
|
115
|
+
- name: Cook Islands
|
116
|
+
calling_code: 682
|
117
|
+
- name: Costa Rica
|
118
|
+
calling_code: 506
|
119
|
+
- name: Côte d'Ivoire
|
120
|
+
calling_code: 225
|
121
|
+
- name: Croatia
|
122
|
+
calling_code: 385
|
123
|
+
- name: Cuba
|
124
|
+
calling_code: 53
|
125
|
+
- name: Curaçao
|
126
|
+
calling_code: 599
|
127
|
+
- name: Cyprus
|
128
|
+
calling_code: 357
|
129
|
+
- name: Czech Republic
|
130
|
+
calling_code: 420
|
131
|
+
- name: Denmark
|
132
|
+
calling_code: 45
|
133
|
+
- name: Diego Garcia
|
134
|
+
calling_code: 246
|
135
|
+
- name: Djibouti
|
136
|
+
calling_code: 253
|
137
|
+
- name: Dominica
|
138
|
+
calling_code: 1767
|
139
|
+
- name: Dominican Republic
|
140
|
+
calling_code: 1809
|
141
|
+
- name: East Timor
|
142
|
+
calling_code: 670
|
143
|
+
- name: Easter Island
|
144
|
+
calling_code: 56
|
145
|
+
- name: Ecuador
|
146
|
+
calling_code: 593
|
147
|
+
- name: Egypt
|
148
|
+
calling_code: 20
|
149
|
+
- name: El Salvador
|
150
|
+
calling_code: 503
|
151
|
+
- name: Ellipso (Mobile Satellite service)
|
152
|
+
calling_code: 881
|
153
|
+
- name: EMSAT (Mobile Satellite service)
|
154
|
+
calling_code: 882
|
155
|
+
- name: Equatorial Guinea
|
156
|
+
calling_code: 240
|
157
|
+
- name: Eritrea
|
158
|
+
calling_code: 291
|
159
|
+
- name: Estonia
|
160
|
+
calling_code: 372
|
161
|
+
- name: Ethiopia
|
162
|
+
calling_code: 251
|
163
|
+
- name: Falkland Islands (Malvinas)
|
164
|
+
calling_code: 500
|
165
|
+
- name: Faroe Islands
|
166
|
+
calling_code: 298
|
167
|
+
- name: Fiji
|
168
|
+
calling_code: 679
|
169
|
+
- name: Finland
|
170
|
+
calling_code: 358
|
171
|
+
- name: France
|
172
|
+
calling_code: 33
|
173
|
+
- name: French Antilles
|
174
|
+
calling_code: 596
|
175
|
+
- name: French Guiana
|
176
|
+
calling_code: 594
|
177
|
+
- name: French Polynesia
|
178
|
+
calling_code: 689
|
179
|
+
- name: Gabon
|
180
|
+
calling_code: 241
|
181
|
+
- name: Gambia
|
182
|
+
calling_code: 220
|
183
|
+
- name: Georgia
|
184
|
+
calling_code: 995
|
185
|
+
- name: Germany
|
186
|
+
calling_code: 49
|
187
|
+
- name: Ghana
|
188
|
+
calling_code: 233
|
189
|
+
- name: Gibraltar
|
190
|
+
calling_code: 350
|
191
|
+
- name: Global Mobile Satellite System (GMSS)
|
192
|
+
calling_code: 881
|
193
|
+
- name: Globalstar (Mobile Satellite Service)
|
194
|
+
calling_code: 881
|
195
|
+
- name: Greece
|
196
|
+
calling_code: 30
|
197
|
+
- name: Greenland
|
198
|
+
calling_code: 299
|
199
|
+
- name: Grenada
|
200
|
+
calling_code: 1473
|
201
|
+
- name: Guadeloupe
|
202
|
+
calling_code: 590
|
203
|
+
- name: Guam
|
204
|
+
calling_code: 1671
|
205
|
+
- name: Guatemala
|
206
|
+
calling_code: 502
|
207
|
+
- name: Guernsey
|
208
|
+
calling_code: 44
|
209
|
+
- name: Guinea
|
210
|
+
calling_code: 224
|
211
|
+
- name: Guinea-Bissau
|
212
|
+
calling_code: 245
|
213
|
+
- name: Guyana
|
214
|
+
calling_code: 592
|
215
|
+
- name: Haiti
|
216
|
+
calling_code: 509
|
217
|
+
- name: Holy See (Vatican City State)
|
218
|
+
calling_code: 39
|
219
|
+
- name: Honduras
|
220
|
+
calling_code: 504
|
221
|
+
- name: Hong Kong
|
222
|
+
calling_code: 852
|
223
|
+
- name: Hungary
|
224
|
+
calling_code: 36
|
225
|
+
- name: Iceland
|
226
|
+
calling_code: 354
|
227
|
+
- name: ICO Global (Mobile Satellite Service)
|
228
|
+
calling_code: 881
|
229
|
+
- name: India
|
230
|
+
calling_code: 91
|
231
|
+
- name: Indonesia
|
232
|
+
calling_code: 62
|
233
|
+
- name: Inmarsat SNAC
|
234
|
+
calling_code: 870
|
235
|
+
- name: International Freephone Service
|
236
|
+
calling_code: 800
|
237
|
+
- name: International Shared Cost Service (ISCS)
|
238
|
+
calling_code: 808
|
239
|
+
- name: Iran
|
240
|
+
calling_code: 98
|
241
|
+
- name: Iraq
|
242
|
+
calling_code: 964
|
243
|
+
- name: Ireland
|
244
|
+
calling_code: 353
|
245
|
+
- name: Iridium (Mobile Satellite service)
|
246
|
+
calling_code: 881
|
247
|
+
- name: Isle of Man
|
248
|
+
calling_code: 44
|
249
|
+
- name: Israel
|
250
|
+
calling_code: 972
|
251
|
+
- name: Italy
|
252
|
+
calling_code: 39
|
253
|
+
- name: Jamaica
|
254
|
+
calling_code: 1876
|
255
|
+
- name: Japan
|
256
|
+
calling_code: 81
|
257
|
+
- name: Jersey
|
258
|
+
calling_code: 44
|
259
|
+
- name: Jordan
|
260
|
+
calling_code: 962
|
261
|
+
- name: Kazakhstan
|
262
|
+
calling_code: 76
|
263
|
+
- name: Kenya
|
264
|
+
calling_code: 254
|
265
|
+
- name: Kiribati
|
266
|
+
calling_code: 686
|
267
|
+
- name: North Korea
|
268
|
+
calling_code: 850
|
269
|
+
- name: South Korea
|
270
|
+
calling_code: 82
|
271
|
+
- name: Kuwait
|
272
|
+
calling_code: 965
|
273
|
+
- name: Kyrgyzstan
|
274
|
+
calling_code: 996
|
275
|
+
- name: Laos
|
276
|
+
calling_code: 856
|
277
|
+
- name: Latvia
|
278
|
+
calling_code: 371
|
279
|
+
- name: Lebanon
|
280
|
+
calling_code: 961
|
281
|
+
- name: Lesotho
|
282
|
+
calling_code: 266
|
283
|
+
- name: Liberia
|
284
|
+
calling_code: 231
|
285
|
+
- name: Libya
|
286
|
+
calling_code: 218
|
287
|
+
- name: Liechtenstein
|
288
|
+
calling_code: 423
|
289
|
+
- name: Lithuania
|
290
|
+
calling_code: 370
|
291
|
+
- name: Luxembourg
|
292
|
+
calling_code: 352
|
293
|
+
- name: Macau
|
294
|
+
calling_code: 853
|
295
|
+
- name: Macedonia
|
296
|
+
calling_code: 389
|
297
|
+
- name: Madagascar
|
298
|
+
calling_code: 261
|
299
|
+
- name: Malawi
|
300
|
+
calling_code: 265
|
301
|
+
- name: Malaysia
|
302
|
+
calling_code: 60
|
303
|
+
- name: Maldives
|
304
|
+
calling_code: 960
|
305
|
+
- name: Mali
|
306
|
+
calling_code: 223
|
307
|
+
- name: Malta
|
308
|
+
calling_code: 356
|
309
|
+
- name: Marshall Islands
|
310
|
+
calling_code: 692
|
311
|
+
- name: Martinique
|
312
|
+
calling_code: 596
|
313
|
+
- name: Mauritania
|
314
|
+
calling_code: 222
|
315
|
+
- name: Mauritius
|
316
|
+
calling_code: 230
|
317
|
+
- name: Mayotte
|
318
|
+
calling_code: 262
|
319
|
+
- name: Mexico
|
320
|
+
calling_code: 52
|
321
|
+
- name: Federated States of Micronesia
|
322
|
+
calling_code: 691
|
323
|
+
- name: Midway Island
|
324
|
+
calling_code: 1808
|
325
|
+
- name: Moldova
|
326
|
+
calling_code: 373
|
327
|
+
- name: Monaco
|
328
|
+
calling_code: 377
|
329
|
+
- name: Mongolia
|
330
|
+
calling_code: 976
|
331
|
+
- name: Montenegro
|
332
|
+
calling_code: 382
|
333
|
+
- name: Montserrat
|
334
|
+
calling_code: 1664
|
335
|
+
- name: Morocco
|
336
|
+
calling_code: 212
|
337
|
+
- name: Mozambique
|
338
|
+
calling_code: 258
|
339
|
+
- name: Myanmar
|
340
|
+
calling_code: 95
|
341
|
+
- name: Namibia
|
342
|
+
calling_code: 264
|
343
|
+
- name: Nauru
|
344
|
+
calling_code: 674
|
345
|
+
- name: Nepal
|
346
|
+
calling_code: 977
|
347
|
+
- name: Netherlands
|
348
|
+
calling_code: 31
|
349
|
+
- name: Nevis
|
350
|
+
calling_code: 1869
|
351
|
+
- name: New Caledonia
|
352
|
+
calling_code: 687
|
353
|
+
- name: New Zealand
|
354
|
+
calling_code: 64
|
355
|
+
- name: Nicaragua
|
356
|
+
calling_code: 505
|
357
|
+
- name: Niger
|
358
|
+
calling_code: 227
|
359
|
+
- name: Nigeria
|
360
|
+
calling_code: 234
|
361
|
+
- name: Niue
|
362
|
+
calling_code: 683
|
363
|
+
- name: Norfolk Island
|
364
|
+
calling_code: 672
|
365
|
+
- name: Northern Mariana Islands
|
366
|
+
calling_code: 1670
|
367
|
+
- name: Norway
|
368
|
+
calling_code: 47
|
369
|
+
- name: Oman
|
370
|
+
calling_code: 968
|
371
|
+
- name: Pakistan
|
372
|
+
calling_code: 92
|
373
|
+
- name: Palau
|
374
|
+
calling_code: 680
|
375
|
+
- name: Palestinian territories
|
376
|
+
calling_code: 970
|
377
|
+
- name: Panama
|
378
|
+
calling_code: 507
|
379
|
+
- name: Papua New Guinea
|
380
|
+
calling_code: 675
|
381
|
+
- name: Paraguay
|
382
|
+
calling_code: 595
|
383
|
+
- name: Peru
|
384
|
+
calling_code: 51
|
385
|
+
- name: Philippines
|
386
|
+
calling_code: 63
|
387
|
+
- name: Poland
|
388
|
+
calling_code: 48
|
389
|
+
- name: Portugal
|
390
|
+
calling_code: 351
|
391
|
+
- name: Puerto Rico
|
392
|
+
calling_code: 1787
|
393
|
+
- name: Qatar
|
394
|
+
calling_code: 974
|
395
|
+
- name: Réunion
|
396
|
+
calling_code: 262
|
397
|
+
- name: Romania
|
398
|
+
calling_code: 40
|
399
|
+
- name: Russia
|
400
|
+
calling_code: 7
|
401
|
+
- name: Rwanda
|
402
|
+
calling_code: 250
|
403
|
+
- name: Saba
|
404
|
+
calling_code: 599
|
405
|
+
- name: Saint Barthélemy
|
406
|
+
calling_code: 590
|
407
|
+
- name: Saint Helena and Tristan da Cunha
|
408
|
+
calling_code: 290
|
409
|
+
- name: Saint Kitts and Nevis
|
410
|
+
calling_code: 1869
|
411
|
+
- name: Saint Lucia
|
412
|
+
calling_code: 1758
|
413
|
+
- name: Saint Martin (French)
|
414
|
+
calling_code: 590
|
415
|
+
- name: Saint Pierre and Miquelon
|
416
|
+
calling_code: 508
|
417
|
+
- name: Saint Vincent and the Grenadines
|
418
|
+
calling_code: 1784
|
419
|
+
- name: Samoa
|
420
|
+
calling_code: 685
|
421
|
+
- name: San Marino
|
422
|
+
calling_code: 378
|
423
|
+
- name: São Tomé and Príncipe
|
424
|
+
calling_code: 239
|
425
|
+
- name: Saudi Arabia
|
426
|
+
calling_code: 966
|
427
|
+
- name: Senegal
|
428
|
+
calling_code: 221
|
429
|
+
- name: Serbia
|
430
|
+
calling_code: 381
|
431
|
+
- name: Seychelles
|
432
|
+
calling_code: 248
|
433
|
+
- name: Sierra Leone
|
434
|
+
calling_code: 232
|
435
|
+
- name: Singapore
|
436
|
+
calling_code: 65
|
437
|
+
- name: Sint Eustatius
|
438
|
+
calling_code: 599
|
439
|
+
- name: Sint Maarten (Dutch)
|
440
|
+
calling_code: 1721
|
441
|
+
- name: Slovakia
|
442
|
+
calling_code: 421
|
443
|
+
- name: Slovenia
|
444
|
+
calling_code: 386
|
445
|
+
- name: Solomon Islands
|
446
|
+
calling_code: 677
|
447
|
+
- name: Somalia
|
448
|
+
calling_code: 252
|
449
|
+
- name: South Africa
|
450
|
+
calling_code: 27
|
451
|
+
- name: South Georgia and the South Sandwich Islands
|
452
|
+
calling_code: 500
|
453
|
+
- name: South Sudan
|
454
|
+
calling_code: 211
|
455
|
+
- name: Spain
|
456
|
+
calling_code: 34
|
457
|
+
- name: Sri Lanka
|
458
|
+
calling_code: 94
|
459
|
+
- name: Sudan
|
460
|
+
calling_code: 249
|
461
|
+
- name: Suriname
|
462
|
+
calling_code: 597
|
463
|
+
- name: Svalbard and Jan Mayen
|
464
|
+
calling_code: 47
|
465
|
+
- name: Swaziland
|
466
|
+
calling_code: 268
|
467
|
+
- name: Sweden
|
468
|
+
calling_code: 46
|
469
|
+
- name: Switzerland
|
470
|
+
calling_code: 41
|
471
|
+
- name: Syria
|
472
|
+
calling_code: 963
|
473
|
+
- name: Taiwan
|
474
|
+
calling_code: 886
|
475
|
+
- name: Tajikistan
|
476
|
+
calling_code: 992
|
477
|
+
- name: Tanzania
|
478
|
+
calling_code: 255
|
479
|
+
- name: Thailand
|
480
|
+
calling_code: 66
|
481
|
+
- name: Thuraya (Mobile Satellite service)
|
482
|
+
calling_code: 882
|
483
|
+
- name: Togo
|
484
|
+
calling_code: 228
|
485
|
+
- name: Tokelau
|
486
|
+
calling_code: 690
|
487
|
+
- name: Tonga
|
488
|
+
calling_code: 676
|
489
|
+
- name: Trinidad and Tobago
|
490
|
+
calling_code: 1868
|
491
|
+
- name: Tunisia
|
492
|
+
calling_code: 216
|
493
|
+
- name: Turkey
|
494
|
+
calling_code: 90
|
495
|
+
- name: Turkmenistan
|
496
|
+
calling_code: 993
|
497
|
+
- name: Turks and Caicos Islands
|
498
|
+
calling_code: 1649
|
499
|
+
- name: Tuvalu
|
500
|
+
calling_code: 688
|
501
|
+
- name: Uganda
|
502
|
+
calling_code: 256
|
503
|
+
- name: Ukraine
|
504
|
+
calling_code: 380
|
505
|
+
- name: United Arab Emirates
|
506
|
+
calling_code: 971
|
507
|
+
- name: United Kingdom
|
508
|
+
calling_code: 44
|
509
|
+
- name: United States
|
510
|
+
calling_code: 1
|
511
|
+
- name: Universal Personal Telecommunications (UPT)
|
512
|
+
calling_code: 878
|
513
|
+
- name: Uruguay
|
514
|
+
calling_code: 598
|
515
|
+
- name: Uzbekistan
|
516
|
+
calling_code: 998
|
517
|
+
- name: Vanuatu
|
518
|
+
calling_code: 678
|
519
|
+
- name: Venezuela
|
520
|
+
calling_code: 58
|
521
|
+
- name: Vatican City State (Holy See)
|
522
|
+
calling_code: 39
|
523
|
+
- name: Vietnam
|
524
|
+
calling_code: 84
|
525
|
+
- name: Virgin Islands (British)
|
526
|
+
calling_code: 1284
|
527
|
+
- name: Virgin Islands (US)
|
528
|
+
calling_code: 1340
|
529
|
+
- name: Wake Island
|
530
|
+
calling_code: 1808
|
531
|
+
- name: Wallis and Futuna
|
532
|
+
calling_code: 681
|
533
|
+
- name: Yemen
|
534
|
+
calling_code: 967
|
535
|
+
- name: Zambia
|
536
|
+
calling_code: 260
|
537
|
+
- name: Zanzibar
|
538
|
+
calling_code: 255
|
539
|
+
- name: Zimbabwe
|
540
|
+
calling_code: 263
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PhoneNumbersTest < Test::Unit::TestCase
|
4
|
+
def test_returns_a_struct
|
5
|
+
assert_instance_of CountryCodes::Entry, CountryCodes.from_phone_number("+19235238497")
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_nil_is_returned_when_no_match
|
9
|
+
assert_nil CountryCodes.from_phone_number("+000000000")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_usa_is_identified
|
13
|
+
assert_equal CountryCodes.from_phone_number("+19254564931").calling_code, 1
|
14
|
+
assert_not_equal CountryCodes.from_phone_number("+134023489713").calling_code, 1
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_virigin_islands_are_identified
|
18
|
+
assert_equal CountryCodes.from_phone_number("+134023489713").calling_code, 1340
|
19
|
+
end
|
20
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: country_codes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- adman65
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70353880443140 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70353880443140
|
25
|
+
description: Lookup country related metadata
|
26
|
+
email:
|
27
|
+
- me@broadcastingadam.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- country_codes.gemspec
|
38
|
+
- lib/country_codes.rb
|
39
|
+
- lib/country_codes/dictionary.yml
|
40
|
+
- lib/country_codes/version.rb
|
41
|
+
- test/phone_numbers_test.rb
|
42
|
+
- test/test_helper.rb
|
43
|
+
homepage: https://github.com/threadedlabs/country_codes
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
hash: 2546854131673753402
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
hash: 2546854131673753402
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.8.11
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: ''
|
73
|
+
test_files:
|
74
|
+
- test/phone_numbers_test.rb
|
75
|
+
- test/test_helper.rb
|