phonelib 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -4
- data/data/PhoneNumberMetaData.xml +698 -455
- data/data/phone_data.yml +912 -762
- data/lib/phonelib/core.rb +65 -10
- data/lib/phonelib/phone.rb +92 -48
- data/lib/phonelib/version.rb +1 -1
- data/lib/tasks/phonelib_tasks.rake +24 -20
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +4138 -0
- data/test/phonelib_test.rb +38 -0
- metadata +22 -6
data/test/phonelib_test.rb
CHANGED
@@ -49,9 +49,27 @@ class PhonelibTest < ActiveSupport::TestCase
|
|
49
49
|
assert Phonelib.impossible?('97254123')
|
50
50
|
end
|
51
51
|
|
52
|
+
test "possible but not valid phone number" do
|
53
|
+
phone = Phonelib.parse('9721234567')
|
54
|
+
assert !phone.valid?
|
55
|
+
assert phone.possible?
|
56
|
+
end
|
57
|
+
|
52
58
|
test "valid_for_country? with correct data" do
|
53
59
|
assert Phonelib.valid_for_country?('972541234567', 'IL')
|
54
60
|
end
|
61
|
+
|
62
|
+
test "valid_for_country? with correct data and national number" do
|
63
|
+
assert Phonelib.valid_for_country?('0541234567', 'IL')
|
64
|
+
end
|
65
|
+
|
66
|
+
test "valid_for_country? with correct data and without prefix" do
|
67
|
+
assert Phonelib.valid_for_country?('541234567', 'IL')
|
68
|
+
end
|
69
|
+
|
70
|
+
test "valid_for_country? with fake data and without prefix" do
|
71
|
+
assert !Phonelib.valid_for_country?('541234567', 'US')
|
72
|
+
end
|
55
73
|
|
56
74
|
test "invalid_for_country? with correct data" do
|
57
75
|
assert !Phonelib.invalid_for_country?('972541234567', 'IL')
|
@@ -64,4 +82,24 @@ class PhonelibTest < ActiveSupport::TestCase
|
|
64
82
|
test "valid_for_country? with incorrect data" do
|
65
83
|
assert !Phonelib.valid_for_country?('972541234567', 'US')
|
66
84
|
end
|
85
|
+
|
86
|
+
test "international method returns with right formatting" do
|
87
|
+
phone = Phonelib.parse('972541234567')
|
88
|
+
assert phone.international == '+972 54-123-4567'
|
89
|
+
end
|
90
|
+
|
91
|
+
test "national method returns right formatting" do
|
92
|
+
phone = Phonelib.parse('972541234567')
|
93
|
+
assert phone.national == '054-123-4567'
|
94
|
+
end
|
95
|
+
|
96
|
+
test "international method returns sanitized when number invalid but possible" do
|
97
|
+
phone = Phonelib.parse('9721234567')
|
98
|
+
assert phone.international == '+9721234567'
|
99
|
+
end
|
100
|
+
|
101
|
+
test "national method returns sanitized national when number invalid but possible" do
|
102
|
+
phone = Phonelib.parse('9721234567')
|
103
|
+
assert phone.national == '1234567'
|
104
|
+
end
|
67
105
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phonelib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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: 2013-
|
12
|
+
date: 2013-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -59,8 +59,24 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
description: Google libphonenumber library was taken as a basis for this gem. Gem
|
63
|
-
uses its data file for validations.
|
79
|
+
uses its data file for validations and number formatting.
|
64
80
|
email:
|
65
81
|
- daddyzgm@gmail.com
|
66
82
|
executables: []
|
@@ -160,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
176
|
version: '0'
|
161
177
|
segments:
|
162
178
|
- 0
|
163
|
-
hash: -
|
179
|
+
hash: -695367896934633309
|
164
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
181
|
none: false
|
166
182
|
requirements:
|
@@ -169,10 +185,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
185
|
version: '0'
|
170
186
|
segments:
|
171
187
|
- 0
|
172
|
-
hash: -
|
188
|
+
hash: -695367896934633309
|
173
189
|
requirements: []
|
174
190
|
rubyforge_project:
|
175
|
-
rubygems_version: 1.8.
|
191
|
+
rubygems_version: 1.8.25
|
176
192
|
signing_key:
|
177
193
|
specification_version: 3
|
178
194
|
summary: Gem validates phone numbers with Google libphonenumber database.
|