emailist 0.0.7 → 0.0.8

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: 16bf3422c88196a6793a874e65fa34c28be33011
4
- data.tar.gz: 32123eb4c18e73e76af9394a877273ccbd4d349f
3
+ metadata.gz: 6e65a28727b5d6bc9bf8c8e42a39458ae027d544
4
+ data.tar.gz: 8aac13086f43425a1d04b6c78e9a69b3c00c17b8
5
5
  SHA512:
6
- metadata.gz: 9fe690edead6847d43df9dcf6d2eddb081e8c8db0a1297312b7e5461ef383798769a024277a00673bcf37579412a1e77f9b56d5f1cb9874bef2f767178046dc5
7
- data.tar.gz: a33d88b2f8979ae209a11ac8d0a5391a30d7c40765edc6b880cc6e8426aaf3cafdf0a2be469b48c1c98c444512422a8eb183cc3944572110d38624e62e84ec7c
6
+ metadata.gz: ff231264a2e0791919081318fd27d731d2f10d8b4ac7d120149bd8201f21c85130b570d26de6ac10ea02844ae0881e3cdf9821f2cd8ee48fed9bd4c6afa4de85
7
+ data.tar.gz: db20eaa77586a5050ac3d3bc71602a6128f4e7e5310c30ed5f1853f16c1d458d7bb4d3e09c58a0e652acbe9eed3e47a4279f3414add0d373d29099a397082f8f
data/emailist.gemspec CHANGED
@@ -26,4 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rake"
27
27
  spec.add_development_dependency "rspec"
28
28
  spec.add_development_dependency "shoulda-matchers"
29
+
30
+ spec.add_runtime_dependency "possible_email"
29
31
  end
@@ -1,3 +1,5 @@
1
1
  class Emailist < Array
2
2
  class InvalidTLD < StandardError; end
3
+ class InvalidEmailFormat < StandardError; end
4
+ class CantVerifyProfile < StandardError; end
3
5
  end
@@ -1,3 +1,3 @@
1
1
  class Emailist < Array
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/emailist.rb CHANGED
@@ -7,13 +7,19 @@ class Emailist < Array
7
7
  File.expand_path(File.join(File.dirname(__FILE__), '..', 'data', 'valid_tlds.txt'))
8
8
  ).lines.to_a.map {|tld| tld.gsub(/[^A-Z\-]/, '') }
9
9
 
10
- INVALID_START_WITH = [
11
- 'TO.', 'To.', 'E-mail', 'AS', 'TO:', 'To:'
12
- ]
10
+ INVALID_START_WITH = [
11
+ 'TO.', 'To.', 'E-mail', 'AS', 'TO:', 'To:'
12
+ ]
13
+
14
+ INVALID_END_WITH = [
15
+ '.TO', '.To', 'E'
16
+ ]
17
+
18
+
19
+ def initialize(verify_profiles: false)
20
+ @verify_profiles = verify_profiles
21
+ end
13
22
 
14
- INVALID_END_WITH = [
15
- '.TO', '.To', 'E'
16
- ]
17
23
 
18
24
  alias_method :_push, :push
19
25
  def push(email)
@@ -125,7 +131,20 @@ private
125
131
  end
126
132
  domain = new_domain.join('.')
127
133
 
128
- "#{local}@#{domain}".downcase
134
+ email = "#{local}@#{domain}".downcase
135
+
136
+ if @verify_profiles
137
+ begin
138
+ response = [PossibleEmail.find_profile(email)].flatten
139
+ if response.empty?
140
+ raise Emailist::CantVerifyProfile
141
+ end
142
+ rescue PossibleEmail::InvalidEmailFormat
143
+ raise Emailist::InvalidEmailFormat
144
+ end
145
+ end
146
+
147
+ email
129
148
  end
130
149
 
131
150
  end
@@ -77,6 +77,14 @@ describe "Emailist" do
77
77
  it "when an email contains no valid TLD" do
78
78
  expect { @email_list.add('bob.jones@yahoo.gloopoopoop') }.to raise_error Emailist::InvalidTLD
79
79
  end
80
+
81
+ #it "when an email is in an invalid format (for possible_email)" do
82
+ # @email_list = Emailist.new(verify_profiles: true)
83
+ # expect { @email_list._push('bob.jones@gloopoopoop') }.to raise_error Emailist::InvalidEmailFormat
84
+ #end
85
+
86
+ #it "when a profile can't be verified" do
87
+ #end
80
88
  end
81
89
 
82
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emailist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Barron
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: possible_email
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: "\n Provides a Ruby array wrapper that helps
70
84
  in managing a list of \n email addresses. Automagically
71
85
  uniquifies the list, as well as\n attempting to clean invalid