telephone_number 1.4.9 → 1.4.10

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -916,12 +916,14 @@
916
916
  1442|America/Los_Angeles
917
917
  1443|America/New_York
918
918
  1445|America/New_York
919
+ 1447|America/Chicago
919
920
  1450|America/Toronto
920
921
  1458|America/Los_Angeles
921
922
  1463|America/New_York
922
923
  1469|America/Chicago
923
924
  1470|America/New_York
924
925
  1473|America/Grenada
926
+ 1474|America/Winnipeg
925
927
  1475|America/New_York
926
928
  1478|America/New_York
927
929
  1479|America/Chicago
@@ -1609,6 +1611,7 @@
1609
1611
  1832|America/Chicago
1610
1612
  1838|America/New_York
1611
1613
  1839|America/New_York
1614
+ 1840|America/Los_Angeles
1612
1615
  1843|America/New_York
1613
1616
  1845|America/New_York
1614
1617
  1847|America/Chicago
@@ -1972,6 +1975,7 @@
1972
1975
  1939|America/Puerto_Rico
1973
1976
  1940|America/Chicago
1974
1977
  1941|America/New_York
1978
+ 1945|America/Chicago
1975
1979
  1947|America/New_York
1976
1980
  1949|America/Los_Angeles
1977
1981
  1951|America/Los_Angeles
@@ -2173,6 +2177,33 @@
2173
2177
  441534|Europe/Jersey
2174
2178
  441624|Europe/Isle_of_Man
2175
2179
  442|Europe/London
2180
+ 443|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2181
+ 445|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2182
+ 4470|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2183
+ 4471|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2184
+ 4472|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2185
+ 4473|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2186
+ 4474|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2187
+ 4475|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2188
+ 44760|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2189
+ 44762|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2190
+ 44763|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2191
+ 447640|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2192
+ 447641|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2193
+ 447643|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2194
+ 447644|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2195
+ 447646|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2196
+ 44765|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2197
+ 44766|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2198
+ 44767|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2199
+ 44768|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2200
+ 447693|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2201
+ 447699|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2202
+ 4477|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2203
+ 4478|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2204
+ 4479|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2205
+ 448|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2206
+ 449|Europe/Guernsey&Europe/Isle_of_Man&Europe/London
2176
2207
  45|Europe/Copenhagen
2177
2208
  46|Europe/Stockholm
2178
2209
  47|Arctic/Longyearbyen&Europe/Oslo
@@ -2839,7 +2870,7 @@
2839
2870
  565|America/Santiago
2840
2871
  566|America/Santiago
2841
2872
  567|America/Santiago
2842
- 56800|America/Santiago
2873
+ 568|America/Santiago
2843
2874
  569|America/Santiago
2844
2875
  57|America/Bogota
2845
2876
  58|America/Caracas
@@ -2905,7 +2936,7 @@
2905
2936
  61851060|Indian/Cocos
2906
2937
  61851087|Australia/Perth
2907
2938
  61851088|Indian/Christmas
2908
- 61851089|Australia/Sydney
2939
+ 61851089|Indian/Cocos
2909
2940
  6185109|Australia/Perth
2910
2941
  618511|Australia/Perth
2911
2942
  61851100|Australia/Adelaide&Australia/Perth
@@ -2924,15 +2955,39 @@
2924
2955
  61851156|Australia/Adelaide&Australia/Perth
2925
2956
  61851158|Australia/Adelaide&Australia/Perth
2926
2957
  61851175|Indian/Christmas
2958
+ 61851176|Indian/Cocos
2927
2959
  61851185|Australia/Adelaide&Australia/Perth
2928
2960
  61851187|Australia/Adelaide&Australia/Perth
2929
2961
  6185120|Australia/Perth
2930
2962
  61851204|Indian/Christmas
2931
2963
  61851205|Australia/Sydney
2932
- 6185123|Australia/Sydney
2964
+ 61851209|Australia/Adelaide&Australia/Perth
2965
+ 6185121|Australia/Adelaide&Australia/Perth
2966
+ 61851221|Australia/Adelaide&Australia/Perth
2967
+ 61851222|Indian/Christmas
2968
+ 61851223|Indian/Cocos
2969
+ 61851224|Australia/Perth
2970
+ 61851225|Australia/Perth
2971
+ 61851226|Australia/Perth
2972
+ 61851227|Australia/Adelaide&Australia/Perth
2973
+ 61851228|Australia/Adelaide&Australia/Perth
2974
+ 61851229|Australia/Adelaide&Australia/Perth
2975
+ 61851230|Australia/Sydney
2976
+ 61851231|Australia/Adelaide&Australia/Perth
2977
+ 61851232|Australia/Sydney
2978
+ 61851233|Australia/Sydney
2979
+ 61851234|Australia/Sydney
2980
+ 61851235|Indian/Christmas
2981
+ 61851236|Australia/Adelaide&Australia/Perth
2982
+ 61851237|Australia/Adelaide&Australia/Perth
2983
+ 61851238|Australia/Adelaide&Australia/Perth
2984
+ 61851239|Australia/Adelaide&Australia/Perth
2933
2985
  6185124|Australia/Sydney
2934
2986
  6185125|Australia/Sydney
2935
2987
  6185126|Australia/Sydney
2988
+ 6185127|Australia/Adelaide&Australia/Perth
2989
+ 6185128|Australia/Adelaide&Australia/Perth
2990
+ 6185129|Australia/Adelaide&Australia/Perth
2936
2991
  6186|Australia/Adelaide&Australia/Perth
2937
2992
  6187|Australia/Adelaide&Australia/Perth
2938
2993
  6188|Australia/Adelaide&Australia/Perth
@@ -2973,11 +3028,15 @@
2973
3028
  61891700|Australia/Adelaide&Australia/Perth&Indian/Christmas
2974
3029
  61891701|Australia/Adelaide&Australia/Perth&Indian/Christmas
2975
3030
  61891702|Australia/Adelaide&Australia/Perth&Indian/Cocos
3031
+ 61891703|Indian/Cocos
2976
3032
  61891710|Australia/Adelaide&Australia/Perth&Indian/Christmas
2977
3033
  61891711|Australia/Adelaide&Australia/Perth&Indian/Christmas
2978
3034
  61891712|Australia/Adelaide&Australia/Perth&Indian/Christmas
3035
+ 61891958|Indian/Christmas
2979
3036
  61891959|Australia/Adelaide&Australia/Perth&Indian/Cocos
2980
3037
  62|Asia/Jakarta&Asia/Jayapura&Asia/Makassar
3038
+ 62007|Asia/Jakarta&Asia/Makassar
3039
+ 621|Asia/Jakarta&Asia/Makassar
2981
3040
  622|Asia/Jakarta
2982
3041
  6231|Asia/Jakarta
2983
3042
  6232|Asia/Jakarta
@@ -2985,12 +3044,8 @@
2985
3044
  6234|Asia/Jakarta
2986
3045
  6235|Asia/Jakarta
2987
3046
  6236|Asia/Makassar
2988
- 62370|Asia/Makassar
2989
- 62371|Asia/Makassar
2990
- 62372|Asia/Makassar
2991
- 62373|Asia/Makassar
2992
- 62374|Asia/Makassar
2993
- 62376|Asia/Makassar
3047
+ 6237|Asia/Makassar
3048
+ 62379|Asia/Jakarta&Asia/Makassar
2994
3049
  6238|Asia/Makassar
2995
3050
  624|Asia/Makassar
2996
3051
  62403|Asia/Jayapura&Asia/Makassar
@@ -3015,27 +3070,21 @@
3015
3070
  6256|Asia/Jakarta
3016
3071
  626|Asia/Jakarta
3017
3072
  627|Asia/Jakarta
3018
- 6281|Asia/Jakarta
3073
+ 628|Asia/Jakarta
3074
+ 6280|Asia/Jakarta&Asia/Makassar
3019
3075
  62811|Asia/Jakarta&Asia/Makassar
3020
3076
  62818|Asia/Jakarta&Asia/Makassar
3021
3077
  62819|Asia/Jakarta&Asia/Makassar
3022
- 6282|Asia/Jakarta
3023
3078
  62824|Asia/Jakarta&Asia/Makassar
