padrino-mailer 0.11.3 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4999c3dcec320d0c662c16b4090d00dd5e9ced37
4
+ data.tar.gz: cb78ad0c60e2dd5c708f2eeb0b4dc9f531e1905d
5
+ SHA512:
6
+ metadata.gz: 8f35233554b45bc32089ef1d7024c8a3f1f115d72d11041907dedbcd0f61943f56f269e3edcdf332491a97efa0b644b5952305da2829f432fb8048a98346ae98
7
+ data.tar.gz: b2b7be9ea7403e1c3aea64809e0fa7cc44b6410b3766c43126293da22cce10b396004e517903543728c81b2281dd7543a8e9ab91e5f42570db42d05ab305c44c
data/README.rdoc CHANGED
@@ -102,4 +102,4 @@ The mailer also supports the attachment of files and various other options. Be s
102
102
 
103
103
  == Copyright
104
104
 
105
- Copyright (c) Padrino. See LICENSE for details.
105
+ Copyright (c) 2011-2013 Padrino. See LICENSE for details.
@@ -7,7 +7,8 @@ require 'padrino-core/support_lite' unless defined?(SupportLite)
7
7
 
8
8
  module Padrino
9
9
  ##
10
- # This component uses the +mail+ library to create a powerful but simple mailer within Padrino (and Sinatra).
10
+ # This component uses the +mail+ library to create a powerful but simple
11
+ # mailer within Padrino (and Sinatra).
11
12
  # There is full support for using plain or html content-types as well as for file attachments.
12
13
  #
13
14
  # Using the mailer in Padrino has two forms. The 'quick' method requires only use
@@ -23,8 +24,6 @@ module Padrino
23
24
  # end
24
25
  # end
25
26
  #
26
- # For a more detailed guide, please read the {Padrino Mailer}[http://www.padrinorb.com/guides/padrino-mailer] guide.
27
- #
28
27
  module Mailer
29
28
  class << self
30
29
  ##
@@ -38,7 +37,6 @@ module Padrino
38
37
  # register Padrino::Mailer::Helpers
39
38
  # end
40
39
  #
41
- # @api public
42
40
  def registered(app)
43
41
  require 'padrino-mailer/base'
44
42
  require 'padrino-mailer/helpers'
@@ -53,5 +51,5 @@ module Padrino
53
51
  end
54
52
  alias :included :registered
55
53
  end
56
- end # Mailer
57
- end # Padrino
54
+ end
55
+ end
@@ -41,11 +41,10 @@ module Padrino
41
41
  #
42
42
  # deliver(:sample, :registration, "Bob", "21")
43
43
  #
44
- # For a more detailed guide, please read the {Padrino Mailer}[http://www.padrinorb.com/guides/padrino-mailer] guide.
45
- #
46
44
  class Base
47
45
  attr_accessor :delivery_settings, :app, :mailer_name, :messages
48
46
 
47
+ ##
49
48
  # Constructs a +Mailer+ base object with specified options.
50
49
  #
51
50
  # @param [Sinatra::Application] app
@@ -56,7 +55,6 @@ module Padrino
56
55
  # The +email+ definitions block.
57
56
  #
58
57
  # @see Padrino::Mailer::Helpers::ClassMethods#mailer
59
- # @api private
60
58
  def initialize(app, name, &block)
61
59
  @mailer_name = name
62
60
  @messages = {}
@@ -65,7 +63,8 @@ module Padrino
65
63
  instance_eval(&block)
66
64
  end
67
65
 
68
- # Defines a mailer object allowing the definition of various email messages that can be delivered.
66
+ # Defines a mailer object allowing the definition of various email
67
+ # messages that can be delivered.
69
68
  #
70
69
  # @param [Symbol] name
71
70
  # The name of this email message.
@@ -81,7 +80,6 @@ module Padrino
81
80
  # render 'birthday'
82
81
  # end
83
82
  #
84
- # @api public
85
83
  def email(name, &block)
86
84
  raise "The email '#{name}' is already defined" if self.messages[name].present?
