email_address 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/email_address.gemspec +1 -0
- data/lib/email_address/address.rb +2 -3
- data/lib/email_address/config.rb +21 -2
- data/lib/email_address/exchanger.rb +1 -1
- data/lib/email_address/host.rb +4 -4
- data/lib/email_address/local.rb +6 -6
- data/lib/email_address/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46541e8de9140acd70cc23c1f60515c077ea919e0b04444a83d681e19fcbd4e1
|
4
|
+
data.tar.gz: 34f52f8bfa70a33d8e40c5986d1c9d4a49956a4c12d6bc69df8037705f76c417
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adde7e6139b151e6759861a0b7054c7f179a7f590d8180141c31b786ebba81aba2d01657c4073158779e879ec27b3c76389679131061661dae46cf1f1c315b92
|
7
|
+
data.tar.gz: 3420904e9bbe4713bf6e57e7bd6d1d059c7616f529a650c07828c9e45eb1a1ce3566412d86358b8c04c335ad49f55aed1f5e715d08a7eb8e4e066a703231f28e
|
data/.travis.yml
CHANGED
data/email_address.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/afair/email_address"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
+
#spec.required_ruby_version = ">= 2.3.0"
|
16
17
|
spec.files = `git ls-files`.split($/)
|
17
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
@@ -23,14 +23,13 @@ module EmailAddress
|
|
23
23
|
# instance, and initializes the address to the "normalized" format of the
|
24
24
|
# address. The original string is available in the #original method.
|
25
25
|
def initialize(email_address, config = {})
|
26
|
-
@config = config
|
26
|
+
@config = EmailAddress::Config.new(config)
|
27
27
|
@original = email_address
|
28
28
|
email_address = (email_address || "").strip
|
29
29
|
email_address = parse_rewritten(email_address) unless config[:skip_rewrite]
|
30
30
|
local, host = EmailAddress::Address.split_local_host(email_address)
|
31
31
|
|
32
|
-
@host = EmailAddress::Host.new(host, config)
|
33
|
-
@config = @host.config
|
32
|
+
@host = EmailAddress::Host.new(host, @config)
|
34
33
|
@local = EmailAddress::Local.new(local, @config, @host)
|
35
34
|
@error = @error_message = nil
|
36
35
|
end
|
data/lib/email_address/config.rb
CHANGED
@@ -175,8 +175,7 @@ module EmailAddress
|
|
175
175
|
def self.provider(name, config = {})
|
176
176
|
name = name.to_sym
|
177
177
|
if config.size > 0
|
178
|
-
@providers[name]
|
179
|
-
@providers[name].merge!(config)
|
178
|
+
@providers[name.to_sym] = config
|
180
179
|
end
|
181
180
|
@providers[name]
|
182
181
|
end
|
@@ -199,5 +198,25 @@ module EmailAddress
|
|
199
198
|
configs.each { |c| config.merge!(c) }
|
200
199
|
config
|
201
200
|
end
|
201
|
+
|
202
|
+
def initialize(overrides = {})
|
203
|
+
@config = EmailAddress::Config.all_settings(overrides)
|
204
|
+
end
|
205
|
+
|
206
|
+
def []=(setting, value)
|
207
|
+
@config[setting.to_sym] = value
|
208
|
+
end
|
209
|
+
|
210
|
+
def [](setting)
|
211
|
+
@config[setting.to_sym]
|
212
|
+
end
|
213
|
+
|
214
|
+
def configure(settings)
|
215
|
+
@config = @config.merge(settings)
|
216
|
+
end
|
217
|
+
|
218
|
+
def to_h
|
219
|
+
@config
|
220
|
+
end
|
202
221
|
end
|
203
222
|
end
|
@@ -24,7 +24,7 @@ module EmailAddress
|
|
24
24
|
|
25
25
|
def initialize(host, config = {})
|
26
26
|
@host = host
|
27
|
-
@config = config
|
27
|
+
@config = config.is_a?(Hash) ? EmailAddress::Config.new(config) : config
|
28
28
|
@dns_disabled = @config[:host_validation] == :syntax || @config[:dns_lookup] == :off
|
29
29
|
end
|
30
30
|
|
data/lib/email_address/host.rb
CHANGED
@@ -87,7 +87,7 @@ module EmailAddress
|
|
87
87
|
def initialize(host_name, config = {})
|
88
88
|
@original = host_name ||= ""
|
89
89
|
config[:host_type] ||= :email
|
90
|
-
@config = config
|
90
|
+
@config = config.is_a?(Hash) ? EmailAddress::Config.new(config) : config
|
91
91
|
@error = @error_message = nil
|
92
92
|
parse(host_name)
|
93
93
|
end
|
@@ -149,7 +149,7 @@ module EmailAddress
|
|
149
149
|
if @config[:host_remove_spaces]
|
150
150
|
@host_name = @host_name.delete(" ")
|
151
151
|
end
|
152
|
-
@dns_name = if /[^[:ascii:]]/.match
|
152
|
+
@dns_name = if /[^[:ascii:]]/.match(host_name)
|
153
153
|
::SimpleIDN.to_ascii(host_name)
|
154
154
|
else
|
155
155
|
host_name
|
@@ -227,8 +227,8 @@ module EmailAddress
|
|
227
227
|
end
|
228
228
|
|
229
229
|
def set_provider(name, provider_config = {}) # :nodoc:
|
230
|
-
|
231
|
-
|
230
|
+
config.configure(provider_config)
|
231
|
+
@provider = name
|
232
232
|
end
|
233
233
|
|
234
234
|
# Returns a hash of the parts of the host name after parsing.
|
data/lib/email_address/local.rb
CHANGED
@@ -107,7 +107,7 @@ module EmailAddress
|
|
107
107
|
%r/^([\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+)$/i.freeze
|
108
108
|
|
109
109
|
def initialize(local, config={}, host=nil)
|
110
|
-
|
110
|
+
@config = config.is_a?(Hash) ? EmailAddress::Config.new(config) : config
|
111
111
|
self.local = local
|
112
112
|
@host = host
|
113
113
|
@error = @error_message = nil
|
@@ -130,10 +130,10 @@ module EmailAddress
|
|
130
130
|
def parse(raw)
|
131
131
|
if raw =~ /\A\"(.*)\"\z/ # Quoted
|
132
132
|
raw = $1
|
133
|
-
raw.gsub
|
133
|
+
raw = raw.gsub(/\\(.)/, '\1') # Unescape
|
134
134
|
elsif @config[:local_fix] && @config[:local_format] != :standard
|
135
|
-
raw.gsub
|
136
|
-
raw.gsub
|
135
|
+
raw = raw.gsub(' ','')
|
136
|
+
raw = raw.gsub(',','.')
|
137
137
|
#raw.gsub!(/([^\p{L}\p{N}]{2,10})/) {|s| s[0] } # Stutter punctuation typo
|
138
138
|
end
|
139
139
|
raw, comment = self.parse_comment(raw)
|
@@ -226,7 +226,7 @@ module EmailAddress
|
|
226
226
|
def relax
|
227
227
|
form = self.mailbox
|
228
228
|
form += @config[:tag_separator] + self.tag if self.tag
|
229
|
-
form.gsub
|
229
|
+
form = form.gsub(/[ \"\(\),:<>@\[\]\\]/,'')
|
230
230
|
form
|
231
231
|
end
|
232
232
|
|
@@ -235,7 +235,7 @@ module EmailAddress
|
|
235
235
|
form = self.mailbox
|
236
236
|
form += @config[:tag_separator] + self.tag if self.tag
|
237
237
|
form += "(" + self.comment + ")" if self.comment
|
238
|
-
form.gsub
|
238
|
+
form = form.gsub(/([\\\"])/, '\\\1') # Escape \ and "
|
239
239
|
if form =~ /[ \"\(\),:<>@\[\\\]]/ # Space and "(),:;<>@[\]
|
240
240
|
form = %Q("#{form}")
|
241
241
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_address
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Fair
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
- !ruby/object:Gem::Version
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
186
|
+
rubygems_version: 3.0.6
|
187
187
|
signing_key:
|
188
188
|
specification_version: 4
|
189
189
|
summary: This gem provides a ruby language library for working with and validating
|