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/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
 
@@ -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
@@ -1,4 +1,4 @@
1
1
  module Phonelib
2
2
  # :nodoc:
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
Binary file
Binary file
@@ -1,31 +1,19 @@
1
1
  Connecting to database specified by database.yml
2
-  (0.1ms) select sqlite_version(*)
3
-  (7.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
4
-  (2.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
5
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
6
- Migrating to CreatePhones (20130121173847)
7
-  (0.1ms) begin transaction
8
-  (0.8ms) CREATE TABLE "phones" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "number" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
9
-  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20130121173847')
10
-  (4.1ms) commit transaction
11
- Migrating to AddPossibleNumberToPhone (20130122075331)
12
-  (0.1ms) begin transaction
13
-  (0.6ms) ALTER TABLE "phones" ADD "possible_number" varchar(255)
14
-  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20130122075331')
15
-  (2.7ms) commit transaction
16
-  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
2
+  (0.9ms) select sqlite_version(*)
3
+  (6.8ms) 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
+  (1.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
5
+  (1.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6
+  (0.1ms) SELECT version FROM "schema_migrations"
7
+  (3.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20130122075331')
8
+  (1.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20130121173847')
9
+  (0.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
17
10
  Connecting to database specified by database.yml
18
-  (0.7ms) select sqlite_version(*)
19
-  (5.1ms) DROP TABLE "phones"
20
-  (3.3ms) 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)) 
21
-  (0.2ms) SELECT version FROM "schema_migrations"
22
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
23
- Connecting to database specified by database.yml
24
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
25
-  (0.3ms) select sqlite_version(*)
26
-  (5.1ms) 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)) 
27
-  (2.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
28
-  (3.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
11
+  (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
12
+  (0.1ms) select sqlite_version(*)
13
+  (3.7ms) 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)) 
14
+  (1.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
15
+  (1.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
29
16
   (0.1ms) SELECT version FROM "schema_migrations"
30
-  (2.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20130122075331')
31
-  (3.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20130121173847')
17
+  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20130122075331')
18
+  (4.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20130121173847')
19
+ Connecting to database specified by database.yml