Skip to content

Commit

Permalink
Bugfix/Net::SMTP#start Ruby 2.x compatibility (#189)
Browse files Browse the repository at this point in the history
* Updated Truemail::Validate::Smtp::Request#run
* Updated rubocop/codeclimate configs
* Updated gem development dependencies
* Updated gem docs, version, changelog
  • Loading branch information
bestwebua authored Dec 3, 2021
1 parent 9898f2c commit 39dd818
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ checks:
plugins:
rubocop:
enabled: true
channel: rubocop-1-22
channel: rubocop-1-23

reek:
enabled: true
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ Style/NumberedParametersLimit:
Style/SelectByRegexp:
Enabled: true

Style/OpenStructUse:
Enabled: true

Layout/LineLength:
Max: 140

Expand Down Expand Up @@ -350,9 +353,15 @@ Lint/IncompatibleIoSelectWithFiberScheduler:
Lint/RequireRelativeSelfPath:
Enabled: true

Lint/UselessRuby2Keywords:
Enabled: true

Gemspec/DateAssignment:
Enabled: true

Gemspec/RequireMFA:
Enabled: false

Security/IoMethods:
Enabled: true

Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.5.4] - 2021.12.03

### Fixed

- `Net::SMTP#start` Ruby 2.x compatibility. Thanks [@evserykh](https://github.com/evserykh) for bug report.

### Updated

- Updated `Truemail::Validate::Smtp::Request#run`
- Updated rubocop/codeclimate configs
- Updated gem development dependencies
- Updated gem docs, version

## [2.5.3] - 2021.11.08

### Fixed
Expand Down
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
truemail (2.5.3)
truemail (2.5.4)
simpleidn (~> 0.2.1)

GEM
Expand All @@ -20,7 +20,7 @@ GEM
crack (0.4.5)
rexml
diff-lcs (1.4.4)
dns_mock (1.4.3)
dns_mock (1.4.4)
simpleidn (~> 0.2.1)
docile (1.4.0)
fasterer (0.9.0)
Expand All @@ -40,7 +40,7 @@ GEM
iniparse (~> 1.4)
rexml (~> 3.2)
parallel (1.21.0)
parser (3.0.2.0)
parser (3.0.3.1)
ast (~> 2.4.1)
pry (0.13.1)
coderay (~> 1.1)
Expand Down Expand Up @@ -70,7 +70,7 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
rubocop (1.22.3)
rubocop (1.23.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
Expand All @@ -79,15 +79,15 @@ GEM
rubocop-ast (>= 1.12.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.13.0)
rubocop-ast (1.14.0)
parser (>= 3.0.1.1)
rubocop-performance (1.12.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rspec (2.6.0)
rubocop (~> 1.19)
ruby-progressbar (1.11.0)
ruby_parser (3.18.0)
ruby_parser (3.18.1)
sexp_processor (~> 4.16)
sexp_processor (4.16.0)
simplecov (0.17.1)
Expand Down Expand Up @@ -115,9 +115,9 @@ PLATFORMS
x86_64-darwin-20

DEPENDENCIES
bundler (~> 2.2, >= 2.2.31)
bundler (~> 2.2, >= 2.2.32)
bundler-audit (~> 0.9.0.1)
dns_mock (~> 1.4, >= 1.4.3)
dns_mock (~> 1.4, >= 1.4.4)
fasterer (~> 0.9.0)
ffaker (~> 2.20)
json_matchers (~> 0.11.1)
Expand All @@ -126,7 +126,7 @@ DEPENDENCIES
rake (~> 13.0, >= 13.0.6)
reek (~> 6.0, >= 6.0.6)
rspec (~> 3.10)
rubocop (~> 1.22, >= 1.22.3)
rubocop (~> 1.23)
rubocop-performance (~> 1.12)
rubocop-rspec (~> 2.6)
simplecov (~> 0.17.1)
Expand All @@ -135,4 +135,4 @@ DEPENDENCIES
webmock (~> 3.14)

BUNDLED WITH
2.2.31
2.2.32
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![CircleCI](https://circleci.com/gh/truemail-rb/truemail/tree/master.svg?style=svg)](https://circleci.com/gh/truemail-rb/truemail/tree/master)
[![Gem Version](https://badge.fury.io/rb/truemail.svg)](https://badge.fury.io/rb/truemail)
[![Downloads](https://img.shields.io/gem/dt/truemail.svg?colorA=004d99&colorB=0073e6)](https://rubygems.org/gems/truemail)
[![SemVer compatibility](https://api.dependabot.com/badges/compatibility_score?dependency-name=truemail&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=truemail&package-manager=bundler&version-scheme=semver)
[![In Awesome Ruby](https://raw.githubusercontent.com/sindresorhus/awesome/main/media/mentioned-badge.svg)](https://github.com/markets/awesome-ruby)
[![Gitter](https://badges.gitter.im/truemail-rb/community.svg)](https://gitter.im/truemail-rb/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![GitHub](https://img.shields.io/github/license/truemail-rb/truemail)](LICENSE.txt)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
Expand Down
17 changes: 13 additions & 4 deletions lib/truemail/validate/smtp/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ def check_port
end

def run
session.start(configuration.verifier_domain, **(::RUBY_VERSION[/\A3\..+\z/] ? { tls_verify: false } : {})) do |smtp_request|
response.connection = response.helo = true
smtp_handshakes(smtp_request, response)
end
return session.start(verifier_domain, tls_verify: false, &session_actions) if ::RUBY_VERSION[/\A3\..+\z/]
session.start(verifier_domain, &session_actions)
rescue => error
retry if attempts_exist?
assign_error(attribute: :connection, message: compose_from(error))
Expand Down Expand Up @@ -98,6 +96,17 @@ def smtp_resolver(smtp_request, method, value)
assign_error(attribute: method, message: compose_from(error))
end

def verifier_domain
configuration.verifier_domain
end

def session_actions
lambda { |smtp_request|
response.connection = response.helo = true
smtp_handshakes(smtp_request, response)
}
end

def smtp_handshakes(smtp_request, smtp_response)
session_data.all? do |method, value|
smtp_response.public_send(:"#{method}=", smtp_resolver(smtp_request, method, value))
Expand Down
2 changes: 1 addition & 1 deletion lib/truemail/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Truemail
VERSION = '2.5.3'
VERSION = '2.5.4'
end
6 changes: 3 additions & 3 deletions truemail.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency 'simpleidn', '~> 0.2.1'

spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.31'
spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.32'
spec.add_development_dependency 'bundler-audit', '~> 0.9.0.1'
spec.add_development_dependency 'dns_mock', '~> 1.4', '>= 1.4.3'
spec.add_development_dependency 'dns_mock', '~> 1.4', '>= 1.4.4'
spec.add_development_dependency 'fasterer', '~> 0.9.0'
spec.add_development_dependency 'ffaker', '~> 2.20'
spec.add_development_dependency 'json_matchers', '~> 0.11.1'
Expand All @@ -44,7 +44,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.6'
spec.add_development_dependency 'rspec', '~> 3.10'
spec.add_development_dependency 'rubocop', '~> 1.22', '>= 1.22.3'
spec.add_development_dependency 'rubocop', '~> 1.23'
spec.add_development_dependency 'rubocop-performance', '~> 1.12'
spec.add_development_dependency 'rubocop-rspec', '~> 2.6'
spec.add_development_dependency 'simplecov', '~> 0.17.1'
Expand Down

0 comments on commit 39dd818

Please sign in to comment.