phony_rails 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +27 -25
- data/lib/phony_rails.rb +10 -3
- data/lib/phony_rails/version.rb +1 -1
- data/spec/lib/phony_rails_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89bf28723abfacd4fca598089c2c674668d21bed
|
4
|
+
data.tar.gz: a8611d6f572bb2e2713abff5d3846e09fb2fd1a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d157afaff06b65a3f1af8f0c5aed1392eeb638071dc6dfec09a572c777f9a7427c35dc2c05180a9eccc42f2a72f39ca0bd1ba0a0aabcaaaf7185b2df2a33c683
|
7
|
+
data.tar.gz: f025d73b8f87578ce4866f1a0a012e32ab4e37ecb26d358c0040f8430daa5e15c18641a36d5cd23cc221e186b110c41627ce1df60b8880adb73d22a3b751d8ca
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
phony_rails (0.
|
4
|
+
phony_rails (0.12.0)
|
5
5
|
activesupport (>= 3.0)
|
6
6
|
countries (~> 0.8, >= 0.8.2)
|
7
7
|
phony (~> 2.12)
|
@@ -9,34 +9,35 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (4.1
|
13
|
-
activesupport (= 4.1
|
12
|
+
activemodel (4.2.1)
|
13
|
+
activesupport (= 4.2.1)
|
14
14
|
builder (~> 3.1)
|
15
|
-
activerecord (4.1
|
16
|
-
activemodel (= 4.1
|
17
|
-
activesupport (= 4.1
|
18
|
-
arel (~>
|
19
|
-
activesupport (4.1
|
20
|
-
i18n (~> 0.
|
15
|
+
activerecord (4.2.1)
|
16
|
+
activemodel (= 4.2.1)
|
17
|
+
activesupport (= 4.2.1)
|
18
|
+
arel (~> 6.0)
|
19
|
+
activesupport (4.2.1)
|
20
|
+
i18n (~> 0.7)
|
21
21
|
json (~> 1.7, >= 1.7.7)
|
22
22
|
minitest (~> 5.1)
|
23
|
-
thread_safe (~> 0.
|
23
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
24
24
|
tzinfo (~> 1.1)
|
25
|
-
arel (
|
25
|
+
arel (6.0.0)
|
26
26
|
bson (2.3.0)
|
27
27
|
builder (3.2.2)
|
28
28
|
celluloid (0.16.0)
|
29
29
|
timers (~> 4.0.0)
|
30
30
|
coderay (1.1.0)
|
31
|
-
connection_pool (2.1.
|
32
|
-
countries (0.
|
31
|
+
connection_pool (2.1.3)
|
32
|
+
countries (0.11.3)
|
33
33
|
currencies (~> 0.4.2)
|
34
|
+
i18n_data (~> 0.6.0)
|
34
35
|
currencies (0.4.2)
|
35
36
|
diff-lcs (1.2.5)
|
36
|
-
ffi (1.9.
|
37
|
+
ffi (1.9.8)
|
37
38
|
formatador (0.2.5)
|
38
39
|
growl (1.0.3)
|
39
|
-
guard (2.10.
|
40
|
+
guard (2.10.5)
|
40
41
|
formatador (>= 0.2.4)
|
41
42
|
listen (~> 2.7)
|
42
43
|
lumberjack (~> 1.0)
|
@@ -50,28 +51,29 @@ GEM
|
|
50
51
|
guard (~> 2.1)
|
51
52
|
rspec (>= 2.14, < 4.0)
|
52
53
|
hitimes (1.2.2)
|
53
|
-
i18n (0.
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
i18n (0.7.0)
|
55
|
+
i18n_data (0.6.3)
|
56
|
+
json (1.8.2)
|
57
|
+
listen (2.10.0)
|
58
|
+
celluloid (~> 0.16.0)
|
57
59
|
rb-fsevent (>= 0.9.3)
|
58
60
|
rb-inotify (>= 0.9)
|
59
61
|
lumberjack (1.0.9)
|
60
62
|
method_source (0.8.2)
|
61
|
-
minitest (5.5.
|
62
|
-
mongoid (4.0.
|
63
|
+
minitest (5.5.1)
|
64
|
+
mongoid (4.0.2)
|
63
65
|
activemodel (~> 4.0)
|
64
66
|
moped (~> 2.0.0)
|
65
67
|
origin (~> 2.1)
|
66
68
|
tzinfo (>= 0.3.37)
|
67
|
-
moped (2.0.
|
69
|
+
moped (2.0.4)
|
68
70
|
bson (~> 2.2)
|
69
71
|
connection_pool (~> 2.0)
|
70
72
|
optionable (~> 0.2.0)
|
71
|
-
nenv (0.
|
73
|
+
nenv (0.2.0)
|
72
74
|
optionable (0.2.0)
|
73
75
|
origin (2.1.1)
|
74
|
-
phony (2.12.
|
76
|
+
phony (2.12.6)
|
75
77
|
pry (0.10.1)
|
76
78
|
coderay (~> 1.1.0)
|
77
79
|
method_source (~> 0.8.1)
|
@@ -91,7 +93,7 @@ GEM
|
|
91
93
|
slop (3.6.0)
|
92
94
|
sqlite3 (1.3.10)
|
93
95
|
thor (0.19.1)
|
94
|
-
thread_safe (0.3.
|
96
|
+
thread_safe (0.3.5)
|
95
97
|
timers (4.0.1)
|
96
98
|
hitimes
|
97
99
|
tzinfo (1.2.2)
|
data/lib/phony_rails.rb
CHANGED
@@ -27,11 +27,13 @@ module PhonyRails
|
|
27
27
|
if _country_number = options[:country_number] || country_number_for(options[:country_code])
|
28
28
|
options[:add_plus] = true if options[:add_plus].nil?
|
29
29
|
# (Force) add country_number if missing
|
30
|
-
|
30
|
+
# NOTE: do we need to force adding country code? Otherwise we can share lofic with next block
|
31
|
+
if !Phony.plausible?(number) || _country_number != country_code_from_number(number)
|
32
|
+
number = "#{_country_number}#{number}"
|
33
|
+
end
|
31
34
|
elsif _default_country_number = options[:default_country_number] || country_number_for(options[:default_country_code])
|
32
35
|
options[:add_plus] = true if options[:add_plus].nil?
|
33
|
-
|
34
|
-
number = "#{_default_country_number}#{number}" if not number =~ /\A(00|\+|#{_default_country_number})/
|
36
|
+
number = "#{_default_country_number}#{number}" unless Phony.plausible?(number)
|
35
37
|
end
|
36
38
|
normalized_number = Phony.normalize(number)
|
37
39
|
options[:add_plus] = true if options[:add_plus].nil? && Phony.plausible?(normalized_number)
|
@@ -40,6 +42,11 @@ module PhonyRails
|
|
40
42
|
number # If all goes wrong .. we still return the original input.
|
41
43
|
end
|
42
44
|
|
45
|
+
def self.country_code_from_number(number)
|
46
|
+
return nil unless Phony.plausible?(number)
|
47
|
+
Phony.split(Phony.normalize(number)).first
|
48
|
+
end
|
49
|
+
|
43
50
|
# Wrapper for Phony.plausible?. Takes the same options as #normalize_number.
|
44
51
|
# NB: This method calls #normalize_number and passes _options_ directly to that method.
|
45
52
|
def self.plausible_number?(number, options = {})
|
data/lib/phony_rails/version.rb
CHANGED
@@ -98,6 +98,10 @@ describe PhonyRails do
|
|
98
98
|
PhonyRails.normalize_number("0606060606", default_country_code: 'FR').should eq('+33606060606')
|
99
99
|
end
|
100
100
|
|
101
|
+
it "should pass issue Github issue #85" do
|
102
|
+
PhonyRails.normalize_number("47386160", default_country_code: 'NO').should eq('+4747386160')
|
103
|
+
PhonyRails.normalize_number("47386160", country_number: '47').should eq('+4747386160')
|
104
|
+
end
|
101
105
|
end
|
102
106
|
|
103
107
|
it "should not change original String" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phony_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joost Hietbrink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phony
|