phony_rails 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +52 -38
- data/README.md +5 -0
- data/lib/phony_rails.rb +2 -3
- data/lib/phony_rails/version.rb +1 -1
- data/phony_rails.gemspec +1 -1
- data/spec/lib/phony_rails_spec.rb +2 -1
- data/spec/lib/validators/phony_validator_spec.rb +3 -3
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,32 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
phony_rails (0.
|
4
|
+
phony_rails (0.7.0)
|
5
5
|
activesupport (>= 3.0)
|
6
6
|
countries (>= 0.8.2)
|
7
|
-
phony (~> 2.
|
7
|
+
phony (~> 2.3.0)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (
|
13
|
-
activesupport (=
|
14
|
-
builder (~> 3.
|
15
|
-
activerecord (
|
16
|
-
activemodel (=
|
17
|
-
activesupport (=
|
18
|
-
arel (~>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
12
|
+
activemodel (4.1.6)
|
13
|
+
activesupport (= 4.1.6)
|
14
|
+
builder (~> 3.1)
|
15
|
+
activerecord (4.1.6)
|
16
|
+
activemodel (= 4.1.6)
|
17
|
+
activesupport (= 4.1.6)
|
18
|
+
arel (~> 5.0.0)
|
19
|
+
activesupport (4.1.6)
|
20
|
+
i18n (~> 0.6, >= 0.6.9)
|
21
|
+
json (~> 1.7, >= 1.7.7)
|
22
|
+
minitest (~> 5.1)
|
23
|
+
thread_safe (~> 0.1)
|
24
|
+
tzinfo (~> 1.1)
|
25
|
+
arel (5.0.1.20140414130214)
|
26
|
+
bson (2.3.0)
|
27
|
+
builder (3.2.2)
|
28
|
+
celluloid (0.16.0)
|
29
|
+
timers (~> 4.0.0)
|
30
|
+
connection_pool (2.0.0)
|
31
|
+
countries (0.9.3)
|
32
|
+
currencies (~> 0.4.2)
|
27
33
|
currencies (0.4.2)
|
28
34
|
diff-lcs (1.1.3)
|
29
|
-
ffi (1.9.
|
35
|
+
ffi (1.9.5)
|
30
36
|
growl (1.0.3)
|
31
37
|
guard (1.2.3)
|
32
38
|
listen (>= 0.4.2)
|
@@ -36,25 +42,29 @@ GEM
|
|
36
42
|
guard (~> 1.1)
|
37
43
|
guard-rspec (1.2.1)
|
38
44
|
guard (>= 1.1)
|
39
|
-
|
40
|
-
|
45
|
+
hitimes (1.2.2)
|
46
|
+
i18n (0.6.11)
|
47
|
+
json (1.8.1)
|
48
|
+
listen (2.7.11)
|
49
|
+
celluloid (>= 0.15.2)
|
41
50
|
rb-fsevent (>= 0.9.3)
|
42
51
|
rb-inotify (>= 0.9)
|
43
|
-
|
44
|
-
mongoid (
|
45
|
-
activemodel (~>
|
46
|
-
moped (~>
|
47
|
-
origin (~> 1
|
48
|
-
tzinfo (
|
49
|
-
moped (
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
rb-
|
52
|
+
minitest (5.4.2)
|
53
|
+
mongoid (4.0.0)
|
54
|
+
activemodel (~> 4.0)
|
55
|
+
moped (~> 2.0.0)
|
56
|
+
origin (~> 2.1)
|
57
|
+
tzinfo (>= 0.3.37)
|
58
|
+
moped (2.0.0)
|
59
|
+
bson (~> 2.2)
|
60
|
+
connection_pool (~> 2.0)
|
61
|
+
optionable (~> 0.2.0)
|
62
|
+
optionable (0.2.0)
|
63
|
+
origin (2.1.1)
|
64
|
+
phony (2.3.0)
|
65
|
+
rake (10.3.2)
|
66
|
+
rb-fsevent (0.9.4)
|
67
|
+
rb-inotify (0.9.5)
|
58
68
|
ffi (>= 0.5.0)
|
59
69
|
rspec (2.11.0)
|
60
70
|
rspec-core (~> 2.11.0)
|
@@ -64,9 +74,13 @@ GEM
|
|
64
74
|
rspec-expectations (2.11.3)
|
65
75
|
diff-lcs (~> 1.1.3)
|
66
76
|
rspec-mocks (2.11.3)
|
67
|
-
sqlite3 (1.3.
|
68
|
-
thor (0.
|
69
|
-
|
77
|
+
sqlite3 (1.3.9)
|
78
|
+
thor (0.19.1)
|
79
|
+
thread_safe (0.3.4)
|
80
|
+
timers (4.0.1)
|
81
|
+
hitimes
|
82
|
+
tzinfo (1.2.2)
|
83
|
+
thread_safe (~> 0.1)
|
70
84
|
|
71
85
|
PLATFORMS
|
72
86
|
ruby
|
data/README.md
CHANGED
data/lib/phony_rails.rb
CHANGED
@@ -25,12 +25,11 @@ module PhonyRails
|
|
25
25
|
return if number.blank?
|
26
26
|
if country_number = options[:country_number] || country_number_for(options[:country_code])
|
27
27
|
# (Force) add country_number if missing
|
28
|
-
number = "#{country_number}#{number}" if not number =~
|
28
|
+
number = "#{country_number}#{number}" if not number =~ /\A(00|\+)?#{country_number}/
|
29
29
|
elsif default_country_number = options[:default_country_number] || country_number_for(options[:default_country_code])
|
30
30
|
# Add default_country_number if missing
|
31
|
-
number = "#{default_country_number}#{number}" if not number =~
|
31
|
+
number = "#{default_country_number}#{number}" if not number =~ /\A(00|\+|#{default_country_number})/
|
32
32
|
end
|
33
|
-
|
34
33
|
Phony.normalize(number)
|
35
34
|
rescue
|
36
35
|
number # If all goes wrong .. we still return the original input.
|
data/lib/phony_rails/version.rb
CHANGED
data/phony_rails.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = PhonyRails::VERSION
|
18
18
|
|
19
|
-
gem.add_dependency "phony", "~> 2.
|
19
|
+
gem.add_dependency "phony", "~> 2.3.0"
|
20
20
|
gem.add_dependency "countries", ">= 0.8.2"
|
21
21
|
gem.add_dependency "activesupport", ">= 3.0"
|
22
22
|
gem.add_development_dependency "activerecord", ">= 3.0"
|
@@ -148,7 +148,8 @@ describe PhonyRails do
|
|
148
148
|
PhonyRails.normalize_number('070-4157134', :country_code => 'NL').should eql('31704157134')
|
149
149
|
PhonyRails.normalize_number('0031-70-4157134', :country_code => 'NL').should eql('31704157134')
|
150
150
|
PhonyRails.normalize_number('+31-70-4157134', :country_code => 'NL').should eql('31704157134')
|
151
|
-
PhonyRails.normalize_number('
|
151
|
+
PhonyRails.normalize_number('0322-69497', :country_code => 'BE').should eql('3232269497')
|
152
|
+
PhonyRails.normalize_number('+32 3 226 94 97', :country_code => 'BE').should eql('3232269497')
|
152
153
|
end
|
153
154
|
|
154
155
|
it "should normalize even an implausible number" do
|
@@ -71,13 +71,13 @@ end
|
|
71
71
|
#--------------------
|
72
72
|
class FormattedHelpfulHome < ActiveRecord::Base
|
73
73
|
attr_accessor :phone_number
|
74
|
-
validates_plausible_phone :phone_number, :with =>
|
74
|
+
validates_plausible_phone :phone_number, :with => /\A\+\d+/
|
75
75
|
end
|
76
76
|
|
77
77
|
#--------------------
|
78
78
|
class NotFormattedHelpfulHome < ActiveRecord::Base
|
79
79
|
attr_accessor :phone_number
|
80
|
-
validates_plausible_phone :phone_number, :without =>
|
80
|
+
validates_plausible_phone :phone_number, :without => /\A\+\d+/
|
81
81
|
end
|
82
82
|
|
83
83
|
#--------------------
|
@@ -95,7 +95,7 @@ end
|
|
95
95
|
#--------------------
|
96
96
|
class BigHelpfulHome < ActiveRecord::Base
|
97
97
|
attr_accessor :phone_number
|
98
|
-
validates_plausible_phone :phone_number, :presence => true, :with =>
|
98
|
+
validates_plausible_phone :phone_number, :presence => true, :with => /\A\+\d+/, :country_number => "33"
|
99
99
|
end
|
100
100
|
|
101
101
|
#-----------------------------------------------------------------------------------------------------------------------
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phony_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.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: 2014-
|
12
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: phony
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 2.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 2.3.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: countries
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|