backframe 0.0.32 → 0.0.33

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: d59f6e11a5b5a46861cbf5deaf1ee801528bedf3
4
- data.tar.gz: b3c6cb6c7ab5f6d0277969b778d2fe5cfc64a1a1
3
+ metadata.gz: ddd42ad68a92951af7d447fe203cf35caefba49e
4
+ data.tar.gz: d6d17949e7f8cd763de6b45c95213d5eb5162c02
5
5
  SHA512:
6
- metadata.gz: 7cda2267bcd265dd17bbbd52addbff1dbcfde18ea24809c05f086ec6a8415838862ce7f5cf8b0bff100bd91092d5a5b1233e59d3d84778f5c075559b4b7db646
7
- data.tar.gz: f21d1df236414604a00e8255788abc6fd451f4f14fe89f925f0204e9bd072cc29bdb68139703aab1d495a17c0bf16cb16d51ba6c95437197878ba3b40178da35
6
+ metadata.gz: dde2bb19707f03d683fd87514d75cf0db6642ab86c3ba045ed0ee82e29f2e14facba701a28216001c315e523376e773994b9d4ea418193bbe26239b7abf59bd5
7
+ data.tar.gz: 060048ae6277590bf40793edbafea2af25565bc2804851d1397ffd97a46a7f4c3c7d2b92b35c80ad3632913a83d333453c14c9319bf964e896d1d3394b6cb8b2
@@ -17,7 +17,7 @@ module Backframe
17
17
 
18
18
  class_eval <<-EOV
19
19
 
20
- after_initialize :uncast_phone_#{entity}, :if => Proc.new { |c| c.#{entity}.present? }
20
+ after_initialize :uncast_phone_#{entity}, :if => Proc.new { |c| !c.new_record? && c.#{entity}.present? }
21
21
  before_save :cast_phone_#{entity}, :if => Proc.new { |c| c.#{entity}.present? }
22
22
  after_save :uncast_phone_#{entity}, :if => Proc.new { |c| c.#{entity}.present? }
23
23
 
@@ -30,18 +30,23 @@ module Backframe
30
30
  end
31
31
 
32
32
  def cast_phone_#{entity}
33
- self.#{entity} = Phony.normalize(self.#{entity})
34
- self.#{entity} = '1'+self.#{entity} if (self.#{entity}.length == 10)
33
+ self.#{entity} = #{entity}_to_international(self.#{entity})
35
34
  end
36
35
 
37
36
  def validates_phone_#{entity}
38
- testvalue = Phony.normalize(self.#{entity})
39
- testvalue = '1'+testvalue if (testvalue.length == 10)
37
+ testvalue = #{entity}_to_international(self.#{entity})
40
38
  if !Phony.plausible?(testvalue)
41
39
  self.errors.add(:#{entity}, 'invalid #{entity} number')
42
40
  end
43
41
  end
44
42
 
43
+ def #{entity}_to_international(value)
44
+ regex = Regexp.new('[\\s\\\.\\\-\\\(\\\)]')
45
+ newvalue = value.gsub(regex, '')
46
+ newvalue = (newvalue.length == 10) ? '1'+value : value
47
+ Phony.normalize(newvalue)
48
+ end
49
+
45
50
  EOV
46
51
 
47
52
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Backframe
4
- VERSION = '0.0.32'
4
+ VERSION = '0.0.33'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backframe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.32
4
+ version: 0.0.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Kops
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-19 00:00:00.000000000 Z
12
+ date: 2016-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: write_xlsx