87
85
  self.messages[name] = Proc.new { |*attrs|
@@ -94,7 +92,8 @@ module Padrino
94
92
  end
95
93
  alias :message :email
96
94
 
97
- # Defines the default attributes for a message in this mailer (including app-wide defaults).
95
+ # Defines the default attributes for a message in this mailer
96
+ # (including app-wide defaults).
98
97
  #
99
98
  # @param [Hash] attributes
100
99
  # The hash of message options to use as default.
@@ -105,7 +104,6 @@ module Padrino
105
104
  # email(:foo) do; end
106
105
  # end
107
106
  #
108
- # @api public
109
107
  def defaults(attributes=nil)
110
108
  if attributes.nil? # Retrieve the default values
111
109
  @app.respond_to?(:mailer_defaults) ? @app.mailer_defaults.merge(@defaults) : @defaults
@@ -113,6 +111,6 @@ module Padrino
113
111
  @defaults = attributes
114
112
  end
115
113
  end
116
- end # Base
117
- end # Mailer
118
- end # Padrino
114
+ end
115
+ end
116
+ end
@@ -12,23 +12,22 @@ module Mail # @private
12
12
  settings.views = File.join(app.views, 'mailers')
13
13
  settings.reload_templates = app.reload_templates?
14
14
  else
15
- # Set a default view for this class
16
15
  settings.views = File.expand_path("./mailers")
17
16
  settings.reload_templates = true
18
17
  end
19
18
 
20
19
  initialize_template_settings!
21
20
 
22
- # Run the original initialize
23
21
  initialize_without_app(*args, &block)
24
22
  end
25
23
  alias_method_chain :initialize, :app
26
24
 
25
+ ##
27
26
  # Setup like in Sinatra/Padrino apps content_type and template lookup.
28
27
  #
29
28
  # @example
30
- # # This add a email plain part if a template called bar.plain.* is found
31
- # # and a html part if a template called bar.html.* is found
29
+ # # This add an email plain part if a template called bar.plain.* is found
30
+ # # and a HTML part if a template called bar.html.* is found
32
31
  # email do
33
32
  # from 'from@email.com'
34
33
  # to 'to@email.com'
@@ -45,6 +44,7 @@ module Mail # @private
45
44
  end
46
45
  end
47
46
 
47
+ ##
48
48
  # Helper to add a text part to a multipart/alternative email. If this and
49
49
  # html_part are both defined in a message, then it will be a multipart/alternative
50
50
  # message and set itself that way.
@@ -60,7 +60,8 @@ module Mail # @private
60
60
  &block)
61
61
  end
62
62
 
63
- # Helper to add a html part to a multipart/alternative email. If this and
63
+ ##
64
+ # Helper to add a HTML part to a multipart/alternative email. If this and
64
65
  # text_part are both defined in a message, then it will be a multipart/alternative
65
66
  # message and set itself that way.
66
67
  #
@@ -87,6 +88,7 @@ module Mail # @private
87
88
  end
88
89
  end
89
90
 
91
+ ##
90
92
  # Allows you to add a part in block form to an existing mail message object.
91
93
  #
92
94
  # @example
@@ -114,12 +116,14 @@ module Mail # @private
114
116
  end
115
117
  alias_method_chain :do_delivery, :logging if Padrino.respond_to?(:logger)
116
118
 
119
+ ##
117
120
  # Sinatra and Padrino compatibility.
118
121
  #
119
122
  def settings
120
123
  self.class
121
124
  end
122
125
 
126
+ ##
123
127
  # Sets the message defined template path to the given view path.
124
128
  #
125
129
  def views(value)
@@ -133,48 +137,56 @@ module Mail # @private
133
137
  @_locals = value
134
138
  end
135
139
 
140
+ ##
136
141
  # Returns the templates for this message.
137
142
  #
138
143
  def self.templates
139
144
  @_templates ||= {}
140
145
  end
141
146
 
147
+ ##
142
148
  # Sets the message defined template path to the given view path.
143
149
  #
144
150
  def self.views=(value)
145
151
  @_views = value
146
152
  end
147
153
 
154
+ ##
148
155
  # Returns the template view path defined for this message.
149
156
  #
150
157
  def self.views
151
158
  @_views
152
159
  end
153
160
 
161
+ ##
154
162
  # Modify whether templates should be reloaded (for development).
155
163
  #
156
164
  def self.reload_templates=(value)
157
165
  @_reload_templates = value
158
166
  end
159
167
 
168
+ ##
160
169
  # Returns true if the templates will be reloaded; false otherwise.
161
170
  #
162
171
  def self.reload_templates?
163
172
  @_reload_templates
164
173
  end
165
174
 
175
+ ##
166
176
  # Return the path of this file, only for compatibility with Sinatra rendering methods.
167
177
  #
168
178
  def self.caller_locations
169
179
  [[File.dirname(__FILE__), 1]]
170
180
  end
171
181
 
182
+ ##
172
183
  # Return the default encoding.
173
184
  #
174
185
  def self.default_encoding
175
186
  "utf-8"
176
187
  end
177
188
 
189
+ ##
178
190
  # Modify the default attributes for this message (if not explicitly specified).
179
191
  #
180
192
  def defaults=(attributes)
@@ -182,6 +194,7 @@ module Mail # @private
182
194
  @_defaults.each_pair { |k, v| default(k.to_sym, v) } if @_defaults.is_a?(Hash)
183
195
  end
184
196
 
197
+ ##
185
198
  # Check if we can log.