3024
3079
  62829|Asia/Jakarta&Asia/Makassar
3025
- 6283|Asia/Jakarta
3026
3080
  62831|Asia/Jakarta&Asia/Makassar
3027
3081
  62833|Asia/Jakarta&Asia/Makassar
3028
3082
  62834|Asia/Jakarta&Asia/Makassar
3029
3083
  62839|Asia/Jakarta&Asia/Makassar
3030
- 6285|Asia/Jakarta
3031
3084
  62853|Asia/Jakarta&Asia/Makassar
3032
- 6286|Asia/Jakarta
3033
3085
  62868|Asia/Jakarta&Asia/Makassar
3034
- 6287|Asia/Jakarta
3035
3086
  62876|Asia/Jakarta&Asia/Makassar
3036
- 6288|Asia/Jakarta
3037
3087
  62887|Asia/Jakarta&Asia/Makassar
3038
- 6289|Asia/Jakarta
3039
3088
  6290|Asia/Jayapura
3040
3089
  6291|Asia/Jayapura
3041
3090
  62915|Asia/Jakarta&Asia/Jayapura
@@ -1,5 +1,4 @@
1
1
  require 'telephone_number/version'
2
- require 'utilities/hash'
3
2
  require 'active_model/telephone_number_validator' if defined?(ActiveModel)
4
3
  require 'forwardable'
5
4
 
@@ -7,18 +7,18 @@ module TelephoneNumber
7
7
  MOBILE_TOKEN_COUNTRIES = { AR: '9' }.freeze
8
8
 
9
9
  def initialize(data_hash)
10
+ validations = data_hash.fetch(:validations, {}).dup
10
11
  @country_code = data_hash[:country_code]
11
12
  @country_id = data_hash[:id]
12
- @general_validation = NumberValidation.new(:general_desc, data_hash[:validations][:general_desc]) if data_hash.fetch(:validations, {})[:general_desc]
13
+ @general_validation = NumberValidation.new(:general_desc, validations[:general_desc]) if validations[:general_desc]
13
14
  @international_prefix = Regexp.new(data_hash[:international_prefix]) if data_hash[:international_prefix]
14
15
  @main_country_for_code = data_hash[:main_country_for_code] == 'true'
15
16
  @mobile_token = MOBILE_TOKEN_COUNTRIES[@country_id.to_sym]
16
17
  @national_prefix = data_hash[:national_prefix]
17
18
  @national_prefix_for_parsing = Regexp.new(data_hash[:national_prefix_for_parsing]) if data_hash[:national_prefix_for_parsing]
18
19
  @national_prefix_transform_rule = data_hash[:national_prefix_transform_rule]
19
- @validations = data_hash.fetch(:validations, {})
20
- .except(:general_desc, :area_code_optional)
21
- .map { |name, data| NumberValidation.new(name, data) }
20
+ @validations = validations.delete_if { |name, _| name == :general_desc || name == :area_code_optional }
21
+ .map { |name, data| NumberValidation.new(name, data) }
22
22
  @formats = data_hash.fetch(:formats, []).map { |format| NumberFormat.new(format, data_hash[:national_prefix_formatting_rule]) }
23
23
  end
24
24
 
@@ -52,11 +52,24 @@ module TelephoneNumber
52
52
  end
53
53
 
54
54
  def self.load_data
55
- data_file = "#{File.dirname(__FILE__)}/../../data/telephone_number_data_file.dat"
56
- main_data = Marshal.load(File.binread(data_file))
57
- override_data = {}
58
- override_data = Marshal.load(File.binread(TelephoneNumber.override_file)) if TelephoneNumber.override_file
59
- return main_data.deep_deep_merge!(override_data)
55
+ data_path = "#{File.dirname(__FILE__)}/../../data/telephone_number_data_file.dat"
56
+ main_data = Marshal.load(File.binread(data_path))
57
+ if TelephoneNumber.override_file
58
+ override_data = Marshal.load(File.binread(TelephoneNumber.override_file))
59
+ main_data = deep_merge(main_data, override_data)
60
+ end
61
+ main_data
62
+ end
63
+
64
+ def self.deep_merge(base_hash, other_hash)
65
+ other_hash.each do |key, value|
66
+ base_hash[key] = if base_hash[key].is_a?(Hash) && value.is_a?(Hash)
67
+ deep_merge(base_hash[key], value)
68
+ else
69
+ value
70
+ end
71
+ end
72
+ base_hash
60
73
  end
