phony 2.20.13 → 2.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.textile +1 -1
  3. data/lib/phony/config.rb +25 -26
  4. data/lib/phony/countries/argentina.rb +311 -314
  5. data/lib/phony/countries/austria.rb +71 -72
  6. data/lib/phony/countries/bangladesh.rb +27 -28
  7. data/lib/phony/countries/belarus.rb +110 -111
  8. data/lib/phony/countries/brazil.rb +92 -92
  9. data/lib/phony/countries/cambodia.rb +9 -9
  10. data/lib/phony/countries/china.rb +22 -21
  11. data/lib/phony/countries/croatia.rb +6 -5
  12. data/lib/phony/countries/georgia.rb +84 -84
  13. data/lib/phony/countries/germany.rb +4067 -4068
  14. data/lib/phony/countries/guinea.rb +8 -8
  15. data/lib/phony/countries/india.rb +31 -34
  16. data/lib/phony/countries/indonesia.rb +57 -46
  17. data/lib/phony/countries/ireland.rb +4 -5
  18. data/lib/phony/countries/italy.rb +54 -53
  19. data/lib/phony/countries/japan.rb +456 -456
  20. data/lib/phony/countries/kyrgyzstan.rb +109 -109
  21. data/lib/phony/countries/latvia.rb +34 -34
  22. data/lib/phony/countries/libya.rb +106 -106
  23. data/lib/phony/countries/malaysia.rb +12 -12
  24. data/lib/phony/countries/moldova.rb +42 -42
  25. data/lib/phony/countries/montenegro.rb +24 -20
  26. data/lib/phony/countries/myanmar.rb +39 -39
  27. data/lib/phony/countries/namibia.rb +35 -29
  28. data/lib/phony/countries/nepal.rb +60 -62
  29. data/lib/phony/countries/netherlands.rb +13 -13
  30. data/lib/phony/countries/pakistan.rb +135 -111
  31. data/lib/phony/countries/paraguay.rb +135 -135
  32. data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +125 -128
  33. data/lib/phony/countries/saudi_arabia.rb +5 -5
  34. data/lib/phony/countries/serbia.rb +47 -39
  35. data/lib/phony/countries/somalia.rb +18 -18
  36. data/lib/phony/countries/south_korea.rb +16 -13
  37. data/lib/phony/countries/sweden.rb +28 -28
  38. data/lib/phony/countries/taiwan.rb +20 -19
  39. data/lib/phony/countries/tajikistan.rb +70 -70
  40. data/lib/phony/countries/turkmenistan.rb +65 -65
  41. data/lib/phony/countries/ukraine.rb +607 -607
  42. data/lib/phony/countries/united_kingdom.rb +66 -66
  43. data/lib/phony/countries/uruguay.rb +40 -41
  44. data/lib/phony/countries/vietnam.rb +19 -17
  45. data/lib/phony/countries/zimbabwe.rb +31 -31
  46. data/lib/phony/countries.rb +457 -443
  47. data/lib/phony/country.rb +44 -44
  48. data/lib/phony/country_codes.rb +67 -60
  49. data/lib/phony/dsl.rb +23 -26
  50. data/lib/phony/local_splitters/fixed.rb +23 -30
  51. data/lib/phony/local_splitters/regex.rb +30 -31
  52. data/lib/phony/national_code.rb +7 -10
  53. data/lib/phony/national_splitters/default.rb +9 -11
  54. data/lib/phony/national_splitters/dsl.rb +8 -18
  55. data/lib/phony/national_splitters/fixed.rb +12 -15
  56. data/lib/phony/national_splitters/none.rb +7 -11
  57. data/lib/phony/national_splitters/regex.rb +13 -17
  58. data/lib/phony/national_splitters/variable.rb +37 -38
  59. data/lib/phony/trunk_code.rb +20 -20
  60. data/lib/phony/vanity.rb +12 -13
  61. data/lib/phony.rb +84 -84
  62. metadata +5 -42
  63. data/spec/functional/config_spec.rb +0 -44
  64. data/spec/functional/plausibility_spec.rb +0 -689
  65. data/spec/lib/phony/countries_spec.rb +0 -1459
  66. data/spec/lib/phony/country_codes_spec.rb +0 -227
  67. data/spec/lib/phony/country_spec.rb +0 -104
  68. data/spec/lib/phony/dsl_spec.rb +0 -28
  69. data/spec/lib/phony/local_splitters/fixed_spec.rb +0 -56
  70. data/spec/lib/phony/local_splitters/regex_spec.rb +0 -94
  71. data/spec/lib/phony/national_code_spec.rb +0 -61
  72. data/spec/lib/phony/national_splitters/default_spec.rb +0 -34
  73. data/spec/lib/phony/national_splitters/fixed_spec.rb +0 -45
  74. data/spec/lib/phony/national_splitters/none_spec.rb +0 -28
  75. data/spec/lib/phony/national_splitters/regex_spec.rb +0 -23
  76. data/spec/lib/phony/national_splitters/variable_spec.rb +0 -35
  77. data/spec/lib/phony/trunk_code_spec.rb +0 -85
  78. data/spec/lib/phony/vanity_spec.rb +0 -30
  79. data/spec/lib/phony_spec.rb +0 -70
