effective_resources 1.18.8 → 1.18.9

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
  SHA256:
3
- metadata.gz: 05cb089260386fe9f72bc8837a10fd8cdfe16abd4414c5deb2f06268fa069c45
4
- data.tar.gz: c1c15c971c728c5d0fdaec7fa571661bce9722fc429b7b8a2345772528be43e5
3
+ metadata.gz: 5cee67d7d1f8986997b77f0a8d4d2f50cd7b0344ec84522dea0980df07662098
4
+ data.tar.gz: 07bd05a2149368657239d5ed7abd4cce69a3d84b761f81f2653353c3cb4441d3
5
5
  SHA512:
6
- metadata.gz: 9f7f1220362e03077e200fe6e9d9cc807b03ce0dce317803278a58b28676f6a936e219c5ba430cbcbe420c04f79cb6decc126d0abdd59e4b3760c7020f5b69ad
7
- data.tar.gz: f35de510ebb41af0722a975939c99ea0c637324282a931846be21f6fe2bcd1a341d0985c7c4c9f2f449f68c3068c168f0ee0a6d7b3f18e9ad035f19e99369d36
6
+ metadata.gz: 395ca8155e668c86d1060901f9106f155d8202d0f235aac7ec8ef9e497b45b6b02386ec6e6e127615a3291640514508f2ccdbbc3696a1ff41c050ad83289b10e
7
+ data.tar.gz: 4d264db3c46fb74607fc31094a435e3b7c6db1895639f7a425ae65b971a0a051e0f09e1ad5ff059c38d3f5f36e243734302205a29fb6a703ac274847578da9e5
@@ -124,8 +124,32 @@ module Effective
124
124
  value.presence
125
125
  when :price # Integer * 100. Number of cents.
126
126
  value.kind_of?(Integer) ? value : (value.to_s.gsub(/[^0-9|\-|\.]/, '').to_f * 100.0).round
127
- when :string, :email
127
+ when :string
128
128
  value.to_s
129
+ when :email
130
+ return nil unless value.kind_of?(String)
131
+
132
+ if value.include?('<') && value.include?('>')
133
+ value = value.match(/<(.+)>/)[1].to_s # John Smith <john.smith@hotmail.com>
134
+ end
135
+
136
+ if value.include?(',')
137
+ value = value.split(',').find { |str| str.include?('@') }.to_s
138
+ end
139
+
140
+ if value.include?(' ')
141
+ value = value.split(' ').find { |str| str.include?('@') }.to_s
142
+ end
143
+
144
+ value = value.to_s.downcase.strip
145
+
146
+ return nil unless value.include?('@') && value.include?('.')
147
+
148
+ if defined?(Devise)
149
+ return nil unless Devise::email_regexp.match?(value)
150
+ end
151
+
152
+ value
129
153
  when :belongs_to_polymorphic
130
154
  value.to_s
131
155
  when :belongs_to, :has_many, :has_and_belongs_to_many, :has_one, :resource, :effective_addresses # Returns an Array of ints, an Int or String
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.18.8'.freeze
2
+ VERSION = '1.18.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.8
4
+ version: 1.18.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-30 00:00:00.000000000 Z
11
+ date: 2022-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails