activemodel-email_address_validator 2.0.0 → 2.1.0

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: 880e994c63a284ed895dfab2da408360b9cd70f8466176e99c1118d76e830f64
4
- data.tar.gz: ef9a1389211791aff43ed9874421515e3417b7e2b00e85ce70ee478c8f8a837b
3
+ metadata.gz: b5580fb86ca5fc584177916ac313ca624193f64f06679f441521d5904250d4f2
4
+ data.tar.gz: ea37fa1181553939391da23a0a4894bc4b98186ca8b5f3b3dcb863c041013478
5
5
  SHA512:
6
- metadata.gz: 0dd406cdb1537d8d8099e71531e8797b9d4ebe3f619842ef65eaf9d43fd1a31062739bbca7ed7fa3f46f63ba2da30a8949f1e0f5795b7af3f26e2ea3cc8c030c
7
- data.tar.gz: c8ebc7e19f10ac906503606c8308c7ade2018a08840465743819d38f86598320955323020fbd73d8b0304794c2cc11104195a9a19639c9740bae246295735c73
6
+ metadata.gz: f21ef9f11bf4ed601b420dab39bbe62206c47873226e22ee9c3db0597105aa23ffe8064379cd81f34f9367fbcc742689e5303c417bcb6032eeb7d326e3ff9b35
7
+ data.tar.gz: 4d4e2b281fec06eb2c15a3e5fce997fb67f9c6bb70899bedd5a681c5cc2318a6a89ac68653a239b7735f7a4b18a78bf979f56abcfa1f496a49cc45bc96c37e6a
@@ -0,0 +1,37 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
24
+ - name: Run tests
25
+ run: bundle exec rake
26
+
27
+ lint:
28
+ runs-on: ubuntu-latest
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - name: Set up Ruby
32
+ uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: '3.0'
35
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
36
+ - name: Lint
37
+ run: bundle exec standardrb
data/CHANGELOG.md CHANGED
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## Unreleased
9
+
10
+ ### Added
11
+
12
+ -
13
+
14
+ ### Removed
15
+
16
+ -
17
+
18
+
19
+ ## [2.1.0]
20
+
21
+ ### Added
22
+
23
+ - Support for Ruby 3.0. We've also started testing against Ruby 3.1 to be
24
+ prepared.
25
+
26
+ - Email addresses with trailing @'s are no longer accepted. Thanks
27
+ @prognostikos!
28
+
8
29
  ## [2.0.0]
9
30
 
10
31
  ### Added
data/Gemfile CHANGED
@@ -3,4 +3,5 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in activemodel-email_address_validator.gemspec
4
4
  gemspec
5
5
 
6
- gem "coveralls", :require => false
6
+ gem "coveralls", require: false
7
+ gem "standard", require: false
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Email Address Validator
2
2
  ## ActiveModel-style email address format validator
3
3
 
