email_address 0.2.1 → 0.2.2

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: 7db5d5d3abee697033dfef4eae04ab363e15ff1de031a11d0a99057c4ced63ae
4
- data.tar.gz: e9a9496562833f2699f5dcbb4def03852f27468e2f292d4a9a86d44654e6d50b
3
+ metadata.gz: c6784502377cd86fe2b6bb53c53ef7700673ed0317d2c96850ba0e9faad32c72
4
+ data.tar.gz: 5a558e95e390bf608225149fa2cb0948dcd9455607592e0c92156f34dced0807
5
5
  SHA512:
6
- metadata.gz: 911ccd6e02bf381a67f78ca14f139b4dc36a4905b4ca784a8e1df969d7bd725c9e679ba92d34b94ecc7038c9b0f39e39e843cac5d533f155874ef526b237d9a5
7
- data.tar.gz: aa01ec4b35d46def0fd36c2d5bd59e1e94e65d4d4f10fb9e6dcea8cf7fda14b05ef61b0ab0269e5f7b50a4f60009cbefa16a3634eadfc01219e4d211eff5b102
6
+ metadata.gz: 65cd1a6acccd37f3580762ba5d97e2956833c979a9fa639369385427bfe0ebf3cca693014d442ab530a005349e6fd36bce3d0b7372f432230bfcc4e0d3d15d79
7
+ data.tar.gz: 6543b62b3d0650717c81d2b25de2008fe6b898707a82c8779646364cb351654322958d38dfbf6b9420728a1eb7d6047d2d4205f0e11254e9d868930f6db74243
@@ -5,7 +5,7 @@ jobs:
5
5
  runs-on: ubuntu-latest
6
6
  strategy:
7
7
  matrix:
8
- ruby-version: [2.6, 2.7, 3.0, jruby]
8
+ ruby-version: [2.6, 2.7, 3.0, 3.1, jruby]
9
9
  steps:
10
10
  - uses: actions/checkout@v2
11
11
  - uses: ruby/setup-ruby@v1
@@ -27,10 +27,11 @@ Gem::Specification.new do |spec|
27
27
  else
28
28
  spec.add_development_dependency "activerecord", "~> 6.1.4"
29
29
  spec.add_development_dependency "sqlite3"
30
+ spec.add_development_dependency "standard", "~> 1.5.0"
30
31
  end
32
+ # spec.add_development_dependency "net-smtp"
31
33
  spec.add_development_dependency "simplecov"
32
34
  spec.add_development_dependency "pry"
33
- spec.add_development_dependency "standard", "~> 1.1.1"
34
35
 
35
36
  spec.add_dependency "simpleidn"
36
37
  end
@@ -258,6 +258,10 @@ module EmailAddress
258
258
  # Connects to host to test if user can receive email. This should NOT be performed
259
259
  # as an email address check, but is provided to assist in problem resolution.
260
260
  # If you abuse this, you *could* be blocked by the ESP.
261
+ #
262
+ # NOTE: As of Ruby 3.1, Net::SMTP was moved from the standard library to the
263
+ # 'net-smtp' gem. In order to avoid adding that dependency for this experimental
264
+ # feature, please add the gem to your Gemfile and require it to use this feature.
261
265
  def connect
262
266
  smtp = Net::SMTP.new(host_name || ip_address)
263
267
  smtp.start(@config[:smtp_helo_name] || "localhost")
@@ -1,6 +1,5 @@
1
1
  require "simpleidn"
2
2
  require "resolv"
3
- require "net/smtp"
4
3
 
5
4
  module EmailAddress
6
5
  ##############################################################################
@@ -402,11 +401,7 @@ module EmailAddress
402
401
  # True if the host name has a DNS A Record
403
402
  def valid_dns?
404
403
  return true unless dns_enabled?
405
- bool = dns_a_record.size > 0 || set_error(:domain_unknown)
406
- if localhost? && !@config[:host_local]
407
- bool = set_error(:domain_no_localhost)
408
- end
409
- bool
404
+ dns_a_record.size > 0 || set_error(:domain_unknown)
410
405
  end
411
406
 
412
407
  # True if the host name has valid MX servers configured in DNS
@@ -430,7 +425,9 @@ module EmailAddress
430
425
  # True if the host_name passes Regular Expression match and size limits.
431
426
  def valid_format?
432
427
  if host_name =~ CANONICAL_HOST_REGEX && to_s.size <= MAX_HOST_LENGTH
433
- return true if localhost?
428
+ if localhost?
429
+ return @config[:host_local] ? true : set_error(:domain_no_localhost)
430
+ end
434
431
  return true if host_name.include?(".") # require FQDN
435
432
  end
436
433
  set_error(:domain_invalid)
@@ -462,6 +459,10 @@ module EmailAddress
462
459
  # Connects to host to test it can receive email. This should NOT be performed
463
460
  # as an email address check, but is provided to assist in problem resolution.
464
461
  # If you abuse this, you *could* be blocked by the ESP.
462
+ #
463
+ # NOTE: As of Ruby 3.1, Net::SMTP was moved from the standard library to the
464
+ # 'net-smtp' gem. In order to avoid adding that dependency for this experimental
465
+ # feature, please add the gem to your Gemfile and require it to use this feature.
465
466
  def connect
466
467
  smtp = Net::SMTP.new(host_name || ip_address)
467
468
  smtp.start(@config[:helo_name] || "localhost")
@@ -1,3 +1,3 @@
1
1
  module EmailAddress
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -104,6 +104,8 @@ class TestAddress < Minitest::Test
104
104
  assert_equal EmailAddress.error("user1"), "Invalid Domain Name"
105
105
  assert_equal EmailAddress.error("user1", host_local: true), "This domain is not configured to accept email"
106
106
  assert_equal EmailAddress.error("user1@localhost", host_local: true), "This domain is not configured to accept email"
107
+ assert_equal EmailAddress.error("user1@localhost", host_local: false, host_validation: :syntax), "localhost is not allowed for your domain name"
108
+ assert_equal EmailAddress.error("user1@localhost", host_local: false, dns_lookup: :off), "localhost is not allowed for your domain name"
107
109
  assert_nil EmailAddress.error("user2@localhost", host_local: true, dns_lookup: :off, host_validation: :syntax)
108
110
  end
109
111
 
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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Fair
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-13 00:00:00.000000000 Z
11
+ date: 2021-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -81,21 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: simplecov
84
+ name: standard
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 1.5.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 1.5.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: pry
98
+ name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,19 +109,19 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: standard
112
+ name: pry
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 1.1.1
117
+ version: '0'
118
118
  type: :development
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.1.1
124
+ version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simpleidn
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
197
  requirements: []
198
- rubygems_version: 3.2.22
198
+ rubygems_version: 3.3.3
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: This gem provides a ruby language library for working with and validating