186
199
  #
187
200
  def self.logging?
@@ -192,7 +205,9 @@ module Mail # @private
192
205
  @_logging = value
193
206
  end
194
207
 
195
- # Shortcut for delivery_method with smarter SMTP overwrites
208
+ ##
209
+ # Shortcut for delivery_method with smarter SMTP overwrites.
210
+ #
196
211
  def via(method = nil, settings = {})
197
212
  if method.nil?
198
213
  delivery_method
@@ -203,6 +218,7 @@ module Mail # @private
203
218
  end
204
219
  end
205
220
 
221
+ ##
206
222
  # If the value is empty return a symbol that represent the content type so:
207
223
  #
208
224
  # "text/plain" => :plain
@@ -218,10 +234,11 @@ module Mail # @private
218
234
 
219
235
  private
220
236
 
237
+ ##
221
238
  # Defines the render for the mailer utilizing the padrino 'rendering' module
239
+ #
222
240
  def render(engine, data=nil, options={}, locals={}, &block)
223
241
  locals = @_locals if options[:locals].blank? && locals.blank?
224
- # Reload templates
225
242
  @template_cache.clear if settings.reload_templates?
226
243
 
227
244
  provides.each do |format|
@@ -235,11 +252,13 @@ module Mail # @private
235
252
  self.body = super(engine, data, options, locals, &block) if provides.empty?
236
253
  end
237
254
 
255
+ ##
238
256
  # Register all special template configurations Padrino has to our fake settings object.
257
+ #
239
258
  def initialize_template_settings!
240
259
  Padrino::Rendering.engine_configurations.each do |name, value|
241
260
  settings.class.instance_eval { define_method(name) { value } }
242
261
  end
243
262
  end
244
- end # Message
245
- end # Mail
263
+ end
264
+ end
@@ -8,6 +8,7 @@ module Padrino
8
8
  base.extend(ClassMethods)
9
9
  end
10
10
 
11
+ ##
11
12
  # Delivers an email with the given mail attributes.
12
13
  #
13
14
  # @param [Hash] mail_attributes
@@ -25,11 +26,11 @@ module Padrino
25
26
  # end
26
27
  #
27
28
  # @see ClassMethods#email
28
- # @api public
29
29
  def email(mail_attributes={}, &block)
30
30
  settings.email(mail_attributes, &block)
31
31
  end
32
32
 
33
+ ##
33
34
  # Delivers a mailer message email with the given attributes.
34
35
  #
35
36
  # @param [Symbol] mailer_name
@@ -44,27 +45,29 @@ module Padrino
44
45
  # deliver(:example, :message, "John")
45
46
  #
46
47
  # @see ClassMethods#deliver
47
- # @api public
48
48
  def deliver(mailer_name, message_name, *attributes)
49
49
  settings.deliver(mailer_name, message_name, *attributes)
50
50
  end
51
51
 
52
- # Class methods responsible for registering mailers, configuring settings and delivering messages.
52
+ # Class methods responsible for registering mailers, configuring
53
+ # settings and delivering messages.
53
54
  #
54
55
  module ClassMethods
55
- def inherited(subclass) # @private
56
+ def inherited(subclass)
56
57
  @_registered_mailers ||= {}
57
58
  super(subclass)
58
59
  end
59
60
 
61
+ ##
60
62
  # Returns all registered mailers for this application.
61
63
  #
62
- # @private
63
64
  def registered_mailers
64
65
  @_registered_mailers ||= {}
65
66
  end
66
67
 
67
- # Defines a mailer object allowing the definition of various email messages that can be delivered.
68
+ ##
69
+ # Defines a mailer object allowing the definition of various
70
+ # email messages that can be delivered.
68
71
  #
69
72
  # @param [Symbol] name
70
73
  # The name of the mailer to initialize.
@@ -80,7 +83,6 @@ module Padrino
80
83
  # end
81
84
  # end
82
85
  #
83
- # @api public
84
86
  def mailer(name, &block)
85
87
  mailer = Padrino::Mailer::Base.new(self, name, &block)
86
88
  mailer.delivery_settings = delivery_settings
@@ -89,6 +91,7 @@ module Padrino
89
91
  end
90
92
  alias :mailers :mailer
91
93
 
94
+ ##
92
95
  # Delivers a mailer message email with the given attributes.
93
96
  #
94
97
  # @param [Symbol] mailer_name
@@ -102,17 +105,17 @@ module Padrino
102
105
  # deliver(:sample, :birthday, "Joey", 21)
103
106
  # deliver(:example, :message, "John")
104
107
  #
105
- # @api public
106
108
  def deliver(mailer_name, message_name, *attributes)
107
109
  message = registered_mailers[mailer_name].messages[message_name].call(*attributes)
