phony 1.7.1 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/phony/country_codes.rb +4 -1
- data/spec/lib/phony/validations_spec.rb +9 -1
- metadata +3 -2
data/lib/phony/country_codes.rb
CHANGED
@@ -24,12 +24,15 @@ module Phony
|
|
24
24
|
|
25
25
|
@@basic_normalizing_pattern = /^0+|\D/
|
26
26
|
def clean number
|
27
|
+
clean! number && number.dup
|
28
|
+
end
|
29
|
+
def clean! number
|
27
30
|
# Remove non-digit chars.
|
28
31
|
#
|
29
32
|
number.gsub!(@@basic_normalizing_pattern, EMPTY_STRING) || number
|
30
33
|
end
|
31
34
|
def normalize number
|
32
|
-
clean number
|
35
|
+
clean! number
|
33
36
|
national_handler, cc, rest = split_cc number
|
34
37
|
@normalize_format % [cc, national_handler.normalize(rest)]
|
35
38
|
end
|
@@ -5,7 +5,15 @@ require 'spec_helper'
|
|
5
5
|
describe 'validations' do
|
6
6
|
|
7
7
|
describe 'plausible?' do
|
8
|
-
|
8
|
+
|
9
|
+
it 'does not change the given number' do
|
10
|
+
number = "123-123-1234"
|
11
|
+
|
12
|
+
Phony.plausible? number
|
13
|
+
|
14
|
+
number.should == '123-123-1234'
|
15
|
+
end
|
16
|
+
|
9
17
|
it "is correct" do
|
10
18
|
Phony.plausible?('0000000').should be_false
|
11
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'Fast international phone number (E164 standard) normalizing, splitting
|
15
15
|
and formatting. Lots of formatting options: International (+.., 00..), national
|
@@ -102,3 +102,4 @@ test_files:
|
|
102
102
|
- spec/lib/phony/validations_spec.rb
|
103
103
|
- spec/lib/phony/vanity_spec.rb
|
104
104
|
- spec/lib/phony_spec.rb
|
105
|
+
has_rdoc: false
|