diff options
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/Rakefile | 27 | ||||
-rw-r--r-- | actionmailer/actionmailer.gemspec | 20 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 120 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/helpers.rb | 2 | ||||
-rw-r--r-- | actionmailer/lib/actionmailer.rb | 1 |
5 files changed, 86 insertions, 84 deletions
diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index ebcca0d246..a756f35ee8 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -46,39 +46,14 @@ Rake::RDocTask.new { |rdoc| rdoc.rdoc_files.include('lib/action_mailer/*.rb') } +spec = eval(File.read('actionmailer.gemspec')) -# Create compressed packages -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = PKG_NAME - s.summary = "Service layer for easy email delivery and testing." - s.description = %q{Makes it trivial to test and deliver emails sent from a single service layer.} - s.version = PKG_VERSION - - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.rubyforge_project = "actionmailer" - s.homepage = "http://www.rubyonrails.org" - - s.add_dependency('actionpack', '= 3.0.pre' + PKG_BUILD) - - s.has_rdoc = true - s.requirements << 'none' - s.require_path = 'lib' - s.autorequire = 'action_mailer' - - s.files = [ "Rakefile", "install.rb", "README", "CHANGELOG", "MIT-LICENSE" ] - s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) } - s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) } -end - Rake::GemPackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = true p.need_zip = true end - desc "Publish the API documentation" task :pgem => [:package] do require 'rake/contrib/sshpublisher' diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec new file mode 100644 index 0000000000..efe50c4f84 --- /dev/null +++ b/actionmailer/actionmailer.gemspec @@ -0,0 +1,20 @@ +Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY + s.name = 'actionmailer' + s.summary = "Service layer for easy email delivery and testing." + s.description = %q{Makes it trivial to test and deliver emails sent from a single service layer.} + s.version = '3.0.pre' + + s.author = "David Heinemeier Hansson" + s.email = "david@loudthinking.com" + s.rubyforge_project = "actionmailer" + s.homepage = "http://www.rubyonrails.org" + + s.add_dependency('actionpack', '= 3.0.pre') + + s.files = Dir['CHANGELOG', 'README', 'MIT-LICENSE', 'lib/**/*'] + s.has_rdoc = true + s.requirements << 'none' + s.require_path = 'lib' + s.autorequire = 'action_mailer' +end diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 5ecefe7c09..b3005c2e5e 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -256,6 +256,8 @@ module ActionMailer #:nodoc: # +implicit_parts_order+. class Base include AdvAttrAccessor, PartContainer, Quoting, Utils + extend AbstractController::RenderingController + if Object.const_defined?(:ActionController) include ActionController::UrlWriter include ActionController::Layout @@ -479,58 +481,62 @@ module ActionMailer #:nodoc: # Initialize the mailer via the given +method_name+. The body will be # rendered and a new TMail::Mail object created. def create!(method_name, *parameters) #:nodoc: - initialize_defaults(method_name) - __send__(method_name, *parameters) - - # If an explicit, textual body has not been set, we check assumptions. - unless String === @body - # First, we look to see if there are any likely templates that match, - # which include the content-type in their file name (i.e., - # "the_template_file.text.html.erb", etc.). Only do this if parts - # have not already been specified manually. - # if @parts.empty? - template_root.find_all_by_parts(@template, {}, template_path).each do |template| - @parts << Part.new( - :content_type => template.mime_type ? template.mime_type.to_s : "text/plain", - :disposition => "inline", - :charset => charset, - :body => render_template(template, @body) - ) - end - - if @parts.size > 1 - @content_type = "multipart/alternative" if @content_type !~ /^multipart/ - @parts = sort_parts(@parts, @implicit_parts_order) - end - # end - - # Then, if there were such templates, we check to see if we ought to - # also render a "normal" template (without the content type). If a - # normal template exists (or if there were no implicit parts) we render - # it. - # ==== - # TODO: Revisit this - # template_exists = @parts.empty? - # template_exists ||= template_root.find("#{mailer_name}/#{@template}") - # @body = render_message(@template, @body) if template_exists - - # Finally, if there are other message parts and a textual body exists, - # we shift it onto the front of the parts and set the body to nil (so - # that create_mail doesn't try to render it in addition to the parts). - # ==== - # TODO: Revisit this - # if !@parts.empty? && String === @body - # @parts.unshift Part.new(:charset => charset, :body => @body) - # @body = nil - # end - end + ActiveSupport::Orchestra.instrument(:create_mail, :name => method_name) do + initialize_defaults(method_name) + __send__(method_name, *parameters) + + # If an explicit, textual body has not been set, we check assumptions. + unless String === @body + # First, we look to see if there are any likely templates that match, + # which include the content-type in their file name (i.e., + # "the_template_file.text.html.erb", etc.). Only do this if parts + # have not already been specified manually. + # if @parts.empty? + template_root.find_all(@template, {}, template_path).each do |template| + @parts << Part.new( + :content_type => template.mime_type ? template.mime_type.to_s : "text/plain", + :disposition => "inline", + :charset => charset, + :body => render_template(template, @body) + ) + end + + if @parts.size > 1 + @content_type = "multipart/alternative" if @content_type !~ /^multipart/ + @parts = sort_parts(@parts, @implicit_parts_order) + end + # end + + # Then, if there were such templates, we check to see if we ought to + # also render a "normal" template (without the content type). If a + # normal template exists (or if there were no implicit parts) we render + # it. + # ==== + # TODO: Revisit this + # template_exists = @parts.empty? + # template_exists ||= template_root.find("#{mailer_name}/#{@template}") + # @body = render_message(@template, @body) if template_exists + + # Finally, if there are other message parts and a textual body exists, + # we shift it onto the front of the parts and set the body to nil (so + # that create_mail doesn't try to render it in addition to the parts). + # ==== + # TODO: Revisit this + # if !@parts.empty? && String === @body + # @parts.unshift Part.new(:charset => charset, :body => @body) + # @body = nil + # end + end + + # If this is a multipart e-mail add the mime_version if it is not + # already set. + @mime_version ||= "1.0" if !@parts.empty? - # If this is a multipart e-mail add the mime_version if it is not - # already set. - @mime_version ||= "1.0" if !@parts.empty? + # build the mail object itself + @mail = create_mail + end - # build the mail object itself - @mail = create_mail + @mail end # Delivers a TMail::Mail object. By default, it delivers the cached mail @@ -538,19 +544,21 @@ module ActionMailer #:nodoc: # no alternate has been given as the parameter, this will fail. def deliver!(mail = @mail) raise "no mail object available for delivery!" unless mail - + unless logger.nil? logger.info "Sent mail to #{Array(recipients).join(', ')}" logger.debug "\n#{mail.encoded}" end - begin - __send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries - rescue Exception => e # Net::SMTP errors or sendmail pipe errors - raise e if raise_delivery_errors + ActiveSupport::Orchestra.instrument(:deliver_mail, :mail => @mail) do + begin + __send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries + rescue Exception => e # Net::SMTP errors or sendmail pipe errors + raise e if raise_delivery_errors + end end - return mail + mail end private diff --git a/actionmailer/lib/action_mailer/helpers.rb b/actionmailer/lib/action_mailer/helpers.rb index 1bb8682315..ecd8f0f5b6 100644 --- a/actionmailer/lib/action_mailer/helpers.rb +++ b/actionmailer/lib/action_mailer/helpers.rb @@ -106,7 +106,7 @@ module ActionMailer private # Extend the template class instance with our controller's helper module. def initialize_template_class_with_helper(assigns) - returning(template = initialize_template_class_without_helper(assigns)) do + initialize_template_class_without_helper(assigns).tap do |template| template.extend self.class.master_helper_module end end diff --git a/actionmailer/lib/actionmailer.rb b/actionmailer/lib/actionmailer.rb deleted file mode 100644 index 506416292c..0000000000 --- a/actionmailer/lib/actionmailer.rb +++ /dev/null @@ -1 +0,0 @@ -require 'action_mailer' |