actionmailer 3.0.20 → 3.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionmailer might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,78 +1,14 @@
1
- ## Rails 3.0.20 (unreleased)
1
+ *Rails 3.1.0 (unreleased)*
2
2
 
3
- ## Rails 3.0.19 (Jan 8, 2013)
3
+ * No changes
4
4
 
5
- * No changes.
6
-
7
- ## Rails 3.0.18 (Jan 2, 2013)
8
-
9
- * No changes.
10
-
11
- ## Rails 3.0.17 (Aug 9, 2012)
12
-
13
- * No changes.
14
-
15
- ## Rails 3.0.16 (Jul 26, 2012)
16
-
17
- * No changes.
18
-
19
- ## Rails 3.0.14 (Jun 12, 2012)
20
-
21
- * No changes.
22
-
23
- * Rails 3.0.13 (May 31, 2012)
24
-
25
- * No changes.
26
-
27
- *Rails 3.0.10 (August 16, 2011)*
28
-
29
- *No changes.
30
-
31
-
32
- *Rails 3.0.9 (June 16, 2011)*
33
-
34
- *No changes.
35
-
36
-
37
- *Rails 3.0.8 (June 7, 2011)*
38
-
39
- * Mail dependency increased to 2.2.19
40
-
41
-
42
- *Rails 3.0.7 (April 18, 2011)*
43
-
44
- * remove AM delegating register_observer and register_interceptor to Mail [Josh Kalderimis]
45
-
46
-
47
- *Rails 3.0.6 (April 5, 2011)
48
-
49
- * Don't allow i18n to change the minor version, version now set to ~> 0.5.0 [Santiago Pastorino]
50
-
51
-
52
- *Rails 3.0.5 (February 26, 2011)*
53
-
54
- * No changes.
55
-
56
-
57
- *Rails 3.0.4 (February 8, 2011)*
58
-
59
- * No changes.
60
-
61
-
62
- *Rails 3.0.3 (November 16, 2010)*
63
-
64
- * No changes.
65
-
66
-
67
- *Rails 3.0.2 (November 15, 2010)*
68
-
69
- * No changes.
5
+ *Rails 3.0.2 (unreleased)*
70
6
 
7
+ * No changes
71
8
 
72
9
  *Rails 3.0.1 (October 15, 2010)*
73
10
 
74
- * No Changes.
75
-
11
+ * No Changes, just a version bump.
76
12
 
77
13
  *Rails 3.0.0 (August 29, 2010)*
78
14
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2010 David Heinemeier Hansson
1
+ Copyright (c) 2004-2011 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -32,7 +32,7 @@ This can be as simple as:
32
32
  end
33
33
 
34
34
  The body of the email is created by using an Action View template (regular
35
- ERb) that has the instance variables that are declared in the mailer action.
35
+ ERB) that has the instance variables that are declared in the mailer action.
36
36
 
37
37
  So the corresponding body template for the method above could look like this:
38
38
 
@@ -59,7 +59,7 @@ generated would look like this:
59
59
 
60
60
  Mr. david@loudthinking.com
61
61
 
62
- In previous version of rails you would call <tt>create_method_name</tt> and
62
+ In previous version of Rails you would call <tt>create_method_name</tt> and
63
63
  <tt>deliver_method_name</tt>. Rails 3.0 has a much simpler interface, you
64
64
  simply call the method and optionally call +deliver+ on the return value.
65
65
 
@@ -72,12 +72,25 @@ Or you can just chain the methods together like:
72
72
 
73
73
  Notifier.welcome.deliver # Creates the email and sends it immediately
74
74
 
75
+ == Setting defaults
76
+
77
+ It is possible to set default values that will be used in every method in your Action Mailer class. To implement this functionality, you just call the public class method <tt>default</tt> which you get for free from ActionMailer::Base. This method accepts a Hash as the parameter. You can use any of the headers e-mail messages has, like <tt>:from</tt> as the key. You can also pass in a string as the key, like "Content-Type", but Action Mailer does this out of the box for you, so you wont need to worry about that. Finally it is also possible to pass in a Proc that will get evaluated when it is needed.
78
+
79
+ Note that every value you set with this method will get over written if you use the same key in your mailer method.
80
+
81
+ Example:
82
+
83
+ class Authenticationmailer < ActionMailer::Base
84
+ default :from => "awesome@application.com", :subject => Proc.new { "E-mail was generated at #{Time.now}" }
85
+ .....
86
+ end
87
+
75
88
  == Receiving emails
76
89
 
77
- To receive emails, you need to implement a public instance method called <tt>receive</tt> that takes a
78
- tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
90
+ To receive emails, you need to implement a public instance method called <tt>receive</tt> that takes an
91
+ email object as its single parameter. The Action Mailer framework has a corresponding class method,
79
92
  which is also called <tt>receive</tt>, that accepts a raw, unprocessed email as a string, which it then turns
80
- into the tmail object and calls the receive instance method.
93
+ into the email object and calls the receive instance method.
81
94
 
