Skip to content

Commit

Permalink
Merge remote branch 'rails/master'
Browse files Browse the repository at this point in the history
Conflicts:
	actionpack/lib/abstract_controller/base.rb
  • Loading branch information
fxn committed Jun 20, 2010
2 parents 31cadc7 + 50d37a7 commit 207fa59
Show file tree
Hide file tree
Showing 117 changed files with 1,885 additions and 954 deletions.
5 changes: 1 addition & 4 deletions Gemfile
Expand Up @@ -5,6 +5,7 @@ gem "rails", :path => File.dirname(__FILE__)

gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
gem "rdoc", "2.2"

mri = !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby"
if mri && RUBY_VERSION < '1.9'
Expand Down Expand Up @@ -44,10 +45,6 @@ elsif RUBY_ENGINE == "jruby"
end
end

group :documentation do
gem 'rdoc', '2.1'
end

if ENV['CI']
gem "nokogiri", ">= 1.4.0"

Expand Down
15 changes: 13 additions & 2 deletions Rakefile
@@ -1,3 +1,6 @@
gem 'rdoc', '= 2.2'
require 'rdoc'

require 'rake'
require 'rake/rdoctask'
require 'rake/gempackagetask'
Expand Down Expand Up @@ -68,7 +71,15 @@ Rake::RDocTask.new do |rdoc|
rdoc.options << '--charset' << 'utf-8'
rdoc.options << '--main' << 'railties/README'

rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : './doc/template/horo'
# Workaround: RDoc assumes that rdoc.template can be required, and that
# rdoc.template.upcase is a constant living in RDoc::Generator::HTML
# which holds the actual template class.
#
# We put 'doc/template' in the load path to be able to set the template
# to the string 'horo' and thus meet those RDoc's assumptions.
$:.unshift('doc/template')

rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : 'horo'