data/lib/phony/vanity.rb CHANGED
@@ -1,38 +1,37 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Phony
2
-
3
4
  # Helper module that maps vanity numbers to digit numbers.
4
5
  #
5
6
  module Vanity
6
-
7
7
  # Returns a char to number mapping string for the String#tr method.
8
8
  #
9
9
  def self.mapping
10
- @@mapping ||= [
11
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.freeze,
12
- '2223334445556667777888999922233344455566677778889999'.freeze
10
+ @@mapping ||= %w[
11
+ ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
12
+ 2223334445556667777888999922233344455566677778889999
13
13
  ]
14
14
  end
15
-
15
+
16
16
  # Replaces (and normalizes) vanity characters of passed number with correct digits.
17
17
  #
18
- def self.replace number
18
+ def self.replace(number)
19
19
  number.tr(*mapping)
20
20
  end
21
-
21
+
22
22
  # Returns true if there is a character in the number
23
23
  # after the first three numbers.
24
24
  #
25
25
  @@vanity_regexp = /\A\d{3}[a-zA-Z]{6,12}\Z/
26
- def self.vanity? number
26
+ def self.vanity?(number)
27
27
  !(normalized(number) =~ @@vanity_regexp).nil?
28
28
  end
29
-
29
+
30
30
  # Vanity-Normalized.
31
31
  #
32
32
  @@vanity_normalizing_regexp = /^0*|[^\w]/
33
- def self.normalized number
33
+ def self.normalized(number)
34
34
  number.gsub @@vanity_normalizing_regexp, ''
35
35
  end
36
-
37
36
  end
38
- end
37
+ end
data/lib/phony.rb CHANGED
@@ -1,81 +1,80 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # NOTE We use Kernel.load here, as it's possible to redefine Phony via Phony::Config.
3
+ # NOTE: We use Kernel.load here, as it's possible to redefine Phony via Phony::Config.
4
4
 
5
5
  # Framework.
6
6
  #
7
- load File.expand_path '../phony/config.rb', __FILE__
8
- load File.expand_path '../phony/vanity.rb', __FILE__
9
- load File.expand_path '../phony/local_splitters/fixed.rb', __FILE__
10
- load File.expand_path '../phony/local_splitters/regex.rb', __FILE__
11
- load File.expand_path '../phony/national_splitters/dsl.rb', __FILE__
12
- load File.expand_path '../phony/national_splitters/fixed.rb', __FILE__
13
- load File.expand_path '../phony/national_splitters/variable.rb', __FILE__
14
- load File.expand_path '../phony/national_splitters/regex.rb', __FILE__
15
- load File.expand_path '../phony/national_splitters/default.rb', __FILE__
16
- load File.expand_path '../phony/national_splitters/none.rb', __FILE__
17
- load File.expand_path '../phony/national_code.rb', __FILE__
18
- load File.expand_path '../phony/country.rb', __FILE__
19
- load File.expand_path '../phony/trunk_code.rb', __FILE__
20
- load File.expand_path '../phony/country_codes.rb', __FILE__
21
- load File.expand_path '../phony/dsl.rb', __FILE__
7
+ load File.expand_path 'phony/config.rb', __dir__
8
+ load File.expand_path 'phony/vanity.rb', __dir__
9
+ load File.expand_path 'phony/local_splitters/fixed.rb', __dir__
10
+ load File.expand_path 'phony/local_splitters/regex.rb', __dir__
11
+ load File.expand_path 'phony/national_splitters/dsl.rb', __dir__
12
+ load File.expand_path 'phony/national_splitters/fixed.rb', __dir__
13
+ load File.expand_path 'phony/national_splitters/variable.rb', __dir__
14
+ load File.expand_path 'phony/national_splitters/regex.rb', __dir__
15
+ load File.expand_path 'phony/national_splitters/default.rb', __dir__
16
+ load File.expand_path 'phony/national_splitters/none.rb', __dir__
17
+ load File.expand_path 'phony/national_code.rb', __dir__
18
+ load File.expand_path 'phony/country.rb', __dir__
19
+ load File.expand_path 'phony/trunk_code.rb', __dir__
20
+ load File.expand_path 'phony/country_codes.rb', __dir__
21
+ load File.expand_path 'phony/dsl.rb', __dir__
22
22
 
23
23
  # Countries.
24
24
  #
25
25
  # The ones that need more space to define.
26
26
  #
27
- load File.expand_path '../phony/countries/argentina.rb', __FILE__
28
- load File.expand_path '../phony/countries/austria.rb', __FILE__
29
- load File.expand_path '../phony/countries/bangladesh.rb', __FILE__
30
- load File.expand_path '../phony/countries/belarus.rb', __FILE__
31
- load File.expand_path '../phony/countries/brazil.rb', __FILE__
32
- load File.expand_path '../phony/countries/cambodia.rb', __FILE__
33
- load File.expand_path '../phony/countries/croatia.rb', __FILE__
34
- load File.expand_path '../phony/countries/china.rb', __FILE__
35
- load File.expand_path '../phony/countries/georgia.rb', __FILE__
36
- load File.expand_path '../phony/countries/germany.rb', __FILE__
37
- load File.expand_path '../phony/countries/guinea.rb', __FILE__
38
- load File.expand_path '../phony/countries/india.rb', __FILE__
39
- load File.expand_path '../phony/countries/indonesia.rb', __FILE__
40
- load File.expand_path '../phony/countries/ireland.rb', __FILE__
41
- load File.expand_path '../phony/countries/italy.rb', __FILE__
42
- load File.expand_path '../phony/countries/japan.rb', __FILE__
43
- load File.expand_path '../phony/countries/kyrgyzstan.rb', __FILE__
44
- load File.expand_path '../phony/countries/latvia.rb', __FILE__
45
- load File.expand_path '../phony/countries/libya.rb', __FILE__
46
- load File.expand_path '../phony/countries/malaysia.rb', __FILE__
47
- load File.expand_path '../phony/countries/moldova.rb', __FILE__
48
- load File.expand_path '../phony/countries/montenegro.rb', __FILE__
49
- load File.expand_path '../phony/countries/myanmar.rb', __FILE__
50
- load File.expand_path '../phony/countries/namibia.rb', __FILE__
51
- load File.expand_path '../phony/countries/nepal.rb', __FILE__
52
- load File.expand_path '../phony/countries/netherlands.rb', __FILE__
53
- load File.expand_path '../phony/countries/pakistan.rb', __FILE__
54
- load File.expand_path '../phony/countries/paraguay.rb', __FILE__
55
- load File.expand_path '../phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb', __FILE__
56
- load File.expand_path '../phony/countries/saudi_arabia.rb', __FILE__
57
- load File.expand_path '../phony/countries/serbia.rb', __FILE__
58
- load File.expand_path '../phony/countries/somalia.rb', __FILE__
59
- load File.expand_path '../phony/countries/south_korea.rb', __FILE__
60
- load File.expand_path '../phony/countries/sweden.rb', __FILE__
61
- load File.expand_path '../phony/countries/taiwan.rb', __FILE__
62
- load File.expand_path '../phony/countries/tajikistan.rb', __FILE__
63
- load File.expand_path '../phony/countries/turkmenistan.rb', __FILE__
64
- load File.expand_path '../phony/countries/vietnam.rb', __FILE__
65
- load File.expand_path '../phony/countries/ukraine.rb', __FILE__
66
- load File.expand_path '../phony/countries/united_kingdom.rb', __FILE__
67
- load File.expand_path '../phony/countries/uruguay.rb', __FILE__
68
- load File.expand_path '../phony/countries/zimbabwe.rb', __FILE__
27
+ load File.expand_path 'phony/countries/argentina.rb', __dir__
28
+ load File.expand_path 'phony/countries/austria.rb', __dir__
29
+ load File.expand_path 'phony/countries/bangladesh.rb', __dir__
30
+ load File.expand_path 'phony/countries/belarus.rb', __dir__
31
+ load File.expand_path 'phony/countries/brazil.rb', __dir__
32
+ load File.expand_path 'phony/countries/cambodia.rb', __dir__
33
+ load File.expand_path 'phony/countries/croatia.rb', __dir__
34
+ load File.expand_path 'phony/countries/china.rb', __dir__
35
+ load File.expand_path 'phony/countries/georgia.rb', __dir__
36
+ load File.expand_path 'phony/countries/germany.rb', __dir__
37
+ load File.expand_path 'phony/countries/guinea.rb', __dir__
38
+ load File.expand_path 'phony/countries/india.rb', __dir__
39
+ load File.expand_path 'phony/countries/indonesia.rb', __dir__
40
+ load File.expand_path 'phony/countries/ireland.rb', __dir__
41
+ load File.expand_path 'phony/countries/italy.rb', __dir__
42
+ load File.expand_path 'phony/countries/japan.rb', __dir__
43
+ load File.expand_path 'phony/countries/kyrgyzstan.rb', __dir__
44
+ load File.expand_path 'phony/countries/latvia.rb', __dir__
45
+ load File.expand_path 'phony/countries/libya.rb', __dir__
46
+ load File.expand_path 'phony/countries/malaysia.rb', __dir__
47
+ load File.expand_path 'phony/countries/moldova.rb', __dir__
48
+ load File.expand_path 'phony/countries/montenegro.rb', __dir__
49
+ load File.expand_path 'phony/countries/myanmar.rb', __dir__
50
+ load File.expand_path 'phony/countries/namibia.rb', __dir__
51
+ load File.expand_path 'phony/countries/nepal.rb', __dir__
52
+ load File.expand_path 'phony/countries/netherlands.rb', __dir__
53
+ load File.expand_path 'phony/countries/pakistan.rb', __dir__
54
+ load File.expand_path 'phony/countries/paraguay.rb', __dir__
55
+ load File.expand_path 'phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb', __dir__
56
+ load File.expand_path 'phony/countries/saudi_arabia.rb', __dir__
57
+ load File.expand_path 'phony/countries/serbia.rb', __dir__
58
+ load File.expand_path 'phony/countries/somalia.rb', __dir__
59
+ load File.expand_path 'phony/countries/south_korea.rb', __dir__
60
+ load File.expand_path 'phony/countries/sweden.rb', __dir__
61
+ load File.expand_path 'phony/countries/taiwan.rb', __dir__
62
+ load File.expand_path 'phony/countries/tajikistan.rb', __dir__
63
+ load File.expand_path 'phony/countries/turkmenistan.rb', __dir__
64
+ load File.expand_path 'phony/countries/vietnam.rb', __dir__
65
+ load File.expand_path 'phony/countries/ukraine.rb', __dir__
66
+ load File.expand_path 'phony/countries/united_kingdom.rb', __dir__
67
+ load File.expand_path 'phony/countries/uruguay.rb', __dir__
68
+ load File.expand_path 'phony/countries/zimbabwe.rb', __dir__
69
69
 
70
70
  # All other countries.
71
71
  #
72
- load File.expand_path '../phony/countries.rb', __FILE__
72
+ load File.expand_path 'phony/countries.rb', __dir__
73
73
 
74
74
  # Phony is the main module and is generally used to process
75
75
  # E164 phone numbers directly.
76
76
  #
77
77
  module Phony
78
-
79
78
  # Raised in case Phony can't normalize a given number.
80
79
  #
81
80
  # @example
@@ -83,21 +82,21 @@ module Phony
83
82
  #
84
83
  class NormalizationError < ArgumentError
85
84
  def initialize
86
- super %Q{Phony could not normalize the given number. Is it a phone number?}
85
+ super(%(Phony could not normalize the given number. Is it a phone number?))
87
86
  end
88
87
  end
89
-
88
+
90
89
  # Raised in case Phony can't split a given number.
91
90
  #
92
91
  # @example
93
92
  # Phony.split("Fnork!") # Raises a Phony::SplittingError.
94
93
  #
95
94
  class SplittingError < ArgumentError
96
- def initialize number
97
- super %Q{Phony could not split the given number. Is #{(number.nil? || number == '') ? 'it' : number.inspect} a phone number?}
95
+ def initialize(number)
96
+ super(%(Phony could not split the given number. Is #{(number.nil? || number == '') ? 'it' : number.inspect} a phone number?))
98
97
  end
99
98
  end
100
-
99
+
101
100
  # Raised in case Phony can't format a given number.
102
101
  #
103
102
  # @example
@@ -105,7 +104,7 @@ module Phony
105
104
  #
106
105
  class FormattingError < ArgumentError
107
106
  def initialize
108
- super %Q{Phony could not format the given number. Is it a phone number?}
107
+ super(%(Phony could not format the given number. Is it a phone number?))
109
108
  end
110
109
  end
111
110
 
@@ -114,7 +113,6 @@ module Phony
114
113
  @codes = CountryCodes.instance
115
114
 
116
115
  class << self
117
-
118
116
  # Get the Country for the given CC.
119
117
  #
120
118
  # @param [String] cc A valid country code.
@@ -125,7 +123,7 @@ module Phony
125
123
  # nanp = Phony['1']
126
124
  # normalized_number = nanp.normalize number
127
125
  #
128
- def [] cc
126
+ def [](cc)
129
127
  @codes[cc]
130
128
  end
131
129
 
@@ -146,11 +144,12 @@ module Phony
146
144
  # @example Normalize a phone number assuming it's a NANP number.
147
145
  # Phony.normalize("301 555 0100", cc: '1') # => "13015550100"
148
146
  #
149
- def normalize phone_number, options = {}
150
- raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.normalize(number)." unless phone_number
151
-
147
+ def normalize(phone_number, options = {})
148
+ raise ArgumentError, 'Phone number cannot be nil. Use e.g. number && Phony.normalize(number).' unless phone_number
149
+
152
150
  normalize! phone_number.dup, options
153
151
  end
152
+
154
153
  # A destructive version of {#normalize}.
155
154
  #
156
155
  # @see #normalize
@@ -168,7 +167,7 @@ module Phony
168
167
  # @example Normalize a phone number assuming it's a NANP number.
169
168
  # Phony.normalize!("301 555 0100", cc: '1') # => "13015550100"
170
169
  #
171
- def normalize! phone_number, options = {}
170
+ def normalize!(phone_number, options = {})
172
171
  @codes.normalize phone_number, options
173
172
  rescue
174
173
  raise NormalizationError.new
@@ -188,11 +187,12 @@ module Phony
188
187
  # @example Split a NANP number.
189
188
  # Phony.split("13015550100") # => ["1", "301", "555", "0100"]
190
189
  #
191
- def split phone_number
192
- raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.split(number)." unless phone_number
193
-
190
+ def split(phone_number)
191
+ raise ArgumentError, 'Phone number cannot be nil. Use e.g. number && Phony.split(number).' unless phone_number
192
+
194
193
  split! phone_number.dup, phone_number
195
194
  end
195
+
196
196
  # A destructive version of {#split}.
197
197
  #
198
198
  # @see #split
@@ -207,7 +207,7 @@ module Phony
207
207
  # @example Split a NANP number.
208
208
  # Phony.split!("13015550100") # => ["1", "301", "555", "0100"]
209
209
  #
210
- def split! phone_number, error_number = nil
210
+ def split!(phone_number, error_number = nil)
211
211
  @codes.split phone_number
212
212
  rescue
213
213
  # NB The error_number (reference) is used because phone_number is destructively handled.
@@ -235,10 +235,12 @@ module Phony
235
235
  # @example Format a NANP number in a specific format.
236
236
  # Phony.format("13015550100", :format => '%{cc} (%{trunk}%{ndc}) %{local}') # => "555 0100"
237
237
  #
238
- def format phone_number, options = {}
239
- raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.format(number)." unless phone_number
238
+ def format(phone_number, options = {})
239
+ raise ArgumentError, 'Phone number cannot be nil. Use e.g. number && Phony.format(number).' unless phone_number
240
+
240
241
  format! phone_number.dup, options
241
242
  end
243
+
242
244
  # A destructive version of {#format}.
243
245
  #
244
246
  # @see #format
@@ -261,7 +263,7 @@ module Phony
261
263
  # @example Format a NANP number in local format.
262
264
  # Phony.format!("13015550100", :format => :local) # => "555 0100"
263
265
  #
264
- def format! phone_number, options = {}
266
+ def format!(phone_number, options = {})
265
267
  @codes.format phone_number, options
266
268
  rescue
267
269
  raise FormattingError.new
@@ -275,14 +277,14 @@ module Phony
275
277
  # If it returns true, it is unclear whether it is plausible,
276
278
  # leaning towards being plausible.
277
279
  #
278
- def plausible? number, hints = {}
280
+ def plausible?(number, hints = {})
279
281
  @codes.plausible? number, hints
280
282
  end
281
283
 
282
284
  # Returns true if there is a character in the number
283
285
  # after the first four numbers.
284
286
  #
285
- def vanity? phone_number
287
+ def vanity?(phone_number)
286
288
  @codes.vanity? phone_number.dup
287
289
  end
288
290
 
@@ -296,10 +298,8 @@ module Phony
296
298
  # @example De-vanitize a number.
297
299
  # Phony.vanity_to_number("1-800-HELLOTHERE") # => "1-800-4355684373"
298
300
  #
299
- def vanity_to_number vanity_number
301
+ def vanity_to_number(vanity_number)
300
302
  @codes.vanity_to_number vanity_number.dup
301
303
  end
302
-
303
304
  end
304
-
305
305
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.20.13
4
+ version: 2.22.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-08-13 00:00:00.000000000 Z
10
+ date: 2025-05-23 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: 'Fast international phone number (E164 standard) normalizing, splitting
14
13
  and formatting. Lots of formatting options: International (+.., 00..), national
@@ -79,28 +78,10 @@ files:
79
78
  - lib/phony/national_splitters/variable.rb
80
79
  - lib/phony/trunk_code.rb
81
80
  - lib/phony/vanity.rb
82
- - spec/functional/config_spec.rb
83
- - spec/functional/plausibility_spec.rb
84
- - spec/lib/phony/countries_spec.rb
85
- - spec/lib/phony/country_codes_spec.rb
86
- - spec/lib/phony/country_spec.rb
87
- - spec/lib/phony/dsl_spec.rb
88
- - spec/lib/phony/local_splitters/fixed_spec.rb
89
- - spec/lib/phony/local_splitters/regex_spec.rb
90
- - spec/lib/phony/national_code_spec.rb
91
- - spec/lib/phony/national_splitters/default_spec.rb
92
- - spec/lib/phony/national_splitters/fixed_spec.rb
93
- - spec/lib/phony/national_splitters/none_spec.rb
94
- - spec/lib/phony/national_splitters/regex_spec.rb
95
- - spec/lib/phony/national_splitters/variable_spec.rb
96
- - spec/lib/phony/trunk_code_spec.rb
97
- - spec/lib/phony/vanity_spec.rb
98
- - spec/lib/phony_spec.rb
99
81
  homepage: https://github.com/floere/phony
100
82
  licenses:
101
83
  - MIT
102
84
  metadata: {}
103
- post_install_message:
104
85
  rdoc_options: []
105
86
  require_paths:
106
87
  - lib
@@ -108,33 +89,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
89
  requirements:
109
90
  - - ">="
110
91
  - !ruby/object:Gem::Version
111
- version: '0'
92
+ version: '2.7'
112
93
  required_rubygems_version: !ruby/object:Gem::Requirement
113
94
  requirements:
114
95
  - - ">="
115
96
  - !ruby/object:Gem::Version
116
97
  version: '0'
117
98
  requirements: []
118
- rubygems_version: 3.4.19
119
- signing_key:
99
+ rubygems_version: 3.6.2
120
100
  specification_version: 4
121
101
  summary: Fast international phone number (E164 standard) normalizing, splitting and
122
102
  formatting.
123
- test_files:
124
- - spec/functional/config_spec.rb
125
- - spec/functional/plausibility_spec.rb
126
- - spec/lib/phony/countries_spec.rb
127
- - spec/lib/phony/country_codes_spec.rb
128
- - spec/lib/phony/country_spec.rb
129
- - spec/lib/phony/dsl_spec.rb
130
- - spec/lib/phony/local_splitters/fixed_spec.rb
131
- - spec/lib/phony/local_splitters/regex_spec.rb
132
- - spec/lib/phony/national_code_spec.rb
133
- - spec/lib/phony/national_splitters/default_spec.rb
134
- - spec/lib/phony/national_splitters/fixed_spec.rb
135
- - spec/lib/phony/national_splitters/none_spec.rb
136
- - spec/lib/phony/national_splitters/regex_spec.rb
137
- - spec/lib/phony/national_splitters/variable_spec.rb
138
- - spec/lib/phony/trunk_code_spec.rb
139
- - spec/lib/phony/vanity_spec.rb
140
- - spec/lib/phony_spec.rb
103
+ test_files: []
@@ -1,44 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- describe 'Phony::Config' do
4
- describe 'load' do
5
- before do
6
- # NOTE We redefine Phony as if it was not loaded for this set of tests.
7
- Object.__send__(:remove_const, :Phony) if Object.constants.include?(:Phony)
8
-
9
- load 'phony/config.rb'
10
- end
11
- after(:all) do
12
- # After running this suite, we load all of Phony for the following tests.
13
- load 'phony/config.rb'
14
-
15
- Phony::Config.load
16
- end
17
-
18
- it 'does not fail when loading all' do
19
- Phony::Config.load
20
-
21
- expect(Phony.split('15551115511')).to eq ['1', '555', '111', '5511']
22
- end
23
- it 'raises when a CC is used that has not been loaded.' do
24
- Phony::Config.load('41')
25
-
26
- expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
27
- end
28
- it 'raises when a CC is used that has not been loaded.' do
29
- Phony::Config.load(only: ['41'])
30
-
31
- expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
32
- end
33
- it 'raises when a CC is used that has not been loaded.' do
34
- Phony::Config.load(except: ['1'])
35
-
36
- expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
37
- end
38
- it 'does not raise when a CC is used that has been loaded.' do
39
- Phony::Config.load(except: ['41'])
40
-
41
- expect(Phony.split('15551115511')).to eq ['1', '555', '111', '5511']
42
- end
43
- end
44
- end