82
95
  Example:
83
96
 
@@ -104,7 +117,7 @@ trivial case like this:
104
117
  rails runner 'Mailman.receive(STDIN.read)'
105
118
 
106
119
  However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
107
- instance of Rails should be run within a daemon if it is going to be utilized to process more than just
120
+ instance of Rails should be run within a daemon, if it is going to be utilized to process more than just
108
121
  a limited number of email.
109
122
 
110
123
  == Configuration
@@ -128,7 +141,7 @@ The latest version of Action Mailer can be installed with Rubygems:
128
141
 
129
142
  Source code can be downloaded as part of the Rails project on GitHub
130
143
 
131
- * http://github.com/rails/rails/tree/master/actionmailer/
144
+ * https://github.com/rails/rails/tree/master/actionmailer/
132
145
 
133
146
 
134
147
  == License
@@ -145,3 +158,4 @@ API documentation is at
145
158
  Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
146
159
 
147
160
  * https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets
161
+
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004-2010 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2011 David Heinemeier Hansson
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -44,7 +44,6 @@ module ActionMailer
44
44
  autoload :Collector
45
45
  autoload :Base
46
46
  autoload :DeliveryMethods
47
- autoload :DeprecatedApi
48
47
  autoload :MailHelper
49
48
  autoload :OldApi
50
49
  autoload :TestCase
@@ -1,26 +1,28 @@
1
1
  module ActionMailer
2
2
  module AdvAttrAccessor #:nodoc:
3
- def adv_attr_accessor(*names)
4
- names.each do |name|
5
- ivar = "@#{name}"
3
+ def adv_attr_accessor(name, deprecation=nil)
4
+ ivar = "@#{name}"
5
+ deprecation ||= "Please pass :#{name} as hash key to mail() instead"
6
6
 
7
- class_eval <<-ACCESSORS, __FILE__, __LINE__ + 1
8
- def #{name}=(value)
9
- #{ivar} = value
10
- end
7
+ class_eval <<-ACCESSORS, __FILE__, __LINE__ + 1
8
+ def #{name}=(value)
9
+ ActiveSupport::Deprecation.warn "#{name}= is deprecated. #{deprecation}"
10
+ #{ivar} = value
11
+ end
11
12
 
12
- def #{name}(*args)
13
- raise ArgumentError, "expected 0 or 1 parameters" unless args.length <= 1
14
- if args.empty?
15
- #{ivar} if instance_variable_names.include?(#{ivar.inspect})
16
- else
17
- #{ivar} = args.first
18
- end
13
+ def #{name}(*args)
14
+ raise ArgumentError, "expected 0 or 1 parameters" unless args.length <= 1
15
+ if args.empty?
16
+ ActiveSupport::Deprecation.warn "#{name}() is deprecated and will be removed in future versions."
17
+ #{ivar} if instance_variable_names.include?(#{ivar.inspect})
18
+ else
19
+ ActiveSupport::Deprecation.warn "#{name}(value) is deprecated. #{deprecation}"
20
+ #{ivar} = args.first
19
21
  end
20
- ACCESSORS
22
+ end
23
+ ACCESSORS
21
24
 
22
- self.protected_instance_variables << ivar if self.respond_to?(:protected_instance_variables)
23
- end
25
+ self.protected_instance_variables << ivar if self.respond_to?(:protected_instance_variables)
24
26
  end
25
27
  end
26
28
  end
@@ -5,6 +5,7 @@ require 'active_support/core_ext/array/wrap'
5
5
  require 'active_support/core_ext/object/blank'
6
6
  require 'active_support/core_ext/proc'
7
7
  require 'active_support/core_ext/string/inflections'
8
+ require 'active_support/core_ext/hash/except'
8
9
  require 'action_mailer/log_subscriber'
9
10
 
10
11
  module ActionMailer #:nodoc:
@@ -223,7 +224,7 @@ module ActionMailer #:nodoc:
223
224
  #
224
225
  # An interceptor object must implement the <tt>:delivering_email(message)</tt> method which will be
225
226
  # called before the email is sent, allowing you to make modifications to the email before it hits
226
- # the delivery agents. Your object should make and needed modifications directly to the passed
227
+ # the delivery agents. Your object should make any needed modifications directly to the passed
227
228
  # in Mail::Message instance.
228
229
  #
229
230
  # = Default Hash
@@ -247,7 +248,7 @@ module ActionMailer #:nodoc:
247
248
  # but Action Mailer translates them appropriately and sets the correct values.
248
249
  #
249
250
  # As you can pass in any header, you need to either quote the header as a string, or pass it in as
250
- # an underscorised symbol, so the following will work:
251
+ # an underscored symbol, so the following will work:
251
252
  #
252
253
  # class Notifier < ActionMailer::Base
253
254
  # default 'Content-Transfer-Encoding' => '7bit',
@@ -292,14 +293,18 @@ module ActionMailer #:nodoc:
292
293
  # * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the