rdoc.rdoc_files.include('railties/CHANGELOG')
rdoc.rdoc_files.include('railties/MIT-LICENSE')
Expand Down Expand Up @@ -117,7 +128,7 @@ end
desc "Publish API docs for Rails as a whole and for each component"
task :pdoc => :rdoc do
require 'rake/contrib/sshpublisher'
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/api", "doc/rdoc").upload
Rake::SshDirPublisher.new("rails@api.rubyonrails.org", "public_html/api", "doc/rdoc").upload
PROJECTS.each do |project|
system %(cd #{project} && #{$0} pdoc)
end
Expand Down
5 changes: 3 additions & 2 deletions actionmailer/Rakefile
@@ -1,4 +1,5 @@
require 'rubygems'
gem 'rdoc', '= 2.2'
require 'rdoc'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
Expand Down Expand Up @@ -53,5 +54,5 @@ end
desc "Publish the API documentation"
task :pdoc => [:rdoc] do
require 'rake/contrib/sshpublisher'
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/am", "doc").upload
Rake::SshDirPublisher.new("rails@api.rubyonrails.org", "public_html/am", "doc").upload
end
10 changes: 10 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,15 @@
*Rails 3.0.0 [Release Candidate] (unreleased)*

* Add shallow routes back to the new router [Diego Carrion, Andrew White]

resources :posts do
shallow do
resources :comments
end
end

You can now use comment_path for /comments/1 instead of post_comment_path for /posts/1/comments/1.

* Add support for multi-subdomain session by setting cookie host in session cookie so you can share session between www.example.com, example.com and user.example.com. #4818 [Guillermo Álvarez]

* Removed textilize, textilize_without_paragraph and markdown helpers. [Santiago Pastorino]
Expand Down
3 changes: 2 additions & 1 deletion actionpack/Rakefile
@@ -1,4 +1,5 @@
require 'rubygems'
gem 'rdoc', '= 2.2'
require 'rdoc'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
Expand Down
13 changes: 2 additions & 11 deletions actionpack/lib/abstract_controller/base.rb
@@ -1,4 +1,5 @@
require 'active_support/configurable'
require 'active_support/descendants_tracker'
require 'active_support/core_ext/module/anonymous'

module AbstractController
Expand All @@ -10,6 +11,7 @@ class Base
attr_internal :action_name

include ActiveSupport::Configurable
extend ActiveSupport::DescendantsTracker

class << self
attr_reader :abstract
Expand All @@ -21,17 +23,6 @@ def abstract!
@abstract = true
end

def inherited(klass)
::AbstractController::Base.descendants << klass.to_s
super
end

# A list of all descendants of AbstractController::Base. This is
# useful for initializers which need to add behavior to all controllers.
def descendants
@descendants ||= []
end

# A list of all internal methods for a controller. This finds the first
# abstract superclass of a controller, and gets a list of all public
# instance methods on that abstract class. Public instance methods of
Expand Down
11 changes: 9 additions & 2 deletions actionpack/lib/action_controller/metal.rb
Expand Up @@ -52,8 +52,7 @@ def build(action, app=nil, &block)
class Metal < AbstractController::Base
abstract!

# :api: public
attr_internal :params, :env
attr_internal :env

# Returns the last part of the controller's name, underscored, without the ending
# "Controller". For instance, MyApp::MyPostsController would return "my_posts" for
Expand Down Expand Up @@ -85,6 +84,14 @@ def initialize(*)
super
end

def params
@_params ||= request.parameters
end

def params=(val)
@_params = val
end

# Basic implementations for content_type=, location=, and headers are
# provided to reduce the dependency on the RackDelegation module
# in Renderer and Redirector.
Expand Down
4 changes: 0 additions & 4 deletions actionpack/lib/action_controller/metal/rack_delegation.rb
Expand Up @@ -14,10 +14,6 @@ def dispatch(action, request, response = ActionDispatch::Response.new)
super(action, request)
end

def params
@_params ||= @_request.parameters
end

def response_body=(body)
response.body = body if response
super
Expand Down
3 changes: 2 additions & 1 deletion actionpack/lib/action_controller/polymorphic_routes.rb
Expand Up @@ -11,7 +11,7 @@ module ActionController
# polymorphic_url([:admin, @article, @comment])
#
# results in:
#
#
# admin_article_comment_url(@article, @comment)
#
# == Usage within the framework
Expand Down Expand Up @@ -166,6 +166,7 @@ def build_named_route_call(records, inflection, options = {})
route << RecordIdentifier.__send__("plural_class_name", record)
route = route.singularize if inflection == :singular
route << "_"
route << "index_" if RecordIdentifier.uncountable?(record) && inflection == :plural
end

action_prefix(options) + route + routing_type(options).to_s
Expand Down
14 changes: 11 additions & 3 deletions actionpack/lib/action_controller/record_identifier.rb
@@ -1,7 +1,7 @@
require 'active_support/core_ext/module'

module ActionController
# The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or
# The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or
# Active Resources or pretty much any other model type that has an id. These patterns are then used to try elevate
# the view actions to a higher logical level. Example:
#
Expand All @@ -28,7 +28,7 @@ module ActionController
# end
#
# As the example above shows, you can stop caring to a large extent what the actual id of the post is. You just know
# that one is being assigned and that the subsequent calls in redirect_to and the RJS expect that same naming
# that one is being assigned and that the subsequent calls in redirect_to and the RJS expect that same naming
# convention and allows you to write less code if you follow it.
module RecordIdentifier
extend self
Expand Down Expand Up @@ -59,7 +59,7 @@ def dom_class(record_or_class, prefix = nil)
# If you need to address multiple instances of the same class in the same view, you can prefix the dom_id:
#
# dom_id(Post.find(45), :edit) # => "edit_post_45"
def dom_id(record, prefix = nil)
def dom_id(record, prefix = nil)
if record_id = record_key_for_dom_id(record)
"#{dom_class(record, prefix)}#{JOIN}#{record_id}"
else
Expand Down Expand Up @@ -102,6 +102,14 @@ def singular_class_name(record_or_class)
model_name_from_record_or_class(record_or_class).singular
end

# Identifies whether the class name of a record or class is uncountable. Examples:
#
# uncountable?(Sheep) # => true
# uncountable?(Post) => false
def uncountable?(record_or_class)
plural_class_name(record_or_class) == singular_class_name(record_or_class)
end

private
def model_name_from_record_or_class(record_or_class)
(record_or_class.is_a?(Class) ? record_or_class : record_or_class.class).model_name
Expand Down
Empty file modified actionpack/lib/action_dispatch/http/request.rb 100755 → 100644
Empty file.
8 changes: 4 additions & 4 deletions actionpack/lib/action_dispatch/middleware/callbacks.rb
Expand Up @@ -8,7 +8,7 @@ module ActionDispatch
class Callbacks
include ActiveSupport::Callbacks

define_callbacks :call, :terminator => "result == false", :rescuable => true
define_callbacks :call, :rescuable => true
define_callbacks :prepare, :scope => :name

# Add a preparation callback. Preparation callbacks are run before every
Expand Down Expand Up @@ -37,12 +37,12 @@ def self.after(*args, &block)

def initialize(app, prepare_each_request = false)
@app, @prepare_each_request = app, prepare_each_request
run_callbacks(:prepare)
_run_prepare_callbacks
end

def call(env)
run_callbacks(:call) do
run_callbacks(:prepare) if @prepare_each_request
_run_call_callbacks do
_run_prepare_callbacks if @prepare_each_request
@app.call(env)
end
end
Expand Down
Expand Up @@ -122,7 +122,7 @@ def status_code(exception)
end

def render(status, body)
[status, {'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s}, [body]]
[status, {'Content-Type' => 'text/html', 'Content-Length' => body.bytesize.to_s}, [body]]
end

def public_path
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/railtie.rb
Expand Up @@ -10,7 +10,7 @@ class Railtie < Rails::Railtie

# Prepare dispatcher callbacks and run 'prepare' callbacks
initializer "action_dispatch.prepare_dispatcher" do |app|
ActionDispatch::Callbacks.to_prepare { app.routes_reloader.reload_if_changed }
ActionDispatch::Callbacks.to_prepare { app.routes_reloader.execute_if_updated }
end
end
end

0 comments on commit 207fa59

Please sign in to comment.