email_address 0.1.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1,20 @@
1
- # encoding: UTF-8
2
- require_relative '../test_helper'
1
+ require_relative "../test_helper"
3
2
 
4
3
  class TestLocal < MiniTest::Test
5
-
6
4
  def test_valid_standard
7
5
  [ # Via https://en.wikipedia.org/wiki/Email_address
8
- %Q{prettyandsimple},
9
- %Q{very.common},
10
- %Q{disposable.style.email.with+symbol},
11
- %Q{other.email-with-dash},
12
- %Q{"much.more unusual"},
13
- %Q{"(comment)very.unusual.@.unusual.com"},
14
- %Q{#!$%&'*+-/=?^_`{}|~},
15
- %Q{" "},
16
- %Q{"very.(),:;<>[]\\".VERY.\\"very@\\ \\"very\\".unusual"},
17
- %Q{"()<>[]:,;@\\\"!#$%&'*+-/=?^_`{}| ~.a"},
18
- %Q{token." ".token},
19
- %Q{abc."defghi".xyz},
6
+ %(prettyandsimple),
7
+ %(very.common),
8
+ %(disposable.style.email.with+symbol),
9
+ %(other.email-with-dash),
10
+ %("much.more unusual"),
11
+ %{"(comment)very.unusual.@.unusual.com"},
12
+ %(#!$%&'*+-/=?^_`{}|~),
13
+ %(" "),
14
+ %{"very.(),:;<>[]\\".VERY.\\"very@\\ \\"very\\".unusual"},
15
+ %{"()<>[]:,;@\\\"!#$%&'*+-/=?^_`{}| ~.a"},
16
+ %(token." ".token),
17
+ %(abc."defghi".xyz)
20
18
  ].each do |local|
21
19
  assert EmailAddress::Local.new(local, local_fix: false).standard?, local
22
20
  end
@@ -24,15 +22,15 @@ class TestLocal < MiniTest::Test
24
22
 
25
23
  def test_invalid_standard
26
24
  [ # Via https://en.wikipedia.org/wiki/Email_address
27
- %Q{A@b@c},
28
- %Q{a"b(c)d,e:f;g<h>i[j\k]l},
29
- %Q{just"not"right},
30
- %Q{this is"not\allowed},
31
- %Q{this\ still\"not\\allowed},
32
- %Q{john..doe},
33
- %Q{ invalid},
34
- %Q{invalid },
35
- %Q{abc"defghi"xyz},
25
+ %(A@b@c),
26
+ %{a"b(c)d,e:f;g<h>i[j\k]l},
27
+ %(just"not"right),
28
+ %(this is"not\allowed),
29
+ %(this\ still\"not\\allowed),
30
+ %(john..doe),
31
+ %( invalid),
32
+ %(invalid ),
33
+ %(abc"defghi"xyz)
36
34
  ].each do |local|
37
35
  assert_equal false, EmailAddress::Local.new(local, local_fix: false).standard?, local
38
36
  end
@@ -42,25 +40,25 @@ class TestLocal < MiniTest::Test
42
40
  assert EmailAddress::Local.new("first..last", local_format: :relaxed).valid?, "relax.."
43
41
  assert EmailAddress::Local.new("first.-last", local_format: :relaxed).valid?, "relax.-"
44
42
  assert EmailAddress::Local.new("a", local_format: :relaxed).valid?, "relax single"
45
- assert ! EmailAddress::Local.new("firstlast_", local_format: :relaxed).valid?, "last_"
43
+ assert EmailAddress::Local.new("firstlast_", local_format: :relaxed).valid?, "last_"
46
44
  end
47
45
 
48
46
  def test_unicode
49
- assert ! EmailAddress::Local.new("üñîçøðé1", local_encoding: :ascii).standard?, "not üñîçøðé1"
47
+ assert !EmailAddress::Local.new("üñîçøðé1", local_encoding: :ascii).standard?, "not üñîçøðé1"
50
48
  assert EmailAddress::Local.new("üñîçøðé2", local_encoding: :unicode).standard?, "üñîçøðé2"
51
- assert ! EmailAddress::Local.new("üñîçøðé3").valid?, "üñîçøðé3 valid"
49
+ assert EmailAddress::Local.new("test", local_encoding: :unicode).valid?, "unicode should include ascii"
50
+ assert !EmailAddress::Local.new("üñîçøðé3").valid?, "üñîçøðé3 valid"
52
51
  end
53
52
 
54
-
55
53
  def test_valid_conventional
56
- %w( first.last first First+Tag o'brien).each do |local|
54
+ %w[first.last first First+Tag o'brien].each do |local|
57
55
  assert EmailAddress::Local.new(local).conventional?, local
58
56
  end
59
57
  end
60
58
 
61
59
  def test_invalid_conventional
62
- (%w( first;.last +leading trailing+ o%brien) + ["first space"]).each do |local|
63
- assert ! EmailAddress::Local.new(local, local_fix:false).conventional?, local
60
+ (%w[first;.last +leading trailing+ o%brien] + ["first space"]).each do |local|
61
+ assert !EmailAddress::Local.new(local, local_fix: false).conventional?, local
64
62
  end
65
63
  end
66
64
 
@@ -71,8 +69,8 @@ class TestLocal < MiniTest::Test
71
69
 
72
70
  def test_format
73
71
  assert_equal :conventional, EmailAddress::Local.new("can1").format?
74
- assert_equal :standard, EmailAddress::Local.new(%Q{"can1"}).format?
75
- assert_equal "can1", EmailAddress::Local.new(%Q{"can1(commment)"}).format(:conventional)
72
+ assert_equal :standard, EmailAddress::Local.new(%("can1")).format?
73
+ assert_equal "can1", EmailAddress::Local.new(%{"can1(commment)"}).format(:conventional)
76
74
  end
77
75
 
78
76
  def test_redacted
@@ -83,13 +81,32 @@ class TestLocal < MiniTest::Test
83
81
 
84
82
  def test_matches
85
83
  a = EmailAddress.new("User+tag@gmail.com")
86
- assert_equal false, a.matches?('user')
87
- assert_equal false, a.matches?('user@')
88
- assert_equal 'user*@', a.matches?('user*@')
84
+ assert_equal false, a.matches?("user")
85
+ assert_equal false, a.matches?("user@")
86
+ assert_equal "user*@", a.matches?("user*@")
89
87
  end
90
88
 
91
89
  def test_munge
92
90
  assert_equal "us*****", EmailAddress::Local.new("User+tag").munge
93
91
  end
94
92
 
93
+ def test_hosted
94
+ assert EmailAddress.valid?("x@exposure.co")
95
+ assert EmailAddress.error("xxxx+subscriber@gmail.com")
96
+ assert EmailAddress.valid?("xxxxx+subscriber@gmail.com")
97
+ end
98
+
99
+ def test_ending_underscore
100
+ assert EmailAddress.valid?("name_@icloud.com")
101
+ assert EmailAddress.valid?("username_@gmail.com")
102
+ assert EmailAddress.valid?("username_____@gmail.com")
103
+ end
104
+
105
+ def test_tag_punctuation
106
+ assert EmailAddress.valid?("first.last+foo.bar@gmail.com")
107
+ end
108
+
109
+ def test_relaxed_tag
110
+ assert EmailAddress.valid? "foo+abc@example.com", host_validation: :syntax, local_format: :relaxed
111
+ end
95
112
  end
@@ -0,0 +1,11 @@
1
+ require_relative "../test_helper"
2
+
3
+ class TestRewriter < Minitest::Test
4
+ def test_srs
5
+ ea = "first.LAST+tag@gmail.com"
6
+ e = EmailAddress.new(ea)
7
+ s = e.srs("example.com")
8
+ assert s.match(EmailAddress::Address::SRS_FORMAT_REGEX)
9
+ assert EmailAddress.new(s).to_s == e.to_s
10
+ end
11
+ end
@@ -0,0 +1,53 @@
1
+ require_relative "test_helper"
2
+
3
+ class TestAliasing < MiniTest::Test
4
+ def setup
5
+ Object.send(:const_set, :EmailAddressValidator, EmailAddress)
6
+ Object.send(:remove_const, :EmailAddress)
7
+ end
8
+
9
+ def test_email_address_not_defined
10
+ assert_nil defined?(EmailAddress)
11
+ assert_nil defined?(EmailAddress::Address)
12
+ assert_nil defined?(EmailAddress::Config)
13
+ assert_nil defined?(EmailAddress::Exchanger)
14
+ assert_nil defined?(EmailAddress::Host)
15
+ assert_nil defined?(EmailAddress::Local)
16
+ assert_nil defined?(EmailAddress::Rewriter)
17
+ end
18
+
19
+ def test_alias_defined
20
+ assert_equal defined?(EmailAddressValidator), "constant"
21
+ assert_equal defined?(EmailAddressValidator::Address), "constant"
22
+ assert_equal defined?(EmailAddressValidator::Config), "constant"
23
+ assert_equal defined?(EmailAddressValidator::Exchanger), "constant"
24
+ assert_equal defined?(EmailAddressValidator::Host), "constant"
25
+ assert_equal defined?(EmailAddressValidator::Local), "constant"
26
+ assert_equal defined?(EmailAddressValidator::Rewriter), "constant"
27
+ end
28
+
29
+ def test_alias_class_methods
30
+ assert_equal true, EmailAddressValidator.valid?("user@yahoo.com")
31
+ end
32
+
33
+ def test_alias_host_methods
34
+ assert_equal true, EmailAddressValidator::Host.new("yahoo.com").valid?
35
+ end
36
+
37
+ def test_alias_address_methods
38
+ assert_equal true, EmailAddressValidator::Address.new("user@yahoo.com").valid?
39
+ end
40
+
41
+ def test_alias_config_methods
42
+ assert Hash, EmailAddressValidator::Config.new.to_h
43
+ end
44
+
45
+ def test_alias_local_methods
46
+ assert_equal true, EmailAddressValidator::Local.new("user").valid?
47
+ end
48
+
49
+ def teardown
50
+ Object.send(:const_set, :EmailAddress, EmailAddressValidator)
51
+ Object.send(:remove_const, :EmailAddressValidator)
52
+ end
53
+ end
@@ -1,45 +1,42 @@
1
- # encoding: UTF-8
2
- require_relative 'test_helper'
1
+ require_relative "test_helper"
3
2
 
4
3
  class TestEmailAddress < MiniTest::Test
5
-
6
4
  def test_new
7
- a = EmailAddress.new('user@example.com')
8
- assert_equal 'user', a.local.to_s
9
- assert_equal 'example.com', a.host.to_s
5
+ a = EmailAddress.new("user@example.com")
6
+ assert_equal "user", a.local.to_s
7
+ assert_equal "example.com", a.host.to_s
10
8
  end
11
9
 
12
10
  def test_canonical
13
- assert_equal "firstlast@gmail.com", EmailAddress.canonical('First.Last+TAG@gmail.com')
14
- a = EmailAddress.new_canonical('First.Last+TAG@gmail.com')
15
- assert_equal 'firstlast', a.local.to_s
11
+ assert_equal "firstlast@gmail.com", EmailAddress.canonical("First.Last+TAG@gmail.com")
12
+ a = EmailAddress.new_canonical("First.Last+TAG@gmail.com")
13
+ assert_equal "firstlast", a.local.to_s
16
14
  end
17
15
 
18
16
  def test_normal
19
- assert_equal 'user+tag@gmail.com', EmailAddress.normal('USER+TAG@GMAIL.com')
17
+ assert_equal "user+tag@gmail.com", EmailAddress.normal("USER+TAG@GMAIL.com")
20
18
  end
21
19
 
22
20
  def test_valid
23
- assert_equal true, EmailAddress.valid?('user@yahoo.com')
24
- assert_equal true, EmailAddress.valid?('a@yahoo.com')
21
+ assert_equal true, EmailAddress.valid?("user@yahoo.com")
22
+ assert_equal true, EmailAddress.valid?("a@yahoo.com")
25
23
  end
26
24
 
27
25
  def test_matches
28
- assert_equal 'yahoo.', EmailAddress.matches?('user@yahoo.com', 'yahoo.')
26
+ assert_equal "yahoo.", EmailAddress.matches?("user@yahoo.com", "yahoo.")
29
27
  end
30
28
 
31
29
  def test_reference
32
- assert_equal 'dfeafc750cecde54f9a4775f5713bf01', EmailAddress.reference('user@yahoo.com')
30
+ assert_equal "dfeafc750cecde54f9a4775f5713bf01", EmailAddress.reference("user@yahoo.com")
33
31
  end
34
32
 
35
33
  def test_redact
36
- assert_equal '{e037b6c476357f34f92b8f35b25d179a4f573f1e}@yahoo.com', EmailAddress.redact('user@yahoo.com')
34
+ assert_equal "{e037b6c476357f34f92b8f35b25d179a4f573f1e}@yahoo.com", EmailAddress.redact("user@yahoo.com")
37
35
  end
38
36
 
39
37
  def test_cases
40
- %w( miles.o'brien@yahoo.com first..last@gmail.com a-b.c_d+e@f.gx
41
- ).each do |address|
42
- assert EmailAddress.valid?(address, dns_lookup: :off), "valid?(#{address})"
38
+ %w[miles.o'brien@yahoo.com first.last@gmail.com a-b.c_d+e@f.gx].each do |address|
39
+ assert EmailAddress.valid?(address, host_validation: :syntax), "valid?(#{address})"
43
40
  end
44
41
  end
45
42
 
@@ -47,5 +44,4 @@ class TestEmailAddress < MiniTest::Test
47
44
  assert_equal "", EmailAddress.normal("")
48
45
  assert_equal "", EmailAddress.normal(" ")
49
46
  end
50
-
51
47
  end
data/test/test_helper.rb CHANGED
@@ -1,11 +1,12 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
2
2
 
3
- require 'simplecov'
3
+ require "pry"
4
+ require "simplecov"
4
5
  SimpleCov.start
5
6
 
6
- require 'active_record'
7
- require 'rubygems'
8
- require 'minitest/autorun'
9
- require 'minitest/unit'
10
- require 'minitest/pride'
11
- require 'email_address'
7
+ require "active_record"
8
+ require "rubygems"
9
+ require "minitest/autorun"
10
+ require "minitest/unit"
11
+ require "minitest/pride"
12
+ require "email_address"
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.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Fair
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-10 00:00:00.000000000 Z
11
+ date: 2022-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,42 +30,42 @@ 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
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activerecord
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 5.0.1
61
+ version: 6.1.4
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.0.1
68
+ version: 6.1.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: codeclimate-test-reporter
84
+ name: standard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.5.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.5.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: net-smtp
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -95,13 +109,27 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: simpleidn
112
+ name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
- type: :runtime
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
@@ -109,7 +137,7 @@ dependencies:
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
- name: netaddr
140
+ name: simpleidn
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ">="
@@ -129,8 +157,8 @@ executables: []
129
157
  extensions: []
130
158
  extra_rdoc_files: []
131
159
  files:
160
+ - ".github/workflows/ci.yml"
132
161
  - ".gitignore"
133
- - ".travis.yml"
134
162
  - Gemfile
135
163
  - LICENSE.txt
136
164
  - README.md
@@ -145,6 +173,8 @@ files:
145
173
  - lib/email_address/exchanger.rb
146
174
  - lib/email_address/host.rb
147
175
  - lib/email_address/local.rb
176
+ - lib/email_address/messages.yaml
177
+ - lib/email_address/rewriter.rb
148
178
  - lib/email_address/version.rb
149
179
  - test/activerecord/test_ar.rb
150
180
  - test/activerecord/user.rb
@@ -153,13 +183,15 @@ files:
153
183
  - test/email_address/test_exchanger.rb
154
184
  - test/email_address/test_host.rb
155
185
  - test/email_address/test_local.rb
186
+ - test/email_address/test_rewriter.rb
187
+ - test/test_aliasing.rb
156
188
  - test/test_email_address.rb
157
189
  - test/test_helper.rb
158
190
  homepage: https://github.com/afair/email_address
159
191
  licenses:
160
192
  - MIT
161
193
  metadata: {}
162
- post_install_message:
194
+ post_install_message:
163
195
  rdoc_options: []
164
196
  require_paths:
165
197
  - lib
@@ -167,16 +199,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
199
  requirements:
168
200
  - - ">="
169
201
  - !ruby/object:Gem::Version
170
- version: '0'
202
+ version: '2.5'
203
+ - - "<"
204
+ - !ruby/object:Gem::Version
205
+ version: '4'
171
206
  required_rubygems_version: !ruby/object:Gem::Requirement
172
207
  requirements:
173
208
  - - ">="
174
209
  - !ruby/object:Gem::Version
175
210
  version: '0'
176
211
  requirements: []
177
- rubyforge_project:
178
- rubygems_version: 2.6.8
179
- signing_key:
212
+ rubygems_version: 3.3.7
213
+ signing_key:
180
214
  specification_version: 4
181
215
  summary: This gem provides a ruby language library for working with and validating
182
216
  email addresses. By default, it validates against conventional usage, the format
@@ -190,5 +224,7 @@ test_files:
190
224
  - test/email_address/test_exchanger.rb
191
225
  - test/email_address/test_host.rb
192
226
  - test/email_address/test_local.rb
227
+ - test/email_address/test_rewriter.rb
228
+ - test/test_aliasing.rb
193
229
  - test/test_email_address.rb
194
230
  - test/test_helper.rb
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - ruby-head
4
- - 2.2.2
5
- - jruby-9.0.4.0
6
- #- rbx
7
-
8
- addons:
9
- code_climate:
10
- repo_token: 729b2d0e2cc94f63b7da91042da0b6d77bbe30c2024dba04881f46caf702636f