108
110
  message.delivery_method(*delivery_settings)
109
111
  message.deliver
110
112
  end
111
113
 
114
+ ##
112
115
  # Delivers an email with the given mail attributes with specified and default settings.
113
116
  #
114
117
  # @param [Hash] mail_attributes
115
- # The attributes for this message (to, from, subject, cc, bcc, body, etc).
118
+ # The attributes for this message (to, from, subject, cc, bcc, body, etc.).
116
119
  # @param [Proc] block
117
120
  # The block mail attributes for this message.
118
121
  #
@@ -128,7 +131,6 @@ module Padrino
128
131
  # body 'path/to/my/template', :locals => { :a => a, :b => b }
129
132
  # end
130
133
  #
131
- # @api public
132
134
  def email(mail_attributes={}, &block)
133
135
  message = _padrino_mailer::Message.new(self)
134
136
  message.delivery_method(*delivery_settings)
@@ -139,6 +141,7 @@ module Padrino
139
141
  end
140
142
 
141
143
  private
144
+ ##
142
145
  # Returns the parsed delivery method options.
143
146
  #
144
147
  def delivery_settings
@@ -151,6 +154,6 @@ module Padrino
151
154
  end
152
155
  end
153
156
  end
154
- end # Helpers
155
- end # Mailer
156
- end # Padrino
157
+ end
158
+ end
159
+ end
@@ -1,13 +1,13 @@
1
1
  module Padrino
2
2
  module Mailer
3
-
3
+ ##
4
4
  # Handles MIME type declarations for mail delivery.
5
5
  #
6
6
  module Mime
7
-
7
+ ##
8
8
  # Returns Symbol with mime type if found, otherwise use +fallback+.
9
9
  # +mime+ should be the content type like "text/plain"
10
- # +fallback+ may be any symbol
10
+ # +fallback+ may be any symbol.
11
11
  #
12
12
  # Also see the documentation for {MIME_TYPES}.
13
13
  #
@@ -30,6 +30,7 @@ module Padrino
30
30
  MIME_TYPES.fetch(mime.to_s.downcase, fallback)
31
31
  end
32
32
 
33
+ ##
33
34
  # List of common mime-types, selected from various sources
34
35
  # according to their usefulness for an email scope.
35
36
  #
@@ -42,6 +43,6 @@ module Padrino
42
43
  "text/plain" => :plain,
43
44
  "text/xml" => :xml
44
45
  }
45
- end # Mime
46
- end # Mailer
47
- end # Padrino
46
+ end
47
+ end
48
+ end
data/test/test_email.rb CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/helper')
2
2
 
3
3
  describe "Email" do
4
4
 
5
- context 'the mailer in a app' do
5
+ context 'the mailer in an app' do
6
6
  should 'send a basic inline email' do
7
7
  mock_app do
8
8
  register Padrino::Mailer
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
5
- prerelease:
4
+ version: 0.11.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Padrino Team
@@ -12,28 +11,25 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-07-29 00:00:00.000000000 Z
14
+ date: 2013-09-24 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: padrino-core
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
20
  - - '='
23
21
  - !ruby/object:Gem::Version
24
- version: 0.11.3
22
+ version: 0.11.4
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
27
  - - '='
31
28
  - !ruby/object:Gem::Version
32
- version: 0.11.3
29
+ version: 0.11.4
33
30
  - !ruby/object:Gem::Dependency
34
31
  name: mail
35
32
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
33
  requirements:
38
34
  - - ~>
39
35
  - !ruby/object:Gem::Version
@@ -41,7 +37,6 @@ dependencies:
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
41
  - - ~>
47
42
  - !ruby/object:Gem::Version
@@ -93,28 +88,27 @@ files:
93
88
  - test/test_part.rb
94
89
  homepage: http://www.padrinorb.com
95
90
  licenses: []
91
+ metadata: {}
96
92
  post_install_message:
97
93
  rdoc_options:
98
94
  - --charset=UTF-8
99
95
  require_paths:
100
96
  - lib
101
97
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
98
  requirements:
104
- - - ! '>='
99
+ - - '>='
105
100
  - !ruby/object:Gem::Version
106
101
  version: '0'
107
102
  required_rubygems_version: !ruby/object:Gem::Requirement
108
- none: false
109
103
  requirements:
110
- - - ! '>='
104
+ - - '>='
111
105
  - !ruby/object:Gem::Version
112
106
  version: 1.3.6
113
107
  requirements: []
114
108
  rubyforge_project: padrino-mailer
115
- rubygems_version: 1.8.25
109
+ rubygems_version: 2.0.6
116
110
  signing_key:
117
- specification_version: 3
111
+ specification_version: 4
118
112
  summary: Mailer system for padrino
119
113
  test_files:
120
114
  - test/fixtures/basic.erb