4
- [![Build Status](https://travis-ci.org/substancelab/activemodel-email_address_validator.svg?branch=master)](https://travis-ci.org/substancelab/activemodel-email_address_validator) [![Code Climate](https://codeclimate.com/github/substancelab/activemodel-email_address_validator/badges/gpa.svg)](https://codeclimate.com/github/substancelab/activemodel-email_address_validator) [![Coverage Status](https://coveralls.io/repos/substancelab/activemodel-email_address_validator/badge.svg?branch=more-badges&service=github)](https://coveralls.io/github/substancelab/activemodel-email_address_validator?branch=more-badges)
4
+ [![Code Climate](https://codeclimate.com/github/substancelab/activemodel-email_address_validator/badges/gpa.svg)](https://codeclimate.com/github/substancelab/activemodel-email_address_validator) [![Coverage Status](https://coveralls.io/repos/substancelab/activemodel-email_address_validator/badge.svg?branch=more-badges&service=github)](https://coveralls.io/github/substancelab/activemodel-email_address_validator?branch=more-badges)
5
5
 
6
6
  Whenever I have wanted to validate an email address it has been because I wanted to be somewhat certain I can send an email to someone. Usually this happens as part of a signup procedure.
7
7
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ Rake::TestTask.new(:test) do |t|
6
6
  t.libs << "test"
7
7
  end
8
8
 
9
- task :default => :test
9
+ task default: :test
10
10
 
11
11
  desc "Launch an IRB console with the gem loaded"
12
12
  task :console do
@@ -1,20 +1,19 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "activemodel_email_address_validator/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "activemodel-email_address_validator"
8
- spec.version = ActiveModelEmailAddressValidator::VERSION
9
- spec.authors = ["Jakob Skjerning"]
10
- spec.email = ["jakob@mentalized.net"]
11
- spec.summary = "ActiveModel-style email address format validator"
12
- spec.homepage = ""
13
- spec.license = "MIT"
6
+ spec.name = "activemodel-email_address_validator"
7
+ spec.version = ActiveModelEmailAddressValidator::VERSION
8
+ spec.authors = ["Jakob Skjerning"]
9
+ spec.email = ["jakob@mentalized.net"]
10
+ spec.summary = "ActiveModel-style email address format validator"
11
+ spec.homepage = ""
12
+ spec.license = "MIT"
14
13
 
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
17
  spec.require_paths = ["lib"]
19
18
 
20
19
  spec.add_dependency "activemodel", ">= 4.0", "< 7.0"
@@ -25,14 +25,14 @@ module ActiveModelEmailAddressValidator
25
25
  end
26
26
 
27
27
  def valid_using_default?
28
- return false if address =~ /\s+/
29
- email_parts = address.split("@")
28
+ return false if /\s+/.match?(address)
29
+ email_parts = address.split("@", -1)
30
30
 
31
31
  return false unless email_parts.size == 2
32
32
 
33
33
  user, host = *email_parts
34
- return false unless user =~ /^([^.]+\S)*[^. ]+$/
35
- return false unless host =~ /^([^,. ~]+\.)+[^,. ]+$/
34
+ return false unless /^([^.]+\S)*[^. ]+$/.match?(user)
35
+ return false unless /^([^,. ~]+\.)+[^,. ]+$/.match?(host)
36
36
  true
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveModelEmailAddressValidator
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -101,6 +101,14 @@ class EmailAddressValidTest < MiniTest::Test
101
101
  reject("my@nice@domain.com")
102
102
  end
103
103
 
104
+ def test_rejects_leading_at_signs
105
+ reject("@my@domain.com")
106
+ end
107
+
108
+ def test_rejects_trailing_at_signs
109
+ reject("my@domain.com@")
110
+ end
111
+
104
112
  def test_rejects_commas_in_hostname
105
113
  reject("my@domain.com,")
106
114
  end
@@ -7,9 +7,8 @@ require "activemodel-email_address_validator"
7
7
  require "minitest/autorun"
8
8
  require "minitest/spec"
9
9
 
10
- SIMPLEST_VALIDATION = {:email => {:email_address => true}}
10
+ SIMPLEST_VALIDATION = {email: {email_address: true}}
11
11
 
12
- # rubocop:disable Metrics/MethodLength
13
12
  def build_model_with_validations(validations = SIMPLEST_VALIDATION)
14
13
  klass = Class.new do
15
14
  include ActiveModel::Validations
@@ -8,7 +8,7 @@ class EmailAddressValidatorTest < MiniTest::Test
8
8
 
9
9
  def test_accepts_nil_email_address
10
10
  @subject = build_model_with_validations(
11
- :email => {:email_address => true, :allow_nil => true}
11
+ email: {email_address: true, allow_nil: true}
12
12
  )
13
13
  accept(nil, @subject)
14
14
  end
@@ -23,7 +23,7 @@ class EmailAddressValidatorTest < MiniTest::Test
23
23
 
24
24
  def test_adds_errors_to_validated_attribute
25
25
  subject = build_model_with_validations(
26
- :work_email => {:email_address => true}
26
+ work_email: {email_address: true}
27
27
  )
28
28
  subject.work_email = "whatever"
29
29
  subject.valid?
@@ -33,7 +33,7 @@ class EmailAddressValidatorTest < MiniTest::Test
33
33
 
34
34
  def test_validates_with_custom_regular_expression
35
35
  subject = build_model_with_validations(
36
- :email => {:email_address => {:format => /.+@enterprise\..+/}}
36
+ email: {email_address: {format: /.+@enterprise\..+/}}
37
37
  )
38
38
  accept("whatever@enterprise.museum", subject)
39
39
  reject("totally@valid.com", subject)
@@ -41,7 +41,7 @@ class EmailAddressValidatorTest < MiniTest::Test
41
41
 
42
42
  def test_validates_with_custom_regular_as_a_rule
43
43
  subject = build_model_with_validations(
44
- :email => {:email_address => {:with => /.+@enterprise\..+/}}
44
+ email: {email_address: {with: /.+@enterprise\..+/}}
45
45
  )
46
46
  accept("whatever@enterprise.museum", subject)
47
47
  reject("totally@valid.com", subject)
@@ -49,9 +49,9 @@ class EmailAddressValidatorTest < MiniTest::Test
49
49
 
50
50
  def test_validates_with_proc
51
51
  subject = build_model_with_validations(
52
- :email => {:email_address => {
53
- :with => proc { |address| address == "foo" }}
54
- }
52
+ email: {email_address: {
53
+ with: proc { |address| address == "foo" }
54
+ }}
55
55
  )
56
56
  accept("foo", subject)
57
57
  reject("foo@bar.com", subject)
@@ -59,12 +59,12 @@ class EmailAddressValidatorTest < MiniTest::Test
59
59
 
60
60
  def test_validates_with_multiple_procs
61
61
  subject = build_model_with_validations(
62
- :email => {:email_address => {
63
- :with => [
62
+ email: {email_address: {
63
+ with: [
64
64
  proc { |address| address == "ada" },
65
65
  proc { |address| address.reverse == address }
66
- ]}
67
- }
66
+ ]
67
+ }}
68
68
  )
69
69
  accept("ada", subject)
70
70
  reject("bob", subject)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel-email_address_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Skjerning
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-04 00:00:00.000000000 Z
11
+ date: 2021-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -72,15 +72,15 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
- description:
75
+ description:
76
76
  email:
77
77
  - jakob@mentalized.net
78
78
  executables: []
79
79
  extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
+ - ".github/workflows/ruby.yml"
82
83
  - ".gitignore"
83
- - ".travis.yml"
84
84
  - CHANGELOG.md
85
85
  - Gemfile
86
86
  - LICENSE.txt
@@ -98,7 +98,7 @@ homepage: ''
98
98
  licenses:
99
99
  - MIT
100
100
  metadata: {}
101
- post_install_message:
101
+ post_install_message:
102
102
  rdoc_options: []
103
103
  require_paths:
104
104
  - lib
@@ -113,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubygems_version: 3.0.6
117
- signing_key:
116
+ rubygems_version: 3.2.32
117
+ signing_key:
118
118
  specification_version: 4
119
119
  summary: ActiveModel-style email address format validator
120
120
  test_files:
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.6
4
- - 2.5.5
5
- - 2.6.3
6
- - 2.7.0-preview1
7
-
8
- before_install:
9
- - gem update --system
10
- - gem install bundler
11
-
12
- notifications:
13
- recipients:
14
- - jakob@mentalized.net