email_address 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/email_address/address.rb +1 -1
- data/lib/email_address/config.rb +3 -2
- data/lib/email_address/host.rb +8 -0
- data/lib/email_address/local.rb +9 -2
- data/lib/email_address/version.rb +1 -1
- data/test/email_address/test_address.rb +7 -0
- data/test/email_address/test_host.rb +8 -3
- 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: 57afc3d96aad109de1df3904de39a5abe068363f
|
4
|
+
data.tar.gz: 968572e1c29c8c0f71b14a8e449da7314e83c3c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0381813f1572a9071db541f353dc135b807359f1dc217d7f6e87096079c61074763697955f849dc6b1cf3d0b279744172a0d41a78c15408123431085921ed8
|
7
|
+
data.tar.gz: ec0f98df2a8b9a177ff3514f752d49bef6f7160c751d75325de58e4429b74062a2205df1a477ac3ef5d37974bf5fe2744138511dbc1f91a64d930ba946cf9d95
|
@@ -29,7 +29,7 @@ module EmailAddress
|
|
29
29
|
end
|
30
30
|
@host = EmailAddress::Host.new(host, config)
|
31
31
|
@config = @host.config
|
32
|
-
@local = EmailAddress::Local.new(local, @config)
|
32
|
+
@local = EmailAddress::Local.new(local, @config, @host)
|
33
33
|
end
|
34
34
|
|
35
35
|
############################################################################
|
data/lib/email_address/config.rb
CHANGED
@@ -119,13 +119,14 @@ module EmailAddress
|
|
119
119
|
},
|
120
120
|
google: {
|
121
121
|
host_match: %w(gmail.com googlemail.com),
|
122
|
-
exchanger_match: %w(google.com),
|
122
|
+
exchanger_match: %w(google.com googlemail.com),
|
123
123
|
local_size: 5..64,
|
124
|
+
local_private_size: 1..64, # When hostname not in host_match (private label)
|
124
125
|
mailbox_canonical: ->(m) {m.gsub('.','')},
|
125
126
|
},
|
126
127
|
msn: {
|
127
128
|
host_match: %w(msn. hotmail. outlook. live.),
|
128
|
-
mailbox_validator: ->(m,t) { m =~ /\A[a-
|
129
|
+
mailbox_validator: ->(m,t) { m =~ /\A[a-z][\-\w]*(?:\.[\-\w]+)*\z/i},
|
129
130
|
},
|
130
131
|
yahoo: {
|
131
132
|
host_match: %w(yahoo. ymail. rocketmail.),
|
data/lib/email_address/host.rb
CHANGED
@@ -169,6 +169,14 @@ module EmailAddress
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
+
# True if host is hosted at the provider, not a public provider host name
|
173
|
+
def hosted_service?
|
174
|
+
return false unless registration_name
|
175
|
+
find_provider
|
176
|
+
return false unless config[:host_match]
|
177
|
+
! matches?(config[:host_match])
|
178
|
+
end
|
179
|
+
|
172
180
|
def find_provider # :nodoc:
|
173
181
|
return self.provider if self.provider
|
174
182
|
|
data/lib/email_address/local.rb
CHANGED
@@ -98,9 +98,10 @@ module EmailAddress
|
|
98
98
|
|
99
99
|
REDACTED_REGEX = /\A \{ [0-9a-f]{40} \} \z/x # {sha1}
|
100
100
|
|
101
|
-
def initialize(local, config={})
|
101
|
+
def initialize(local, config={}, host=nil)
|
102
102
|
self.config = config.empty? ? EmailAddress::Config.all_settings : config
|
103
103
|
self.local = local
|
104
|
+
@host = host
|
104
105
|
end
|
105
106
|
|
106
107
|
def local=(raw)
|
@@ -299,7 +300,13 @@ module EmailAddress
|
|
299
300
|
end
|
300
301
|
|
301
302
|
def valid_size?
|
302
|
-
|
303
|
+
if @host && @host.hosted_service?
|
304
|
+
return false if @config[:local_private_size] &&
|
305
|
+
!@config[:local_private_size].include?(self.local.size)
|
306
|
+
else
|
307
|
+
return false if @config[:local_size] &&
|
308
|
+
!@config[:local_size].include?(self.local.size)
|
309
|
+
end
|
303
310
|
return false if @config[:mailbox_size] && !@config[:mailbox_size].include?(self.mailbox.size)
|
304
311
|
return false if self.local.size > STANDARD_MAX_SIZE
|
305
312
|
true
|
@@ -85,4 +85,11 @@ class TestAddress < Minitest::Test
|
|
85
85
|
assert "aasdf-34-.z@example.com".match(EmailAddress::Address::RELAXED_REGEX)
|
86
86
|
end
|
87
87
|
|
88
|
+
# Quick Regression tests for addresses that should have been valid (but fixed)
|
89
|
+
def test_issues
|
90
|
+
assert true, EmailAddress.valid?('test@jiff.com', dns_lookup: :mx) # #7
|
91
|
+
assert true, EmailAddress.valid?("w.-asdf-_@hotmail.com") # #8
|
92
|
+
assert true, EmailAddress.valid?("first_last@hotmail.com") # #8
|
93
|
+
end
|
94
|
+
|
88
95
|
end
|
@@ -10,9 +10,9 @@ class TestHost < MiniTest::Test
|
|
10
10
|
assert_equal "example", a.registration_name
|
11
11
|
assert_equal "com", a.tld
|
12
12
|
assert_equal "ex*****", a.munge
|
13
|
-
|
13
|
+
assert_nil a.subdomains
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_dns_enabled
|
17
17
|
a = EmailAddress::Host.new("example.com")
|
18
18
|
assert_instance_of TrueClass, a.dns_enabled?
|
@@ -94,6 +94,11 @@ class TestHost < MiniTest::Test
|
|
94
94
|
assert "xn--5ca.com".match EmailAddress::Host::CANONICAL_HOST_REGEX
|
95
95
|
assert "[127.0.0.1]".match EmailAddress::Host::STANDARD_HOST_REGEX
|
96
96
|
assert "[IPv6:2001:dead::1]".match EmailAddress::Host::STANDARD_HOST_REGEX
|
97
|
-
|
97
|
+
assert_nil "[256.0.0.1]".match(EmailAddress::Host::STANDARD_HOST_REGEX)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_hosted_service
|
101
|
+
assert EmailAddress.valid?('test@jiff.com', dns_lookup: :mx)
|
102
|
+
assert ! EmailAddress.valid?('test@gmail.com', dns_lookup: :mx)
|
98
103
|
end
|
99
104
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Fair
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.5.1
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: This gem provides a ruby language library for working with and validating
|