no_phone 0.0.2 → 0.0.3
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.
- data/Gemfile.lock +1 -1
- data/lib/no_phone.rb +9 -0
- data/lib/no_phone/version.rb +1 -1
- data/spec/international_spec.rb +15 -0
- data/spec/isdnize_spec.rb +10 -0
- metadata +5 -3
data/Gemfile.lock
CHANGED
data/lib/no_phone.rb
CHANGED
@@ -19,6 +19,10 @@ module NoPhone
|
|
19
19
|
number
|
20
20
|
end
|
21
21
|
|
22
|
+
def unmsisdnize(number)
|
23
|
+
normalize("+#{number}") if number
|
24
|
+
end
|
25
|
+
|
22
26
|
def valid?(number)
|
23
27
|
return false if number.nil?
|
24
28
|
return false if number == ""
|
@@ -28,5 +32,10 @@ module NoPhone
|
|
28
32
|
end
|
29
33
|
false
|
30
34
|
end
|
35
|
+
|
36
|
+
# Norway-centric. True if not a norwegian number.
|
37
|
+
def international?(number)
|
38
|
+
!!(normalize(number) =~ /^\+/)
|
39
|
+
end
|
31
40
|
end
|
32
41
|
end
|
data/lib/no_phone/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NoPhone, "#international" do
|
4
|
+
it "knows a norse number when it sees one" do
|
5
|
+
NoPhone.international?("12345678").should == false
|
6
|
+
end
|
7
|
+
|
8
|
+
it "knows a norse number even when it looks international" do
|
9
|
+
NoPhone.international?("+4712345678").should == false
|
10
|
+
end
|
11
|
+
|
12
|
+
it "correctly identifies a non-norwegian international number" do
|
13
|
+
NoPhone.international?("+4612345678").should == true
|
14
|
+
end
|
15
|
+
end
|
data/spec/isdnize_spec.rb
CHANGED
@@ -9,3 +9,13 @@ describe NoPhone, "#msisdnize" do
|
|
9
9
|
NoPhone.msisdnize("+123456789").should eq("123456789")
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
describe NoPhone, "#unmsisdnize" do
|
14
|
+
it "localizes norwegian numbers" do
|
15
|
+
NoPhone.unmsisdnize("4712345678").should eq("12345678")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "adds a + to international numbers" do
|
19
|
+
NoPhone.unmsisdnize("123456789").should eq("+123456789")
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Simen Svale Skogsrud, Katrina Owen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-06-03 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/no_phone.rb
|
49
49
|
- lib/no_phone/version.rb
|
50
50
|
- no_phone.gemspec
|
51
|
+
- spec/international_spec.rb
|
51
52
|
- spec/isdnize_spec.rb
|
52
53
|
- spec/normalize_spec.rb
|
53
54
|
- spec/spec_helper.rb
|
@@ -85,6 +86,7 @@ signing_key:
|
|
85
86
|
specification_version: 3
|
86
87
|
summary: Norwegian phone number scrubber
|
87
88
|
test_files:
|
89
|
+
- spec/international_spec.rb
|
88
90
|
- spec/isdnize_spec.rb
|
89
91
|
- spec/normalize_spec.rb
|
90
92
|
- spec/spec_helper.rb
|