phone 1.3.0.beta0 → 1.3.0.beta1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 968e42477f674e7f318948884bc9af50d369e934
4
- data.tar.gz: fd0e865669d8ba5c3031be42f5bb8b0af92c11f3
3
+ metadata.gz: fab9b04ed81180114e3eda2b6a4ee53589771921
4
+ data.tar.gz: 1112e0c61798c1e60b21ac26f5cc69dd5365174a
5
5
  SHA512:
6
- metadata.gz: 920a4b87ec5e07f39d87141d51e9cf916ff20ea833e0d26e2ae98ff267a54d6505acda34b1f5db3750dc60bd2c3756b9c9dfdd7f53664bcabb876805ea2d0d21
7
- data.tar.gz: 6dd4129fbd34830c5ca6ce4728ebaf1584878660bf8d8e80a627ceb369aec1d0bf28dddcb76770d0ddb191ca49ce8fa606a74960954a60c4cd889982a18c3386
6
+ metadata.gz: 9f8abc7778aa6bff2096bcd6d89c93e3aed7484bd9d4ee8ba74329352a229fd2016d009d8749b40549550b1e73678067aee27ca0c8927c12f7b9effc20288155
7
+ data.tar.gz: debc024c5dd45f515ba9925aaa61c59c7a037aa0be2ba1add877d288b5280c0eb3390492d8097060eed35eba6050c9840cc8d383150671cacb4ee06c3cd12588
@@ -3,12 +3,17 @@ bundler_args: --without doc
3
3
  rvm:
4
4
  - 1.8.7
5
5
  - 1.9.3
6
- - 2.0.0
7
- - 2.1.0
6
+ - 2.0
7
+ - 2.1
8
+ - rbx
9
+ - rbx-2
10
+ - jruby
8
11
  - ruby-head
9
- - jruby-19mode
10
12
  - jruby-head
11
- - rbx
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+ - rvm: jruby-head
12
17
  notifications:
13
18
  email:
14
19
  - github@elskwid.net
@@ -15,6 +15,12 @@
15
15
  * [improvement] Remove need for ActiveSupport detection. (elskwid)
16
16
  * [improvement] Remove monkeypatching support library. (elskwid)
17
17
  * [improvement] Add support for Travis CI. (elskwid)
18
+ * [improvement] Add tests for parameter mutation in `#valid?`. (elskwid)
19
+ * [fix] Fix parameter mutation in extension extraction. (elskwid)
20
+ * [fix] ME (Montenegro) area code correction and tests. (bsboris)
21
+ * [improvement] Add test for parameter mutation in `::parse`. (elskwid)
22
+ * [improvement] Code style clean up and method refactoring to clarify processing and remove multiple gsub calls. (elskwid)
23
+ * [doc] README updates.
18
24
 
19
25
  # 1.2.3 / 2013-11-16
20
26
 
data/README.md CHANGED
@@ -1,5 +1,19 @@
1
+ [gem]: https://rubygems.org/gems/phone
2
+ [stable]: https://github.com/carr/phone/tree/v1.2.3
3
+ [gem-beta]: https://rubygems.org/gems/phone/versions/1.3.0.beta1
4
+ [beta]: https://github.com/carr/phone/tree/v1.3.0.beta1/
5
+ [travis]: https://travis-ci.org/carr/phone
6
+ [gemnasium]: https://gemnasium.com/carr/phone
7
+ [codeclimate]: https://codeclimate.com/github/carr/phone
8
+
1
9
  # phone
2
10
 
