email_address 0.1.8 → 0.1.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: f54dab3992bf4e19436dd4771c376b5c4a770b263b6e91704bb8f4b4aa1c33c6
4
- data.tar.gz: 64f8de302e904131bcc25be93674d8e976e6f7ee37d6f75b3c4fcaf362054256
3
+ metadata.gz: 3825a1fafdf4659a5bc444b2bea01e83d4a52a0ae3faf57042c2cf83cae0d364
4
+ data.tar.gz: e9c2f046f52648f7f7f2e0326457f1aaa11f36e075e87d40818a34de7a84f2f3
5
5
  SHA512:
6
- metadata.gz: e5f284c688160493c8d30170007b797179ed18c38132e3d9d96d7d1afb390f996ac4f4d68dd3d473706c9a7a8be19cbaa2de2cf64b603032408cc7f3a1d60253
7
- data.tar.gz: e78d1280da5668f07bd101f6f83df0e48c8f07a93bfdfe23b8a837632b5c62c57f2e19e309999c3b05c39f9c05a387394efd32bfc6f3ac2cdb28f49d0d4d0cad
6
+ metadata.gz: 39f199aab0bd33b42a57841df03a033142217aa5a39fe0652b779c4522509d450660178fc51eee23bc3111905a967475ac3625718d020d275ef9d697b672fe79
7
+ data.tar.gz: e3ee79489ea98a0b6c11a3b438e84087833ce9782f16bf3865d7169514cd9a939f383a17e6ef2b695273351cbd427de2f36332d0d63e693c99c6f3fa7173430b
@@ -19,17 +19,17 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "rake"
22
- spec.add_development_dependency "minitest", "~> 5.8.3"
22
+ spec.add_development_dependency "minitest", "~> 5.11"
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  if RUBY_PLATFORM == 'java'
25
25
  spec.add_development_dependency "activerecord", "= 4.2.5"
26
26
  spec.add_development_dependency "activerecord-jdbcsqlite3-adapter", '=1.3.19'
27
27
  else
28
- spec.add_development_dependency "activerecord", "~> 5.1.3"
28
+ spec.add_development_dependency "activerecord", "~> 5.2.0.rc2"
29
29
  spec.add_development_dependency "sqlite3"
30
30
  end
31
31
  spec.add_development_dependency "codeclimate-test-reporter"
32
32
 
33
33
  spec.add_dependency "simpleidn"
34
- spec.add_dependency "netaddr", "~> 1.5.1"
34
+ spec.add_dependency "netaddr", "~> 2.0"
35
35
  end
@@ -92,14 +92,22 @@ module EmailAddress
92
92
 
93
93
  # Given a cidr (ip/bits) and ip address, returns true on match. Caches cidr object.
94
94
  def in_cidr?(cidr)
95
- c = NetAddr::CIDR.create(cidr)
96
95
  if cidr.include?(":")
97
- mx_ips.find { |ip| ip.include?(":") && c.matches?(ip) } ? true : false
96
+ c = NetAddr::IPv6Net.parse(cidr)
97
+ return true if mx_ips.find do |ip|
98
+ next unless ip.include?(":")
99
+ rel = c.rel NetAddr::IPv6Net.parse(ip)
100
+ !rel.nil? && rel >= 0
101
+ end
98
102
  elsif cidr.include?(".")
99
- mx_ips.find { |ip| !ip.include?(":") && c.matches?(ip) } ? true : false
100
- else
101
- false
103
+ c = NetAddr::IPv4Net.parse(cidr)
104
+ return true if mx_ips.find do |ip|
105
+ next if ip.include?(":")
106
+ rel = c.rel NetAddr::IPv4Net.parse(ip)
107
+ !rel.nil? && rel >= 0
108
+ end
102
109
  end
110
+ false
103
111
  end
104
112
  end
105
113
  end
@@ -455,11 +455,17 @@ module EmailAddress
455
455
 
456
456
  def localhost?
457
457
  if self.ip_address
458
- if self.ip_address.include?(":")
459
- return NetAddr::CIDR.create("::1").matches?(self.ip_address)
460
- else
461
- return NetAddr::CIDR.create("127.0.0.0/8").matches?(self.ip_address)
462
- end
458
+ rel =
459
+ if self.ip_address.include?(":")
460
+ NetAddr::IPv6Net.parse("::1").rel(
461
+ NetAddr::IPv6Net.parse(self.ip_address)
462
+ )
463
+ else
464
+ NetAddr::IPv4Net.parse("127.0.0.0/8").rel(
465
+ NetAddr::IPv4Net.parse(self.ip_address)
466
+ )
467
+ end
468
+ !rel.nil? && rel >= 0
463
469
  else
