email_address 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module EmailAddress
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -8,7 +8,7 @@ class TestAddress < Minitest::Test
8
8
  assert_equal "example.com", a.host.to_s
9
9
  assert_equal :unknown, a.provider
10
10
  end
11
-
11
+
12
12
  def test_noramlize
13
13
  a = EmailAddress.new("User+tag@Example.com")
14
14
  assert_equal "user+tag@example.com", a.normalize
@@ -25,6 +25,28 @@ class TestAddress < Minitest::Test
25
25
  a = EmailAddress.new("User+tag@Example.com")
26
26
  assert_equal "b58996c504c5638798eb6b511e6f49af", a.md5
27
27
  assert_equal "63a710569261a24b3766275b7000ce8d7b32e2f7", a.sha1
28
- assert_equal "63a710569261a24b3766275b7000ce8d7b32e2f7@example.com", a.archive
28
+ assert_equal "63a710569261a24b3766275b7000ce8d7b32e2f7@example.com", a.redact
29
+ end
30
+
31
+ def test_idn
32
+ a = EmailAddress.new("User+tag@ɹᴉɐℲuǝll∀.ws")
33
+ assert_equal "user@xn--ull-6eb78cvh231oq7gdzb.ws", a.canonical
34
+ assert_equal "9c06226d81149f59b4df32bb426c64a0cbafcea5@xn--ull-6eb78cvh231oq7gdzb.ws", a.redact
35
+ end
36
+
37
+ def test_no_domain
38
+ e = EmailAddress.new("User+tag.gmail.ws")
39
+ assert_equal false, e.valid?
40
+ end
41
+
42
+ def test_equality
43
+ a = EmailAddress.new("User+tag@Example.com")
44
+ b = EmailAddress.new("user@Example.com")
45
+ c = EmailAddress.new( EmailAddress.new("USER@Example.com").redact)
46
+ assert a != b
47
+ assert a < b
48
+ assert b > a
49
+ assert a.same_as?(b)
50
+ assert a.same_as?(c)
29
51
  end
30
52
  end
@@ -1,15 +1,21 @@
1
1
  require_relative '../test_helper'
2
2
 
3
3
  class TestDomainMatcher < MiniTest::Test
4
+ MATCHER = EmailAddress::DomainMatcher
5
+
4
6
  def test_hostname
5
- assert_equal true, EmailAddress::DomainMatcher.matches?("example.com", "example.com")
6
- assert_equal true, EmailAddress::DomainMatcher.matches?("example.com", "example")
7
- assert_equal true, EmailAddress::DomainMatcher.matches?("example.com", ".com")
8
- assert_equal true, EmailAddress::DomainMatcher.matches?("example.com", ".example.com")
7
+ assert_equal true, MATCHER.matches?("example.com", "example.com")
8
+ assert_equal true, MATCHER.matches?("example.com", "example")
9
+ assert_equal true, MATCHER.matches?("example.com", ".com")
10
+ assert_equal true, MATCHER.matches?("example.com", ".example.com")
9
11
  end
10
12
 
11
13
  def test_list
12
- assert_equal true, EmailAddress::DomainMatcher.matches?("example.com", %w(ex .tld example))
14
+ assert_equal true, MATCHER.matches?("example.com", %w(ex .tld example))
15
+ end
16
+
17
+ def test_glob_matches
18
+ assert_equal true, MATCHER.matches?("example.com", %w(ex*.com))
13
19
  end
14
-
20
+
15
21
  end
@@ -2,7 +2,7 @@
2
2
  require_relative '../test_helper'
3
3
 
4
4
 
5
- class TestHost < MiniTest::Unit::TestCase
5
+ class TestHost < MiniTest::Test
6
6
  def test_host
7
7
  a = EmailAddress::Host.new("example.com")
8
8
  assert_equal "example.com", a.host_name
@@ -40,4 +40,10 @@ class TestHost < MiniTest::Unit::TestCase
40
40
  assert_equal :unknown, a.provider
41
41
  end
42
42
 
43
+ def test_dmarc
44
+ d = EmailAddress::Host.new("yahoo.com").dmarc
45
+ assert_equal 'reject', d[:p]
46
+ d = EmailAddress::Host.new("example.com").dmarc
47
+ assert_equal true, d.empty?
48
+ end
43
49
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require_relative '../test_helper'
3
3
 
4
- class TestLocal < MiniTest::Unit::TestCase
4
+ class TestLocal < MiniTest::Test
5
5
  def test_local
6
6
  a = EmailAddress::Local.new("TestMonkey")
