From 5c22819a0827c0e9d45ee10bf819f116099bc4a4 Mon Sep 17 00:00:00 2001 From: syguer Date: Fri, 21 Apr 2023 16:24:12 +0900 Subject: [PATCH 1/2] Update Ruby and Rails version --- .travis.yml | 33 +++++++++++++++++++++++++-------- email_validator.gemspec | 12 ++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9f820a9..1b77247 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,18 +4,35 @@ arch: - ppc64le rvm: - - 2.5.0 - - 2.5.8 - - 2.6.0 - - 2.6.10 - - 2.7.0 - - 2.7.6 - - 3.0.1 + - 2.7.7 + - 2.7.8 - 3.0.4 - - 3.1.0 + - 3.0.6 - 3.1.2 + - 3.1.4 + - 3.2.2 - ruby-head - jruby-head + +jobs: + exclude: + # ref: https://rubies.travis-ci.org/index.txt + - rvm: 2.7.8 + arch: ppc64le + - rvm: 3.0.6 + arch: ppc64le + - rvm: 3.1.4 + arch: ppc64le + - rvm: 3.2.2 + arch: ppc64le + + - rvm: 2.7.7 + arch: amd64 + - rvm: 3.0.4 + arch: amd64 + - rvm: 3.1.2 + arch: amd64 + notifications: recipients: - karl@kandrsoftware.com diff --git a/email_validator.gemspec b/email_validator.gemspec index a74228e..5f191d7 100644 --- a/email_validator.gemspec +++ b/email_validator.gemspec @@ -2,8 +2,8 @@ Gem::Specification.new do |s| s.name = 'email_validator' s.version = '2.2.4' s.authors = ['Brian Alexander', 'Karl Wilbur'] - s.summary = 'An email validator for Rails 3+.' - s.description = 'An email validator for Rails 3+. See homepage for details: http://github.com/K-and-R/email_validator' + s.summary = 'An email validator for Rails.' + s.description = 'An email validator for Rails. See homepage for details: http://github.com/K-and-R/email_validator' s.email = 'karl@kandrsoftware.com' s.homepage = 'https://github.com/K-and-R/email_validator' s.licenses = ['MIT'] @@ -12,13 +12,9 @@ Gem::Specification.new do |s| README.md CHANGELOG.md ] - s.files = `git ls-files -- lib/*`.split("\n") + s.files = Dir['lib/**/*.rb'] s.require_paths = %w[lib] - - s.test_files = `git ls-files -- spec/*`.split("\n") - - # This gem will work with 2.4.0 or greater... but *should* work with 1.8.7+ - s.required_ruby_version = '>= 2.4.0' + s.required_ruby_version = '>= 2.7.0' s.add_dependency('activemodel') From 592ed9a70b085ab64b31fd9cc01ee1794c4d6998 Mon Sep 17 00:00:00 2001 From: syguer Date: Fri, 21 Apr 2023 18:36:30 +0900 Subject: [PATCH 2/2] Fix cop offenses --- .rubocop.yml | 2 +- .ruby-version | 1 + email_validator.gemspec | 1 + lib/email_validator.rb | 2 +- spec/email_validator_spec.rb | 20 ++++++++++---------- 5 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 .ruby-version diff --git a/.rubocop.yml b/.rubocop.yml index 48cded8..56eca58 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,7 +16,7 @@ AllCops: Exclude: - 'bin/*' NewCops: enable - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.7 Bundler/GemComment: Enabled: true diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..be94e6f --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.2.2 diff --git a/email_validator.gemspec b/email_validator.gemspec index 5f191d7..2cb82da 100644 --- a/email_validator.gemspec +++ b/email_validator.gemspec @@ -19,4 +19,5 @@ Gem::Specification.new do |s| s.add_dependency('activemodel') s.add_development_dependency('rubysl', '~> 2.0') if RUBY_ENGINE == 'rbx' + s.metadata['rubygems_mfa_required'] = 'true' end diff --git a/lib/email_validator.rb b/lib/email_validator.rb index 0c388d6..d6d2f86 100644 --- a/lib/email_validator.rb +++ b/lib/email_validator.rb @@ -96,7 +96,7 @@ def address_literal def host_label_pattern "#{label_is_correct_length}" \ - "#{alnum}(?:#{alnumhy}{,61}#{alnum})?" + "#{alnum}(?:#{alnumhy}{,61}#{alnum})?" end # splitting this up into separate regex pattern for performance; let's not diff --git a/spec/email_validator_spec.rb b/spec/email_validator_spec.rb index 1d70207..5e73760 100644 --- a/spec/email_validator_spec.rb +++ b/spec/email_validator_spec.rb @@ -126,7 +126,7 @@ class DefaultUserWithMessage < TestModel "#{v}start-with-#{k}@valid-characters-in-local.dev" ]}).concat(valid_endable.map { |k, v| [ "end-with-#{k}-#{v}@valid-characters-in-local.dev" - ]}).concat([ + ]}).push( 'a+b@plus-in-local.com', 'a_b@underscore-in-local.com', 'user@example.com', @@ -162,7 +162,7 @@ class DefaultUserWithMessage < TestModel 'jonh.doe@163.com', 'test@umläut.com', # non-ASCII 'test@xn--umlut-ira.com' # ASCII-compatibale encoding of non-ASCII - ]).flatten.each do |email| + ).flatten.each do |email| context 'when using defaults' do it "'#{email}' should be valid" do expect(DefaultUser.new(:email => email)).to be_valid @@ -348,9 +348,9 @@ class DefaultUserWithMessage < TestModel "#{v}-start-with-#{k}-user" ]}).concat(valid_endable.map { |k, v| [ "end-with-#{k}-#{v}" - ]}).concat([ + ]}).push( 'user' - ]).flatten.each do |email| + ).flatten.each do |email| context 'when using defaults' do it "'#{email}' should not be valid" do expect(DefaultUser.new(:email => email)).not_to be_valid @@ -477,7 +477,7 @@ class DefaultUserWithMessage < TestModel "end-with-#{k}@invalid-characters-in-domain#{v}.dev" ]}).concat(domain_invalid_includable.map { |k, v| [ "include-#{k}@invalid-characters-#{v}-in-domain.dev" - ]}).concat([ + ]}).push( 'test@example.com@example.com', 'missing-sld@.com', 'missing-tld@sld.', @@ -494,7 +494,7 @@ class DefaultUserWithMessage < TestModel 'the-local-part-is-invalid-if-it-is-longer-than-sixty-four-characters@sld.dev', "domain-too-long@t#{".#{'o' * 63}" * 5}.long", "user@example.com" - ]).flatten.each do |email| + ).flatten.each do |email| context 'when using defaults' do it "'#{email}' should be valid" do expect(DefaultUser.new(:email => email)).to be_valid @@ -554,7 +554,7 @@ class DefaultUserWithMessage < TestModel context 'when given the invalid email with whitespace in parts' do whitespace.map { |k, v| [ "include-#{v}-#{k}@invalid-characters-in-local.dev" - ]}.concat([ + ]}.push( 'foo @bar.com', "foo\t@bar.com", "foo\n@bar.com", @@ -587,7 +587,7 @@ class DefaultUserWithMessage < TestModel "domain-with-trailing-whitespace-tab@example.com\t", "domain-with-trailing-whitespace-newline@example.com " - ]).flatten.each do |email| + ).flatten.each do |email| context 'when using defaults' do it "'#{email}' should not be valid" do expect(DefaultUser.new(:email => email)).not_to be_valid @@ -715,12 +715,12 @@ class DefaultUserWithMessage < TestModel "#{v}start-with-#{k}@invalid-characters-in-local.dev" ]}).concat(strictly_invalid_endable.map { |k, v| [ "end-with-#{k}#{v}@invalid-characters-in-local.dev" - ]}).concat([ + ]}).push( 'user..-with-double-dots@example.com', '.user-beginning-with-dot@example.com', 'user-ending-with-dot.@example.com', 'fully-numeric-tld@example.123' - ]).flatten.each do |email| + ).flatten.each do |email| context 'when using defaults' do it "#{email.strip} in a model should be valid" do expect(DefaultUser.new(:email => email)).to be_valid