telephone_number 1.4.3 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/geocoding/bs/387.dat +0 -0
- data/data/geocoding/bs/387.txt +2 -0
- data/data/geocoding/de/352.dat +0 -0
- data/data/geocoding/de/352.txt +0 -1
- data/data/geocoding/de/43.dat +0 -0
- data/data/geocoding/de/43.txt +2 -0
- data/data/geocoding/en/1.dat +0 -0
- data/data/geocoding/en/1.txt +38 -6
- data/data/geocoding/en/212.dat +0 -0
- data/data/geocoding/en/212.txt +4 -4
- data/data/geocoding/en/216.dat +0 -0
- data/data/geocoding/en/216.txt +1 -0
- data/data/geocoding/en/218.dat +0 -0
- data/data/geocoding/en/218.txt +77 -1
- data/data/geocoding/en/220.dat +0 -0
- data/data/geocoding/en/220.txt +1 -0
- data/data/geocoding/en/221.dat +0 -0
- data/data/geocoding/en/221.txt +7 -1
- data/data/geocoding/en/224.dat +0 -0
- data/data/geocoding/en/224.txt +1 -1
- data/data/geocoding/en/225.dat +0 -0
- data/data/geocoding/en/225.txt +14 -4
- data/data/geocoding/en/233.dat +0 -0
- data/data/geocoding/en/233.txt +1 -0
- data/data/geocoding/en/234.dat +0 -0
- data/data/geocoding/en/234.txt +16 -1
- data/data/geocoding/en/236.dat +0 -0
- data/data/geocoding/en/236.txt +15 -0
- data/data/geocoding/en/241.dat +0 -0
- data/data/geocoding/en/241.txt +30 -0
- data/data/geocoding/en/251.dat +0 -0
- data/data/geocoding/en/251.txt +1 -6
- data/data/geocoding/en/252.dat +0 -0
- data/data/geocoding/en/252.txt +0 -1
- data/data/geocoding/en/264.dat +0 -0
- data/data/geocoding/en/264.txt +2 -0
- data/data/geocoding/en/290.dat +0 -0
- data/data/geocoding/en/290.txt +6 -1
- data/data/geocoding/en/33.dat +0 -0
- data/data/geocoding/en/33.txt +10598 -2177
- data/data/geocoding/en/34.dat +0 -0
- data/data/geocoding/en/34.txt +62 -2
- data/data/geocoding/en/352.dat +0 -0
- data/data/geocoding/en/352.txt +0 -1
- data/data/geocoding/en/353.dat +0 -0
- data/data/geocoding/en/353.txt +266 -15
- data/data/geocoding/en/354.dat +0 -0
- data/data/geocoding/en/354.txt +5 -6
- data/data/geocoding/en/370.dat +0 -0
- data/data/geocoding/en/370.txt +9 -2
- data/data/geocoding/en/374.dat +0 -0
- data/data/geocoding/en/374.txt +0 -5
- data/data/geocoding/en/386.dat +0 -0
- data/data/geocoding/en/386.txt +43 -0
- data/data/geocoding/en/389.dat +0 -0
- data/data/geocoding/en/389.txt +28 -2
- data/data/geocoding/en/421.dat +0 -0
- data/data/geocoding/en/421.txt +15 -14
- data/data/geocoding/en/43.dat +0 -0
- data/data/geocoding/en/43.txt +2 -0
- data/data/geocoding/en/44.dat +0 -0
- data/data/geocoding/en/44.txt +9 -1
- data/data/geocoding/en/46.dat +0 -0
- data/data/geocoding/en/46.txt +10 -2
- data/data/geocoding/en/47.dat +0 -0
- data/data/geocoding/en/47.txt +137 -1
- data/data/geocoding/en/504.dat +0 -0
- data/data/geocoding/en/504.txt +74 -0
- data/data/geocoding/en/52.dat +0 -0
- data/data/geocoding/en/52.txt +1 -1
- data/data/geocoding/en/54.dat +0 -0
- data/data/geocoding/en/54.txt +19 -6
- data/data/geocoding/en/56.dat +0 -0
- data/data/geocoding/en/56.txt +37 -1
- data/data/geocoding/en/58.dat +0 -0
- data/data/geocoding/en/58.txt +21 -12
- data/data/geocoding/en/593.dat +0 -0
- data/data/geocoding/en/593.txt +21 -0
- data/data/geocoding/en/595.dat +0 -0
- data/data/geocoding/en/595.txt +73 -0
- data/data/geocoding/en/598.dat +0 -0
- data/data/geocoding/en/598.txt +33 -0
- data/data/geocoding/en/599.dat +0 -0
- data/data/geocoding/en/599.txt +8 -2
- data/data/geocoding/en/60.dat +0 -0
- data/data/geocoding/en/60.txt +9 -8
- data/data/geocoding/en/61.dat +0 -0
- data/data/geocoding/en/61.txt +20633 -1991
- data/data/geocoding/en/63.dat +0 -0
- data/data/geocoding/en/63.txt +61 -0
- data/data/geocoding/en/64.dat +0 -0
- data/data/geocoding/en/64.txt +2862 -108
- data/data/geocoding/en/66.dat +0 -0
- data/data/geocoding/en/66.txt +4 -0
- data/data/geocoding/en/670.dat +0 -0
- data/data/geocoding/en/670.txt +31 -0
- data/data/geocoding/en/672.dat +0 -0
- data/data/geocoding/en/672.txt +18 -0
- data/data/geocoding/en/673.dat +0 -0
- data/data/geocoding/en/673.txt +41 -0
- data/data/geocoding/en/678.dat +0 -0
- data/data/geocoding/en/678.txt +27 -0
- data/data/geocoding/en/679.dat +0 -0
- data/data/geocoding/en/679.txt +20 -0
- data/data/geocoding/en/680.dat +0 -0
- data/data/geocoding/en/680.txt +1 -1
- data/data/geocoding/en/682.dat +0 -0
- data/data/geocoding/en/682.txt +26 -0
- data/data/geocoding/en/685.dat +0 -0
- data/data/geocoding/en/685.txt +27 -0
- data/data/geocoding/en/686.dat +0 -0
- data/data/geocoding/en/686.txt +0 -1
- data/data/geocoding/en/689.dat +0 -0
- data/data/geocoding/en/689.txt +24 -0
- data/data/geocoding/en/690.dat +0 -0
- data/data/geocoding/en/690.txt +17 -0
- data/data/geocoding/en/7.dat +0 -0
- data/data/geocoding/en/7.txt +3 -0
- data/data/geocoding/en/81.dat +0 -0
- data/data/geocoding/en/81.txt +1 -1
- data/data/geocoding/en/850.dat +0 -0
- data/data/geocoding/en/850.txt +31 -0
- data/data/geocoding/en/880.dat +0 -0
- data/data/geocoding/en/880.txt +247 -613
- data/data/geocoding/en/886.dat +0 -0
- data/data/geocoding/en/886.txt +36 -2
- data/data/geocoding/en/91.dat +0 -0
- data/data/geocoding/en/91.txt +3606 -516
- data/data/geocoding/en/92.dat +0 -0
- data/data/geocoding/en/92.txt +760 -0
- data/data/geocoding/en/94.dat +0 -0
- data/data/geocoding/en/94.txt +2 -2
- data/data/geocoding/en/95.dat +0 -0
- data/data/geocoding/en/95.txt +14 -0
- data/data/geocoding/en/962.dat +0 -0
- data/data/geocoding/en/962.txt +24 -2
- data/data/geocoding/en/963.dat +0 -0
- data/data/geocoding/en/963.txt +35 -0
- data/data/geocoding/en/967.dat +0 -0
- data/data/geocoding/en/967.txt +98 -0
- data/data/geocoding/en/970.dat +0 -0
- data/data/geocoding/en/970.txt +29 -0
- data/data/geocoding/en/971.dat +0 -0
- data/data/geocoding/en/971.txt +49 -0
- data/data/geocoding/en/993.dat +0 -0
- data/data/geocoding/en/993.txt +5 -0
- data/data/geocoding/en/995.dat +0 -0
- data/data/geocoding/en/995.txt +91 -0
- data/data/geocoding/en/996.dat +0 -0
- data/data/geocoding/en/996.txt +35 -1
- data/data/geocoding/es/34.dat +0 -0
- data/data/geocoding/es/34.txt +62 -2
- data/data/geocoding/es/54.dat +0 -0
- data/data/geocoding/es/54.txt +19 -6
- data/data/geocoding/es/56.dat +0 -0
- data/data/geocoding/es/56.txt +37 -1
- data/data/geocoding/es/58.dat +0 -0
- data/data/geocoding/es/58.txt +21 -12
- data/data/geocoding/fr/212.dat +0 -0
- data/data/geocoding/fr/212.txt +4 -4
- data/data/geocoding/fr/225.dat +0 -0
- data/data/geocoding/fr/225.txt +14 -4
- data/data/geocoding/fr/290.dat +0 -0
- data/data/geocoding/fr/290.txt +6 -1
- data/data/geocoding/fr/33.dat +0 -0
- data/data/geocoding/fr/33.txt +10586 -2165
- data/data/geocoding/fr/352.dat +0 -0
- data/data/geocoding/fr/352.txt +0 -1
- data/data/geocoding/hy/374.dat +0 -0
- data/data/geocoding/hy/374.txt +0 -5
- data/data/geocoding/ru/374.dat +0 -0
- data/data/geocoding/ru/374.txt +0 -6
- data/data/geocoding/ru/7.dat +0 -0
- data/data/geocoding/ru/7.txt +92 -1
- data/data/geocoding/sv/46.dat +0 -0
- data/data/geocoding/sv/46.txt +26 -3
- data/data/geocoding/th/66.dat +0 -0
- data/data/geocoding/th/66.txt +4 -0
- data/data/geocoding/zh/886.dat +0 -0
- data/data/geocoding/zh/886.txt +37 -2
- data/data/telephone_number_data_file.dat +0 -0
- data/data/telephone_number_data_file.xml +3460 -1908
- data/data/timezones/map_data.dat +0 -0
- data/data/timezones/map_data.txt +114 -250
- data/lib/importers/geo_location_data_importer.rb +1 -1
- data/lib/importers/test_data_importer.rb +1 -1
- data/lib/telephone_number/parser.rb +10 -5
- data/lib/telephone_number/version.rb +1 -1
- metadata +49 -3
@@ -8,7 +8,7 @@ module TelephoneNumber
|
|
8
8
|
master_data = {}
|
9
9
|
bin_file_path = "#{File.dirname(file_path)}/#{File.basename(file_path, '.txt')}.dat"
|
10
10
|
|
11
|
-
File.open(file_path, 'r').each do |row|
|
11
|
+
File.open(file_path, 'r:UTF-8').each do |row|
|
12
12
|
next if row.strip !~ /^[0-9]/
|
13
13
|
number, location = row.split('|')
|
14
14
|
master_data[number.strip] = location.strip
|
@@ -11,7 +11,7 @@ module TelephoneNumber
|
|
11
11
|
AU: %w(0467703037),
|
12
12
|
BE: %w(32498485960 32477702206 32474095692),
|
13
13
|
BO: %w(59178500348 59178006138 59178006139),
|
14
|
-
BR: %w(011992339376 1123456789 11961234567),
|
14
|
+
BR: %w(011992339376 1123456789 11961234567 55991472683),
|
15
15
|
BY: %w(80152450911 294911911 152450911),
|
16
16
|
CA: %w(16135550119 16135550171 16135550112 16135550194
|
17
17
|
16135550122 16135550131 15146708700 14169158200),
|
@@ -9,7 +9,7 @@ module TelephoneNumber
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def valid_types
|
12
|
-
@valid_types ||=
|
12
|
+
@valid_types ||= generate_valid_types(normalized_number)
|
13
13
|
end
|
14
14
|
|
15
15
|
def valid?(keys = [])
|
@@ -23,15 +23,20 @@ module TelephoneNumber
|
|
23
23
|
# basically anything else that uses google data
|
24
24
|
def build_normalized_number
|
25
25
|
match_result = parse_prefix.match(country.full_general_pattern)
|
26
|
-
|
26
|
+
|
27
|
+
if match_result && generate_valid_types(match_result[:national_num]).any?
|
28
|
+
match_result[:national_num]
|
29
|
+
else
|
30
|
+
original_number
|
31
|
+
end
|
27
32
|
end
|
28
33
|
|
29
|
-
# returns an array of valid types for the
|
34
|
+
# returns an array of valid types for the given number
|
30
35
|
# if array is empty, we can assume that the number is invalid
|
31
|
-
def
|
36
|
+
def generate_valid_types(number)
|
32
37
|
return [] unless country
|
33
38
|
country.validations.select do |validation|
|
34
|
-
|
39
|
+
number.match?(Regexp.new("^(#{validation.pattern})$"))
|
35
40
|
end.map(&:name)
|
36
41
|
end
|
37
42
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telephone_number
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MOBI Wireless Management
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -217,6 +217,8 @@ files:
|
|
217
217
|
- data/geocoding/en/233.txt
|
218
218
|
- data/geocoding/en/234.dat
|
219
219
|
- data/geocoding/en/234.txt
|
220
|
+
- data/geocoding/en/236.dat
|
221
|
+
- data/geocoding/en/236.txt
|
220
222
|
- data/geocoding/en/237.dat
|
221
223
|
- data/geocoding/en/237.txt
|
222
224
|
- data/geocoding/en/238.dat
|
@@ -323,6 +325,8 @@ files:
|
|
323
325
|
- data/geocoding/en/383.txt
|
324
326
|
- data/geocoding/en/385.dat
|
325
327
|
- data/geocoding/en/385.txt
|
328
|
+
- data/geocoding/en/386.dat
|
329
|
+
- data/geocoding/en/386.txt
|
326
330
|
- data/geocoding/en/387.dat
|
327
331
|
- data/geocoding/en/387.txt
|
328
332
|
- data/geocoding/en/389.dat
|
@@ -371,6 +375,12 @@ files:
|
|
371
375
|
- data/geocoding/en/58.txt
|
372
376
|
- data/geocoding/en/592.dat
|
373
377
|
- data/geocoding/en/592.txt
|
378
|
+
- data/geocoding/en/593.dat
|
379
|
+
- data/geocoding/en/593.txt
|
380
|
+
- data/geocoding/en/595.dat
|
381
|
+
- data/geocoding/en/595.txt
|
382
|
+
- data/geocoding/en/598.dat
|
383
|
+
- data/geocoding/en/598.txt
|
374
384
|
- data/geocoding/en/599.dat
|
375
385
|
- data/geocoding/en/599.txt
|
376
386
|
- data/geocoding/en/60.dat
|
@@ -379,20 +389,40 @@ files:
|
|
379
389
|
- data/geocoding/en/61.txt
|
380
390
|
- data/geocoding/en/62.dat
|
381
391
|
- data/geocoding/en/62.txt
|
392
|
+
- data/geocoding/en/63.dat
|
393
|
+
- data/geocoding/en/63.txt
|
382
394
|
- data/geocoding/en/64.dat
|
383
395
|
- data/geocoding/en/64.txt
|
384
396
|
- data/geocoding/en/66.dat
|
385
397
|
- data/geocoding/en/66.txt
|
398
|
+
- data/geocoding/en/670.dat
|
399
|
+
- data/geocoding/en/670.txt
|
400
|
+
- data/geocoding/en/672.dat
|
401
|
+
- data/geocoding/en/672.txt
|
402
|
+
- data/geocoding/en/673.dat
|
403
|
+
- data/geocoding/en/673.txt
|
386
404
|
- data/geocoding/en/675.dat
|
387
405
|
- data/geocoding/en/675.txt
|
388
406
|
- data/geocoding/en/676.dat
|
389
407
|
- data/geocoding/en/676.txt
|
408
|
+
- data/geocoding/en/678.dat
|
409
|
+
- data/geocoding/en/678.txt
|
410
|
+
- data/geocoding/en/679.dat
|
411
|
+
- data/geocoding/en/679.txt
|
390
412
|
- data/geocoding/en/680.dat
|
391
413
|
- data/geocoding/en/680.txt
|
414
|
+
- data/geocoding/en/682.dat
|
415
|
+
- data/geocoding/en/682.txt
|
416
|
+
- data/geocoding/en/685.dat
|
417
|
+
- data/geocoding/en/685.txt
|
392
418
|
- data/geocoding/en/686.dat
|
393
419
|
- data/geocoding/en/686.txt
|
394
420
|
- data/geocoding/en/688.dat
|
395
421
|
- data/geocoding/en/688.txt
|
422
|
+
- data/geocoding/en/689.dat
|
423
|
+
- data/geocoding/en/689.txt
|
424
|
+
- data/geocoding/en/690.dat
|
425
|
+
- data/geocoding/en/690.txt
|
396
426
|
- data/geocoding/en/7.dat
|
397
427
|
- data/geocoding/en/7.txt
|
398
428
|
- data/geocoding/en/81.dat
|
@@ -401,6 +431,8 @@ files:
|
|
401
431
|
- data/geocoding/en/82.txt
|
402
432
|
- data/geocoding/en/84.dat
|
403
433
|
- data/geocoding/en/84.txt
|
434
|
+
- data/geocoding/en/850.dat
|
435
|
+
- data/geocoding/en/850.txt
|
404
436
|
- data/geocoding/en/86.dat
|
405
437
|
- data/geocoding/en/86.txt
|
406
438
|
- data/geocoding/en/880.dat
|
@@ -411,6 +443,8 @@ files:
|
|
411
443
|
- data/geocoding/en/90.txt
|
412
444
|
- data/geocoding/en/91.dat
|
413
445
|
- data/geocoding/en/91.txt
|
446
|
+
- data/geocoding/en/92.dat
|
447
|
+
- data/geocoding/en/92.txt
|
414
448
|
- data/geocoding/en/93.dat
|
415
449
|
- data/geocoding/en/93.txt
|
416
450
|
- data/geocoding/en/94.dat
|
@@ -421,10 +455,18 @@ files:
|
|
421
455
|
- data/geocoding/en/960.txt
|
422
456
|
- data/geocoding/en/962.dat
|
423
457
|
- data/geocoding/en/962.txt
|
458
|
+
- data/geocoding/en/963.dat
|
459
|
+
- data/geocoding/en/963.txt
|
424
460
|
- data/geocoding/en/966.dat
|
425
461
|
- data/geocoding/en/966.txt
|
462
|
+
- data/geocoding/en/967.dat
|
463
|
+
- data/geocoding/en/967.txt
|
426
464
|
- data/geocoding/en/968.dat
|
427
465
|
- data/geocoding/en/968.txt
|
466
|
+
- data/geocoding/en/970.dat
|
467
|
+
- data/geocoding/en/970.txt
|
468
|
+
- data/geocoding/en/971.dat
|
469
|
+
- data/geocoding/en/971.txt
|
428
470
|
- data/geocoding/en/972.dat
|
429
471
|
- data/geocoding/en/972.txt
|
430
472
|
- data/geocoding/en/975.dat
|
@@ -435,8 +477,12 @@ files:
|
|
435
477
|
- data/geocoding/en/98.txt
|
436
478
|
- data/geocoding/en/992.dat
|
437
479
|
- data/geocoding/en/992.txt
|
480
|
+
- data/geocoding/en/993.dat
|
481
|
+
- data/geocoding/en/993.txt
|
438
482
|
- data/geocoding/en/994.dat
|
439
483
|
- data/geocoding/en/994.txt
|
484
|
+
- data/geocoding/en/995.dat
|
485
|
+
- data/geocoding/en/995.txt
|
440
486
|
- data/geocoding/en/996.dat
|
441
487
|
- data/geocoding/en/996.txt
|
442
488
|
- data/geocoding/es/228.dat
|
@@ -608,7 +654,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
608
654
|
version: '0'
|
609
655
|
requirements: []
|
610
656
|
rubyforge_project:
|
611
|
-
rubygems_version: 2.
|
657
|
+
rubygems_version: 2.6.14
|
612
658
|
signing_key:
|
613
659
|
specification_version: 4
|
614
660
|
summary: Phone number validation
|