malone 0.1.0.rc1 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +21 -0
- data/README.md +71 -0
- data/lib/malone.rb +76 -28
- data/lib/malone/{sandbox.rb → test.rb} +2 -2
- data/malone.gemspec +23 -0
- data/test/helper.rb +3 -43
- data/test/malone.rb +181 -93
- metadata +14 -24
- data/README.markdown +0 -54
- data/test/sandbox.rb +0 -16
data/CHANGELOG
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
1.0.0
|
2
|
+
|
3
|
+
- Malone.configure has been replaced with Malone.connect
|
4
|
+
Use Malone.current to retrieve the last configured Malone
|
5
|
+
instance (using Malone.connect)
|
6
|
+
|
7
|
+
- Malone.deliver has been replaced with an instance method.
|
8
|
+
Call deliver (with the same arguments as before) on the
|
9
|
+
return value of Malone.connect or Malone.current.
|
10
|
+
|
11
|
+
- Malone#deliver now receives :text and :html instead of :body.
|
12
|
+
|
13
|
+
- No need to pass in TLS. it's tries to do TLS automatically.
|
14
|
+
|
15
|
+
- Errors during SMTP authentication (and any other error) aren't
|
16
|
+
trapped silently now. (via @tizoc, @elpollila)
|
17
|
+
|
18
|
+
- Configuration parameters are more strict (i.e. passing :password
|
19
|
+
would throw a NoMethodError via @tizoc, @elpollila)
|
20
|
+
|
21
|
+
- malone/sandbox has been renamed to malone/test.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
Originally taken from my initial draft [here][blogpost].
|
2
|
+
|
3
|
+
[blogpost]: http://www.pipetodevnull.com/past/2010/11/27/simple_mailer/
|
4
|
+
|
5
|
+
## USAGE
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
$ gem install malone
|
9
|
+
|
10
|
+
require "malone"
|
11
|
+
|
12
|
+
# Typically you would do this somewhere in the bootstrapping
|
13
|
+
# part of your application
|
14
|
+
|
15
|
+
m = Malone.connect(url: "smtp://foo%40bar.com:pass1234@smtp.gmail.com:587",
|
16
|
+
domain: "mysite.com")
|
17
|
+
|
18
|
+
m.deliver(from: "me@me.com", to: "you@me.com",
|
19
|
+
subject: "Test subject", text: "Great!")
|
20
|
+
|
21
|
+
# Malone.current will now remember the last configuration you setup.
|
22
|
+
Malone.current.config == m.config
|
23
|
+
|
24
|
+
# Now you can also do Malone.deliver, which is syntactic sugar
|
25
|
+
# for Malone.current.deliver
|
26
|
+
Malone.deliver(from: "me@me.com", to: "you@me.com",
|
27
|
+
subject: "Test subject", text: "Great!")
|
28
|
+
|
29
|
+
# Also starting with Malone 1.0, you can also pass in :html
|
30
|
+
# for multipart emails.
|
31
|
+
|
32
|
+
m.deliver(from: "me@me.com", to: "you@me.com",
|
33
|
+
subject: "Test subject",
|
34
|
+
text: "Great!", html: "<b>Great!</b>")
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
That's it!
|
39
|
+
|
40
|
+
## TESTING
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
require "malone/test"
|
44
|
+
|
45
|
+
m = Malone.connect(url: "smtp://foo%40bar.com:pass1234@smtp.gmail.com:587",
|
46
|
+
domain: "mysite.com")
|
47
|
+
|
48
|
+
m.deliver(from: "me@me.com", to: "you@me.com",
|
49
|
+
subject: "Test subject", text: "Great!")
|
50
|
+
|
51
|
+
Malone.deliveries.size == 1
|
52
|
+
# => true
|
53
|
+
|
54
|
+
mail = Malone.deliveries.first
|
55
|
+
|
56
|
+
"me@me.com" == mail.from
|
57
|
+
# => true
|
58
|
+
|
59
|
+
"you@me.com" == mail.to
|
60
|
+
# => true
|
61
|
+
|
62
|
+
"FooBar" == mail.text
|
63
|
+
# => true
|
64
|
+
|
65
|
+
"Hello World" == envelope.subject
|
66
|
+
# => true
|
67
|
+
```
|
68
|
+
|
69
|
+
## LICENSE
|
70
|
+
|
71
|
+
MIT
|
data/lib/malone.rb
CHANGED
@@ -1,47 +1,95 @@
|
|
1
|
-
require "
|
2
|
-
require "ostruct"
|
1
|
+
require "cgi"
|
3
2
|
require "mailfactory"
|
3
|
+
require "net/smtp"
|
4
|
+
require "uri"
|
4
5
|
|
5
6
|
class Malone
|
6
|
-
attr :
|
7
|
+
attr :config
|
8
|
+
|
9
|
+
def self.connect(options = {})
|
10
|
+
@config = Configuration.new(options)
|
7
11
|
|
8
|
-
|
9
|
-
new(params).deliver
|
12
|
+
current
|
10
13
|
end
|
11
|
-
|
12
|
-
def self.
|
13
|
-
@config
|
14
|
+
|
15
|
+
def self.current
|
16
|
+
unless defined?(@config)
|
17
|
+
raise RuntimeError, "Missing configuration: Try doing `Malone.connect`."
|
18
|
+
end
|
19
|
+
|
20
|
+
return new(@config)
|
14
21
|
end
|
15
22
|
|
16
|
-
def self.
|
17
|
-
|
23
|
+
def self.deliver(dict)
|
24
|
+
current.deliver(dict)
|
18
25
|
end
|
19
26
|
|
20
|
-
def initialize(
|
21
|
-
@
|
22
|
-
@envelope.from = params[:from]
|
23
|
-
@envelope.to = params[:to]
|
24
|
-
@envelope.text = params[:text]
|
25
|
-
@envelope.html = params[:html] if params[:html]
|
26
|
-
@envelope.subject = params[:subject]
|
27
|
+
def initialize(config)
|
28
|
+
@config = config
|
27
29
|
end
|
28
30
|
|
29
|
-
def deliver
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
def deliver(dict)
|
32
|
+
mail = envelope(dict)
|
33
|
+
|
34
|
+
smtp = Net::SMTP.new(config.host, config.port)
|
35
|
+
smtp.enable_starttls_auto
|
36
|
+
|
33
37
|
begin
|
34
|
-
smtp.start(config.domain, config.user, config.
|
35
|
-
smtp.send_message(
|
38
|
+
smtp.start(config.domain, config.user, config.password, config.auth)
|
39
|
+
smtp.send_message(mail.to_s, mail.from.first, mail.to)
|
36
40
|
ensure
|
37
|
-
smtp.finish
|
41
|
+
smtp.finish if smtp.started?
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
|
-
|
42
|
-
|
45
|
+
def envelope(dict)
|
46
|
+
envelope = MailFactory.new
|
47
|
+
envelope.from = dict[:from]
|
48
|
+
envelope.to = dict[:to]
|
49
|
+
envelope.text = dict[:text]
|
50
|
+
envelope.rawhtml = dict[:html] if dict[:html]
|
51
|
+
envelope.subject = dict[:subject]
|
52
|
+
|
53
|
+
return envelope
|
54
|
+
end
|
55
|
+
|
56
|
+
class Configuration
|
57
|
+
attr_accessor :host
|
58
|
+
attr_accessor :port
|
59
|
+
attr_accessor :user
|
60
|
+
attr_accessor :password
|
61
|
+
attr_accessor :domain
|
62
|
+
attr_accessor :auth
|
43
63
|
|
44
|
-
|
45
|
-
|
64
|
+
def initialize(options)
|
65
|
+
opts = options.dup
|
66
|
+
|
67
|
+
url = opts.delete(:url) || ENV["MALONE_URL"]
|
68
|
+
|
69
|
+
if url
|
70
|
+
uri = URI(url)
|
71
|
+
|
72
|
+
opts[:host] ||= uri.host
|
73
|
+
opts[:port] ||= uri.port.to_i
|
74
|
+
opts[:user] ||= unescaped(uri.user)
|
75
|
+
opts[:password] ||= unescaped(uri.password)
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.each do |key, val|
|
79
|
+
send(:"#{key}=", val)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def auth=(val)
|
84
|
+
@auth = val
|
85
|
+
@auth = @auth.to_sym if @auth
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
def unescaped(val)
|
90
|
+
return if val.to_s.empty?
|
91
|
+
|
92
|
+
CGI.unescape(val)
|
93
|
+
end
|
46
94
|
end
|
47
95
|
end
|
data/malone.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'malone'
|
3
|
+
s.version = "1.0.0.rc1"
|
4
|
+
s.summary = %{Dead-simple Ruby mailing solution which always delivers.}
|
5
|
+
s.date = "2011-01-10"
|
6
|
+
s.author = "Cyril David"
|
7
|
+
s.email = "me@cyrildavid.com"
|
8
|
+
s.homepage = "http://github.com/cyx/malone"
|
9
|
+
|
10
|
+
s.files = Dir[
|
11
|
+
"CHANGELOG",
|
12
|
+
"LICENSE",
|
13
|
+
"README.md",
|
14
|
+
"lib/**/*.rb",
|
15
|
+
"test/*.*",
|
16
|
+
"*.gemspec"
|
17
|
+
]
|
18
|
+
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency "mailfactory", "~> 1.4"
|
22
|
+
s.add_development_dependency "cutest"
|
23
|
+
end
|
data/test/helper.rb
CHANGED
@@ -1,44 +1,4 @@
|
|
1
|
-
|
2
|
-
require "flexmock/base"
|
3
|
-
|
4
|
-
require File.expand_path("../lib/malone", File.dirname(__FILE__))
|
5
|
-
|
6
|
-
class FlexMock
|
7
|
-
class CutestFrameworkAdapter
|
8
|
-
def assert_block(msg, &block)
|
9
|
-
unless yield
|
10
|
-
puts msg
|
11
|
-
flunk(7)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def assert_equal(a, b, msg=nil)
|
16
|
-
flunk unless a == b
|
17
|
-
end
|
18
|
-
|
19
|
-
class AssertionFailedError < StandardError; end
|
20
|
-
|
21
|
-
def assertion_failed_error
|
22
|
-
Cutest::AssertionFailed
|
23
|
-
end
|
24
|
-
end
|
1
|
+
$:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
|
25
2
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
module Cutest::Flexmocked
|
30
|
-
def test(*args, &block)
|
31
|
-
super
|
32
|
-
|
33
|
-
flexmock_verify
|
34
|
-
ensure
|
35
|
-
flexmock_close
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class Cutest::Scope
|
40
|
-
include FlexMock::ArgumentTypes
|
41
|
-
include FlexMock::MockContainer
|
42
|
-
|
43
|
-
include Cutest::Flexmocked
|
44
|
-
end
|
3
|
+
require "cutest"
|
4
|
+
require "malone"
|
data/test/malone.rb
CHANGED
@@ -1,125 +1,213 @@
|
|
1
|
-
|
1
|
+
require_relative "helper"
|
2
2
|
|
3
|
-
|
4
|
-
m = Malone.
|
5
|
-
|
3
|
+
test "basic configuration" do
|
4
|
+
m = Malone.connect(host: "smtp.gmail.com", port: 587,
|
5
|
+
user: "foo@bar.com", password: "pass1234",
|
6
|
+
domain: "foo.com", auth: "login")
|
7
|
+
|
8
|
+
c = m.config
|
9
|
+
|
10
|
+
assert_equal "smtp.gmail.com", c.host
|
11
|
+
assert_equal 587, c.port
|
12
|
+
assert_equal "foo@bar.com", c.user
|
13
|
+
assert_equal "pass1234", c.password
|
14
|
+
assert_equal "foo.com", c.domain
|
15
|
+
assert_equal :login, c.auth
|
6
16
|
end
|
7
17
|
|
8
|
-
test "
|
9
|
-
|
10
|
-
assert m.envelope.to == ["you@me.com"]
|
18
|
+
test "configuration via url" do
|
19
|
+
m = Malone.connect(url: "smtp://foo%40bar.com:pass1234@smtp.gmail.com:587")
|
11
20
|
|
12
|
-
|
13
|
-
|
21
|
+
c = m.config
|
22
|
+
|
23
|
+
assert_equal "smtp.gmail.com", c.host
|
24
|
+
assert_equal 587, c.port
|
25
|
+
assert_equal "foo@bar.com", c.user
|
26
|
+
assert_equal "pass1234", c.password
|
14
27
|
end
|
15
28
|
|
16
|
-
test "
|
17
|
-
|
18
|
-
|
29
|
+
test "configuration via url and params" do
|
30
|
+
m = Malone.connect(url: "smtp://foo%40bar.com:pass1234@smtp.gmail.com:587",
|
31
|
+
domain: "foo.com", auth: "login", password: "barbaz123")
|
32
|
+
|
33
|
+
c = m.config
|
34
|
+
|
35
|
+
assert_equal "smtp.gmail.com", c.host
|
36
|
+
assert_equal 587, c.port
|
37
|
+
assert_equal "foo@bar.com", c.user
|
38
|
+
assert_equal "foo.com", c.domain
|
39
|
+
assert_equal :login, c.auth
|
40
|
+
|
41
|
+
# We verify that parameters passed takes precedence over the URL.
|
42
|
+
assert_equal "barbaz123", c.password
|
43
|
+
end
|
44
|
+
|
45
|
+
test "configuration via MALONE_URL" do
|
46
|
+
ENV["MALONE_URL"] = "smtp://foo%40bar.com:pass1234@smtp.gmail.com:587"
|
47
|
+
|
48
|
+
m = Malone.connect(domain: "foo.com", auth: "login")
|
49
|
+
c = m.config
|
50
|
+
|
51
|
+
assert_equal "smtp.gmail.com", c.host
|
52
|
+
assert_equal 587, c.port
|
53
|
+
assert_equal "foo@bar.com", c.user
|
54
|
+
assert_equal "foo.com", c.domain
|
55
|
+
assert_equal :login, c.auth
|
56
|
+
end
|
57
|
+
|
58
|
+
test "typos in configuration" do
|
59
|
+
assert_raise NoMethodError do
|
60
|
+
Malone.connect(pass: "pass")
|
19
61
|
end
|
20
62
|
end
|
21
63
|
|
22
|
-
test "
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
64
|
+
test "Malone.connect doesn't mutate the options" do
|
65
|
+
ex = nil
|
66
|
+
begin
|
67
|
+
Malone.connect({}.freeze)
|
68
|
+
rescue RuntimeError => ex
|
69
|
+
end
|
70
|
+
|
71
|
+
assert_equal nil, ex
|
72
|
+
end
|
73
|
+
|
74
|
+
test "Malone.current" do
|
75
|
+
Malone.connect(url: "smtp://foo%40bar.com:pass1234@smtp.gmail.com:587")
|
76
|
+
|
77
|
+
c = Malone.current.config
|
78
|
+
|
79
|
+
assert_equal "smtp.gmail.com", c.host
|
80
|
+
assert_equal 587, c.port
|
81
|
+
assert_equal "foo@bar.com", c.user
|
82
|
+
assert_equal "pass1234", c.password
|
83
|
+
end
|
84
|
+
|
85
|
+
test "#envelope" do
|
86
|
+
m = Malone.connect
|
87
|
+
|
88
|
+
mail = m.envelope(to: "recipient@me.com", from: "no-reply@mydomain.com",
|
89
|
+
subject: "SUB", text: "TEXT", html: "<h1>TEXT</h1>")
|
90
|
+
|
91
|
+
assert_equal ["recipient@me.com"], mail.to
|
92
|
+
assert_equal ["no-reply@mydomain.com"], mail.from
|
93
|
+
assert_equal ["=?utf-8?Q?SUB?="], mail.subject
|
94
|
+
|
95
|
+
assert_equal "TEXT", mail.instance_variable_get(:@text)
|
96
|
+
assert_equal "<h1>TEXT</h1>", mail.instance_variable_get(:@html)
|
40
97
|
end
|
41
98
|
|
42
99
|
scope do
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
user
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
100
|
+
class FakeSMTP < Struct.new(:host, :port)
|
101
|
+
def enable_starttls_auto
|
102
|
+
@enable_starttls_auto = true
|
103
|
+
end
|
104
|
+
|
105
|
+
def start(domain, user, password, auth)
|
106
|
+
@domain, @user, @password, @auth = domain, user, password, auth
|
107
|
+
|
108
|
+
@started = true
|
109
|
+
end
|
110
|
+
|
111
|
+
def started?
|
112
|
+
defined?(@started)
|
113
|
+
end
|
54
114
|
|
55
|
-
|
56
|
-
|
57
|
-
|
115
|
+
def finish
|
116
|
+
@finish = true
|
117
|
+
end
|
58
118
|
|
59
|
-
|
60
|
-
|
119
|
+
def send_message(blob, from, to)
|
120
|
+
@blob, @from, @to = blob, from, to
|
121
|
+
end
|
61
122
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
123
|
+
def [](key)
|
124
|
+
instance_variable_get(:"@#{key}")
|
125
|
+
end
|
126
|
+
end
|
66
127
|
|
67
|
-
|
68
|
-
|
69
|
-
|
128
|
+
module Net
|
129
|
+
def SMTP.new(host, port)
|
130
|
+
$smtp = FakeSMTP.new(host, port)
|
131
|
+
end
|
132
|
+
end
|
70
133
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
)
|
134
|
+
setup do
|
135
|
+
Malone.connect(url: "smtp://foo%40bar.com:pass1234@smtp.gmail.com:587",
|
136
|
+
domain: "mydomain.com", auth: :login)
|
137
|
+
end
|
76
138
|
|
77
|
-
|
78
|
-
|
79
|
-
|
139
|
+
test "delivering successfully" do |m|
|
140
|
+
m.deliver(to: "recipient@me.com", from: "no-reply@mydomain.com",
|
141
|
+
subject: "SUB", text: "TEXT")
|
80
142
|
|
81
|
-
|
82
|
-
|
143
|
+
assert_equal "smtp.gmail.com", $smtp.host
|
144
|
+
assert_equal 587, $smtp.port
|
83
145
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
146
|
+
assert $smtp[:enable_starttls_auto]
|
147
|
+
assert_equal "mydomain.com", $smtp[:domain]
|
148
|
+
assert_equal "foo@bar.com", $smtp[:user]
|
149
|
+
assert_equal "pass1234", $smtp[:password]
|
150
|
+
assert_equal :login, $smtp[:auth]
|
89
151
|
|
90
|
-
|
91
|
-
|
92
|
-
sender.should_receive(:finish).once
|
152
|
+
assert_equal ["recipient@me.com"], $smtp[:to]
|
153
|
+
assert_equal "no-reply@mydomain.com", $smtp[:from]
|
93
154
|
|
94
|
-
|
95
|
-
|
96
|
-
assert "OK" == malone.deliver
|
155
|
+
assert $smtp[:started]
|
156
|
+
assert $smtp[:finish]
|
97
157
|
end
|
98
158
|
|
99
|
-
test "
|
100
|
-
|
101
|
-
|
159
|
+
test "Malone.deliver forwards to Malone.current" do |m|
|
160
|
+
Malone.deliver(to: "recipient@me.com", from: "no-reply@mydomain.com",
|
161
|
+
subject: "SUB", text: "TEXT")
|
102
162
|
|
103
|
-
|
104
|
-
|
105
|
-
# and verify that finish is still called
|
106
|
-
sender = flexmock("smtp sender")
|
163
|
+
assert_equal "smtp.gmail.com", $smtp.host
|
164
|
+
assert_equal 587, $smtp.port
|
107
165
|
|
108
|
-
|
109
|
-
|
110
|
-
|
166
|
+
assert $smtp[:enable_starttls_auto]
|
167
|
+
assert_equal "mydomain.com", $smtp[:domain]
|
168
|
+
assert_equal "foo@bar.com", $smtp[:user]
|
169
|
+
assert_equal "pass1234", $smtp[:password]
|
170
|
+
assert_equal :login, $smtp[:auth]
|
111
171
|
|
112
|
-
|
172
|
+
assert_equal ["recipient@me.com"], $smtp[:to]
|
173
|
+
assert_equal "no-reply@mydomain.com", $smtp[:from]
|
113
174
|
|
114
|
-
|
115
|
-
|
116
|
-
|
175
|
+
assert $smtp[:started]
|
176
|
+
assert $smtp[:finish]
|
177
|
+
end
|
117
178
|
|
118
|
-
|
119
|
-
|
179
|
+
test "calls #finish even when it fails during send_message" do |m|
|
180
|
+
class FakeSMTP
|
181
|
+
def send_message(*args)
|
182
|
+
raise
|
183
|
+
end
|
184
|
+
end
|
120
185
|
|
121
|
-
|
122
|
-
|
186
|
+
begin
|
187
|
+
m.deliver(to: "recipient@me.com", from: "no-reply@mydomain.com",
|
188
|
+
subject: "SUB", text: "TEXT")
|
189
|
+
rescue
|
123
190
|
end
|
191
|
+
|
192
|
+
assert $smtp[:started]
|
193
|
+
assert $smtp[:finish]
|
124
194
|
end
|
125
|
-
end
|
195
|
+
end
|
196
|
+
|
197
|
+
test "sandbox" do
|
198
|
+
require "malone/test"
|
199
|
+
|
200
|
+
m = Malone.connect
|
201
|
+
m.deliver(to: "recipient@me.com", from: "no-reply@mydomain.com",
|
202
|
+
subject: "SUB", text: "TEXT", html: "<h1>TEXT</h1>")
|
203
|
+
|
204
|
+
assert_equal 1, Malone.deliveries.size
|
205
|
+
|
206
|
+
mail = Malone.deliveries.first
|
207
|
+
|
208
|
+
assert_equal "no-reply@mydomain.com", mail.from
|
209
|
+
assert_equal "recipient@me.com", mail.to
|
210
|
+
assert_equal "SUB", mail.subject
|
211
|
+
assert_equal "TEXT", mail.text
|
212
|
+
assert_equal "<h1>TEXT</h1>", mail.html
|
213
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: malone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,29 +13,18 @@ date: 2011-01-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mailfactory
|
16
|
-
requirement: &
|
16
|
+
requirement: &70255670212260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '1.4'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70255670212260
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cutest
|
27
|
-
requirement: &
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ! '>='
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0'
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *2151851120
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: flexmock
|
38
|
-
requirement: &2151850660 !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70255670211520 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
29
|
requirements:
|
41
30
|
- - ! '>='
|
@@ -43,20 +32,21 @@ dependencies:
|
|
43
32
|
version: '0'
|
44
33
|
type: :development
|
45
34
|
prerelease: false
|
46
|
-
version_requirements: *
|
35
|
+
version_requirements: *70255670211520
|
47
36
|
description:
|
48
|
-
email:
|
37
|
+
email: me@cyrildavid.com
|
49
38
|
executables: []
|
50
39
|
extensions: []
|
51
40
|
extra_rdoc_files: []
|
52
41
|
files:
|
53
|
-
-
|
54
|
-
- lib/malone.rb
|
55
|
-
- README.markdown
|
42
|
+
- CHANGELOG
|
56
43
|
- LICENSE
|
44
|
+
- README.md
|
45
|
+
- lib/malone/test.rb
|
46
|
+
- lib/malone.rb
|
57
47
|
- test/helper.rb
|
58
48
|
- test/malone.rb
|
59
|
-
-
|
49
|
+
- malone.gemspec
|
60
50
|
homepage: http://github.com/cyx/malone
|
61
51
|
licenses: []
|
62
52
|
post_install_message:
|
@@ -79,6 +69,6 @@ requirements: []
|
|
79
69
|
rubyforge_project:
|
80
70
|
rubygems_version: 1.8.11
|
81
71
|
signing_key:
|
82
|
-
specification_version:
|
72
|
+
specification_version: 3
|
83
73
|
summary: Dead-simple Ruby mailing solution which always delivers.
|
84
74
|
test_files: []
|
data/README.markdown
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
Originally taken from my initial draft [here][blogpost].
|
2
|
-
|
3
|
-
[blogpost]: http://www.pipetodevnull.com/past/2010/11/27/simple_mailer/
|
4
|
-
|
5
|
-
## USAGE
|
6
|
-
|
7
|
-
$ gem install malone
|
8
|
-
|
9
|
-
require "malone"
|
10
|
-
|
11
|
-
# typically you would do this somewhere in the bootstrapping
|
12
|
-
# part of your application
|
13
|
-
|
14
|
-
Malone.configure(
|
15
|
-
host: "smtp.gmail.com",
|
16
|
-
port: 587,
|
17
|
-
tls: true,
|
18
|
-
domain: "mydomain.com",
|
19
|
-
user: "me@mydomain.com",
|
20
|
-
pass: "mypass",
|
21
|
-
auth: :login,
|
22
|
-
from: "no-reply@mydomain.com"
|
23
|
-
)
|
24
|
-
|
25
|
-
Malone.deliver(from: "me@me.com", to: "you@me.com",
|
26
|
-
subject: "Test subject", body: "Great!")
|
27
|
-
|
28
|
-
That's it!
|
29
|
-
|
30
|
-
## TESTING
|
31
|
-
|
32
|
-
require "malone/sandbox"
|
33
|
-
|
34
|
-
Malone.deliver(from: "me@me.com", to: "you@me.com",
|
35
|
-
subject: "Test subject", body: "Great!")
|
36
|
-
|
37
|
-
Malone.deliveries.size == 1
|
38
|
-
# => true
|
39
|
-
|
40
|
-
envelope = Malone.deliveries.first
|
41
|
-
|
42
|
-
"me@me.com" == envelope.from
|
43
|
-
# => true
|
44
|
-
|
45
|
-
"you@me.com" == envelope.to
|
46
|
-
# => true
|
47
|
-
|
48
|
-
"FooBar" == envelope.body
|
49
|
-
# => true
|
50
|
-
|
51
|
-
"Hello World" == envelope.subject## LICENSE
|
52
|
-
# => true
|
53
|
-
|
54
|
-
MIT
|
data/test/sandbox.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
2
|
-
require File.expand_path("../lib/malone/sandbox", File.dirname(__FILE__))
|
3
|
-
|
4
|
-
test "deliveries" do
|
5
|
-
Malone.deliver from: "me@me.com", to: "you@me.com",
|
6
|
-
body: "FooBar", subject: "Hello World"
|
7
|
-
|
8
|
-
assert_equal 1, Malone.deliveries.size
|
9
|
-
|
10
|
-
envelope = Malone.deliveries.first
|
11
|
-
|
12
|
-
assert_equal "me@me.com", envelope.from
|
13
|
-
assert_equal "you@me.com", envelope.to
|
14
|
-
assert_equal "FooBar", envelope.body
|
15
|
-
assert_equal "Hello World", envelope.subject
|
16
|
-
end
|