diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-14 17:38:30 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-14 17:38:30 -0700 |
commit | b6bac73b282c7e500c43810f2a937fc0047e5979 (patch) | |
tree | b234951c42e4c682ef723320287383ac3fff0cf1 /actionpack | |
parent | da65320433088548bc4cff33758e5acd71fd137a (diff) | |
parent | c286952050e8fe16b0f6d64ba0687b52cc8f2ae1 (diff) | |
download | rails-b6bac73b282c7e500c43810f2a937fc0047e5979.tar.gz rails-b6bac73b282c7e500c43810f2a937fc0047e5979.tar.bz2 rails-b6bac73b282c7e500c43810f2a937fc0047e5979.zip |
Merge commit 'origin/master'
Conflicts:
actionpack/lib/action_controller/abstract/base.rb
actionpack/lib/action_controller/routing.rb
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/examples/minimal.rb | 34 | ||||
-rw-r--r-- | actionpack/lib/action_controller/abstract/base.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/abstract/logger.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_controller/new_base/http.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/status_codes.rb | 6 | ||||
-rw-r--r-- | actionpack/test/activerecord/polymorphic_routes_test.rb | 1 |
7 files changed, 51 insertions, 4 deletions
diff --git a/actionpack/examples/minimal.rb b/actionpack/examples/minimal.rb new file mode 100644 index 0000000000..84a8499daf --- /dev/null +++ b/actionpack/examples/minimal.rb @@ -0,0 +1,34 @@ +$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" +require 'action_controller' +require 'action_controller/new_base' if ENV['NEW'] +require 'benchmark' + +class BaseController < ActionController::Base + def index + render :text => '' + end +end + +n = (ENV['N'] || 10000).to_i +input = StringIO.new('') + +def call_index(controller, input, n) + n.times do + controller.action(:index).call({ 'rack.input' => input }) + end + + puts controller.name + status, headers, body = controller.action(:index).call({ 'rack.input' => input }) + + puts status + puts headers.to_yaml + puts '---' + body.each do |part| + puts part + end + puts '---' +end + +elapsed = Benchmark.realtime { call_index BaseController, input, n } + +puts "%dms elapsed, %d requests/sec" % [1000 * elapsed, n / elapsed] diff --git a/actionpack/lib/action_controller/abstract/base.rb b/actionpack/lib/action_controller/abstract/base.rb index 483356a4be..f2db201063 100644 --- a/actionpack/lib/action_controller/abstract/base.rb +++ b/actionpack/lib/action_controller/abstract/base.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/module/attr_internal' + module AbstractController class Error < StandardError; end diff --git a/actionpack/lib/action_controller/abstract/logger.rb b/actionpack/lib/action_controller/abstract/logger.rb index d0603a4ad7..750a5c9fb6 100644 --- a/actionpack/lib/action_controller/abstract/logger.rb +++ b/actionpack/lib/action_controller/abstract/logger.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/class/attribute_accessors' + module AbstractController module Logger extend ActiveSupport::DependencyModule @@ -39,4 +41,4 @@ module AbstractController @request_origin ||= "#{request.remote_ip} at #{Time.now.to_s(:db)}" end end -end
\ No newline at end of file +end diff --git a/actionpack/lib/action_controller/new_base/http.rb b/actionpack/lib/action_controller/new_base/http.rb index f3a60b3bf8..e9a1d5b12f 100644 --- a/actionpack/lib/action_controller/new_base/http.rb +++ b/actionpack/lib/action_controller/new_base/http.rb @@ -1,3 +1,6 @@ +require 'action_controller/abstract' +require 'active_support/core_ext/module/delegation' + module ActionController class Http < AbstractController::Base abstract! @@ -52,7 +55,7 @@ module ActionController def self.action(name) @actions ||= {} - @actions[name] ||= proc do |env| + @actions[name.to_s] ||= proc do |env| new.call(name, env) end end diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 06a07a4d0a..ce59866531 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -1,6 +1,9 @@ require 'cgi' require 'uri' require 'set' + +require 'active_support/core_ext/module/aliasing' +require 'active_support/core_ext/module/attribute_accessors' require 'action_controller/routing/optimisations' require 'action_controller/routing/routing_ext' require 'action_controller/routing/route' diff --git a/actionpack/lib/action_dispatch/http/status_codes.rb b/actionpack/lib/action_dispatch/http/status_codes.rb index 830de2a6db..5bac842ec1 100644 --- a/actionpack/lib/action_dispatch/http/status_codes.rb +++ b/actionpack/lib/action_dispatch/http/status_codes.rb @@ -1,3 +1,5 @@ +require 'active_support/inflector' + module ActionDispatch module StatusCodes #:nodoc: STATUS_CODES = Rack::Utils::HTTP_STATUS_CODES.merge({ @@ -16,7 +18,7 @@ module ActionDispatch # :created or :not_implemented) into its corresponding HTTP status # code (like 200 or 501). SYMBOL_TO_STATUS_CODE = STATUS_CODES.inject({}) { |hash, (code, message)| - hash[message.gsub(/ /, "").underscore.to_sym] = code + hash[ActiveSupport::Inflector.underscore(message.gsub(/ /, "")).to_sym] = code hash }.freeze @@ -37,4 +39,4 @@ module ActionDispatch end end end -end
\ No newline at end of file +end diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionpack/test/activerecord/polymorphic_routes_test.rb index 35139fbb7f..b9f5be2361 100644 --- a/actionpack/test/activerecord/polymorphic_routes_test.rb +++ b/actionpack/test/activerecord/polymorphic_routes_test.rb @@ -1,4 +1,5 @@ require 'active_record_unit' +require 'fixtures/project' class Task < ActiveRecord::Base set_table_name 'projects' |