293
294
  # authentication type here.
294
295
  # This is a symbol and one of <tt>:plain</tt> (will send the password in the clear), <tt>:login</tt> (will
295
- # send password BASE64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
296
+ # send password Base64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
296
297
  # information and a cryptographic Message Digest 5 algorithm to hash important information)
297
298
  # * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server
298
299
  # and starts to use it.
300
+ # * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is
301
+ # really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name
302
+ # of an OpenSSL verify constant ('none', 'peer', 'client_once','fail_if_no_peer_cert') or directly the
303
+ # constant (OpenSSL::SSL::VERIFY_NONE, OpenSSL::SSL::VERIFY_PEER,...).
299
304
  #
300
305
  # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
301
306
  # * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
302
- # * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt> with <tt>-f sender@addres</tt>
307
+ # * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt> with <tt>-f sender@address</tt>
303
308
  # added automatically before the message is sent.
304
309
  #
305
310
  # * <tt>file_settings</tt> - Allows you to override options for the <tt>:file</tt> delivery method.
@@ -344,10 +349,11 @@ module ActionMailer #:nodoc:
344
349
  include AbstractController::Translation
345
350
  include AbstractController::AssetPaths
346
351
 
347
- helper ActionMailer::MailHelper
352
+ cattr_reader :protected_instance_variables
353
+ @@protected_instance_variables = []
348
354
 
355
+ helper ActionMailer::MailHelper
349
356
  include ActionMailer::OldApi
350
- include ActionMailer::DeprecatedApi
351
357
 
352
358
  private_class_method :new #:nodoc:
353
359
 
@@ -427,14 +433,14 @@ module ActionMailer #:nodoc:
427
433
  end
428
434
  end
429
435
 
430
- def respond_to?(method, *args) #:nodoc:
436
+ def respond_to?(method, include_private = false) #:nodoc:
431
437
  super || action_methods.include?(method.to_s)
432
438
  end
433
439
 
434
440
  protected
435
441
 
436
442
  def set_payload_for_mail(payload, mail) #:nodoc:
437
- payload[:mailer] = self.name
443
+ payload[:mailer] = name
438
444
  payload[:message_id] = mail.message_id
439
445
  payload[:subject] = mail.subject
440
446
  payload[:to] = mail.to
@@ -446,11 +452,8 @@ module ActionMailer #:nodoc:
446
452
  end
447
453
 
448
454
  def method_missing(method, *args) #:nodoc:
449
- if action_methods.include?(method.to_s)
450
- new(method, *args).message
451
- else
452
- super
453
- end
455
+ return super unless respond_to?(method)
456
+ new(method, *args).message
454
457
  end
455
458
  end
456
459
 
@@ -471,31 +474,8 @@ module ActionMailer #:nodoc:
471
474
  super
472
475
  end
473
476
 
474
- class DeprecatedHeaderProxy < ActiveSupport::BasicObject
475
- def initialize(message)
476
- @message = message
477
- end
478
-
479
- def []=(key, value)
480
- unless value.is_a?(::String)
481
- ::ActiveSupport::Deprecation.warn("Using a non-String object for a header's value is deprecated. " \
482
- "You specified #{value.inspect} (a #{value.class}) for #{key}", caller)
483
-
484
- value = value.to_s
485
- end
486
-
487
- @message[key] = value
488
- end
489
-
490
- def headers(hash = {})
491
- hash.each_pair do |k,v|
492
- self[k] = v
493
- end
494
- end
495
-
496
- def method_missing(meth, *args, &block)
497
- @message.send(meth, *args, &block)
498
- end
477
+ def mailer_name
478
+ self.class.mailer_name
499
479
  end
500
480
 
501
481
  # Allows you to pass random and unusual headers to the new +Mail::Message+ object
@@ -514,9 +494,9 @@ module ActionMailer #:nodoc:
514
494
  # X-Special-Domain-Specific-Header: SecretValue
515
495
  def headers(args=nil)
516
496
  if args
517
- DeprecatedHeaderProxy.new(@_message).headers(args)
497
+ @_message.headers(args)
518
498
  else
519
- DeprecatedHeaderProxy.new(@_message)
499
+ @_message
520
500
  end
521
501
  end
522
502
 
@@ -706,6 +686,9 @@ module ActionMailer #:nodoc:
706
686
  end
707
687
  end
708
688
 
689
+ # Translates the +subject+ using Rails I18n class under <tt>[:actionmailer, mailer_scope, action_name]</tt> scope.
690
+ # If it does not find a translation for the +subject+ under the specified scope it will default to a
691
+ # humanized version of the <tt>action_name</tt>.
709
692
  def default_i18n_subject #:nodoc:
710
693
  mailer_scope = self.class.mailer_name.gsub('/', '.')
711
694
  I18n.t(:subject, :scope => [mailer_scope, action_name], :default => action_name.humanize)
@@ -742,15 +725,8 @@ module ActionMailer #:nodoc:
742
725
  end
743
726
 
744
727
  def each_template(paths, name, &block) #:nodoc:
745
- Array.wrap(paths).each do |path|
746
- templates = lookup_context.find_all(name, path)
747
- templates = templates.uniq_by { |t| t.formats }
748
-
749
- unless templates.empty?
750
- templates.each(&block)
751
- return
752
- end
753
- end
728
+ templates = lookup_context.find_all(name, Array.wrap(paths))
729
+ templates.uniq_by { |t| t.formats }.each(&block)
754
730
  end
755
731
 
756
732
  def create_parts_from_responses(m, responses) #:nodoc:
@@ -772,28 +748,6 @@ module ActionMailer #:nodoc:
772
748
  container.add_part(part)
773
749
  end
774
750
 
775
- module DeprecatedUrlOptions
776
- def default_url_options
777
- deprecated_url_options
778
- end
779
-
780
- def default_url_options=(val)
781
- deprecated_url_options
782
- end
783
-
784
- def deprecated_url_options
785
- raise "You can no longer call ActionMailer::Base.default_url_options " \
786
- "directly. You need to set config.action_mailer.default_url_options. " \
787
- "If you are using ActionMailer standalone, you need to include the " \
788
- "routing url_helpers directly."
789
- end
790
- end
791
-
792
- # This module will complain if the user tries to set default_url_options
793
- # directly instead of through the config object. In Action Mailer's Railtie,
794
- # we include the router's url_helpers, which will override this module.
795
- extend DeprecatedUrlOptions
796
-
797
751
  ActiveSupport.run_load_hooks(:action_mailer, self)
798
752
  end
799
753
  end
@@ -4,7 +4,7 @@ module ActionMailer
4
4
  # each line, and wrapped at 72 columns.
5
5
  def block_format(text)
6
6
  formatted = text.split(/\n\r\n/).collect { |paragraph|
7
- simple_format(paragraph)
7
+ format_paragraph(paragraph)
8
8
  }.join("\n")
9
9
 
10
10
  # Make list points stand on their own line
@@ -29,8 +29,15 @@ module ActionMailer
29
29
  @_message.attachments
30
30
  end
31
31
 
32
- private
33
- def simple_format(text, len = 72, indent = 2)
32
+ # Returns +text+ wrapped at +len+ columns and indented +indent+ spaces.
33
+ #
34
+ # === Examples
35
+ #
36
+ # my_text = "Here is a sample text with more than 40 characters"
37
+ #
38
+ # format_paragraph(my_text, 25, 4)
39
+ # # => " Here is a sample text with\n more than 40 characters"
40
+ def format_paragraph(text, len = 72, indent = 2)
34
41
  sentences = [[]]
35
42
 
36
43
  text.split.each do |word|
@@ -8,9 +8,7 @@ module ActionMailer
8
8
 
9
9
  included do
10
10
  extend ActionMailer::AdvAttrAccessor
11
-
12
- @@protected_instance_variables = %w(@parts)
13
- cattr_reader :protected_instance_variables
11
+ self.protected_instance_variables.concat %w(@parts @mail_was_called)
14
12
 
15
13
  # Specify the BCC addresses for the message
16
14
  adv_attr_accessor :bcc
@@ -42,11 +40,11 @@ module ActionMailer
42
40
 
43
41
  # The recipient addresses for the message, either as a string (for a single
44
42
  # address) or an array (for multiple addresses).
45
- adv_attr_accessor :recipients
43
+ adv_attr_accessor :recipients, "Please pass :to as hash key to mail() instead"
46
44
 
47
45
  # The date on which the message was sent. If not set (the default), the
48
46
  # header will be set by the delivery agent.
49
- adv_attr_accessor :sent_on
47
+ adv_attr_accessor :sent_on, "Please pass :date as hash key to mail() instead"
50
48
 
51
49
  # Specify the subject of the message.
52
50
  adv_attr_accessor :subject
@@ -54,20 +52,12 @@ module ActionMailer
54
52
  # Specify the template name to use for current message. This is the "base"
55
53
  # template name, without the extension or directory, and may be used to
56
54
  # have multiple mailer methods share the same template.
57
- adv_attr_accessor :template
58
-
59
- # Override the mailer name, which defaults to an inflected version of the
60
- # mailer's class name. If you want to use a template in a non-standard
61
- # location, you can use this to specify that location.
62
- adv_attr_accessor :mailer_name
55
+ adv_attr_accessor :template, "Please pass :template_name or :template_path as hash key to mail() instead"
63
56
 
64
57
  # Define the body of the message. This is either a Hash (in which case it
65
58
  # specifies the variables to pass to the template when it is rendered),
66
59
  # or a string, in which case it specifies the actual text of the message.
67
60
  adv_attr_accessor :body
68
-
69
- # Alias controller_path to mailer_name so render :partial in views work.
70
- alias :controller_path :mailer_name
71
61
  end
72
62
 
73
63
  def process(method_name, *args)
@@ -84,6 +74,8 @@ module ActionMailer
84
74
  # part itself is yielded to the block so that other properties (charset,
85
75
  # body, headers, etc.) can be set on it.
86
76
  def part(params)
77
+ ActiveSupport::Deprecation.warn "part() is deprecated and will be removed in future versions. " <<
78
+ "Please pass a block to mail() instead."
87
79
  params = {:content_type => params} if String === params
88
80
 
89
81
  if custom_headers = params.delete(:headers)
@@ -99,6 +91,8 @@ module ActionMailer
99
91
  # Add an attachment to a multipart message. This is simply a part with the
100
92
  # content-disposition set to "attachment".
101
93
  def attachment(params, &block)
94
+ ActiveSupport::Deprecation.warn "attachment() is deprecated and will be removed in future versions. " <<
95
+ "Please use the attachments[] API instead."
102
96
  params = { :content_type => params } if String === params
103
97
 
104
98
  params[:content] ||= params.delete(:data) || params.delete(:body)
@@ -148,11 +142,11 @@ module ActionMailer
148
142
  def create_mail
149
143
  m = @_message
150
144
 
151
- set_fields!({:subject => subject, :to => recipients, :from => from,
152
- :bcc => bcc, :cc => cc, :reply_to => reply_to}, charset)
145
+ set_fields!({:subject => @subject, :to => @recipients, :from => @from,
146
+ :bcc => @bcc, :cc => @cc, :reply_to => @reply_to}, @charset)
153
147
 
154
- m.mime_version = mime_version unless mime_version.nil?
155
- m.date = sent_on.to_time rescue sent_on if sent_on
148
+ m.mime_version = @mime_version if @mime_version
149
+ m.date = @sent_on.to_time rescue @sent_on if @sent_on
156
150
 
157
151
  @headers.each { |k, v| m[k] = v }
158
152
 
@@ -191,6 +185,8 @@ module ActionMailer
191
185
  @implicit_parts_order ||= self.class.default[:parts_order].try(:dup)
192
186
  @mime_version ||= self.class.default[:mime_version].try(:dup)
193
187
 
188
+ @cc, @bcc, @reply_to, @subject, @from, @recipients = nil, nil, nil, nil, nil, nil
189
+
194
190
  @mailer_name ||= self.class.mailer_name.dup
195
191
  @template ||= method_name
196
192
  @mail_was_called = false
@@ -205,7 +201,7 @@ module ActionMailer
205
201
  if String === @body
206
202
  @parts.unshift create_inline_part(@body)
207
203
  elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ }
208
- lookup_context.find_all(@template, @mailer_name).each do |template|
204
+ lookup_context.find_all(@template, [@mailer_name]).each do |template|
209
205
  self.formats = template.formats
210
206
  @parts << create_inline_part(render(:template => template), template.mime_type)
211
207
  end
@@ -216,7 +212,7 @@ module ActionMailer
216
212
 
217
213
  # If this is a multipart e-mail add the mime_version if it is not
218
214
  # already set.
219
- @mime_version ||= "1.0" if !@parts.empty?
215
+ @mime_version ||= "1.0" unless @parts.empty?
220
216
  end
221
217
  end
222
218
 
@@ -246,13 +242,13 @@ module ActionMailer
246
242
  ct.to_s.split("/")
247
243
  end
248
244
 
249
- def parse_content_type(defaults=nil)
245
+ def parse_content_type
250
246
  if @content_type.blank?
251
247
  [ nil, {} ]
252
248
  else
253
249
  ctype, *attrs = @content_type.split(/;\s*/)
254
- attrs = attrs.inject({}) { |h,s| k,v = s.split(/\=/, 2); h[k] = v; h }
255
- [ctype, {"charset" => @charset}.merge(attrs)]
250
+ attrs = Hash[attrs.map { |attr| attr.split(/=/, 2) }]
251
+ [ctype, {"charset" => @charset}.merge!(attrs)]
256
252
  end
257
253
  end
258
254
  end
@@ -1,5 +1,6 @@
1
1
  require "action_mailer"
2
2
  require "rails"
3
+ require "abstract_controller/railties/routes_helpers"
3
4
 
4
5
  module ActionMailer
5
6
  class Railtie < Rails::Railtie
@@ -13,12 +14,18 @@ module ActionMailer
13
14
  paths = app.config.paths
14
15
  options = app.config.action_mailer
15
16
 
16
- options.assets_dir ||= paths.public.to_a.first
17
- options.javascripts_dir ||= paths.public.javascripts.to_a.first
18
- options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
17
+ options.assets_dir ||= paths["public"].first
18
+ options.javascripts_dir ||= paths["public/javascripts"].first
19
+ options.stylesheets_dir ||= paths["public/stylesheets"].first
20
+
21
+ # make sure readers methods get compiled
22
+ options.asset_path ||= app.config.asset_path
23
+ options.asset_host ||= app.config.asset_host
19
24
 
20
25
  ActiveSupport.on_load(:action_mailer) do
21
- include app.routes.url_helpers
26
+ include AbstractController::UrlFor
27
+ extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
28
+ include app.routes.mounted_helpers
22
29
 
23
30
  register_interceptors(options.delete(:interceptors))
24
31
  register_observers(options.delete(:observers))
@@ -26,5 +33,11 @@ module ActionMailer
26
33
  options.each { |k,v| send("#{k}=", v) }
27
34
  end
28
35
  end
36
+
37
+ initializer "action_mailer.compile_config_methods" do
38
+ ActiveSupport.on_load(:action_mailer) do
39
+ config.compile_methods! if config.respond_to?(:compile_methods!)
40
+ end
41
+ end
29
42
  end
30
- end
43
+ end
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/class/attribute'
2
+
1
3
  module ActionMailer
2
4
  class NonInferrableMailerError < ::StandardError
3
5
  def initialize(name)
@@ -15,11 +17,11 @@ module ActionMailer
15
17
 
16
18
  module ClassMethods
17
19
  def tests(mailer)
18
- write_inheritable_attribute(:mailer_class, mailer)
20
+ self._mailer_class = mailer
19
21
  end
20
22
 
21
23
  def mailer_class
22
- if mailer = read_inheritable_attribute(:mailer_class)
24
+ if mailer = self._mailer_class
23
25
  mailer
24
26
  else
25
27
  tests determine_default_mailer(name)
@@ -65,6 +67,7 @@ module ActionMailer
65
67
  end
66
68
 
67
69
  included do
70
+ class_attribute :_mailer_class
68
71
  setup :initialize_test_deliveries
69
72
  setup :set_expected_mail
70
73
  end
@@ -2,16 +2,18 @@ module Mail
2
2
  class Message
3
3
 
4
4
  def set_content_type(*args)
5
- ActiveSupport::Deprecation.warn('Message#set_content_type is deprecated, please just call ' <<
6
- 'Message#content_type with the same arguments', caller[0,2])
5
+ message = 'Message#set_content_type is deprecated, please just call ' <<
6
+ 'Message#content_type with the same arguments'
7
+ ActiveSupport::Deprecation.warn(message, caller[0,2])
7
8
  content_type(*args)
8
9
  end
9
10
 
10
11
  alias :old_transfer_encoding :transfer_encoding
11
12
  def transfer_encoding(value = nil)
12
13
  if value
13
- ActiveSupport::Deprecation.warn('Message#transfer_encoding is deprecated, please call ' <<
14
- 'Message#content_transfer_encoding with the same arguments', caller[0,2])
14
+ message = 'Message#transfer_encoding is deprecated, ' <<
15
+ 'please call Message#content_transfer_encoding with the same arguments'
16
+ ActiveSupport::Deprecation.warn(message, caller[0,2])
15
17
  content_transfer_encoding(value)
16
18
  else
17
19
  old_transfer_encoding
@@ -19,16 +21,17 @@ module Mail
19
21
  end
20
22
 
21
23
  def transfer_encoding=(value)
22
- ActiveSupport::Deprecation.warn('Message#transfer_encoding= is deprecated, please call ' <<
23
- 'Message#content_transfer_encoding= with the same arguments', caller[0,2])
24
+ message = 'Message#transfer_encoding= is deprecated, ' <<
25
+ 'please call Message#content_transfer_encoding= with the same arguments'
26
+ ActiveSupport::Deprecation.warn(message, caller[0,2])
24
27
  self.content_transfer_encoding = value
25
28
  end
26
29
 
27
30
  def original_filename
28
- ActiveSupport::Deprecation.warn('Message#original_filename is deprecated, ' <<
29
- 'please call Message#filename', caller[0,2])
31
+ message = 'Message#original_filename is deprecated, please call Message#filename'
32
+ ActiveSupport::Deprecation.warn(message, caller[0,2])
30
33
  filename
31
34
  end
32
35
 
33
36
  end
34
- end
37
+ end
@@ -1,9 +1,9 @@
1
1
  module ActionMailer
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
- MINOR = 0
5
- TINY = 20
6
- PRE = nil
4
+ MINOR = 1
5
+ TINY = 0
6
+ PRE = "beta1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
@@ -1,4 +1,5 @@
1
1
  Description:
2
+ ============
2
3
  Stubs out a new mailer and its views. Pass the mailer name, either
3
4
  CamelCased or under_scored, and an optional list of emails as arguments.
4
5
 
@@ -6,10 +7,12 @@ Description:
6
7
  engine and test framework generators.
7
8
 
8
9
  Example:
9
- `rails generate mailer Notifications signup forgot_password invoice`
10
+ ========
11
+ rails generate mailer Notifications signup forgot_password invoice
10
12
 
11
13
  creates a Notifications mailer class, views, test, and fixtures:
12
14
  Mailer: app/mailers/notifications.rb
13
15
  Views: app/views/notifications/signup.erb [...]
14
16
  Test: test/functional/notifications_test.rb
15
17
  Fixtures: test/fixtures/notifications/signup [...]
18
+
@@ -1,3 +1,4 @@
1
+ <% module_namespacing do -%>
1
2
  class <%= class_name %> < ActionMailer::Base
2
3
  default :from => "from@example.com"
3
4
  <% for action in actions -%>
@@ -14,3 +15,4 @@ class <%= class_name %> < ActionMailer::Base
14
15
  end
15
16
  <% end -%>
16
17
  end
18
+ <% end -%>
metadata CHANGED
@@ -1,50 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: actionmailer
3
- version: !ruby/object:Gem::Version
4
- version: 3.0.20
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 6
5
+ version: 3.1.0.beta1
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - David Heinemeier Hansson
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-01-28 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2011-05-04 00:00:00 -05:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
14
17
  name: actionpack
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 3.0.20
20
- type: :runtime
21
18
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 3.0.20
27
- - !ruby/object:Gem::Dependency
28
- name: mail
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 2.2.19
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - "="
23
+ - !ruby/object:Gem::Version
24
+ version: 3.1.0.beta1
34
25
  type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: mail
35
29
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 2.2.19
41
- description: Email on Rails. Compose, deliver, receive, and test emails using the
42
- familiar controller/view pattern. First-class support for multipart email and attachments.
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 2.3.0
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description: Email on Rails. Compose, deliver, receive, and test emails using the familiar controller/view pattern. First-class support for multipart email and attachments.
43
39
  email: david@loudthinking.com
44
40
  executables: []
41
+
45
42
  extensions: []
43
+
46
44
  extra_rdoc_files: []
47
- files:
45
+
46
+ files:
48
47
  - CHANGELOG
49
48
  - README.rdoc
50
49
  - MIT-LICENSE
@@ -52,7 +51,6 @@ files:
52
51
  - lib/action_mailer/base.rb
53
52
  - lib/action_mailer/collector.rb
54
53
  - lib/action_mailer/delivery_methods.rb
55
- - lib/action_mailer/deprecated_api.rb
56
54
  - lib/action_mailer/log_subscriber.rb
57
55
  - lib/action_mailer/mail_helper.rb
58
56
  - lib/action_mailer/old_api.rb
@@ -65,28 +63,33 @@ files:
65
63
  - lib/rails/generators/mailer/mailer_generator.rb
66
64
  - lib/rails/generators/mailer/templates/mailer.rb
67
65
  - lib/rails/generators/mailer/USAGE
66
+ has_rdoc: true
68
67
  homepage: http://www.rubyonrails.org
69
68
  licenses: []
70
- metadata: {}
69
+
71
70
  post_install_message:
72
71
  rdoc_options: []
73
- require_paths:
72
+
73
+ require_paths:
74
74
  - lib
75
- required_ruby_version: !ruby/object:Gem::Requirement
76
- requirements:
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
77
78
  - - ">="
78
- - !ruby/object:Gem::Version
79
+ - !ruby/object:Gem::Version
79
80
  version: 1.8.7
80
- required_rubygems_version: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: '0'
85
- requirements:
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">"
85
+ - !ruby/object:Gem::Version
86
+ version: 1.3.1
87
+ requirements:
86
88
  - none
87
89
  rubyforge_project: actionmailer
88
- rubygems_version: 2.0.0.preview3.1
90
+ rubygems_version: 1.6.2
89
91
  signing_key:
90
- specification_version: 4
92
+ specification_version: 3
91
93
  summary: Email composition, delivery, and receiving framework (part of Rails).
92
94
  test_files: []
