no_phone 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/no_phone/version.rb +1 -1
- data/lib/no_phone.rb +7 -0
- data/spec/isdnize_spec.rb +9 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/no_phone/version.rb
CHANGED
data/lib/no_phone.rb
CHANGED
@@ -12,6 +12,8 @@ module NoPhone
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def msisdnize(number)
|
15
|
+
return nil if missing?(number)
|
16
|
+
|
15
17
|
number = normalize(number)
|
16
18
|
number = "47#{number}" unless number =~ /^\+/
|
17
19
|
number.gsub!(/^\+/, '')
|
@@ -36,4 +38,9 @@ module NoPhone
|
|
36
38
|
def international?(number)
|
37
39
|
!!(normalize(number) =~ /^\+/)
|
38
40
|
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def missing?(number)
|
44
|
+
number.nil? || (number == "")
|
45
|
+
end
|
39
46
|
end
|
data/spec/isdnize_spec.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe NoPhone, "#msisdnize" do
|
4
|
+
|
5
|
+
it "ignores nils" do
|
6
|
+
NoPhoneWrapper.msisdnize(nil).should eq(nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "ignores empty strings" do
|
10
|
+
NoPhoneWrapper.msisdnize("").should eq(nil)
|
11
|
+
end
|
12
|
+
|
4
13
|
it "adds country code to naked norwegian-ish numbers" do
|
5
14
|
NoPhoneWrapper.msisdnize("12345678").should eq("4712345678")
|
6
15
|
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
|
+
- 5
|
9
|
+
version: 0.0.5
|
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-07-15 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|