464
470
  self.host_name == 'localhost'
465
471
  end
@@ -1,3 +1,3 @@
1
1
  module EmailAddress
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -80,14 +80,14 @@ class TestAddress < Minitest::Test
80
80
  assert_equal EmailAddress.error("user1"), :domain_invalid
81
81
  assert_equal EmailAddress.error("user1", host_local:true), :domain_does_not_accept_email
82
82
  assert_equal EmailAddress.error("user1@localhost", host_local:true), :domain_does_not_accept_email
83
- assert_equal EmailAddress.error("user2@localhost", host_local:true, dns_lookup: :off, host_validation: :syntax), nil
83
+ assert_nil EmailAddress.error("user2@localhost", host_local:true, dns_lookup: :off, host_validation: :syntax)
84
84
  end
85
85
 
86
86
  def test_regexen
87
87
  assert "First.Last+TAG@example.com".match(EmailAddress::Address::CONVENTIONAL_REGEX)
88
88
  assert "First.Last+TAG@example.com".match(EmailAddress::Address::STANDARD_REGEX)
89
- assert_equal nil, "First.Last+TAGexample.com".match(EmailAddress::Address::STANDARD_REGEX)
90
- assert_equal nil, "First#Last+TAGexample.com".match(EmailAddress::Address::CONVENTIONAL_REGEX)
89
+ assert_nil "First.Last+TAGexample.com".match(EmailAddress::Address::STANDARD_REGEX)
90
+ assert_nil "First#Last+TAGexample.com".match(EmailAddress::Address::CONVENTIONAL_REGEX)
91
91
  assert "aasdf-34-.z@example.com".match(EmailAddress::Address::RELAXED_REGEX)
92
92
  end
93
93
 
@@ -18,11 +18,11 @@ class TestConfig < MiniTest::Test
18
18
  end
19
19
 
20
20
  def test_provider
21
- assert_equal nil, EmailAddress::Config.provider(:github)
21
+ assert_nil EmailAddress::Config.provider(:github)
22
22
  EmailAddress::Config.provider(:github, host_match: %w(github.com), local_format: :standard)
23
23
  assert_equal :standard, EmailAddress::Config.provider(:github)[:local_format]
24
24
  assert_equal :github, EmailAddress::Host.new("github.com").provider
25
25
  EmailAddress::Config.providers.delete(:github)
26
- assert_equal nil, EmailAddress::Config.provider(:github)
26
+ assert_nil EmailAddress::Config.provider(:github)
27
27
  end
28
28
  end
@@ -113,10 +113,10 @@ class TestHost < MiniTest::Test
113
113
  end
114
114
 
115
115
  def test_errors
116
- assert_equal EmailAddress::Host.new("yahoo.com").error, nil
116
+ assert_nil EmailAddress::Host.new("yahoo.com").error
117
117
  assert_equal EmailAddress::Host.new("example.com").error, :domain_does_not_accept_email
118
118
  assert_equal EmailAddress::Host.new("yahoo.wtf").error, :domain_unknown
119
- assert_equal EmailAddress::Host.new("ajsdfhajshdfklasjhd.wtf", host_validation: :syntax).error, nil
119
+ assert_nil EmailAddress::Host.new("ajsdfhajshdfklasjhd.wtf", host_validation: :syntax).error
120
120
  assert_equal EmailAddress::Host.new("ya hoo.com", host_validation: :syntax).error, :domain_invalid
121
121
  assert_equal EmailAddress::Host.new("[127.0.0.1]").error, :ip_address_forbidden
122
122
  assert_equal EmailAddress::Host.new("[127.0.0.666]", host_allow_ip:true).error, :ipv4_address_invalid
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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Fair
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-25 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.8.3
33
+ version: '5.11'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 5.8.3
40
+ version: '5.11'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 5.1.3
61
+ version: 5.2.0.rc2
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 5.1.3
68
+ version: 5.2.0.rc2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.5.1
117
+ version: '2.0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.5.1
124
+ version: '2.0'
125
125
  description: The EmailAddress Gem to work with and validate email addresses.
126
126
  email:
127
127
  - allen.fair@gmail.com