11
+ [![Beta Gem Version](https://img.shields.io/badge/beta-v1.3.0.beta1-blue.svg)][gem-beta]
12
+ [![Gem Version](https://img.shields.io/gem/v/phone.svg)][gem]
13
+ [![Build Status](https://img.shields.io/travis/carr/phone.svg)][travis]
14
+ [![Dependency Status](https://img.shields.io/gemnasium/carr/phone.svg)][gemnasium]
15
+ [![Code Climate](https://img.shields.io/codeclimate/github/carr/phone.svg)][codeclimate]
16
+
3
17
  Parsing, validating and creating phone numbers
4
18
 
5
19
  * [Homepage](https://github.com/carr/phone#readme)
@@ -9,11 +23,14 @@ Parsing, validating and creating phone numbers
9
23
 
10
24
  ## Version
11
25
 
12
- This documentation is for the unreleased development branch. The current stable version is [1.2.3](https://github.com/carr/phone/tree/v1.2.3)
26
+ This documentation is for the unreleased development branch.
27
+
28
+ * Current release: [1.3.0.beta1][beta]
29
+ * Current stable: [1.2.3][stable]
13
30
 
14
31
  ## Description
15
32
 
16
- TODO: Description
33
+ Ruby library for phone number parsing, validation, and formatting.
17
34
 
18
35
  ## Features
19
36
 
@@ -58,7 +75,7 @@ When given a symbol it is used as a lookup for the format in the <tt>Phoner::Pho
58
75
 
59
76
  ```ruby
60
77
  pn.format(:europe) # => "+385 (0) 91 512 5486"
61
- pn.format(:us) # => "(234) 123 4567"
78
+ pn.format(:us) # => "(234) 123-4567"
62
79
  pn.format(:default_with_extension) # => "+3851234567x143"
63
80
  ```
64
81
 
@@ -147,13 +164,16 @@ Phoner::Phone.parse '451-588'
147
164
  * [HR] Croatia
148
165
  * [HU] Hungary
149
166
  * [IE] Ireland
167
+ * [ME] Montenegro
150
168
  * [NL] Netherlands
151
169
  * [NZ] New Zealand
170
+ * [PT] Portugal
152
171
  * [RS] Serbia
153
172
  * [SE] Sweden
154
173
  * [SI] Slovenia
155
174
  * [UA] Ukraine
156
175
  * [US] United States
176
+ * [UY] Uruguay
157
177
  * [ZA] South Africa
158
178
 
159
179
  ## Known issues
@@ -173,10 +193,10 @@ Or as a Rails plugin
173
193
 
174
194
  ## Copyright
175
195
 
176
- Copyright (c) 2010-2013 Tomislav Car, [Infinum](http://www.infinumdigital.com)
196
+ Copyright (c) 2010-2013 Tomislav Car, [Infinum](http://www.infinum.co)
177
197
  Copyright (c) 2013 Don Morrison
178
198
 
179
- See {file:LICENSE.txt} for details.
199
+ See [LICENSE.txt](LICENSE.txt) for details.
180
200
 
181
201
  ## Contributors
182
202
 
@@ -1069,6 +1069,7 @@
1069
1069
  :char_3_code: ME
1070
1070
  :name: Montenegro
1071
1071
  :international_dialing_prefix: "99"
1072
+ :area_code: "[2-6][0-9]"
1072
1073
  "976":
1073
1074
  :country_code: "976"
1074
1075
  :national_dialing_prefix: "0"
@@ -1,9 +1,9 @@
1
1
  # An object representing a phone number.
2
2
  #
3
3
  # The phone number is recorded in 3 separate parts:
4
- # * country_code - e.g. '385', '386'
5
- # * area_code - e.g. '91', '47'
6
- # * number - e.g. '5125486', '451588'
4
+ # * country_code - e.g. "385", "386"
5
+ # * area_code - e.g. "91", "47"
6
+ # * number - e.g. "5125486", "451588"
7
7
  #
8
8
  # All parts are mandatory, but country code and area code can be set for all phone numbers using
9
9
  # Phone.default_country_code
@@ -41,15 +41,10 @@ module Phoner
41
41
  end
42
42
  include ClassAttributeAccessors
43
43
 
44
- NUMBER = '([0-9]{1,8})$'
45
- DEFAULT_AREA_CODE = '[0-9][0-9][0-9]' # any 3 digits
46
-
47
- attr_accessor :country_code, :area_code, :number, :extension
48
-
49
44
  self.named_formats = {
50
45
  :default => "+%c%a%n",
51
46
  :default_with_extension => "+%c%a%nx%x",
52
- :europe => '+%c (0) %a %f %l',
47
+ :europe => "+%c (0) %a %f %l",
53
48
  :us => "(%a) %f-%l"
54
49
  }
55
50
 
@@ -57,22 +52,34 @@ module Phoner
57
52
  # default length of first number part
58
53
  self.n1_length = 3
59
54
 
60
- def initialize(*hash_or_args)
61
- if hash_or_args.first.is_a?(Hash)
62
- hash_or_args = hash_or_args.first
63
- keys = {:number => :number, :area_code => :area_code, :country_code => :country_code, :extension => :extension}
64
- else
65
- keys = {:number => 0, :area_code => 1, :country_code => 2, :extension => 3}
66
- end
55
+ # phone number pattern
56
+ NUMBER = "([0-9]{1,8})$".freeze
57
+ # default area code format - any 3 digits
58
+ DEFAULT_AREA_CODE = "[0-9][0-9][0-9]".freeze
59
+ # common extension patterns
60
+ COMMON_EXTENSIONS = /[ ]*(ext|ex|x|xt|#|:)+[^0-9]*\(*([-0-9]{1,})\)*#?$/i
61
+ # common extra characters and sequences we normalize out
62
+ COMMON_EXTRAS = /(\(0\)|[^0-9+]|^\+?00?)/
63
+ # replacements for extra characters
64
+ COMMON_EXTRAS_REPLACEMENTS = {
65
+ "00" => "+",
66
+ "+00" => "+",
67
+ "+0" => "+"
68
+ }
69
+ # default replacement
70
+ COMMON_EXTRAS_REPLACEMENTS.default = ""
67
71
 
68
- self.number = hash_or_args[ keys[:number] ].to_s.strip
69
- self.area_code = (hash_or_args[ keys[:area_code] ] || self.default_area_code).to_s.strip
70
- self.country_code = (hash_or_args[ keys[:country_code] ] || self.default_country_code).to_s.strip
71
- self.extension = hash_or_args[ keys[:extension] ]
72
+ # tokens used in the formatting string: %c, %a, %A, etc
73
+ FORMAT_TOKENS = /(%[caAnflx])/
72
74
 
73
- raise BlankNumberError, "Must enter number" if self.number.empty?
74
- raise AreaCodeError, "Must enter area code or set default area code" if self.area_code.empty?
75
- raise CountryCodeError, "Must enter country code or set default country code" if self.country_code.empty?
75
+ # is this string a valid phone number?
76
+ def self.valid?(string, options = {})
77
+ begin
78
+ !parse(string, options).nil?
79
+ # if we encountered exceptions (missing country code, missing area code etc)
80
+ rescue PhoneError
81
+ return false
82
+ end
76
83
  end
77
84
 
78
85
  # create a new phone number by parsing a string
@@ -81,7 +88,7 @@ module Phoner
81
88
  return if string.to_s.empty?
82
89
 
83
90
  Country.load
84
- extension = extract_extension(string)
91
+ string, extension = extract_extension(string)
85
92
  string = normalize(string)
86
93
 
87
94
  options[:country_code] ||= self.default_country_code
@@ -93,14 +100,27 @@ module Phoner
93
100
  return pn
94
101
  end
95
102
 
103
+ # Returns an array of the number with the extension removed, and the extension.
104
+ #
105
+ # Example:
106
+ #
107
+ # number, ext = Phoner::Phone.extract_extension("+1 (123) 456-7890 x321")
108
+ # # []
109
+ def self.extract_extension(string)
110
+ return [nil, nil] if string.nil?
96
111
 
97
- # is this string a valid phone number?
98
- def self.valid?(string, options = {})
99
- begin
100
- !parse(string, options).nil?
101
- # if we encountered exceptions (missing country code, missing area code etc)
102
- rescue PhoneError
103
- return false
112
+ if subbed = string.sub(COMMON_EXTENSIONS, "")
113
+ [subbed, $2]
114
+ else
115
+ [string, nil]
116
+ end
117
+ end
118
+
119
+ # fix string so it's easier to parse, remove extra characters etc.
120
+ def self.normalize(string_with_number)
121
+ # TODO: When we drop 1.8.7 we can pass the hash in as an arg to #gsub
122
+ string_with_number.gsub(COMMON_EXTRAS) do |match|
123
+ COMMON_EXTRAS_REPLACEMENTS[match.to_s]
104
124
  end
105
125
  end
106
126
 
@@ -110,7 +130,7 @@ module Phoner
110
130
 
111
131
  if country
112
132
  options[:country_code] = country.country_code
113
- string = string.gsub(country.country_code_regexp, '0')
133
+ string = string.gsub(country.country_code_regexp, "0")
114
134
  else
115
135
  if options[:country_code]
116
136
  country = Country.find_by_country_code options[:country_code]
@@ -136,9 +156,17 @@ module Phoner
136
156
 
137
157
  case format
138
158
  when :short
139
- {:number => parts[2], :area_code => parts[1], :country_code => options[:country_code]}
159
+ {
160
+ :number => parts[2],
161
+ :area_code => parts[1],
162
+ :country_code => options[:country_code]
163
+ }
140
164
  when :really_short
141
- {:number => parts[1], :area_code => options[:area_code], :country_code => options[:country_code]}
165
+ {
166
+ :number => parts[1],
167
+ :area_code => options[:area_code],
168
+ :country_code => options[:country_code]
169
+ }
142
170
  end
143
171
  end
144
172
 
@@ -154,16 +182,6 @@ module Phoner
154
182
  detected_country
155
183
  end
156
184
 
157
- def self.formats(country)
158
- area_code_regexp = country.area_code || DEFAULT_AREA_CODE
159
- {
160
- # 047451588, 013668734
161
- :short => Regexp.new('^0?(' + area_code_regexp + ')' + NUMBER),
162
- # 451588
163
- :really_short => Regexp.new('^' + NUMBER)
164
- }
165
- end
166
-
167
185
  # detect format (from FORMATS) of input string
168
186
  def self.detect_format(string_with_number, country)
169
187
  arr = []
@@ -171,44 +189,64 @@ module Phoner
171
189
  arr << format if string_with_number =~ regexp
172
190
  end
173
191
 
174
- # raise "Detected more than 1 format for #{string_with_number}" if arr.size > 1
192
+ # raise "Detected more than 1 format for #{string_with_number}" if arr.size > 1
175
193
  if arr.length > 1
176
- # puts %Q{detect_format: more than one format found - #{arr.inspect}}
194
+ # puts %Q{detect_format: more than one format found - #{arr.inspect}}
177
195
  return :really_short
178
196
  end
179
197
  arr.first
180
198
  end
181
199
 
182
- # fix string so it's easier to parse, remove extra characters etc.
183
- def self.normalize(string_with_number)
184
- string_with_number.gsub("(0)", "").gsub(/[^0-9+]/, '').gsub(/^00/, '+').gsub(/^\+00/, '+').gsub(/^\+0/, '+')
200
+ def self.formats(country)
201
+ area_code_regexp = country.area_code || DEFAULT_AREA_CODE
202
+ {
203
+ # 047451588, 013668734
204
+ :short => Regexp.new("^0?(#{area_code_regexp})#{NUMBER}"),
205
+ # 451588
206
+ :really_short => Regexp.new("^#{NUMBER}")
207
+ }
185
208
  end
186
209
 
187
- # pull off anything that look like an extension
188
- #TODO: refactor things so this doesn't change string as a side effect
210
+ attr_accessor :country_code, :area_code, :number, :extension
211
+
212
+ # Initialize a new instance with a list or hash of phone number parts
189
213
  #
190
- def self.extract_extension(string)
191
- return nil if string.nil?
192
- if string.sub! /[ ]*(ext|ex|x|xt|#|:)+[^0-9]*\(*([-0-9]{1,})\)*#?$/i, ''
193
- extension = $2
194
- return extension
195
- end
196
- #
197
- # We already returned any recognizable extension.
198
- # However, we might still have extra junk to the right
199
- # of the phone number proper, so just chop it off.
200
- #
201
- idx = string.rindex(/[0-9]/)
202
- return nil if idx.nil?
203
- return nil if idx == (string.length - 1) # at the end
204
- string.slice!((idx+1)..-1) # chop it
205
- return nil
214
+ # Example:
215
+ # Phone.new("5125486", "91", "385")
216
+ #
217
+ # # or
218
+ #
219
+ # Phone.new(
220
+ # :number => "5125486",
221
+ # :area_code => "91",
222
+ # :country_code => "385",
223
+ # :extension => "143"
224
+ # )
225
+ def initialize(*args)
226
+ input = args.first.is_a?(Hash) ? args.first : args_to_hash(args)
227
+
228
+ # set defaults
229
+ input[:area_code] ||= self.default_area_code
230
+ input[:country_code] ||= self.default_country_code
231
+
232
+ @number = input[:number].to_s.strip
233
+ raise BlankNumberError, "Must enter number" if @number.empty?
234
+
235
+ @area_code = input[:area_code].to_s.strip
236
+ raise AreaCodeError,
237
+ "Must enter area code or set default" if @area_code.empty?
238
+
239
+ @country_code = input[:country_code].to_s.strip
240
+ raise CountryCodeError,
241
+ "Must enter country code or set default" if @country_code.empty?
242
+
243
+ @extension = input[:extension]
206
244
  end
207
245
 
208
246
  # format area_code with trailing zero (e.g. 91 as 091)
209
247
  # format area_code with trailing zero (e.g. 91 as 091)
210
248
  def area_code_long
211
- "0" + area_code if area_code
249
+ "0#{area_code}" if area_code
212
250
  end
213
251
 
214
252
  # first n characters of :number
@@ -238,7 +276,7 @@ module Phoner
238
276
  # pn.format(:europe)
239
277
  def format(fmt)
240
278
  if fmt.is_a?(Symbol)
241
- raise "The format #{fmt} doesn't exist'" unless named_formats.has_key?(fmt)
279
+ raise "The format #{fmt} doesn't exist" unless named_formats.has_key?(fmt)
242
280
  format_number named_formats[fmt]
243
281
  else
244
282
  format_number(fmt)
@@ -268,15 +306,39 @@ module Phoner
268
306
 
269
307
  private
270
308
 
309
+ # Convert initialize arguments into parameter hash
310
+ #
311
+ # Example:
312
+ #
313
+ # args_to_hash ["5125486", "91", "385"]
314
+ # #=> { :number => "5125486",
315
+ # :area_code => "91",
316
+ # :country_code => "385",
317
+ # :extension => nil }
318
+ def args_to_hash(args)
319
+ {
320
+ :number => args[0],
321
+ :area_code => args[1],
322
+ :country_code => args[2],
323
+ :extension => args[3]
324
+ }
325
+ end
326
+
271
327
  def format_number(fmt)
272
- result = fmt.gsub("%c", country_code || "").
273
- gsub("%a", area_code || "").
274
- gsub("%A", area_code_long || "").
275
- gsub("%n", number || "").
276
- gsub("%f", number1 || "").
277
- gsub("%l", number2 || "").
278
- gsub("%x", extension || "")
279
- return result
328
+ replacements = {
329
+ "%c" => (country_code || ""),
330
+ "%a" => (area_code || ""),
331
+ "%A" => (area_code_long || ""),
332
+ "%n" => (number || ""),
333
+ "%f" => (number1 || ""),
334
+ "%l" => (number2 || ""),
335
+ "%x" => (extension || "")
336
+ }
337
+
338
+ # TODO: When we drop 1.8.7 we can pass the hash in as an arg to #gsub
339
+ fmt.gsub(FORMAT_TOKENS) do |match|
340
+ replacements[match.to_s]
341
+ end
280
342
  end
281
343
  end
282
344
  end
@@ -1,4 +1,4 @@
1
- require 'yaml'
1
+ require "yaml"
2
2
 
3
3
  module Phoner
4
4
  class Country < Struct.new(:name, :country_code, :char_2_code, :char_3_code, :area_code)
@@ -14,32 +14,38 @@ module Phoner
14
14
  def self.load
15
15
  return self.all if !self.all.nil? && !self.all.empty?
16
16
 
17
- data_file = File.expand_path(File.join('..','..','data', 'phone', 'countries.yml'), File.dirname(__FILE__))
17
+ data_file = File.join("..","..","data", "phone", "countries.yml")
18
+ data_path = File.expand_path(data_file, File.dirname(__FILE__))
18
19
 
19
20
  self.all = {}
20
- YAML.load(File.read(data_file)).each_pair do |key, c|
21
- self.all[key] = Country.new(c[:name], c[:country_code], c[:char_2_code], c[:char_3_code], c[:area_code])
21
+ YAML.load(File.read(data_path)).each_pair do |key, c|
22
+ self.all[key] = Country.new(
23
+ c[:name],
24
+ c[:country_code],
25
+ c[:char_2_code],
26
+ c[:char_3_code],
27
+ c[:area_code]
28
+ )
22
29
  end
23
30
  self.all
24
31
  end
25
32
 
26
- def to_s
27
- name
28
- end
29
-
30
33
  def self.find_by_country_code(code)
31
34
  self.all[code]
32
35
  end
33
-
36
+
34
37
  def self.find_by_country_isocode(isocode)
35
38
  if country = self.all.detect{|c|c[1].char_3_code.downcase == isocode}
36
39
  country[1]
37
40
  end
38
41
  end
39
42
 
43
+ def to_s
44
+ name
45
+ end
46
+
40
47
  def country_code_regexp
41
48
  @country_code_regexp ||= Regexp.new("^[+]#{country_code}")
42
49
  end
43
50
  end
44
-
45
51
  end
@@ -1,4 +1,4 @@
1
1
  module Phone
2
2
  # phone version
3
- VERSION = "1.3.0.beta0"
3
+ VERSION = "1.3.0.beta1"
4
4
  end
@@ -0,0 +1,14 @@
1
+ require "helper"
2
+
3
+ ## Montenegro
4
+ class METest < Minitest::Test
5
+
6
+ def test_mobile
7
+ parse_test('+382 69 555 5555', '382', '69', '5555555')
8
+ end
9
+
10
+ def test_local
11
+ parse_test('+382 20 555 5555', '382', '20', '5555555')
12
+ end
13
+
14
+ end
@@ -22,4 +22,12 @@ class ExtensionTest < Minitest::Test
22
22
  assert_equal '(091)/512-5486 x 143', pn.format('(%A)/%f-%l x %x')
23
23
  end
24
24
 
25
+ def test_extract_extension
26
+ string = "+1 2069735100 x143"
27
+ number, ext = Phoner::Phone.extract_extension(string)
28
+
29
+ assert_equal "+1 2069735100 x143", string
30
+ assert_equal "+1 2069735100", number
31
+ assert_equal "143", ext
32
+ end
25
33
  end
@@ -72,13 +72,19 @@ class PhoneTest < Minitest::Test
72
72
  end
73
73
 
74
74
  def test_parse_with_extension
75
- pn = Phoner::Phone.parse"+1 545-545-5454 ext. 4307"
75
+ pn = Phoner::Phone.parse "+1 545-545-5454 ext. 4307"
76
76
  assert "1", pn.country_code
77
77
  assert "545", pn.area_code
78
78
  assert "5455454", pn.number
79
79
  assert "4307", pn.extension
80
80
  end
81
81
 
82
+ def test_parse_wont_alter_parameter
83
+ number = "+1 545-545-5454 ext. 4307"
84
+ parsed = Phoner::Phone.parse number
85
+ assert_equal "+1 545-545-5454 ext. 4307", number
86
+ end
87
+
82
88
  def test_parse_short_without_special_characters_without_country
83
89
  Phoner::Phone.default_country_code = nil
84
90
 
@@ -95,6 +101,20 @@ class PhoneTest < Minitest::Test
95
101
  end
96
102
  end
97
103
 
104
+ def test_normalize
105
+ numbers = [
106
+ ["(0)512-5486", "5125486"],
107
+ ["z512-5486", "5125486"],
108
+ ["00512-5486", "+5125486"],
109
+ ["+00512-5486", "+5125486"],
110
+ ["+0512-5486", "+5125486"],
111
+ ]
112
+
113
+ numbers.each do |number, expected|
114
+ assert_equal expected, Phoner::Phone.normalize(number)
115
+ end
116
+ end
117
+
98
118
  def test_to_s
99
119
  Phoner::Phone.default_country_code = nil
100
120
  pn = Phoner::Phone.new '5125486', '91', '385'
@@ -150,6 +170,20 @@ class PhoneTest < Minitest::Test
150
170
  assert_equal Phoner::Phone.valid?('385915125486'), false
151
171
  end
152
172
 
173
+ def test_valid_wont_strip_the_extension
174
+ number = '+1 (123) 456-7890 x321'
175
+
176
+ parsed = Phoner::Phone.parse(number)
177
+ assert_equal "+11234567890", parsed.to_s
178
+ assert_equal "321", parsed.extension
179
+
180
+ assert Phoner::Phone.valid?(number)
181
+
182
+ parsed = Phoner::Phone.parse(number)
183
+ assert_equal "+11234567890", parsed.to_s
184
+ assert_equal"321", parsed.extension
185
+ end
186
+
153
187
  def test_comparison_true
154
188
  pn1 = Phoner::Phone.new '5125486', '91', '385'
155
189
  pn2 = Phoner::Phone.new '5125486', '91', '385'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.beta0
4
+ version: 1.3.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomislav Carr
@@ -10,76 +10,76 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-04-27 00:00:00.000000000 Z
13
+ date: 2015-08-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
21
  version: '1.2'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ~>
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.2'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: minitest
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ~>
33
+ - - "~>"
34
34
  - !ruby/object:Gem::Version
35
35
  version: '5.0'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ~>
40
+ - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '5.0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rake
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: '10.0'
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ~>
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: '10.0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rubygems-tasks
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ~>
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0.2'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ~>
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0.2'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: yard
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ~>
75
+ - - "~>"
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0.8'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ~>
82
+ - - "~>"
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0.8'
85
85
  description: Phone number parsing, validation and formatting in Ruby
@@ -91,11 +91,11 @@ executables: []
91
91
  extensions: []
92
92
  extra_rdoc_files: []
93
93
  files:
94
- - .document
95
- - .gitignore
96
- - .ruby-version
97
- - .travis.yml
98
- - .yardopts
94
+ - ".document"
95
+ - ".gitignore"
96
+ - ".ruby-version"
97
+ - ".travis.yml"
98
+ - ".yardopts"
99
99
  - ChangeLog.md
100
100
  - Gemfile
101
101
  - LICENSE.txt
@@ -117,6 +117,7 @@ files:
117
117
  - test/countries/hr_test.rb
118
118
  - test/countries/hu_test.rb
119
119
  - test/countries/ie_test.rb
120
+ - test/countries/me_test.rb
120
121
  - test/countries/nl_test.rb
121
122
  - test/countries/nz_test.rb
122
123
  - test/countries/pt_test.rb
@@ -141,17 +142,17 @@ require_paths:
141
142
  - lib
142
143
  required_ruby_version: !ruby/object:Gem::Requirement
143
144
  requirements:
144
- - - '>='
145
+ - - ">="
145
146
  - !ruby/object:Gem::Version
146
147
  version: '0'
147
148
  required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  requirements:
149
- - - '>'
150
+ - - ">"
150
151
  - !ruby/object:Gem::Version
151
152
  version: 1.3.1
152
153
  requirements: []
153
154
  rubyforge_project:
154
- rubygems_version: 2.0.3
155
+ rubygems_version: 2.4.5
155
156
  signing_key:
156
157
  specification_version: 4
157
158
  summary: Phone number parsing, validation and formatting
@@ -166,6 +167,7 @@ test_files:
166
167
  - test/countries/hr_test.rb
167
168
  - test/countries/hu_test.rb
168
169
  - test/countries/ie_test.rb
170
+ - test/countries/me_test.rb
169
171
  - test/countries/nl_test.rb
170
172
  - test/countries/nz_test.rb
171
173
  - test/countries/pt_test.rb