phony_rails 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/phony_rails/version.rb +1 -1
- data/lib/phony_rails.rb +1 -1
- data/phony_rails.gemspec +1 -1
- data/spec/lib/phony_rails_spec.rb +22 -0
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b65451e2281a2975a3f79dcf31ca25dc60c7ad0
|
4
|
+
data.tar.gz: 939a731c8afe851abf63610553b2cac826c5744e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deaf1d6b24044a7dbf4267946a07d6262a9fab5e6d17736b49fa731ca8531793950721025227b78793da9d267d2c6e3c06c74aa8f4579b0ad6fe40c33bf76b29
|
7
|
+
data.tar.gz: befd928d11956eced60622a6172df21786599c0cd84130a247b2aa5550d83071f87c33be4edb9425364b7df75164f2bfa58f9d2d92e664309d262d60a98c16c8
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
phony_rails (0.
|
4
|
+
phony_rails (0.11.0)
|
5
5
|
activesupport (>= 3.0)
|
6
|
-
countries (>= 0.8.2)
|
7
|
-
phony (~> 2.
|
6
|
+
countries (~> 0.8, >= 0.8.2)
|
7
|
+
phony (~> 2.12)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -71,7 +71,7 @@ GEM
|
|
71
71
|
nenv (0.1.1)
|
72
72
|
optionable (0.2.0)
|
73
73
|
origin (2.1.1)
|
74
|
-
phony (2.
|
74
|
+
phony (2.12.4)
|
75
75
|
pry (0.10.1)
|
76
76
|
coderay (~> 1.1.0)
|
77
77
|
method_source (~> 0.8.1)
|
data/lib/phony_rails/version.rb
CHANGED
data/lib/phony_rails.rb
CHANGED
@@ -80,7 +80,7 @@ module PhonyRails
|
|
80
80
|
# you've geocoded before calling this method!
|
81
81
|
def phony_normalize(*attributes)
|
82
82
|
options = attributes.last.is_a?(Hash) ? attributes.pop : {}
|
83
|
-
options.assert_valid_keys :country_code, :default_country_code, :as
|
83
|
+
options.assert_valid_keys :country_number, :default_country_number, :country_code, :default_country_code, :add_plus, :as
|
84
84
|
if options[:as].present?
|
85
85
|
raise ArgumentError, ':as option can not be used on phony_normalize with multiple attribute names! (PhonyRails)' if attributes.size > 1
|
86
86
|
end
|
data/phony_rails.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.post_install_message = "PhonyRails v0.10.0 changes the way numbers are stored!"
|
20
20
|
gem.post_install_message = "It now ads a '+' to the normalized number when it starts with a country number!"
|
21
21
|
|
22
|
-
gem.add_dependency "phony", '~> 2.
|
22
|
+
gem.add_dependency "phony", '~> 2.12'
|
23
23
|
gem.add_dependency "countries", '~> 0.8', '>= 0.8.2'
|
24
24
|
gem.add_dependency "activesupport", ">= 3.0"
|
25
25
|
gem.add_development_dependency "activerecord", ">= 3.0"
|
@@ -315,6 +315,21 @@ describe PhonyRails do
|
|
315
315
|
dummy_klass.phony_normalize(:non_existing_attribute)
|
316
316
|
}.should_not raise_error
|
317
317
|
end
|
318
|
+
|
319
|
+
it "should accept supported options" do
|
320
|
+
options = [:country_number, :default_country_number, :country_code, :default_country_code, :add_plus, :as]
|
321
|
+
options.each do |option_sym|
|
322
|
+
lambda {
|
323
|
+
dummy_klass.phony_normalize(:phone_number, option_sym => false)
|
324
|
+
}.should_not raise_error
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should not accept unsupported options" do
|
329
|
+
lambda {
|
330
|
+
dummy_klass.phony_normalize(:phone_number, unsupported_option: false)
|
331
|
+
}.should raise_error(ArgumentError)
|
332
|
+
end
|
318
333
|
end
|
319
334
|
|
320
335
|
describe 'using model#phony_normalized_method' do
|
@@ -393,6 +408,13 @@ describe PhonyRails do
|
|
393
408
|
model.phone_number_as_normalized.should eql('+31101234123')
|
394
409
|
end
|
395
410
|
|
411
|
+
it "should not add a + using :add_plus option" do
|
412
|
+
model_klass.phony_normalize :phone_number, :add_plus => false
|
413
|
+
model = model_klass.new(:phone_number => "+31-(0)10-1234123")
|
414
|
+
model.valid?.should be_true
|
415
|
+
model.phone_number.should eql('31101234123')
|
416
|
+
end
|
417
|
+
|
396
418
|
it "should raise a RuntimeError at validation if the attribute doesn't exist" do
|
397
419
|
dummy_klass.phony_normalize :non_existing_attribute
|
398
420
|
dummy = dummy_klass.new
|
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.
|
4
|
+
version: 0.12.0
|
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-03-
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phony
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 2.11.1
|
19
|
+
version: '2.12'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '2.
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 2.11.1
|
26
|
+
version: '2.12'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: countries
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
138
|
version: '0'
|
145
139
|
requirements: []
|
146
140
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.4.5
|
148
142
|
signing_key:
|
149
143
|
specification_version: 4
|
150
144
|
summary: This Gem adds useful methods to your Rails app to validate, display and save
|