phony_rails 0.12.4 → 0.12.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/phony_rails/string_extensions.rb +4 -0
- data/lib/phony_rails/version.rb +1 -1
- data/spec/lib/phony_rails_spec.rb +12 -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: 35b127b81167348fe916e75a9f18befb03c60c22
|
4
|
+
data.tar.gz: 948a30d5c8aa1372adcfc02d8bbc6ca336ad8c66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc3f537416f6dc4c49953ef01f6ec945aaf117135d8b4a3cb01d2545073926217ac4fab9402e13e052e73c4c5face5a1f477cbc6c692f40f4edde83ed7c09465
|
7
|
+
data.tar.gz: 868a145b573c8cc5727c1097f3c33dc0acd57bb70ab3236e8dd247c71a9dc55f373bd6efd42dded3943d2ac315a7cc45ae12938d517490666d7c9a124c626ec2
|
@@ -5,6 +5,8 @@
|
|
5
5
|
# "(0)30 1234 123".phony_normalized # => '301234123'
|
6
6
|
# "(0)30 1234 123".phony_normalized(country_code: 'NL') # => '301234123'
|
7
7
|
def phony_normalized(options = {})
|
8
|
+
raise ArgumentError, "Expected options to be a Hash, got #{options.inspect}" if not options.is_a?(Hash)
|
9
|
+
options = options.dup
|
8
10
|
normalize_country_code = options.delete(:country_code)
|
9
11
|
PhonyRails.normalize_number(self, :default_country_code => normalize_country_code.to_s)
|
10
12
|
end
|
@@ -21,6 +23,8 @@
|
|
21
23
|
# To raise an error use:
|
22
24
|
# "somestring".phone_formatted(raise: true)
|
23
25
|
def phony_formatted(options = {})
|
26
|
+
raise ArgumentError, "Expected options to be a Hash, got #{options.inspect}" if not options.is_a?(Hash)
|
27
|
+
options = options.dup
|
24
28
|
normalize_country_code = options.delete(:normalize)
|
25
29
|
s = (normalize_country_code ? PhonyRails.normalize_number(self, :default_country_code => normalize_country_code.to_s, :add_plus => false) : self.gsub(/\D/, ''))
|
26
30
|
return if s.blank?
|
data/lib/phony_rails/version.rb
CHANGED
@@ -9,6 +9,12 @@ describe PhonyRails do
|
|
9
9
|
|
10
10
|
describe 'the phony_formatted method' do
|
11
11
|
|
12
|
+
it 'should not modify the original options Hash' do
|
13
|
+
options = {:normalize => :NL, :format => :international}
|
14
|
+
"0101234123".phony_formatted(options)
|
15
|
+
options.should eql({:normalize => :NL, :format => :international})
|
16
|
+
end
|
17
|
+
|
12
18
|
describe 'with the bang!' do
|
13
19
|
|
14
20
|
it "should change the String using the bang method" do
|
@@ -146,6 +152,12 @@ describe PhonyRails do
|
|
146
152
|
"".phony_normalized.should be_nil
|
147
153
|
end
|
148
154
|
|
155
|
+
it 'should not modify the original options Hash' do
|
156
|
+
options = {:normalize => :NL, :format => :international}
|
157
|
+
"0101234123".phony_normalized(options)
|
158
|
+
options.should eql({:normalize => :NL, :format => :international})
|
159
|
+
end
|
160
|
+
|
149
161
|
context "when String misses a country_code" do
|
150
162
|
it "should normalize with :country_code option" do
|
151
163
|
"010 1231234".phony_normalized(:country_code => :NL).should eql("+31101231234")
|
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.5
|
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-04-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phony
|