7
7
  assert_equal "testmonkey", a.to_s
@@ -20,8 +20,12 @@ class TestLocal < MiniTest::Unit::TestCase
20
20
  end
21
21
 
22
22
  def test_gmail
23
- a = EmailAddress::Local.new("first.last", :google)
23
+ a = EmailAddress::Local.new("first.last", EmailAddress::Host.new('gmail.com'))
24
24
  assert_equal "firstlast", a.canonical
25
25
  end
26
-
26
+
27
+ def test_root_name
28
+ a = EmailAddress::Local.new("superman123", EmailAddress::Host.new('gmail.com'))
29
+ assert_equal "superman", a.root_name
30
+ end
27
31
  end
@@ -0,0 +1,44 @@
1
+ require_relative '../test_helper'
2
+
3
+ class TestDomainMatcher < MiniTest::Test
4
+
5
+ def setup
6
+ @matcher = EmailAddress::Matcher.new(
7
+ ".org example.com domain*.com hotmail. google user*@ root@*.com 207.99.0.0/16")
8
+ end
9
+
10
+ def test_tld
11
+ assert_equal true, @matcher.include?("pat@example.org")
12
+ end
13
+
14
+ def test_domain
15
+ assert_equal true, @matcher.include?("pat@example.com")
16
+ assert_equal false, @matcher.include?("pat@nomatch.com")
17
+ end
18
+
19
+ def test_registration
20
+ assert_equal true, @matcher.include?("pat@hotmail.ca")
21
+ end
22
+
23
+ def test_domain_glob
24
+ assert_equal true, @matcher.include?("pat@domain123.com")
25
+ end
26
+
27
+ def test_provider
28
+ assert_equal true, @matcher.include?("pat@gmail.com")
29
+ end
30
+
31
+ def test_mailbox
32
+ assert_equal true, @matcher.include?("user123@example.com")
33
+ end
34
+
35
+ def test_address
36
+ assert_equal true, @matcher.include?("root@example.com")
37
+ end
38
+
39
+ def test_cidr
40
+ # If this breaks, check its MX IP addresses against "207.99.0.0/30"
41
+ assert_equal true, @matcher.include?("test@biglist.com")
42
+ end
43
+
44
+ end
@@ -9,4 +9,9 @@ class TestEmailAddress < MiniTest::Test
9
9
  assert_equal a.host.to_s, 'example.com'
10
10
  end
11
11
 
12
+ def test_valid
13
+ v = EmailAddress.valid?('user@yahoo.com')
14
+ assert_equal v, true
15
+ end
16
+
12
17
  end
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.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Fair
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-13 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -82,13 +96,16 @@ files:
82
96
  - Rakefile
83
97
  - email_address.gemspec
84
98
  - lib/email_address.rb
99
+ - lib/email_address/active_record_validator.rb
85
100
  - lib/email_address/address.rb
86
101
  - lib/email_address/config.rb
87
102
  - lib/email_address/domain_matcher.rb
88
103
  - lib/email_address/domain_parser.rb
104
+ - lib/email_address/email_address_type.rb
89
105
  - lib/email_address/exchanger.rb
90
106
  - lib/email_address/host.rb
91
107
  - lib/email_address/local.rb
108
+ - lib/email_address/matcher.rb
92
109
  - lib/email_address/validator.rb
93
110
  - lib/email_address/version.rb
94
111
  - test/email_address/test_address.rb
@@ -98,6 +115,7 @@ files:
98
115
  - test/email_address/test_exchanger.rb
99
116
  - test/email_address/test_host.rb
100
117
  - test/email_address/test_local.rb
118
+ - test/email_address/test_matcher.rb
101
119
  - test/email_address/test_validator.rb
102
120
  - test/test_email_address.rb
103
121
  - test/test_helper.rb
@@ -121,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
139
  version: '0'
122
140
  requirements: []
123
141
  rubyforge_project:
124
- rubygems_version: 2.2.2
142
+ rubygems_version: 2.5.1
125
143
  signing_key:
126
144
  specification_version: 4
127
145
  summary: EmailAddress checks on validates an acceptable set of email addresses.
@@ -133,6 +151,7 @@ test_files:
133
151
  - test/email_address/test_exchanger.rb
134
152
  - test/email_address/test_host.rb
135
153
  - test/email_address/test_local.rb
154
+ - test/email_address/test_matcher.rb
136
155
  - test/email_address/test_validator.rb
137
156
  - test/test_email_address.rb
138
157
  - test/test_helper.rb