email_checker 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 287b145d67ecd07f435e662d23557d5383365e9e
4
- data.tar.gz: 91062933ded8f2ff2e4081cf148cde5eac0bf137
3
+ metadata.gz: e6187abcb5b21a81b97d88b4f77879d237abb301
4
+ data.tar.gz: 3288b04c61442116a410264f2f36634c6b47f87c
5
5
  SHA512:
6
- metadata.gz: 5eacfdcdb7e892fec853b94e8d880161a379c76e806785b2530693825473360c6a72742440432479ae0dc9aef17569c1a2bbe2e40432b68af783f7ae12b791a2
7
- data.tar.gz: df4ae4f2a51a082e59451dd631060bf5d37fcb2367b93337ec9ba66c81b668b33f0a1a280f890a822cabaecb55b5a4f29f333738cde212d677270cfc484f6887
6
+ metadata.gz: db83aa157497c79588ad6763b7fe7589593a4ad58dd0e87578bf678cef9ac9c34ab4f678f8f09756e3ac0d8b712b25b21daa68ab7c65dd3a143495bf540dbf2b
7
+ data.tar.gz: aa6251f1b167ebb547bc43523d256b448e406d157657b422a3b82b83c1bfe0aa5a3aee2d9f39b52942af1b09d74e12ed7f92cd4adabbd1a31145c211d3a6d927
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  *.a
14
14
  mkmf.log
15
15
  *.gem
16
+ rubocop.html
data/Rakefile CHANGED
@@ -3,4 +3,3 @@ require 'bundler/gem_tasks'
3
3
  task :console do
4
4
  exec 'irb -r email_checker -I ./lib'
5
5
  end
6
-
data/bump CHANGED
File without changes
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = EmailChecker::VERSION
9
9
  spec.authors = ['Genaro Madrid']
10
10
  spec.email = ['genmadrid@gmail.com']
11
- spec.summary = %q{Check if an email address is can receive E-mails.}
12
- spec.description = %q{Validates, at some degree, that the email you want to send to it's valid and exists.}
11
+ spec.summary = 'Check if an email address is can receive E-mails.'
12
+ spec.description = "Validates, at some degree, that the email you want to send to it's valid and exists."
13
13
  spec.homepage = 'https://github.com/genaromadrid/email_checker'
14
14
  spec.license = 'MIT'
15
15
 
@@ -23,20 +23,17 @@ module EmailChecker
23
23
 
24
24
  def smtp
25
25
  return @smtp if @smtp
26
- tries ||= 5
27
26
  domain.mx_servers.each do |server|
28
- @smtp = Net::SMTP.start(server[:address], 25, EmailChecker.config.verifier_domain)
29
- return @smtp if @smtp
27
+ @smtp = connect(server[:address])
28
+ break if @smtp
30
29
  end
31
- fail EmailChecker::ServerConnectionError, "Unable to connect to any of the mail servers for #{@email}"
32
- rescue EmailChecker::ServerConnectionError => e
33
- fail EmailChecker::ServerConnectionError, e.message
30
+ fail EmailChecker::ServerConnectionError, "Unable to connect to any of the mail servers for #{@email}" unless @smtp
31
+ end
32
+
33
+ def connect(address)
34
+ Net::SMTP.start(address, 25, EmailChecker.config.verifier_domain)
34
35
  rescue => e
35
- if (tries -= 1) > 0
36
- retry
37
- else
38
- fail EmailChecker::FailureError, e.message
39
- end
36
+ raise EmailChecker::FailureError, e.message
40
37
  end
41
38
 
42
39
  def mailfrom
@@ -49,7 +46,7 @@ module EmailChecker
49
46
  if e.message[/^550/]
50
47
  return false
51
48
  else
52
- fail EmailChecker::FailureError, e.message
49
+ raise EmailChecker::FailureError, e.message
53
50
  end
54
51
  end
55
52
 
@@ -8,9 +8,7 @@ module EmailChecker
8
8
  def reset
9
9
  @verifier_email = nil
10
10
  @test_mode = false
11
- if defined?(Rails) && defined?(Rails.env) && Rails.env.test?
12
- @test_mode = true
13
- end
11
+ @test_mode = true if defined?(Rails) && defined?(Rails.env) && Rails.env.test?
14
12
  end
15
13
 
16
14
  def verifier_email=(verifier_email)
@@ -19,6 +17,6 @@ module EmailChecker
19
17
  end
20
18
  end
21
19
 
22
- self.reset
20
+ reset
23
21
  end
24
22
  end
@@ -1,6 +1,5 @@
1
1
  module EmailChecker
2
2
  class Domain
3
-
4
3
  def initialize(domain)
5
4
  @domain = domain
6
5
  end
@@ -10,7 +9,7 @@ module EmailChecker
10
9
  # @return [type] [description]
11
10
  def valid?
12
11
  return false unless @domain
13
- Timeout::timeout(SERVER_TIMEOUT) do
12
+ Timeout.timeout(SERVER_TIMEOUT) do
14
13
  return true if valid_mx_records?
15
14
  return true if a_records?
16
15
  end
@@ -42,7 +41,7 @@ module EmailChecker
42
41
  end
43
42
 
44
43
  def mx_records
45
- @mx_records ||= dns.getresources(@domain, Resolv::DNS::Resource::IN::MX).sort_by {|mx| mx.preference}
44
+ @mx_records ||= dns.getresources(@domain, Resolv::DNS::Resource::IN::MX).sort_by(&:preference)
46
45
  end
47
46
 
48
47
  def mx_servers
@@ -1,3 +1,3 @@
1
1
  module EmailChecker
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genaro Madrid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler