Permalink
Browse files

Merge remote branch 'mainstream/master'

Conflicts:
	activerecord/lib/active_record/base.rb
	railties/lib/rails/configuration.rb
	railties/lib/rails/log_subscriber.rb
  • Loading branch information...
2 parents ef6462c + 1684655 commit e68bfaf1fe1a7890a67af6f444281185f507cf9e @lifo lifo committed Mar 12, 2010
Showing 361 changed files with 5,293 additions and 4,154 deletions.
View
@@ -1,3 +1,6 @@
+*.gem
+pkg
+.bundle
debug.log
doc/rdoc
activemodel/doc
@@ -16,6 +19,3 @@ railties/doc/guides/html/images
railties/doc/guides/html/stylesheets
railties/guides/output
railties/tmp
-bin
-.bundle
-pkg
View
@@ -1,6 +1,7 @@
path File.dirname(__FILE__)
-source 'http://gemcutter.org'
+source 'http://rubygems.org'
+gem "arel", :git => "git://github.com/rails/arel.git"
gem "rails", "3.0.0.beta1"
gem "rake", ">= 0.8.7"
@@ -14,14 +15,18 @@ end
gem "sqlite3-ruby", ">= 1.2.5", :require => 'sqlite3'
group :test do
- gem "pg", ">= 0.8.0"
+ gem "pg", ">= 0.9.0"
gem "mysql", ">= 2.8.1"
end
# AP
gem "rack-test", "0.5.3", :require => 'rack/test'
gem "RedCloth", ">= 4.2.2"
+group :documentation do
+ gem 'rdoc', '2.1'
+end
+
if ENV['CI']
gem "nokogiri", ">= 1.4.0"
View
@@ -0,0 +1 @@
+3.0.0.beta1
View
@@ -2,23 +2,17 @@ require 'rake'
require 'rake/rdoctask'
require 'rake/gempackagetask'
-env = %(PKG_BUILD="#{ENV['PKG_BUILD']}") if ENV['PKG_BUILD']
-
PROJECTS = %w(activesupport activemodel actionpack actionmailer activeresource activerecord railties)
-Dir["#{File.dirname(__FILE__)}/*/lib/*/version.rb"].each do |version_path|
- require version_path
-end
-
desc 'Run all tests by default'
task :default => %w(test test:isolated)
-%w(test test:isolated rdoc pgem package gem gemspec).each do |task_name|
+%w(test test:isolated rdoc package gem).each do |task_name|
desc "Run #{task_name} task for all projects"
task task_name do
errors = []
PROJECTS.each do |project|
- system(%(cd #{project} && #{env} #{$0} #{task_name})) || errors << project
+ system(%(cd #{project} && #{$0} #{task_name})) || errors << project
end
fail("Errors in #{errors.join(', ')}") unless errors.empty?
end
@@ -27,9 +21,9 @@ end
desc "Smoke-test all projects"
task :smoke do
(PROJECTS - %w(activerecord)).each do |project|
- system %(cd #{project} && #{env} #{$0} test:isolated)
+ system %(cd #{project} && #{$0} test:isolated)
end
- system %(cd activerecord && #{env} #{$0} sqlite3:isolated_test)
+ system %(cd activerecord && #{$0} sqlite3:isolated_test)
end
spec = eval(File.read('rails.gemspec'))
@@ -48,12 +42,14 @@ desc "Release all components to gemcutter."
task :release_projects => :package do
errors = []
PROJECTS.each do |project|
- system(%(cd #{project} && #{env} #{$0} release)) || errors << project
+ system(%(cd #{project} && #{$0} release)) || errors << project
end
fail("Errors in #{errors.join(', ')}") unless errors.empty?
end
+desc "Install gems for all projects."
task :install => :gem do
+ require File.expand_path("../actionpack/lib/action_pack/version", __FILE__)
(PROJECTS - ["railties"]).each do |project|
puts "INSTALLING #{project}"
system("gem install #{project}/pkg/#{project}-#{ActionPack::VERSION::STRING}.gem --no-ri --no-rdoc")
@@ -121,6 +117,34 @@ task :pdoc => :rdoc do
require 'rake/contrib/sshpublisher'
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/api", "doc/rdoc").upload
PROJECTS.each do |project|
- system %(cd #{project} && #{env} #{$0} pdoc)
+ system %(cd #{project} && #{$0} pdoc)
+ end
+end
+
+task :update_versions do
+ require File.dirname(__FILE__) + "/version"
+
+ File.open("RAILS_VERSION", "w") do |f|
+ f.write Rails::VERSION::STRING + "\n"
+ end
+
+ constants = {
+ "activesupport" => "ActiveSupport",
+ "activemodel" => "ActiveModel",
+ "actionpack" => "ActionPack",
+ "actionmailer" => "ActionMailer",
+ "activeresource" => "ActiveResource",
+ "activerecord" => "ActiveRecord",
+ "railties" => "Rails"
+ }
+
+ version_file = File.read("version.rb")
+
+ PROJECTS.each do |project|
+ Dir["#{project}/lib/*/version.rb"].each do |file|
+ File.open(file, "w") do |f|
+ f.write version_file.gsub(/Rails/, constants[project])
+ end
+ end
end
end
View
@@ -4,17 +4,6 @@ require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
-require File.join(File.dirname(__FILE__), 'lib', 'action_mailer', 'version')
-
-PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
-PKG_NAME = 'actionmailer'
-PKG_VERSION = ActionMailer::VERSION::STRING + PKG_BUILD
-PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
-
-RELEASE_NAME = "REL #{PKG_VERSION}"
-
-RUBY_FORGE_PROJECT = "actionmailer"
-RUBY_FORGE_USER = "webster132"
desc "Default Task"
task :default => [ :test ]
@@ -1,9 +1,11 @@
+version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip
+
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionmailer'
- s.version = '3.0.0.beta1'
- s.summary = 'Email composition, delivery, and recieval framework (part of Rails).'
- s.description = 'Email composition, delivery, and recieval framework (part of Rails).'
+ s.version = version
+ s.summary = 'Email composition, delivery, and receiving framework (part of Rails).'
+ s.description = 'Email on Rails. Compose, deliver, receive, and test emails using the familiar controller/view pattern. First-class support for multipart email and attachments.'
s.required_ruby_version = '>= 1.8.7'
s.author = 'David Heinemeier Hansson'
@@ -17,7 +19,7 @@ Gem::Specification.new do |s|
s.has_rdoc = true
- s.add_dependency('actionpack', '= 3.0.0.beta1')
- s.add_dependency('mail', '~> 2.1.2')
+ s.add_dependency('actionpack', version)
+ s.add_dependency('mail', '~> 2.1.3')
s.add_dependency('text-format', '~> 1.0.0')
end
@@ -34,6 +34,7 @@
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/string/inflections'
+require 'active_support/lazy_load_hooks'
module ActionMailer
extend ::ActiveSupport::Autoload
@@ -181,6 +181,18 @@ module ActionMailer #:nodoc:
# and the second being a <tt>application/pdf</tt> with a Base64 encoded copy of the file.pdf book
# with the filename +free_book.pdf+.
#
+ # = Observing and Intercepting Mails
+ #
+ # ActionMailer provides hooks into the Mail observer and interceptor methods. These allow you to
+ # register objects that are called during the mail delivery life cycle.
+ #
+ # An observer object must implement the <tt>:delivered_email(message)</tt> method which will be
+ # called once for every email sent after the email has been sent.
+ #
+ # An interceptor object must implement the <tt>:delivering_email(message)</tt> method which will be
+ # called before the email is sent, allowing you to make modifications to the email before it hits
+ # the delivery agents. Your object should make and needed modifications directly to the passed
+ # in Mail::Message instance.
#
# = Configuration options
#
@@ -255,16 +267,17 @@ class Base < AbstractController::Base
include AbstractController::Logger
include AbstractController::Rendering
- include AbstractController::LocalizedCache
include AbstractController::Layouts
include AbstractController::Helpers
include AbstractController::Translation
- include AbstractController::Compatibility
helper ActionMailer::MailHelper
include ActionMailer::OldApi
include ActionMailer::DeprecatedApi
+
+ delegate :register_observer, :to => Mail
+ delegate :register_interceptor, :to => Mail
private_class_method :new #:nodoc:
@@ -276,6 +289,8 @@ class Base < AbstractController::Base
:parts_order => [ "text/plain", "text/enriched", "text/html" ]
}.freeze
+ ActionMailer.run_base_hooks(self)
+
class << self
def mailer_name
@@ -452,10 +467,27 @@ def attachments
# field for the 'envelope from' value.
#
# If you do not pass a block to the +mail+ method, it will find all templates in the
- # template path that match the method name that it is being called from, it will then
- # create parts for each of these templates intelligently, making educated guesses
- # on correct content type and sequence, and return a fully prepared Mail::Message
- # ready to call <tt>:deliver</tt> on to send.
+ # view paths using by default the mailer name and the method name that it is being
+ # called from, it will then create parts for each of these templates intelligently,
+ # making educated guesses on correct content type and sequence, and return a fully
+ # prepared Mail::Message ready to call <tt>:deliver</tt> on to send.
+ #
+ # For example:
+ #
+ # class Notifier < ActionMailer::Base
+ # default :from => 'no-reply@test.lindsaar.net',
+ #
+ # def welcome
+ # mail(:to => 'mikel@test.lindsaar.net')
+ # end
+ # end
+ #
+ # Will look for all templates at "app/views/notifier" with name "welcome". However, those
+ # can be customized:
+ #
+ # mail(:template_path => 'notifications', :template_name => 'another')
+ #
+ # And now it will look for all templates at "app/views/notifications" with name "another".
#
# If you do pass a block, you can render specific templates of your choice:
#
@@ -493,7 +525,7 @@ def mail(headers={}, &block)
# Merge defaults from class
headers = headers.reverse_merge(self.class.default)
- charset = headers[:charset]
+ charset = headers.delete(:charset)
# Quote fields
headers[:subject] ||= default_i18n_subject
@@ -514,13 +546,11 @@ def mail(headers={}, &block)
end
# Set configure delivery behavior
- wrap_delivery_behavior!(headers[:delivery_method])
+ wrap_delivery_behavior!(headers.delete(:delivery_method))
- # Remove headers already treated and assign all others
- headers.except!(:subject, :to, :from, :cc, :bcc, :reply_to)
- headers.except!(:body, :parts_order, :content_type, :charset, :delivery_method)
+ # Remove any missing configuration header and assign all others
+ headers.except!(:parts_order, :content_type)
headers.each { |k, v| m[k] = v }
-
m
end
@@ -548,12 +578,12 @@ def default_i18n_subject #:nodoc:
# TODO: Move this into Mail
def quote_fields!(headers, charset) #:nodoc:
m = @_message
- m.subject ||= quote_if_necessary(headers[:subject], charset) if headers[:subject]
- m.to ||= quote_address_if_necessary(headers[:to], charset) if headers[:to]
- m.from ||= quote_address_if_necessary(headers[:from], charset) if headers[:from]
- m.cc ||= quote_address_if_necessary(headers[:cc], charset) if headers[:cc]
- m.bcc ||= quote_address_if_necessary(headers[:bcc], charset) if headers[:bcc]
- m.reply_to ||= quote_address_if_necessary(headers[:reply_to], charset) if headers[:reply_to]
+ m.subject ||= quote_if_necessary(headers.delete(:subject), charset) if headers[:subject]
+ m.to ||= quote_address_if_necessary(headers.delete(:to), charset) if headers[:to]
+ m.from ||= quote_address_if_necessary(headers.delete(:from), charset) if headers[:from]
+ m.cc ||= quote_address_if_necessary(headers.delete(:cc), charset) if headers[:cc]
+ m.bcc ||= quote_address_if_necessary(headers.delete(:bcc), charset) if headers[:bcc]
+ m.reply_to ||= quote_address_if_necessary(headers.delete(:reply_to), charset) if headers[:reply_to]
end
def collect_responses_and_parts_order(headers) #:nodoc:
@@ -566,13 +596,16 @@ def collect_responses_and_parts_order(headers) #:nodoc:
responses = collector.responses
elsif headers[:body]
responses << {
- :body => headers[:body],
+ :body => headers.delete(:body),
:content_type => self.class.default[:content_type] || "text/plain"
}
else
- each_template do |template|
+ templates_path = headers.delete(:template_path) || self.class.mailer_name
+ templates_name = headers.delete(:template_name) || action_name
+
+ each_template(templates_path, templates_name) do |template|
responses << {
- :body => render_to_body(:_template => template),
+ :body => render(:_template => template),
:content_type => template.mime_type.to_s
}
end
@@ -581,10 +614,10 @@ def collect_responses_and_parts_order(headers) #:nodoc:
[responses, parts_order]
end
- def each_template(&block) #:nodoc:
- self.class.view_paths.each do |load_paths|
- templates = load_paths.find_all(action_name, {}, self.class.mailer_name)
- templates = templates.uniq_by { |t| t.details[:formats] }
+ def each_template(paths, name, &block) #:nodoc:
+ Array(paths).each do |path|
+ templates = lookup_context.find_all(name, path)
+ templates = templates.uniq_by { |t| t.formats }
unless templates.empty?
templates.each(&block)
@@ -206,8 +206,8 @@ def create_parts
if String === @body
@parts.unshift create_inline_part(@body)
elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ }
- self.class.view_paths.first.find_all(@template, {}, @mailer_name).each do |template|
- @parts << create_inline_part(render_to_body(:_template => template), template.mime_type)
+ lookup_context.find_all(@template, @mailer_name).each do |template|
+ @parts << create_inline_part(render(:_template => template), template.mime_type)
end
if @parts.size > 1
@@ -22,7 +22,7 @@ def quoted_printable_encode(character)
# A quick-and-dirty regexp for determining whether a string contains any
# characters that need escaping.
if !defined?(CHARS_NEEDING_QUOTING)
- CHARS_NEEDING_QUOTING = /[\000-\011\013\014\016-\037\177-\377]/
+ CHARS_NEEDING_QUOTING = Regexp.new('[\000-\011\013\014\016-\037\177-\377]', nil, 'n')
end
# Quote the given text if it contains any "illegal" characters
@@ -6,19 +6,21 @@ class Railtie < Rails::Railtie
railtie_name :action_mailer
initializer "action_mailer.url_for", :before => :load_environment_config do |app|
- ActionMailer::Base.send(:include, ActionController::UrlFor) if defined?(ActionController)
+ ActionMailer.base_hook { include app.routes.url_helpers }
end
- require "action_mailer/railties/subscriber"
- subscriber ActionMailer::Railties::Subscriber.new
+ require "action_mailer/railties/log_subscriber"
+ log_subscriber ActionMailer::Railties::LogSubscriber.new
initializer "action_mailer.logger" do
- ActionMailer::Base.logger ||= Rails.logger
+ ActionMailer.base_hook { self.logger ||= Rails.logger }
end
initializer "action_mailer.set_configs" do |app|
- app.config.action_mailer.each do |k,v|
- ActionMailer::Base.send "#{k}=", v
+ ActionMailer.base_hook do
+ app.config.action_mailer.each do |k,v|
+ send "#{k}=", v
+ end
end
end
end
Oops, something went wrong.

0 comments on commit e68bfaf

Please sign in to comment.