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.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/data/geocoding/bs/387.dat +0 -0
  3. data/data/geocoding/bs/387.txt +2 -0
  4. data/data/geocoding/de/352.dat +0 -0
  5. data/data/geocoding/de/352.txt +0 -1
  6. data/data/geocoding/de/43.dat +0 -0
  7. data/data/geocoding/de/43.txt +2 -0
  8. data/data/geocoding/en/1.dat +0 -0
  9. data/data/geocoding/en/1.txt +38 -6
  10. data/data/geocoding/en/212.dat +0 -0
  11. data/data/geocoding/en/212.txt +4 -4
  12. data/data/geocoding/en/216.dat +0 -0
  13. data/data/geocoding/en/216.txt +1 -0
  14. data/data/geocoding/en/218.dat +0 -0
  15. data/data/geocoding/en/218.txt +77 -1
  16. data/data/geocoding/en/220.dat +0 -0
  17. data/data/geocoding/en/220.txt +1 -0
  18. data/data/geocoding/en/221.dat +0 -0
  19. data/data/geocoding/en/221.txt +7 -1
  20. data/data/geocoding/en/224.dat +0 -0
  21. data/data/geocoding/en/224.txt +1 -1
  22. data/data/geocoding/en/225.dat +0 -0
  23. data/data/geocoding/en/225.txt +14 -4
  24. data/data/geocoding/en/233.dat +0 -0
  25. data/data/geocoding/en/233.txt +1 -0
  26. data/data/geocoding/en/234.dat +0 -0
  27. data/data/geocoding/en/234.txt +16 -1
  28. data/data/geocoding/en/236.dat +0 -0
  29. data/data/geocoding/en/236.txt +15 -0
  30. data/data/geocoding/en/241.dat +0 -0
  31. data/data/geocoding/en/241.txt +30 -0
  32. data/data/geocoding/en/251.dat +0 -0
  33. data/data/geocoding/en/251.txt +1 -6
  34. data/data/geocoding/en/252.dat +0 -0
  35. data/data/geocoding/en/252.txt +0 -1
  36. data/data/geocoding/en/264.dat +0 -0
  37. data/data/geocoding/en/264.txt +2 -0
  38. data/data/geocoding/en/290.dat +0 -0
  39. data/data/geocoding/en/290.txt +6 -1
  40. data/data/geocoding/en/33.dat +0 -0
  41. data/data/geocoding/en/33.txt +10598 -2177
  42. data/data/geocoding/en/34.dat +0 -0
  43. data/data/geocoding/en/34.txt +62 -2
  44. data/data/geocoding/en/352.dat +0 -0
  45. data/data/geocoding/en/352.txt +0 -1
  46. data/data/geocoding/en/353.dat +0 -0
  47. data/data/geocoding/en/353.txt +266 -15
  48. data/data/geocoding/en/354.dat +0 -0
  49. data/data/geocoding/en/354.txt +5 -6
  50. data/data/geocoding/en/370.dat +0 -0
  51. data/data/geocoding/en/370.txt +9 -2
  52. data/data/geocoding/en/374.dat +0 -0
  53. data/data/geocoding/en/374.txt +0 -5
  54. data/data/geocoding/en/386.dat +0 -0
  55. data/data/geocoding/en/386.txt +43 -0
  56. data/data/geocoding/en/389.dat +0 -0
  57. data/data/geocoding/en/389.txt +28 -2
  58. data/data/geocoding/en/421.dat +0 -0
  59. data/data/geocoding/en/421.txt +15 -14
  60. data/data/geocoding/en/43.dat +0 -0
  61. data/data/geocoding/en/43.txt +2 -0
  62. data/data/geocoding/en/44.dat +0 -0
  63. data/data/geocoding/en/44.txt +9 -1
  64. data/data/geocoding/en/46.dat +0 -0
  65. data/data/geocoding/en/46.txt +10 -2
  66. data/data/geocoding/en/47.dat +0 -0
  67. data/data/geocoding/en/47.txt +137 -1
  68. data/data/geocoding/en/504.dat +0 -0
  69. data/data/geocoding/en/504.txt +74 -0
  70. data/data/geocoding/en/52.dat +0 -0
  71. data/data/geocoding/en/52.txt +1 -1
  72. data/data/geocoding/en/54.dat +0 -0
  73. data/data/geocoding/en/54.txt +19 -6
  74. data/data/geocoding/en/56.dat +0 -0
  75. data/data/geocoding/en/56.txt +37 -1
  76. data/data/geocoding/en/58.dat +0 -0
  77. data/data/geocoding/en/58.txt +21 -12
  78. data/data/geocoding/en/593.dat +0 -0
  79. data/data/geocoding/en/593.txt +21 -0
  80. data/data/geocoding/en/595.dat +0 -0
  81. data/data/geocoding/en/595.txt +73 -0
  82. data/data/geocoding/en/598.dat +0 -0
  83. data/data/geocoding/en/598.txt +33 -0
  84. data/data/geocoding/en/599.dat +0 -0
  85. data/data/geocoding/en/599.txt +8 -2
  86. data/data/geocoding/en/60.dat +0 -0
  87. data/data/geocoding/en/60.txt +9 -8
  88. data/data/geocoding/en/61.dat +0 -0
  89. data/data/geocoding/en/61.txt +20633 -1991
  90. data/data/geocoding/en/63.dat +0 -0
  91. data/data/geocoding/en/63.txt +61 -0
  92. data/data/geocoding/en/64.dat +0 -0
  93. data/data/geocoding/en/64.txt +2862 -108
  94. data/data/geocoding/en/66.dat +0 -0
  95. data/data/geocoding/en/66.txt +4 -0
  96. data/data/geocoding/en/670.dat +0 -0
  97. data/data/geocoding/en/670.txt +31 -0
  98. data/data/geocoding/en/672.dat +0 -0
  99. data/data/geocoding/en/672.txt +18 -0
  100. data/data/geocoding/en/673.dat +0 -0
  101. data/data/geocoding/en/673.txt +41 -0
  102. data/data/geocoding/en/678.dat +0 -0
  103. data/data/geocoding/en/678.txt +27 -0
  104. data/data/geocoding/en/679.dat +0 -0
  105. data/data/geocoding/en/679.txt +20 -0
  106. data/data/geocoding/en/680.dat +0 -0
  107. data/data/geocoding/en/680.txt +1 -1
  108. data/data/geocoding/en/682.dat +0 -0
  109. data/data/geocoding/en/682.txt +26 -0
  110. data/data/geocoding/en/685.dat +0 -0
  111. data/data/geocoding/en/685.txt +27 -0
  112. data/data/geocoding/en/686.dat +0 -0
  113. data/data/geocoding/en/686.txt +0 -1
  114. data/data/geocoding/en/689.dat +0 -0
  115. data/data/geocoding/en/689.txt +24 -0
  116. data/data/geocoding/en/690.dat +0 -0
  117. data/data/geocoding/en/690.txt +17 -0
  118. data/data/geocoding/en/7.dat +0 -0
  119. data/data/geocoding/en/7.txt +3 -0
  120. data/data/geocoding/en/81.dat +0 -0
  121. data/data/geocoding/en/81.txt +1 -1
  122. data/data/geocoding/en/850.dat +0 -0
  123. data/data/geocoding/en/850.txt +31 -0
  124. data/data/geocoding/en/880.dat +0 -0
  125. data/data/geocoding/en/880.txt +247 -613
  126. data/data/geocoding/en/886.dat +0 -0
  127. data/data/geocoding/en/886.txt +36 -2
  128. data/data/geocoding/en/91.dat +0 -0
  129. data/data/geocoding/en/91.txt +3606 -516
  130. data/data/geocoding/en/92.dat +0 -0
  131. data/data/geocoding/en/92.txt +760 -0
  132. data/data/geocoding/en/94.dat +0 -0
  133. data/data/geocoding/en/94.txt +2 -2
  134. data/data/geocoding/en/95.dat +0 -0
  135. data/data/geocoding/en/95.txt +14 -0
  136. data/data/geocoding/en/962.dat +0 -0
  137. data/data/geocoding/en/962.txt +24 -2
  138. data/data/geocoding/en/963.dat +0 -0
  139. data/data/geocoding/en/963.txt +35 -0
  140. data/data/geocoding/en/967.dat +0 -0
  141. data/data/geocoding/en/967.txt +98 -0
  142. data/data/geocoding/en/970.dat +0 -0
  143. data/data/geocoding/en/970.txt +29 -0
  144. data/data/geocoding/en/971.dat +0 -0
  145. data/data/geocoding/en/971.txt +49 -0
  146. data/data/geocoding/en/993.dat +0 -0
  147. data/data/geocoding/en/993.txt +5 -0
  148. data/data/geocoding/en/995.dat +0 -0
  149. data/data/geocoding/en/995.txt +91 -0
  150. data/data/geocoding/en/996.dat +0 -0
  151. data/data/geocoding/en/996.txt +35 -1
  152. data/data/geocoding/es/34.dat +0 -0
  153. data/data/geocoding/es/34.txt +62 -2
  154. data/data/geocoding/es/54.dat +0 -0
  155. data/data/geocoding/es/54.txt +19 -6
  156. data/data/geocoding/es/56.dat +0 -0
  157. data/data/geocoding/es/56.txt +37 -1
  158. data/data/geocoding/es/58.dat +0 -0
  159. data/data/geocoding/es/58.txt +21 -12
  160. data/data/geocoding/fr/212.dat +0 -0
  161. data/data/geocoding/fr/212.txt +4 -4
  162. data/data/geocoding/fr/225.dat +0 -0
  163. data/data/geocoding/fr/225.txt +14 -4
  164. data/data/geocoding/fr/290.dat +0 -0
  165. data/data/geocoding/fr/290.txt +6 -1
  166. data/data/geocoding/fr/33.dat +0 -0
  167. data/data/geocoding/fr/33.txt +10586 -2165
  168. data/data/geocoding/fr/352.dat +0 -0
  169. data/data/geocoding/fr/352.txt +0 -1
  170. data/data/geocoding/hy/374.dat +0 -0
  171. data/data/geocoding/hy/374.txt +0 -5
  172. data/data/geocoding/ru/374.dat +0 -0
  173. data/data/geocoding/ru/374.txt +0 -6
  174. data/data/geocoding/ru/7.dat +0 -0
  175. data/data/geocoding/ru/7.txt +92 -1
  176. data/data/geocoding/sv/46.dat +0 -0
  177. data/data/geocoding/sv/46.txt +26 -3
  178. data/data/geocoding/th/66.dat +0 -0
  179. data/data/geocoding/th/66.txt +4 -0
  180. data/data/geocoding/zh/886.dat +0 -0
  181. data/data/geocoding/zh/886.txt +37 -2
  182. data/data/telephone_number_data_file.dat +0 -0
  183. data/data/telephone_number_data_file.xml +3460 -1908
  184. data/data/timezones/map_data.dat +0 -0
  185. data/data/timezones/map_data.txt +114 -250
  186. data/lib/importers/geo_location_data_importer.rb +1 -1
  187. data/lib/importers/test_data_importer.rb +1 -1
  188. data/lib/telephone_number/parser.rb +10 -5
  189. data/lib/telephone_number/version.rb +1 -1
  190. 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 ||= validate
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
- match_result ? match_result[:national_num] : original_number
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 normalized number
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 validate
36
+ def generate_valid_types(number)
32
37
  return [] unless country
33
38
  country.validations.select do |validation|
34
- normalized_number.match?(Regexp.new("^(#{validation.pattern})$"))
39
+ number.match?(Regexp.new("^(#{validation.pattern})$"))
35
40
  end.map(&:name)
36
41
  end
37
42
 
@@ -1,3 +1,3 @@
1
1
  module TelephoneNumber
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.8"
3
3
  end
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.3
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: 2019-09-27 00:00:00.000000000 Z
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.5.2.3
657
+ rubygems_version: 2.6.14
612
658
  signing_key:
613
659
  specification_version: 4
614
660
  summary: Phone number validation