Permalink
Browse files

Merge commit 'rails/master'

  • Loading branch information...
2 parents 5f9540e + 420004e commit 29457a21c0d4451f5dbc66f72b8256baa02a55bd @miloops miloops committed Oct 2, 2009
Showing 414 changed files with 1,675 additions and 1,485 deletions.
View
@@ -28,4 +28,7 @@ railties/guides/output
*.swp
*.swo
actionpack/bin
-*/vendor/gems
+vendor/gems/
+*/vendor/gems/
+bin/
+railties/tmp
View
@@ -46,44 +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
-task :gemspec do
- File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w") do |file|
- file.puts spec.to_ruby
- end
-end
-
desc "Publish the API documentation"
task :pgem => [:package] do
require 'rake/contrib/sshpublisher'
@@ -1,33 +1,20 @@
-# -*- encoding: utf-8 -*-
-
Gem::Specification.new do |s|
- s.name = %q{actionmailer}
- s.version = "3.0.pre"
-
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
- s.authors = ["David Heinemeier Hansson"]
- s.autorequire = %q{action_mailer}
- s.date = %q{2009-09-01}
+ 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.email = %q{david@loudthinking.com}
- s.files = ["Rakefile", "install.rb", "README", "CHANGELOG", "MIT-LICENSE", "lib/action_mailer", "lib/action_mailer/adv_attr_accessor.rb", "lib/action_mailer/base.rb", "lib/action_mailer/helpers.rb", "lib/action_mailer/mail_helper.rb", "lib/action_mailer/part.rb", "lib/action_mailer/part_container.rb", "lib/action_mailer/quoting.rb", "lib/action_mailer/test_case.rb", "lib/action_mailer/test_helper.rb", "lib/action_mailer/utils.rb", "lib/action_mailer/vendor", "lib/action_mailer/vendor/text-format-0.6.3", "lib/action_mailer/vendor/text-format-0.6.3/text", "lib/action_mailer/vendor/text-format-0.6.3/text/format.rb", "lib/action_mailer/vendor/text_format.rb", "lib/action_mailer/vendor/tmail-1.2.3", "lib/action_mailer/vendor/tmail-1.2.3/tmail", "lib/action_mailer/vendor/tmail-1.2.3/tmail/address.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/attachments.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/base64.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/compat.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/config.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/core_extensions.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/encode.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/header.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/index.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/interface.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/loader.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/mail.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/mailbox.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/main.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/mbox.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/net.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/obsolete.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/parser.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/port.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/quoting.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/require_arch.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/scanner.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/scanner_r.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/stringio.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/utils.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail/version.rb", "lib/action_mailer/vendor/tmail-1.2.3/tmail.rb", "lib/action_mailer/vendor/tmail.rb", "lib/action_mailer/version.rb", "lib/action_mailer.rb", "lib/actionmailer.rb", "test/abstract_unit.rb", "test/adv_attr_test.rb", "test/asset_host_test.rb", "test/delivery_method_test.rb", "test/fixtures", "test/fixtures/asset_host_mailer", "test/fixtures/asset_host_mailer/email_with_asset.html.erb", "test/fixtures/auto_layout_mailer", "test/fixtures/auto_layout_mailer/hello.html.erb", "test/fixtures/auto_layout_mailer/multipart.html.erb", "test/fixtures/auto_layout_mailer/multipart.text.erb", "test/fixtures/explicit_layout_mailer", "test/fixtures/explicit_layout_mailer/logout.html.erb", "test/fixtures/explicit_layout_mailer/signup.html.erb", "test/fixtures/first_mailer", "test/fixtures/first_mailer/share.erb", "test/fixtures/helper_mailer", "test/fixtures/helper_mailer/use_example_helper.erb", "test/fixtures/helper_mailer/use_helper.erb", "test/fixtures/helper_mailer/use_helper_method.erb", "test/fixtures/helper_mailer/use_mail_helper.erb", "test/fixtures/helpers", "test/fixtures/helpers/example_helper.rb", "test/fixtures/layouts", "test/fixtures/layouts/auto_layout_mailer.html.erb", "test/fixtures/layouts/auto_layout_mailer.text.erb", "test/fixtures/layouts/spam.html.erb", "test/fixtures/path.with.dots", "test/fixtures/path.with.dots/funky_path_mailer", "test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.erb", "test/fixtures/raw_email", "test/fixtures/raw_email10", "test/fixtures/raw_email12", "test/fixtures/raw_email13", "test/fixtures/raw_email2", "test/fixtures/raw_email3", "test/fixtures/raw_email4", "test/fixtures/raw_email5", "test/fixtures/raw_email6", "test/fixtures/raw_email7", "test/fixtures/raw_email8", "test/fixtures/raw_email9", "test/fixtures/raw_email_quoted_with_0d0a", "test/fixtures/raw_email_with_invalid_characters_in_content_type", "test/fixtures/raw_email_with_nested_attachment", "test/fixtures/raw_email_with_partially_quoted_subject", "test/fixtures/second_mailer", "test/fixtures/second_mailer/share.erb", "test/fixtures/templates", "test/fixtures/templates/signed_up.erb", "test/fixtures/test_mailer", "test/fixtures/test_mailer/_subtemplate.text.erb", "test/fixtures/test_mailer/body_ivar.erb", "test/fixtures/test_mailer/custom_templating_extension.html.haml", "test/fixtures/test_mailer/custom_templating_extension.text.haml", "test/fixtures/test_mailer/implicitly_multipart_example.html.erb", "test/fixtures/test_mailer/implicitly_multipart_example.html.erb~", "test/fixtures/test_mailer/implicitly_multipart_example.ignored.erb", "test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak", "test/fixtures/test_mailer/implicitly_multipart_example.text.erb", "test/fixtures/test_mailer/implicitly_multipart_example.yaml.erb", "test/fixtures/test_mailer/included_subtemplate.text.erb", "test/fixtures/test_mailer/rxml_template.rxml", "test/fixtures/test_mailer/signed_up.html.erb", "test/fixtures/test_mailer/signed_up_with_url.erb", "test/mail_helper_test.rb", "test/mail_layout_test.rb", "test/mail_render_test.rb", "test/mail_service_test.rb", "test/quoting_test.rb", "test/test_helper_test.rb", "test/tmail_test.rb", "test/url_test.rb"]
- s.homepage = %q{http://www.rubyonrails.org}
- s.require_paths = ["lib"]
- s.requirements = ["none"]
- s.rubyforge_project = %q{actionmailer}
- s.rubygems_version = %q{1.3.5}
- s.summary = %q{Service layer for easy email delivery and testing.}
+ 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"
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
+ s.add_dependency('actionpack', '= 3.0.pre')
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<actionpack>, ["= 3.0.pre"])
- else
- s.add_dependency(%q<actionpack>, ["= 3.0.pre"])
- end
- else
- s.add_dependency(%q<actionpack>, ["= 3.0.pre"])
- end
+ s.files = Dir['CHANGELOG', 'README', 'MIT-LICENSE', 'lib/**/*']
+ s.has_rdoc = true
+ s.requirements << 'none'
+ s.require_path = 'lib'
+ s.autorequire = 'action_mailer'
end
@@ -106,7 +106,7 @@ def inherited_with_helper(child)
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
View
@@ -1,7 +1,7 @@
rails_root = Pathname.new(File.dirname(__FILE__)).join("..")
gem "rack", "~> 1.0.0"
-gem "rack-test", "~> 0.4.2"
+gem "rack-test", "~> 0.5.0"
gem "activesupport", "3.0.pre", :vendored_at => rails_root.join("activesupport")
gem "activemodel", "3.0.pre", :vendored_at => rails_root.join("activemodel")
View
@@ -34,7 +34,7 @@ end
desc "Run all unit tests"
task :test => [:test_action_pack, :test_active_record_integration]
-TESTS_GLOB = "test/{abstract,controller,dispatch,new_base,template,html-scanner}/**/*_test.rb"
+TESTS_GLOB = "test/{abstract,controller,dispatch,new_base,template,html-scanner,view}/**/*_test.rb"
Rake::TestTask.new(:test_action_pack) do |t|
t.libs << 'test'
@@ -77,50 +77,14 @@ Rake::RDocTask.new { |rdoc|
end
}
-# Create compressed packages
-dist_dirs = [ "lib", "test" ]
+spec = eval(File.read('actionpack.gemspec'))
-spec = Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = PKG_NAME
- s.version = PKG_VERSION
- s.summary = "Web-flow and rendering framework putting the VC in MVC."
- s.description = %q{Eases web-request routing, handling, and response as a half-way front, half-way page controller. Implemented with specific emphasis on enabling easy unit/integration testing that doesn't require a browser.} #'
-
- s.author = "David Heinemeier Hansson"
- s.email = "david@loudthinking.com"
- s.rubyforge_project = "actionpack"
- s.homepage = "http://www.rubyonrails.org"
-
- s.has_rdoc = true
- s.requirements << 'none'
-
- s.add_dependency('activesupport', '= 3.0.pre' + PKG_BUILD)
- s.add_dependency('activemodel', '= 3.0.pre' + PKG_BUILD)
- s.add_dependency('rack', '~> 1.0.0')
- s.add_dependency('rack-test', '~> 0.4.2')
-
- s.require_path = 'lib'
- s.autorequire = 'action_controller'
-
- s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG", "MIT-LICENSE" ]
- dist_dirs.each do |dir|
- s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
- end
-end
-
Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
p.need_tar = true
p.need_zip = true
end
-task :gemspec do
- File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w") do |file|
- file.puts spec.to_ruby
- end
-end
-
task :lines do
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
Oops, something went wrong.
@@ -1,28 +1,31 @@
module ActionController
autoload :Base, "action_controller/base"
+ autoload :Benchmarking, "action_controller/metal/benchmarking"
autoload :ConditionalGet, "action_controller/metal/conditional_get"
+ autoload :Helpers, "action_controller/metal/helpers"
autoload :HideActions, "action_controller/metal/hide_actions"
+ autoload :Layouts, "action_controller/metal/layouts"
autoload :Metal, "action_controller/metal"
autoload :Middleware, "action_controller/middleware"
- autoload :Layouts, "action_controller/metal/layouts"
autoload :RackConvenience, "action_controller/metal/rack_convenience"
autoload :Rails2Compatibility, "action_controller/metal/compatibility"
autoload :Redirector, "action_controller/metal/redirector"
autoload :RenderingController, "action_controller/metal/rendering_controller"
autoload :RenderOptions, "action_controller/metal/render_options"
autoload :Rescue, "action_controller/metal/rescuable"
autoload :Responder, "action_controller/metal/responder"
+ autoload :Session, "action_controller/metal/session"
autoload :Testing, "action_controller/metal/testing"
autoload :UrlFor, "action_controller/metal/url_for"
- autoload :Session, "action_controller/metal/session"
- autoload :Helpers, "action_controller/metal/helpers"
# Ported modules
# require 'action_controller/routing'
autoload :Caching, 'action_controller/caching'
autoload :Dispatcher, 'action_controller/dispatch/dispatcher'
- autoload :Integration, 'action_controller/testing/integration'
+ autoload :Integration, 'action_controller/deprecated/integration_test'
+ autoload :IntegrationTest, 'action_controller/deprecated/integration_test'
autoload :MimeResponds, 'action_controller/metal/mime_responds'
+ autoload :PerformanceTest, 'action_controller/deprecated/performance_test'
autoload :PolymorphicRoutes, 'action_controller/routing/generation/polymorphic_routes'
autoload :RecordIdentifier, 'action_controller/record_identifier'
autoload :Resources, 'action_controller/routing/resources'
@@ -42,7 +45,6 @@ module ActionController
autoload :Cookies, 'action_controller/metal/cookies'
autoload :ActionControllerError, 'action_controller/metal/exceptions'
- autoload :SessionRestoreError, 'action_controller/metal/exceptions'
autoload :RenderError, 'action_controller/metal/exceptions'
autoload :RoutingError, 'action_controller/metal/exceptions'
autoload :MethodNotAllowed, 'action_controller/metal/exceptions'
@@ -14,6 +14,7 @@ class Base < Metal
include ActionController::Layouts
include ActionController::ConditionalGet
include ActionController::RackConvenience
+ include ActionController::Benchmarking
# Legacy modules
include SessionManagement
@@ -0,0 +1,2 @@
+ActionController::Integration = ActionDispatch::Integration
+ActionController::IntegrationTest = ActionDispatch::IntegrationTest
@@ -0,0 +1 @@
+ActionController::PerformanceTest = ActionDispatch::PerformanceTest
@@ -7,15 +7,6 @@ class Dispatcher
cattr_accessor :prepare_each_request
self.prepare_each_request = false
- cattr_accessor :router
- self.router = Routing::Routes
-
- cattr_accessor :middleware
- self.middleware = ActionDispatch::MiddlewareStack.new do |middleware|
- middlewares = File.join(File.dirname(__FILE__), "middlewares.rb")
- middleware.instance_eval(File.read(middlewares), middlewares, 1)
- end
-
class << self
def define_dispatcher_callbacks(cache_classes)
unless cache_classes
@@ -24,7 +15,7 @@ def define_dispatcher_callbacks(cache_classes)
# Development mode callbacks
ActionDispatch::Callbacks.before_dispatch do |app|
- ActionController::Dispatcher.router.reload
+ ActionController::Routing::Routes.reload
end
ActionDispatch::Callbacks.after_dispatch do
@@ -58,7 +49,8 @@ def define_dispatcher_callbacks(cache_classes)
:to => ActionDispatch::Callbacks
def new
- @@middleware.build(@@router)
+ # DEPRECATE Rails application fallback
+ Rails.application
end
end
end
@@ -1,16 +0,0 @@
-use "Rack::Lock", :if => lambda {
- !ActionController::Base.allow_concurrency
-}
-
-use "ActionDispatch::ShowExceptions", lambda { ActionController::Base.consider_all_requests_local }
-use "ActionDispatch::Callbacks", lambda { ActionController::Dispatcher.prepare_each_request }
-
-# TODO: Redirect global exceptions somewhere?
-# use "ActionDispatch::Rescue"
-
-use lambda { ActionController::Base.session_store },
- lambda { ActionController::Base.session_options }
-
-use "ActionDispatch::ParamsParser"
-use "Rack::MethodOverride"
-use "Rack::Head"
@@ -0,0 +1,92 @@
+require 'benchmark'
+
+module ActionController #:nodoc:
+ # The benchmarking module times the performance of actions and reports to the logger. If the Active Record
+ # package has been included, a separate timing section for database calls will be added as well.
+ module Benchmarking #:nodoc:
+ extend ActiveSupport::Concern
+
+ module ClassMethods
+ # Log and benchmark the workings of a single block and silence whatever logging that may have happened inside it
+ # (unless <tt>use_silence</tt> is set to false).
+ #
+ # The benchmark is only recorded if the current level of the logger matches the <tt>log_level</tt>, which makes it
+ # easy to include benchmarking statements in production software that will remain inexpensive because the benchmark
+ # will only be conducted if the log level is low enough.
+ def benchmark(title, log_level = Logger::DEBUG, use_silence = true)
+ if logger && logger.level == log_level
+ result = nil
+ ms = Benchmark.ms { result = use_silence ? silence { yield } : yield }
+ logger.add(log_level, "#{title} (#{('%.1f' % ms)}ms)")
+ result
+ else
+ yield
+ end
+ end
+ end
+
+ protected
+ def render(*args, &block)
+ if logger
+ if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
+ db_runtime = ActiveRecord::Base.connection.reset_runtime
+ end
+
+ render_output = nil
+ @view_runtime = Benchmark.ms { render_output = super }
+
+ if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
+ @db_rt_before_render = db_runtime
+ @db_rt_after_render = ActiveRecord::Base.connection.reset_runtime
+ @view_runtime -= @db_rt_after_render
+ end
+
+ render_output
+ else
+ super
+ end
+ end
+
+ private
+ def process_action(*args)
+ if logger
+ ms = [Benchmark.ms { super }, 0.01].max
+ logging_view = defined?(@view_runtime)
+ logging_active_record = Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
+
+ log_message = 'Completed in %.0fms' % ms
+
+ if logging_view || logging_active_record
+ log_message << " ("
+ log_message << view_runtime if logging_view
+
+ if logging_active_record
+ log_message << ", " if logging_view
+ log_message << active_record_runtime + ")"
+ else
+ ")"
+ end
+ end
+
+ log_message << " | #{response.status}"
+ log_message << " [#{complete_request_uri rescue "unknown"}]"
+
+ logger.info(log_message)
+ response.headers["X-Runtime"] = "%.0f" % ms
+ else
+ super
+ end
+ end
+
+ def view_runtime
+ "View: %.0f" % @view_runtime
+ end
+
+ def active_record_runtime
+ db_runtime = ActiveRecord::Base.connection.reset_runtime
+ db_runtime += @db_rt_before_render if @db_rt_before_render
+ db_runtime += @db_rt_after_render if @db_rt_after_render
+ "DB: %.0f" % db_runtime
+ end
+ end
+end
@@ -2,9 +2,6 @@ module ActionController
class ActionControllerError < StandardError #:nodoc:
end
- class SessionRestoreError < ActionControllerError #:nodoc:
- end
-
class RenderError < ActionControllerError #:nodoc:
end
Oops, something went wrong.

0 comments on commit 29457a2

Please sign in to comment.