phonelib 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/data/PhoneNumberMetaData.xml +365 -253
- data/data/phone_data.yml +598 -506
- data/lib/phonelib/core.rb +10 -3
- data/lib/phonelib/phone.rb +1 -0
- data/lib/phonelib/version.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +16 -28
- data/test/dummy/log/test.log +807 -3397
- metadata +114 -121
- checksums.yaml +0 -7
data/lib/phonelib/core.rb
CHANGED
@@ -5,9 +5,18 @@ module Phonelib
|
|
5
5
|
@@phone_data = nil
|
6
6
|
|
7
7
|
# default country for parsing variable setting
|
8
|
-
mattr_accessor :default_country
|
9
8
|
@@default_country = nil
|
10
9
|
|
10
|
+
# getter method for default_country variable
|
11
|
+
def default_country
|
12
|
+
@@default_country
|
13
|
+
end
|
14
|
+
|
15
|
+
# setter method for default_country variable
|
16
|
+
def default_country=(country)
|
17
|
+
@@default_country = country
|
18
|
+
end
|
19
|
+
|
11
20
|
# gem constants definition
|
12
21
|
# constants for phone types
|
13
22
|
|
@@ -118,13 +127,11 @@ module Phonelib
|
|
118
127
|
|
119
128
|
# method checks if passed phone number is valid for provided country
|
120
129
|
def valid_for_country?(phone_number, country)
|
121
|
-
country = country.to_s.upcase
|
122
130
|
parse(phone_number, country).valid_for_country?(country)
|
123
131
|
end
|
124
132
|
|
125
133
|
# method checks if passed phone number is invalid for provided country
|
126
134
|
def invalid_for_country?(phone_number, country)
|
127
|
-
country = country.to_s.upcase
|
128
135
|
parse(phone_number, country).invalid_for_country?(country)
|
129
136
|
end
|
130
137
|
|
data/lib/phonelib/phone.rb
CHANGED
@@ -96,6 +96,7 @@ module Phonelib
|
|
96
96
|
# * +country+ - ISO code of country (2 letters) like 'US', 'us' or :us for United States
|
97
97
|
#
|
98
98
|
def valid_for_country?(country)
|
99
|
+
country = country.to_s.upcase
|
99
100
|
@analyzed_data.select {|iso2, data| country == iso2 &&
|
100
101
|
data[:valid].any? }.any?
|
101
102
|
end
|
data/lib/phonelib/version.rb
CHANGED
Binary file
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -1,31 +1,19 @@
|
|
1
1
|
Connecting to database specified by database.yml
|
2
|
-
[1m[36m (0.
|
3
|
-
[1m[35m (
|
4
|
-
[1m[36m (
|
5
|
-
[1m[35m (
|
6
|
-
|
7
|
-
[1m[
|
8
|
-
[1m[
|
9
|
-
[1m[
|
10
|
-
[1m[35m (4.1ms)[0m commit transaction
|
11
|
-
Migrating to AddPossibleNumberToPhone (20130122075331)
|
12
|
-
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
13
|
-
[1m[35m (0.6ms)[0m ALTER TABLE "phones" ADD "possible_number" varchar(255)
|
14
|
-
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20130122075331')[0m
|
15
|
-
[1m[35m (2.7ms)[0m commit transaction
|
16
|
-
[1m[36m (0.2ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
2
|
+
[1m[36m (0.9ms)[0m [1mselect sqlite_version(*)[0m
|
3
|
+
[1m[35m (6.8ms)[0m CREATE TABLE "phones" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "number" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "possible_number" varchar(255))
|
4
|
+
[1m[36m (1.4ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
5
|
+
[1m[35m (1.6ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
6
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
7
|
+
[1m[35m (3.2ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20130122075331')
|
8
|
+
[1m[36m (1.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20130121173847')[0m
|
9
|
+
[1m[35m (0.7ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
17
10
|
Connecting to database specified by database.yml
|
18
|
-
[1m[36m (0.
|
19
|
-
[1m[35m (
|
20
|
-
[1m[36m (3.
|
21
|
-
[1m[35m (
|
22
|
-
[1m[36m (
|
23
|
-
Connecting to database specified by database.yml
|
24
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
25
|
-
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
26
|
-
[1m[36m (5.1ms)[0m [1mCREATE TABLE "phones" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "number" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "possible_number" varchar(255)) [0m
|
27
|
-
[1m[35m (2.3ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
28
|
-
[1m[36m (3.4ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
11
|
+
[1m[36m (0.6ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
12
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
13
|
+
[1m[36m (3.7ms)[0m [1mCREATE TABLE "phones" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "number" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "possible_number" varchar(255)) [0m
|
14
|
+
[1m[35m (1.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
15
|
+
[1m[36m (1.7ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
29
16
|
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
30
|
-
[1m[36m (
|
31
|
-
[1m[35m (
|
17
|
+
[1m[36m (1.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20130122075331')[0m
|
18
|
+
[1m[35m (4.9ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20130121173847')
|
19
|
+
Connecting to database specified by database.yml
|