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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 580be97d53e4e08977013b8033af91d391dea1b2
4
- data.tar.gz: 86fbc558bf484ab8f60a63eaa197d9dbdea887d8
3
+ metadata.gz: 35b127b81167348fe916e75a9f18befb03c60c22
4
+ data.tar.gz: 948a30d5c8aa1372adcfc02d8bbc6ca336ad8c66
5
5
  SHA512:
6
- metadata.gz: 80b6bfc73635665590541c82cf4653016cc7b853faea145889be9008ec74aa2e522ac5f2bf9e2aea29015801666f1c09f0d986dcc01490b7975dba30ee6a2df2
7
- data.tar.gz: 7312b87a901d27a09e923e02a916277f1da3af13e180bc08a701a6480521141f1331067ec92e8f16db449739046676c6202d77610b448510969f85c080a18b40
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?
@@ -1,3 +1,3 @@
1
1
  module PhonyRails
2
- VERSION = "0.12.4"
2
+ VERSION = "0.12.5"
3
3
  end
@@ -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
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-08 00:00:00.000000000 Z
11
+ date: 2015-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phony