email_veracity 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,5 +1,3 @@
1
- *.tmproj
2
- .DS_Store
3
1
  /coverage
4
2
  /pkg
5
3
  /rdoc
data/CONTRIBUTORS ADDED
@@ -0,0 +1,2 @@
1
+ Carsten Nielsen <http://heycarsten.com>
2
+ Patrick Reagan <http://sneaq.net>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{email_veracity}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Carsten Nielsen"]
12
- s.date = %q{2009-12-12}
12
+ s.date = %q{2010-01-29}
13
13
  s.description = %q{Email Veracity abstracts an email address into a series of objects which makes it easy to see if an address is invalid, and if so, why.}
14
14
  s.email = %q{heycarsten@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".gitignore",
21
+ "CONTRIBUTORS",
21
22
  "LICENSE",
22
23
  "README.md",
23
24
  "Rakefile",
@@ -2,10 +2,26 @@ module EmailVeracity
2
2
  module Config
3
3
 
4
4
  DEFAULT_OPTIONS = {
5
- :whitelist => %w[ aol.com gmail.com hotmail.com mac.com msn.com
6
- rogers.com sympatico.ca yahoo.com telus.com sprint.com sprint.ca ],
7
- :blacklist => %w[ dodgeit.com mintemail.com mintemail.uni.cc
8
- 1mintemail.mooo.com spammotel.com trashmail.net ],
5
+ :whitelist => %w[
6
+ aol.com
7
+ gmail.com
8
+ hotmail.com
9
+ me.com
10
+ mac.com
11
+ msn.com
12
+ rogers.com
13
+ sympatico.ca
14
+ yahoo.com
15
+ telus.com
16
+ sprint.com
17
+ sprint.ca ],
18
+ :blacklist => %w[
19
+ dodgeit.com
20
+ mintemail.com
21
+ mintemail.uni.cc
22
+ 1mintemail.mooo.com
23
+ spammotel.com
24
+ trashmail.net ],
9
25
  :valid_pattern => %r{\A
10
26
  (
11
27
  (
@@ -25,6 +41,7 @@ module EmailVeracity
25
41
  \Z}xi,
26
42
  :must_include => [], # :a, :mx
27
43
  :timeout => 2,
44
+ :skip_lookup => false,
28
45
  :enforce_blacklist => false,
29
46
  :enforce_whitelist => true }
30
47
  @options = DEFAULT_OPTIONS.clone
@@ -49,17 +49,19 @@ module EmailVeracity
49
49
  return if whitelisted?
50
50
  add_error(:blacklisted) if blacklisted? &&
51
51
  Config[:enforce_blacklist]
52
- add_error(:no_records) if servers.empty? &&
53
- !Config.enforced_record?(:a) &&
54
- !Config.enforced_record?(:mx)
55
- add_error(:no_address_servers) if address_servers.empty? &&
56
- Config.enforced_record?(:a)
57
- add_error(:no_exchange_servers) if exchange_servers.empty? &&
58
- Config.enforced_record?(:mx)
52
+ unless Config[:skip_lookup]
53
+ add_error(:no_records) if servers.empty? &&
54
+ !Config.enforced_record?(:a) &&
55
+ !Config.enforced_record?(:mx)
56
+ add_error(:no_address_servers) if address_servers.empty? &&
57
+ Config.enforced_record?(:a)
58
+ add_error(:no_exchange_servers) if exchange_servers.empty? &&
59
+ Config.enforced_record?(:mx)
60
+ end
59
61
  end
60
62
 
61
63
  def servers_in(record)
62
- return [] if Utils.blank?(name)
64
+ return [] if Config[:skip_lookup] || Utils.blank?(name)
63
65
  Resolver.get_servers_for(name, record)
64
66
  rescue DomainResourcesTimeoutError
65
67
  add_error :timed_out
data/test/helper.rb CHANGED
@@ -4,8 +4,8 @@ require 'shoulda'
4
4
  require 'mocha'
5
5
  require 'redgreen'
6
6
 
7
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $:.unshift(File.dirname(__FILE__))
9
9
 
10
10
  require 'email_veracity'
11
11
 
data/test/test_config.rb CHANGED
@@ -20,6 +20,7 @@ class TestConfig < Test::Unit::TestCase
20
20
  i@shouldwork.com
21
21
  1@shouldworktoo.com ]
22
22
  INVALID_EMAIL_ADDRESS_EXAMPLES = %w[
23
+ two@email.com\ addresses@example.com
23
24
  @failure.net
24
25
  craptastic@
25
26
  !!!!!@gmail.com
data/test/test_domain.rb CHANGED
@@ -51,7 +51,7 @@ class TestDomain < Test::Unit::TestCase
51
51
  domain.expects(:servers_in).with(:a).returns([])
52
52
  assert_empty domain.address_servers, 'Should not contain address servers.'
53
53
  end
54
-
54
+
55
55
  def test_an_invalid_domain_for_exchange_servers
56
56
  domain = new_domain('i-surely-do-not.exist')
57
57
  domain.expects(:servers_in).with(:mx).returns([])
@@ -85,6 +85,26 @@ class TestDomain < Test::Unit::TestCase
85
85
  end
86
86
  end
87
87
 
88
+ context 'A domain validation when Config[:skip_lookup] is set' do
89
+ setup do
90
+ EmailVeracity::Config[:skip_lookup] = true
91
+ @domain = new_domain('heycarsten.com')
92
+ @domain.stubs(:address_servers).returns([:something])
93
+ end
94
+
95
+ should 'not perform any lookups for validations' do
96
+ assert @domain.errors.empty?
97
+ end
98
+
99
+ should 'still allow explicit lookups' do
100
+ assert @domain.address_servers.any?
101
+ end
102
+
103
+ teardown do
104
+ EmailVeracity::Config.revert!
105
+ end
106
+ end
107
+
88
108
  private
89
109
 
90
110
  def new_domain(name = 'heycarsten.com')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_veracity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Nielsen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-12 00:00:00 -05:00
12
+ date: 2010-01-29 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -43,6 +43,7 @@ extra_rdoc_files:
43
43
  - README.md
44
44
  files:
45
45
  - .gitignore
46
+ - CONTRIBUTORS
46
47
  - LICENSE
47
48
  - README.md
48
49
  - Rakefile