95
+
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e5710a05e9d6795ebb565f2a232b5cadeb2501c5
4
- data.tar.gz: 5beee97e19b15559708e6237d05522e7e79d3843
5
- SHA512:
6
- metadata.gz: b8d55551d2fb046ee9bf2f0cd91cfed4fc87132b9c4d179e57e535bd0c32b8798b5e04d78c23e16c7b48258c61b6f0633560c9be9f4403254d69e6d68cb05fa5
7
- data.tar.gz: 05624d9359a911ad62823ce4a9ce5d7f52c0e7f1ad0d4f44f2b73ac732e40c30da0e89147e17a4fe532150424cb333d3dd52e40852485d933850cc16541dc6e9
@@ -1,147 +0,0 @@
1
- require 'active_support/core_ext/object/try'
2
-
3
- module ActionMailer
4
- # This is the API which is deprecated and is going to be removed on Rails 3.1 release.
5
- # Part of the old API will be deprecated after 3.1, for a smoother deprecation process.
6
- # Check those in OldApi instead.
7
- module DeprecatedApi #:nodoc:
8
- extend ActiveSupport::Concern
9
-
10
- included do
11
- [:charset, :content_type, :mime_version, :implicit_parts_order].each do |method|
12
- class_eval <<-FILE, __FILE__, __LINE__ + 1
13
- def self.default_#{method}
14
- @@default_#{method}
15
- end
16
-
17
- def self.default_#{method}=(value)
18
- ActiveSupport::Deprecation.warn "ActionMailer::Base.default_#{method}=value is deprecated, " <<
19
- "use default :#{method} => value instead"
20
- @@default_#{method} = value
21
- end
22
-
23
- @@default_#{method} = nil
24
- FILE
25
- end
26
- end
27
-
28
- module ClassMethods
29
- # Deliver the given mail object directly. This can be used to deliver
30
- # a preconstructed mail object, like:
31
- #
32
- # email = MyMailer.create_some_mail(parameters)
33
- # email.set_some_obscure_header "frobnicate"
34
- # MyMailer.deliver(email)
35
- def deliver(mail, show_warning=true)
36
- if show_warning
37
- ActiveSupport::Deprecation.warn "#{self}.deliver is deprecated, call " <<
38
- "deliver in the mailer instance instead", caller[0,2]
39
- end
40
-
41
- raise "no mail object available for delivery!" unless mail
42
- wrap_delivery_behavior(mail)
43
- mail.deliver
44
- mail
45
- end
46
-
47
- def template_root
48
- self.view_paths && self.view_paths.first
49
- end
50
-
51
- def template_root=(root)
52
- ActiveSupport::Deprecation.warn "template_root= is deprecated, use prepend_view_path instead", caller[0,2]
53
- self.view_paths = ActionView::Base.process_view_paths(root)
54
- end
55
-
56
- def respond_to?(method_symbol, include_private = false)
57
- matches_dynamic_method?(method_symbol) || super
58
- end
59
-
60
- def method_missing(method_symbol, *parameters)
61
- if match = matches_dynamic_method?(method_symbol)
62
- case match[1]
63
- when 'create'
64
- ActiveSupport::Deprecation.warn "#{self}.create_#{match[2]} is deprecated, " <<
65
- "use #{self}.#{match[2]} instead", caller[0,2]
66
- new(match[2], *parameters).message
67
- when 'deliver'
68
- ActiveSupport::Deprecation.warn "#{self}.deliver_#{match[2]} is deprecated, " <<
69
- "use #{self}.#{match[2]}.deliver instead", caller[0,2]
70
- new(match[2], *parameters).message.deliver
71
- else super
72
- end
73
- else
74
- super
75
- end
76
- end
77
-
78
- private
79
-
80
- def matches_dynamic_method?(method_name)
81
- method_name = method_name.to_s
82
- /^(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name)
83
- end
84
- end
85
-
86
- # Delivers a Mail object. By default, it delivers the cached mail
87
- # object (from the <tt>create!</tt> method). If no cached mail object exists, and
88
- # no alternate has been given as the parameter, this will fail.
89
- def deliver!(mail = @_message)
90
- ActiveSupport::Deprecation.warn "Calling deliver in the AM::Base object is deprecated, " <<
91
- "please call deliver in the Mail instance", caller[0,2]
92
- self.class.deliver(mail, false)
93
- end
94
- alias :deliver :deliver!
95
-
96
- def render(*args)
97
- options = args.last.is_a?(Hash) ? args.last : {}
98
-
99
- if file = options[:file] and !file.index("/")
100
- ActiveSupport::Deprecation.warn("render :file is deprecated except for absolute paths. " \
101
- "Please use render :template instead")
102
- options[:prefix] = _prefix
103
- end
104
-
105
- if options[:body].is_a?(Hash)
106
- ActiveSupport::Deprecation.warn(':body in render deprecated. Please use instance ' <<
107
- 'variables as assigns instead', caller[0,1])
108
-
109
- options[:body].each { |k,v| instance_variable_set(:"@#{k}", v) }
110
- end
111
- super
112
- end
113
-
114
- # Render a message but does not set it as mail body. Useful for rendering
115
- # data for part and attachments.
116
- #
117
- # Examples:
118
- #
119
- # render_message "special_message"
120
- # render_message :template => "special_message"
121
- # render_message :inline => "<%= 'Hi!' %>"
122
- #
123
- def render_message(*args)
124
- ActiveSupport::Deprecation.warn "render_message is deprecated, use render instead", caller[0,2]
125
- render(*args)
126
- end
127
-
128
- private
129
-
130
- def initialize_defaults(*)
131
- @charset ||= self.class.default_charset.try(:dup)
132
- @content_type ||= self.class.default_content_type.try(:dup)
133
- @implicit_parts_order ||= self.class.default_implicit_parts_order.try(:dup)
134
- @mime_version ||= self.class.default_mime_version.try(:dup)
135
- super
136
- end
137
-
138
- def create_parts
139
- if @body.is_a?(Hash) && !@body.empty?
140
- ActiveSupport::Deprecation.warn "Giving a hash to body is deprecated, please use instance variables instead", caller[0,2]
141
- @body.each { |k, v| instance_variable_set(:"@#{k}", v) }
142
- end
143
- super
144
- end
145
-
146
- end
147
- end