padrino-mailer 0.9.14 → 0.9.15
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/lib/padrino-mailer/base.rb +4 -4
- data/lib/padrino-mailer/ext.rb +2 -2
- data/lib/padrino-mailer/helpers.rb +3 -1
- data/padrino-mailer.gemspec +10 -11
- data/test/fixtures/padrino_app/app.rb +18 -9
- data/test/fixtures/padrino_app/views/mailers/sample/helper_message.erb +1 -0
- data/test/fixtures/sinatra_app/app.rb +1 -9
- data/test/helper.rb +1 -0
- data/test/test_email.rb +4 -1
- data/test/test_padrino_mailer.rb +10 -1
- metadata +13 -108
data/LICENSE
CHANGED
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/padrino-mailer/base.rb
CHANGED
@@ -59,16 +59,16 @@ module Padrino
|
|
59
59
|
}
|
60
60
|
end
|
61
61
|
alias :message :email
|
62
|
-
|
62
|
+
|
63
63
|
# Defines the default attributes for a message in this mailer (including app-wide defaults)
|
64
|
-
#
|
64
|
+
#
|
65
65
|
# ==== Examples
|
66
66
|
#
|
67
67
|
# mailer :alternate do
|
68
68
|
# defaults :from => 'padrino@from.com', :to => 'padrino@to.com'
|
69
69
|
# email(:foo) do ... end
|
70
|
-
#
|
71
|
-
#
|
70
|
+
# end
|
71
|
+
#
|
72
72
|
def defaults(attributes=nil)
|
73
73
|
if attributes.nil? # Retrieve the default values
|
74
74
|
@app.respond_to?(:mailer_defaults) ? @app.mailer_defaults.merge(@defaults) : @defaults
|
data/lib/padrino-mailer/ext.rb
CHANGED
@@ -79,7 +79,9 @@ module Padrino
|
|
79
79
|
# deliver(:example, :message, "John")
|
80
80
|
#
|
81
81
|
def deliver(mailer_name, message_name, *attributes)
|
82
|
-
registered_mailers[mailer_name].messages[message_name].call(*attributes)
|
82
|
+
message = registered_mailers[mailer_name].messages[message_name].call(*attributes)
|
83
|
+
message.delivery_method(*delivery_settings)
|
84
|
+
message.deliver
|
83
85
|
end
|
84
86
|
|
85
87
|
##
|
data/padrino-mailer.gemspec
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
require File.expand_path("../../padrino-core/lib/padrino-core/version.rb", __FILE__)
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler'
|
4
2
|
|
5
3
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
7
|
-
s.rubyforge_project =
|
4
|
+
s.name = "padrino-mailer"
|
5
|
+
s.rubyforge_project = "padrino-mailer"
|
8
6
|
s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
|
9
|
-
s.email =
|
10
|
-
s.summary =
|
11
|
-
s.homepage =
|
12
|
-
s.description =
|
7
|
+
s.email = "padrinorb@gmail.com"
|
8
|
+
s.summary = "Mailer system for padrino"
|
9
|
+
s.homepage = "http://www.padrinorb.com"
|
10
|
+
s.description = "Mailer system for padrino allowing easy delivery of application emails"
|
13
11
|
s.required_rubygems_version = ">= 1.3.6"
|
14
12
|
s.version = Padrino.version
|
15
13
|
s.date = Time.now.strftime("%Y-%m-%d")
|
16
14
|
s.extra_rdoc_files = Dir["*.rdoc"]
|
17
15
|
s.files = %w(.document .gitignore LICENSE README.rdoc Rakefile padrino-mailer.gemspec) + Dir.glob("{bin,lib,test}/**/*")
|
18
16
|
s.rdoc_options = ["--charset=UTF-8"]
|
19
|
-
s.require_path =
|
20
|
-
s.
|
21
|
-
s.
|
17
|
+
s.require_path = "lib"
|
18
|
+
s.add_dependency("padrino-core", Padrino.version)
|
19
|
+
s.add_dependency("mail", ">= 2.2.0")
|
20
|
+
s.add_dependency("tlsmail") if RUBY_VERSION == "1.8.6"
|
22
21
|
end
|
@@ -2,17 +2,10 @@ ENV['PADRINO_ENV'] = 'test'
|
|
2
2
|
PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
3
3
|
|
4
4
|
class PadrinoApp < Padrino::Application
|
5
|
+
register Padrino::Helpers
|
5
6
|
register Padrino::Mailer
|
6
7
|
|
7
|
-
set :delivery_method, :
|
8
|
-
:address => "smtp.gmail.com",
|
9
|
-
:port => 587,
|
10
|
-
:domain => 'your.host.name',
|
11
|
-
:user_name => '<username>',
|
12
|
-
:password => '<password>',
|
13
|
-
:authentication => 'plain',
|
14
|
-
:enable_starttls_auto => true
|
15
|
-
}
|
8
|
+
set :delivery_method, :test
|
16
9
|
|
17
10
|
mailer :sample do
|
18
11
|
email :birthday do |name, age|
|
@@ -42,6 +35,16 @@ class PadrinoApp < Padrino::Application
|
|
42
35
|
via :test
|
43
36
|
render 'sample/foo_message'
|
44
37
|
end
|
38
|
+
|
39
|
+
message :helper do |name|
|
40
|
+
subject "Welcome Helper!"
|
41
|
+
to 'jim@fake.com'
|
42
|
+
from 'noreply@custom.com'
|
43
|
+
locals :name => name
|
44
|
+
via :test
|
45
|
+
render 'sample/helper_message'
|
46
|
+
end
|
47
|
+
|
45
48
|
end
|
46
49
|
|
47
50
|
post "/deliver/inline" do
|
@@ -63,6 +66,12 @@ class PadrinoApp < Padrino::Application
|
|
63
66
|
result = deliver(:sample, :welcome, "Bobby")
|
64
67
|
result ? "mail delivered" : 'mail not delivered'
|
65
68
|
end
|
69
|
+
|
70
|
+
post "/deliver/helper" do
|
71
|
+
result = deliver(:sample, :helper, "Jim")
|
72
|
+
result ? "mail delivered" : 'mail not delivered'
|
73
|
+
end
|
74
|
+
|
66
75
|
end
|
67
76
|
|
68
77
|
Padrino.mount("PadrinoApp").to("/")
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= link_to name, "#" %>
|
@@ -5,15 +5,7 @@ class SinatraApp < Sinatra::Base
|
|
5
5
|
register Padrino::Mailer
|
6
6
|
|
7
7
|
set :root, File.dirname(__FILE__)
|
8
|
-
set :delivery_method, :
|
9
|
-
:address => "smtp.gmail.com",
|
10
|
-
:port => 587,
|
11
|
-
:domain => 'your.host.name',
|
12
|
-
:user_name => '<username>',
|
13
|
-
:password => '<password>',
|
14
|
-
:authentication => 'plain',
|
15
|
-
:enable_starttls_auto => true
|
16
|
-
}
|
8
|
+
set :delivery_method, :test
|
17
9
|
|
18
10
|
mailer :sample do
|
19
11
|
email :birthday do |name, age|
|
data/test/helper.rb
CHANGED
data/test/test_email.rb
CHANGED
@@ -75,6 +75,7 @@ class TestEmail < Test::Unit::TestCase
|
|
75
75
|
mock_app do
|
76
76
|
register Padrino::Mailer
|
77
77
|
set :views, File.dirname(__FILE__) + '/fixtures/views'
|
78
|
+
set :delivery_method, :test
|
78
79
|
mailer :alternate do
|
79
80
|
defaults :from => 'padrino@from.com', :to => 'padrino@to.com'
|
80
81
|
email :foo do
|
@@ -98,6 +99,7 @@ class TestEmail < Test::Unit::TestCase
|
|
98
99
|
should 'send emails with app mailer defaults' do
|
99
100
|
mock_app do
|
100
101
|
register Padrino::Mailer
|
102
|
+
set :delivery_method, :test
|
101
103
|
set :views, File.dirname(__FILE__) + '/fixtures/views'
|
102
104
|
set :mailer_defaults, :from => 'padrino@from.com', :to => 'padrino@to.com', :subject => "This is a test"
|
103
105
|
mailer :alternate do
|
@@ -122,6 +124,7 @@ class TestEmail < Test::Unit::TestCase
|
|
122
124
|
mock_app do
|
123
125
|
register Padrino::Mailer
|
124
126
|
set :views, File.dirname(__FILE__) + '/fixtures/views'
|
127
|
+
set :delivery_method, :test
|
125
128
|
mailer :alternate do
|
126
129
|
email :foo do
|
127
130
|
from 'padrino@me.com'
|
@@ -155,4 +158,4 @@ class TestEmail < Test::Unit::TestCase
|
|
155
158
|
end
|
156
159
|
end
|
157
160
|
end
|
158
|
-
end
|
161
|
+
end
|
data/test/test_padrino_mailer.rb
CHANGED
@@ -82,5 +82,14 @@ class TestPadrinoMailer < Test::Unit::TestCase
|
|
82
82
|
assert_email_sent(:to => 'john@apple.com', :from => 'joe@smith.com',
|
83
83
|
:subject => 'Test Email', :body => 'Test Body', :delivery_method => @app.delivery_method)
|
84
84
|
end
|
85
|
+
|
86
|
+
should_eventually 'be able to deliver a basic email using Padrino::Helpers' do
|
87
|
+
post '/deliver/helper'
|
88
|
+
assert_equal 'mail delivered', body
|
89
|
+
assert_email_sent(:to => 'jim@fake.com', :from => 'noreply@custom.com',
|
90
|
+
:content_type => 'text/html', :delivery_method => @app.delivery_method,
|
91
|
+
:subject => "Welcome Helper!", :body => "<a href=\"#\">jim</a>")
|
92
|
+
end
|
93
|
+
|
85
94
|
end
|
86
|
-
end
|
95
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 37
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 15
|
10
|
+
version: 0.9.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Padrino Team
|
@@ -18,26 +18,28 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-
|
21
|
+
date: 2010-08-28 00:00:00 +02:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
|
+
name: padrino-core
|
26
|
+
prerelease: false
|
25
27
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
28
|
none: false
|
27
29
|
requirements:
|
28
30
|
- - "="
|
29
31
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
32
|
+
hash: 37
|
31
33
|
segments:
|
32
34
|
- 0
|
33
35
|
- 9
|
34
|
-
-
|
35
|
-
version: 0.9.
|
36
|
+
- 15
|
37
|
+
version: 0.9.15
|
36
38
|
type: :runtime
|
37
|
-
name: padrino-core
|
38
|
-
prerelease: false
|
39
39
|
version_requirements: *id001
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
+
name: mail
|
42
|
+
prerelease: false
|
41
43
|
requirement: &id002 !ruby/object:Gem::Requirement
|
42
44
|
none: false
|
43
45
|
requirements:
|
@@ -50,105 +52,7 @@ dependencies:
|
|
50
52
|
- 0
|
51
53
|
version: 2.2.0
|
52
54
|
type: :runtime
|
53
|
-
name: mail
|
54
|
-
prerelease: false
|
55
55
|
version_requirements: *id002
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
|
-
requirements:
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
hash: 49
|
63
|
-
segments:
|
64
|
-
- 0
|
65
|
-
- 8
|
66
|
-
- 7
|
67
|
-
version: 0.8.7
|
68
|
-
type: :development
|
69
|
-
name: rake
|
70
|
-
prerelease: false
|
71
|
-
version_requirements: *id003
|
72
|
-
- !ruby/object:Gem::Dependency
|
73
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
|
-
requirements:
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
hash: 43
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
- 9
|
82
|
-
- 8
|
83
|
-
version: 0.9.8
|
84
|
-
type: :development
|
85
|
-
name: mocha
|
86
|
-
prerelease: false
|
87
|
-
version_requirements: *id004
|
88
|
-
- !ruby/object:Gem::Dependency
|
89
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
|
-
requirements:
|
92
|
-
- - ">="
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
hash: 11
|
95
|
-
segments:
|
96
|
-
- 0
|
97
|
-
- 5
|
98
|
-
- 0
|
99
|
-
version: 0.5.0
|
100
|
-
type: :development
|
101
|
-
name: rack-test
|
102
|
-
prerelease: false
|
103
|
-
version_requirements: *id005
|
104
|
-
- !ruby/object:Gem::Dependency
|
105
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
hash: 9
|
111
|
-
segments:
|
112
|
-
- 0
|
113
|
-
- 5
|
114
|
-
- 1
|
115
|
-
version: 0.5.1
|
116
|
-
type: :development
|
117
|
-
name: webrat
|
118
|
-
prerelease: false
|
119
|
-
version_requirements: *id006
|
120
|
-
- !ruby/object:Gem::Dependency
|
121
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
|
-
requirements:
|
124
|
-
- - ">="
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
hash: 43
|
127
|
-
segments:
|
128
|
-
- 2
|
129
|
-
- 2
|
130
|
-
- 22
|
131
|
-
version: 2.2.22
|
132
|
-
type: :development
|
133
|
-
name: haml
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: *id007
|
136
|
-
- !ruby/object:Gem::Dependency
|
137
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
138
|
-
none: false
|
139
|
-
requirements:
|
140
|
-
- - ">="
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
hash: 33
|
143
|
-
segments:
|
144
|
-
- 2
|
145
|
-
- 10
|
146
|
-
- 3
|
147
|
-
version: 2.10.3
|
148
|
-
type: :development
|
149
|
-
name: shoulda
|
150
|
-
prerelease: false
|
151
|
-
version_requirements: *id008
|
152
56
|
description: Mailer system for padrino allowing easy delivery of application emails
|
153
57
|
email: padrinorb@gmail.com
|
154
58
|
executables: []
|
@@ -176,6 +80,7 @@ files:
|
|
176
80
|
- test/fixtures/padrino_app/views/mailers/sample/anniversary.erb
|
177
81
|
- test/fixtures/padrino_app/views/mailers/sample/birthday.erb
|
178
82
|
- test/fixtures/padrino_app/views/mailers/sample/foo_message.erb
|
83
|
+
- test/fixtures/padrino_app/views/mailers/sample/helper_message.erb
|
179
84
|
- test/fixtures/sinatra_app/app.rb
|
180
85
|
- test/fixtures/sinatra_app/views/mailers/demo/sample_mail.erb
|
181
86
|
- test/fixtures/sinatra_app/views/mailers/sample/anniversary.erb
|
@@ -195,7 +100,7 @@ files:
|
|
195
100
|
- test/test_padrino_mailer.rb
|
196
101
|
- test/test_part.rb
|
197
102
|
has_rdoc: true
|
198
|
-
homepage: http://
|
103
|
+
homepage: http://www.padrinorb.com
|
199
104
|
licenses: []
|
200
105
|
|
201
106
|
post_install_message:
|