61
74
 
62
75
  def self.all_countries
@@ -1,3 +1,3 @@
1
1
  module TelephoneNumber
2
- VERSION = "1.4.9"
2
+ VERSION = "1.4.10"
3
3
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.bindir = 'exe'
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
+ spec.required_ruby_version = '>= 2.4.0'
22
23
 
23
24
  spec.add_development_dependency 'bundler'
24
25
  spec.add_development_dependency 'rake'
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.9
4
+ version: 1.4.10
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: 2020-08-17 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,6 +150,7 @@ files:
150
150
  - ".rubocop.yml"
151
151
  - ".ruby-version"
152
152
  - ".travis.yml"
153
+ - CHANGELOG.md
153
154
  - CODE_OF_CONDUCT.md
154
155
  - Gemfile
155
156
  - LICENSE
@@ -453,6 +454,8 @@ files:
453
454
  - data/geocoding/en/95.txt
454
455
  - data/geocoding/en/960.dat
455
456
  - data/geocoding/en/960.txt
457
+ - data/geocoding/en/961.dat
458
+ - data/geocoding/en/961.txt
456
459
  - data/geocoding/en/962.dat
457
460
  - data/geocoding/en/962.txt
458
461
  - data/geocoding/en/963.dat
@@ -632,7 +635,6 @@ files:
632
635
  - lib/telephone_number/parser.rb
633
636
  - lib/telephone_number/time_zone_detector.rb
634
637
  - lib/telephone_number/version.rb
635
- - lib/utilities/hash.rb
636
638
  - telephone_number.gemspec
637
639
  homepage: https://github.com/mobi/telephone_number
638
640
  licenses:
@@ -646,15 +648,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
646
648
  requirements:
647
649
  - - ">="
648
650
  - !ruby/object:Gem::Version
649
- version: '0'
651
+ version: 2.4.0
650
652
  required_rubygems_version: !ruby/object:Gem::Requirement
651
653
  requirements:
652
654
  - - ">="
653
655
  - !ruby/object:Gem::Version
654
656
  version: '0'
655
657
  requirements: []
656
- rubyforge_project:
657
- rubygems_version: 2.6.14
658
+ rubygems_version: 3.0.3
658
659
  signing_key:
659
660
  specification_version: 4
660
661
  summary: Phone number validation
@@ -1,47 +0,0 @@
1
- class Hash
2
- # Returns a new hash with +self+ and +other_hash+ merged recursively.
3
- #
4
- # h1 = { a: true, b: { c: [1, 2, 3] } }
5
- # h2 = { a: false, b: { x: [3, 4, 5] } }
6
- #
7
- # h1.deep_merge(h2) # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
8
- #
9
- # Like with Hash#merge in the standard library, a block can be provided
10
- # to merge values:
11
- #
12
- # h1 = { a: 100, b: 200, c: { c1: 100 } }
13
- # h2 = { b: 250, c: { c1: 200 } }
14
- # h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
15
- # # => { a: 100, b: 450, c: { c1: 300 } }
16
- def deep_deep_merge(other_hash, &block)
17
- dup.deep_deep_merge!(other_hash, &block)
18
- end
19
-
20
- # Same as +deep_merge+, but modifies +self+.
21
- def deep_deep_merge!(other_hash, &block)
22
- other_hash.each_pair do |current_key, other_value|
23
- this_value = self[current_key]
24
-
25
- self[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
26
- this_value.deep_deep_merge(other_value, &block)
27
- else
28
- if block_given? && key?(current_key)
29
- block.call(current_key, this_value, other_value)
30
- else
31
- other_value
32
- end
33
- end
34
- end
35
-
36
- self
37
- end
38
-
39
- def except(*keys)
40
- dup.except!(*keys)
41
- end
42
-
43
- def except!(*keys)
44
- keys.each { |key| delete(key) }
45
- self
46
- end
47
- end