email_checker 0.0.2 → 0.0.3

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: e6187abcb5b21a81b97d88b4f77879d237abb301
4
- data.tar.gz: 3288b04c61442116a410264f2f36634c6b47f87c
3
+ metadata.gz: 4ce0e55f098f2eed3764851101fc8d5390944d73
4
+ data.tar.gz: 28b06a5b98b0fd9c9732a2af2cc0c05d3daba2c8
5
5
  SHA512:
6
- metadata.gz: db83aa157497c79588ad6763b7fe7589593a4ad58dd0e87578bf678cef9ac9c34ab4f678f8f09756e3ac0d8b712b25b21daa68ab7c65dd3a143495bf540dbf2b
7
- data.tar.gz: aa6251f1b167ebb547bc43523d256b448e406d157657b422a3b82b83c1bfe0aa5a3aee2d9f39b52942af1b09d74e12ed7f92cd4adabbd1a31145c211d3a6d927
6
+ metadata.gz: c9959ff3f032bcc13010933308c5a6771e26ac46c99964a507bb78813f6f4754c52dabe3cafbe40fe73f9160adbab4cd6b09b243a8332c3032fa4fe1edef87e5
7
+ data.tar.gz: fab981bf91741391cfbe9374fbb7014f6c787908e18b431e541d51bb09779cbc8e421de9a44d71ea408a605aa023573fb1290abe586facc4f03bb34b3e549157
@@ -2,14 +2,22 @@ require 'net/smtp'
2
2
 
3
3
  module EmailChecker
4
4
  class Checker
5
+
6
+ # @return [Domain]
5
7
  attr_reader :domain
6
8
 
9
+ # Returns a new instance of Checker
10
+ #
11
+ # @param email [String] The email to Check
7
12
  def initialize(email)
8
13
  @email = email
9
14
  email_m = email.match(EMAIL_PATTERN)
10
15
  @domain = Domain.new(email_m[2])
11
16
  end
12
17
 
18
+ # Checks if the email exists in the mail provider.
19
+ #
20
+ # @return [Boolean]
13
21
  def email_exists_in_server?
14
22
  mailfrom if EmailChecker.config.verifier_domain
15
23
  rcptto.tap do
@@ -28,6 +36,7 @@ module EmailChecker
28
36
  break if @smtp
29
37
  end
30
38
  fail EmailChecker::ServerConnectionError, "Unable to connect to any of the mail servers for #{@email}" unless @smtp
39
+ @smtp
31
40
  end
32
41
 
33
42
  def connect(address)
@@ -1,12 +1,19 @@
1
+ # @author Genaro Madrid
1
2
  module EmailChecker
2
3
  class Domain
4
+
5
+ # Returns a new instance of Domain
6
+ #
7
+ # @param domain [String] The domain name.
8
+ #
9
+ # @example EmailChecker::Domain.new('google.com')
3
10
  def initialize(domain)
4
11
  @domain = domain
5
12
  end
6
13
 
7
- # Checks if the domian exists and has valid MX and A records
14
+ # Checks if the domian exists and has valid MX and A records.
8
15
  #
9
- # @return [type] [description]
16
+ # @return [Boolean]
10
17
  def valid?
11
18
  return false unless @domain
12
19
  Timeout.timeout(SERVER_TIMEOUT) do
@@ -17,7 +24,7 @@ module EmailChecker
17
24
  false
18
25
  end
19
26
 
20
- # Check if it has valid MX records and it can receive emails.
27
+ # Check if the domian has valid MX records and it can receive emails.
21
28
  # The MX server exists and it has valid A records.
22
29
  #
23
30
  # @return [Boolean]
@@ -29,21 +36,31 @@ module EmailChecker
29
36
  false
30
37
  end
31
38
 
32
- # Check if the domain exists validation that has at least 1 A record.
39
+ # Validates that has at least 1 A record.
40
+ # Check if the domain exists.
33
41
  #
34
42
  # @return [Boolean]
35
43
  def a_records?
36
44
  a_records.any?
37
45
  end
38
46
 
47
+ # The A records for the domain.
48
+ #
49
+ # @return [Array<Resolv::DNS::Resource::IN::A>]
39
50
  def a_records
40
51
  @a_records ||= dns.getresources(@domain, Resolv::DNS::Resource::IN::A)
41
52
  end
42
53
 
54
+ # The MX records of the domain.
55
+ #
56
+ # @return [Array<Resolv::DNS::Resource::IN::MX>]
43
57
  def mx_records
44
58
  @mx_records ||= dns.getresources(@domain, Resolv::DNS::Resource::IN::MX).sort_by(&:preference)
45
59
  end
46
60
 
61
+ # The servers that this domian MX records point at.
62
+ #
63
+ # @return [Array<Hash>] Array of type { preference: 1, address: '127.0.0.1' }
47
64
  def mx_servers
48
65
  return @mx_servers if @mx_servers
49
66
  @mx_servers = []
@@ -1,3 +1,3 @@
1
1
  module EmailChecker
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
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.2
4
+ version: 0.0.3
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-17 00:00:00.000000000 Z
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler