ez-email 0.1.0 → 0.1.1
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.
- data/CHANGES +7 -1
- data/Rakefile +39 -0
- data/ez-email.gemspec +18 -0
- data/lib/ez/email.rb +11 -4
- data/test/test_ez_email.rb +76 -76
- metadata +10 -9
data/CHANGES
CHANGED
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
desc "Cleanup .test-result files if present"
|
5
|
+
task :clean do
|
6
|
+
rm_rf '.test-result' if File.exists?('.test-result')
|
7
|
+
|
8
|
+
Dir.foreach(Dir.pwd){ |file|
|
9
|
+
if File.directory?(file)
|
10
|
+
Dir.chdir(file){
|
11
|
+
rm_rf '.test-result' if File.exists?('.test-result')
|
12
|
+
}
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Install the ez-email library (non-gem)"
|
18
|
+
task :install do
|
19
|
+
dest = File.join(Config::CONFIG['sitelibdir'], 'file')
|
20
|
+
Dir.mkdir(dest) unless File.exists? dest
|
21
|
+
cp 'lib/file/find.rb', dest, :verbose => true
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Build the ez-email gem'
|
25
|
+
task :gem do
|
26
|
+
spec = eval(IO.read('ez-email.gemspec'))
|
27
|
+
Gem::Builder.new(spec).build
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Install the ez-email package as a gem"
|
31
|
+
task :install_gem => [:gem] do
|
32
|
+
file = Dir["*.gem"].first
|
33
|
+
sh "gem install #{file}"
|
34
|
+
end
|
35
|
+
|
36
|
+
Rake::TestTask.new do |t|
|
37
|
+
t.warning = true
|
38
|
+
t.verbose = true
|
39
|
+
end
|
data/ez-email.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'ez-email'
|
5
|
+
s.version = '0.1.1'
|
6
|
+
s.license = 'Artistic 2.0'
|
7
|
+
s.summary = 'Really easy emails'
|
8
|
+
s.description = 'A very simple interface for sending email'
|
9
|
+
s.author = 'Daniel Berger'
|
10
|
+
s.email = 'djberg96@gmail.com'
|
11
|
+
s.homepage = 'http://www.rubyforge.org/projects/shards'
|
12
|
+
s.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
13
|
+
s.test_file = 'test/test_ez_email.rb'
|
14
|
+
s.has_rdoc = true
|
15
|
+
|
16
|
+
s.rubyforge_project = 'shards'
|
17
|
+
s.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
|
18
|
+
end
|
data/lib/ez/email.rb
CHANGED
@@ -9,14 +9,21 @@ module EZ
|
|
9
9
|
# The Email class encapsulates certain SMTP attributes, which are then
|
10
10
|
# used to send simple emails.
|
11
11
|
class Email
|
12
|
-
# The version of
|
13
|
-
VERSION = '0.1.
|
12
|
+
# The version of the ez-email library
|
13
|
+
VERSION = '0.1.1'
|
14
14
|
|
15
|
-
|
15
|
+
begin
|
16
|
+
@@mail_host = Resolv.getaddress('mailhost')
|
17
|
+
rescue Resolv::ResolvError
|
18
|
+
@@mail_host = 'localhost'
|
19
|
+
end
|
20
|
+
|
16
21
|
@@mail_port = 25
|
17
22
|
|
18
23
|
# The name of the mail host to use when sending email. The default
|
19
24
|
# is whatever the address of your system's 'mailhost' resolves to.
|
25
|
+
# If that cannot be determined, your localhost is used.
|
26
|
+
#
|
20
27
|
def self.mail_host
|
21
28
|
@@mail_host
|
22
29
|
end
|
@@ -104,7 +111,7 @@ module EZ
|
|
104
111
|
# :body => 'How are you?'
|
105
112
|
# )
|
106
113
|
#
|
107
|
-
# This is a shortcut for EZ::Email.new + EZ::Email
|
114
|
+
# This is a shortcut for EZ::Email.new + EZ::Email#deliver.
|
108
115
|
#
|
109
116
|
def self.deliver(options)
|
110
117
|
new(options).deliver
|
data/test/test_ez_email.rb
CHANGED
@@ -1,76 +1,76 @@
|
|
1
|
-
########################################################################
|
2
|
-
# test_ez_email.rb
|
3
|
-
#
|
4
|
-
# Test suite for the EZ::Email library.
|
5
|
-
########################################################################
|
6
|
-
require 'test/unit'
|
7
|
-
require 'ez/email'
|
8
|
-
|
9
|
-
class TC_EZ_Email < Test::Unit::TestCase
|
10
|
-
def setup
|
11
|
-
@to = 'foo@some_mail_service.com'
|
12
|
-
@from = 'bar@some_mail_service.com'
|
13
|
-
@subj = 'This is a test'
|
14
|
-
@body = 'How are you?'
|
15
|
-
|
16
|
-
@opts = {:to => @to, :from => @from, :subject => @subj, :body => @body }
|
17
|
-
@email = EZ::Email.new(@opts)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_version
|
21
|
-
assert_equal('0.1.
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_to
|
25
|
-
assert_respond_to(@email, :to)
|
26
|
-
assert_respond_to(@email, :to=)
|
27
|
-
assert_equal(@to, @email.to)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_from
|
31
|
-
assert_respond_to(@email, :from)
|
32
|
-
assert_respond_to(@email, :from=)
|
33
|
-
assert_equal(@from, @email.from)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_subject
|
37
|
-
assert_respond_to(@email, :subject)
|
38
|
-
assert_respond_to(@email, :subject=)
|
39
|
-
assert_equal(@subj, @email.subject)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_body
|
43
|
-
assert_respond_to(@email, :body)
|
44
|
-
assert_respond_to(@email, :body=)
|
45
|
-
assert_equal(@body, @email.body)
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_mail_host
|
49
|
-
assert_respond_to(EZ::Email, :mail_host)
|
50
|
-
assert_respond_to(EZ::Email, :mail_host=)
|
51
|
-
assert_kind_of(String, EZ::Email.mail_host)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_mail_port
|
55
|
-
assert_respond_to(EZ::Email, :mail_port)
|
56
|
-
assert_respond_to(EZ::Email, :mail_port=)
|
57
|
-
assert_equal(25, EZ::Email.mail_port)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_deliver
|
61
|
-
assert_respond_to(EZ::Email, :deliver)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_invalid_option_raises_error
|
65
|
-
assert_raise(ArgumentError){ EZ::Email.send(:new, {:bogus => 77}) }
|
66
|
-
end
|
67
|
-
|
68
|
-
def teardown
|
69
|
-
@to = nil
|
70
|
-
@from = nil
|
71
|
-
@subj = nil
|
72
|
-
@body = nil
|
73
|
-
@opts = nil
|
74
|
-
@email = nil
|
75
|
-
end
|
76
|
-
end
|
1
|
+
########################################################################
|
2
|
+
# test_ez_email.rb
|
3
|
+
#
|
4
|
+
# Test suite for the EZ::Email library.
|
5
|
+
########################################################################
|
6
|
+
require 'test/unit'
|
7
|
+
require 'ez/email'
|
8
|
+
|
9
|
+
class TC_EZ_Email < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@to = 'foo@some_mail_service.com'
|
12
|
+
@from = 'bar@some_mail_service.com'
|
13
|
+
@subj = 'This is a test'
|
14
|
+
@body = 'How are you?'
|
15
|
+
|
16
|
+
@opts = {:to => @to, :from => @from, :subject => @subj, :body => @body }
|
17
|
+
@email = EZ::Email.new(@opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_version
|
21
|
+
assert_equal('0.1.1', EZ::Email::VERSION)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_to
|
25
|
+
assert_respond_to(@email, :to)
|
26
|
+
assert_respond_to(@email, :to=)
|
27
|
+
assert_equal(@to, @email.to)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_from
|
31
|
+
assert_respond_to(@email, :from)
|
32
|
+
assert_respond_to(@email, :from=)
|
33
|
+
assert_equal(@from, @email.from)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_subject
|
37
|
+
assert_respond_to(@email, :subject)
|
38
|
+
assert_respond_to(@email, :subject=)
|
39
|
+
assert_equal(@subj, @email.subject)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_body
|
43
|
+
assert_respond_to(@email, :body)
|
44
|
+
assert_respond_to(@email, :body=)
|
45
|
+
assert_equal(@body, @email.body)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_mail_host
|
49
|
+
assert_respond_to(EZ::Email, :mail_host)
|
50
|
+
assert_respond_to(EZ::Email, :mail_host=)
|
51
|
+
assert_kind_of(String, EZ::Email.mail_host)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_mail_port
|
55
|
+
assert_respond_to(EZ::Email, :mail_port)
|
56
|
+
assert_respond_to(EZ::Email, :mail_port=)
|
57
|
+
assert_equal(25, EZ::Email.mail_port)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_deliver
|
61
|
+
assert_respond_to(EZ::Email, :deliver)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_invalid_option_raises_error
|
65
|
+
assert_raise(ArgumentError){ EZ::Email.send(:new, {:bogus => 77}) }
|
66
|
+
end
|
67
|
+
|
68
|
+
def teardown
|
69
|
+
@to = nil
|
70
|
+
@from = nil
|
71
|
+
@subj = nil
|
72
|
+
@body = nil
|
73
|
+
@opts = nil
|
74
|
+
@email = nil
|
75
|
+
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ez-email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Berger
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-27 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -24,16 +24,17 @@ extra_rdoc_files:
|
|
24
24
|
- CHANGES
|
25
25
|
- MANIFEST
|
26
26
|
files:
|
27
|
-
- lib/ez
|
28
|
-
- lib/ez/email.rb
|
29
|
-
- test/test_ez_email.rb
|
30
|
-
- README
|
31
27
|
- CHANGES
|
28
|
+
- ez-email.gemspec
|
29
|
+
- lib/ez/email.rb
|
32
30
|
- MANIFEST
|
31
|
+
- Rakefile
|
32
|
+
- README
|
33
|
+
- test/test_ez_email.rb
|
33
34
|
has_rdoc: true
|
34
35
|
homepage: http://www.rubyforge.org/projects/shards
|
35
|
-
licenses:
|
36
|
-
|
36
|
+
licenses:
|
37
|
+
- Artistic 2.0
|
37
38
|
post_install_message:
|
38
39
|
rdoc_options: []
|
39
40
|
|
@@ -54,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
55
|
requirements: []
|
55
56
|
|
56
57
|
rubyforge_project: shards
|
57
|
-
rubygems_version: 1.3.
|
58
|
+
rubygems_version: 1.3.5
|
58
59
|
signing_key:
|
59
60
|
specification_version: 3
|
60
61
|
summary: Really easy emails
|