Skip to content

Commit

Permalink
Update rails
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Jun 20, 2009
1 parent cb34329 commit 1e18650
Show file tree
Hide file tree
Showing 41 changed files with 960 additions and 635 deletions.
Empty file.
81 changes: 81 additions & 0 deletions vendor/rails/Rakefile
@@ -0,0 +1,81 @@
require 'rake'
require 'rake/rdoctask'
require 'rake/contrib/sshpublisher'

env = %(PKG_BUILD="#{ENV['PKG_BUILD']}") if ENV['PKG_BUILD']

PROJECTS = %w(activesupport 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 => :test

%w(test rdoc pgem package release).each do |task_name|
desc "Run #{task_name} task for all projects"
task task_name do
PROJECTS.each do |project|
system %(cd #{project} && #{env} #{$0} #{task_name})
end
end
end


desc "Generate documentation for the Rails framework"
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'doc/rdoc'
rdoc.title = "Ruby on Rails Documentation"

rdoc.options << '--line-numbers' << '--inline-source'
rdoc.options << '-A cattr_accessor=object'
rdoc.options << '--charset' << 'utf-8'

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

rdoc.rdoc_files.include('railties/CHANGELOG')
rdoc.rdoc_files.include('railties/MIT-LICENSE')
rdoc.rdoc_files.include('railties/README')
rdoc.rdoc_files.include('railties/lib/{*.rb,commands/*.rb,rails/*.rb,rails_generator/*.rb}')

rdoc.rdoc_files.include('activerecord/README')
rdoc.rdoc_files.include('activerecord/CHANGELOG')
rdoc.rdoc_files.include('activerecord/lib/active_record/**/*.rb')
rdoc.rdoc_files.exclude('activerecord/lib/active_record/vendor/*')

rdoc.rdoc_files.include('activeresource/README')
rdoc.rdoc_files.include('activeresource/CHANGELOG')
rdoc.rdoc_files.include('activeresource/lib/active_resource.rb')
rdoc.rdoc_files.include('activeresource/lib/active_resource/*')

rdoc.rdoc_files.include('actionpack/README')
rdoc.rdoc_files.include('actionpack/CHANGELOG')
rdoc.rdoc_files.include('actionpack/lib/action_controller/**/*.rb')
rdoc.rdoc_files.include('actionpack/lib/action_view/**/*.rb')
rdoc.rdoc_files.exclude('actionpack/lib/action_controller/vendor/*')

rdoc.rdoc_files.include('actionmailer/README')
rdoc.rdoc_files.include('actionmailer/CHANGELOG')
rdoc.rdoc_files.include('actionmailer/lib/action_mailer/base.rb')
rdoc.rdoc_files.exclude('actionmailer/lib/action_mailer/vendor/*')

rdoc.rdoc_files.include('activesupport/README')
rdoc.rdoc_files.include('activesupport/CHANGELOG')
rdoc.rdoc_files.include('activesupport/lib/active_support/**/*.rb')
rdoc.rdoc_files.exclude('activesupport/lib/active_support/vendor/*')
end

# Enhance rdoc task to copy referenced images also
task :rdoc do
FileUtils.mkdir_p "doc/rdoc/files/examples/"
FileUtils.copy "activerecord/examples/associations.png", "doc/rdoc/files/examples/associations.png"
end

desc "Publish API docs for Rails as a whole and for each component"
task :pdoc => :rdoc do
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/api", "doc/rdoc").upload
PROJECTS.each do |project|
system %(cd #{project} && #{env} #{$0} pdoc)
end
end
12 changes: 6 additions & 6 deletions vendor/rails/actionpack/lib/action_controller/base.rb
Expand Up @@ -984,7 +984,6 @@ def render(options = nil, extra_options = {}, &block) #:doc:
# of sending it as the response body to the browser.
def render_to_string(options = nil, &block) #:doc:
render(options, &block)
response.body
ensure
response.content_type = nil
erase_render_results
Expand Down Expand Up @@ -1021,7 +1020,7 @@ def head(*args)

# Clears the rendered results, allowing for another render to be performed.
def erase_render_results #:nodoc:
response.body = []
response.body = nil
@performed_render = false
end

Expand Down Expand Up @@ -1248,12 +1247,13 @@ def render_for_text(text = nil, status = nil, append_response = false) #:nodoc:
response.status = interpret_status(status || DEFAULT_RENDER_STATUS_CODE)

if append_response
response.body_parts << text.to_s
response.body ||= ''
response.body << text.to_s
else
response.body = case text
when Proc then text
when nil then [" "] # Safari doesn't pass the headers of the return if the response is zero length
else [text.to_s]
when Proc then text
when nil then " " # Safari doesn't pass the headers of the return if the response is zero length
else text.to_s
end
end
end
Expand Down
10 changes: 4 additions & 6 deletions vendor/rails/actionpack/lib/action_controller/integration.rb
Expand Up @@ -332,13 +332,11 @@ def process(method, path, parameters = nil, headers = nil)
@cookies[name] = value
end

@body = ""
if body.is_a?(String)
@body_parts = [body]
@body = body
@body << body
else
@body_parts = []
body.each { |part| @body_parts << part.to_s }
@body = @body_parts.join
body.each { |part| @body << part }
end

if @controller = ActionController::Base.last_instantiation
Expand All @@ -351,7 +349,7 @@ def process(method, path, parameters = nil, headers = nil)
@response = Response.new
@response.status = status.to_s
@response.headers.replace(@headers)
@response.body = @body_parts
@response.body = @body
end

# Decorate the response with the standard behavior of the
Expand Down
41 changes: 11 additions & 30 deletions vendor/rails/actionpack/lib/action_controller/response.rb
Expand Up @@ -40,28 +40,14 @@ class Response < Rack::Response
delegate :default_charset, :to => 'ActionController::Base'

def initialize
super
@status = 200
@header = Rack::Utils::HeaderHash.new(DEFAULT_HEADERS)
@session, @assigns = [], []
end

def body
str = ''
each { |part| str << part.to_s }
str
end
@writer = lambda { |x| @body << x }
@block = nil

def body=(body)
@body =
if body.is_a?(String)
[body]
else
body
end
end

def body_parts
@body
@body = "",
@session, @assigns = [], []
end

def location; headers['Location'] end
Expand Down Expand Up @@ -166,7 +152,7 @@ def each(&callback)
@writer = lambda { |x| callback.call(x) }
@body.call(self, self)
elsif @body.is_a?(String)
callback.call(@body)
@body.each_line(&callback)
else
@body.each(&callback)
end
Expand All @@ -176,8 +162,7 @@ def each(&callback)
end

def write(str)
str = str.to_s
@writer.call str
@writer.call str.to_s
str
end

Expand All @@ -201,7 +186,7 @@ def handle_conditional_get!

if request && request.etag_matches?(etag)
self.status = '304 Not Modified'
self.body = []
self.body = ''
end

set_conditional_cache_control!
Expand All @@ -210,11 +195,7 @@ def handle_conditional_get!

def nonempty_ok_response?
ok = !status || status.to_s[0..2] == '200'
ok && string_body?
end

def string_body?
!body_parts.respond_to?(:call) && body_parts.any? && body_parts.all? { |part| part.is_a?(String) }
ok && body.is_a?(String) && !body.empty?
end

def set_conditional_cache_control!
Expand All @@ -235,8 +216,8 @@ def set_content_length!
headers.delete('Content-Length')
elsif length = headers['Content-Length']
headers['Content-Length'] = length.to_s
elsif string_body? && (!status || status.to_s[0..2] != '304')
headers["Content-Length"] = Rack::Utils.bytesize(body).to_s
elsif !body.respond_to?(:call) && (!status || status.to_s[0..2] != '304')
headers["Content-Length"] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
end
end

Expand Down
6 changes: 2 additions & 4 deletions vendor/rails/actionpack/lib/action_controller/test_process.rb
Expand Up @@ -13,7 +13,6 @@ def initialize(env = {})

@query_parameters = {}
@session = TestSession.new
@session_options ||= {}

initialize_default_values
initialize_containers
Expand Down Expand Up @@ -111,7 +110,6 @@ def assign_parameters(controller_path, action, parameters)
end

def recycle!
@env["action_controller.request.request_parameters"] = {}
self.query_parameters = {}
self.path_parameters = {}
@headers, @request_method, @accepts, @content_type = nil, nil, nil, nil
Expand Down Expand Up @@ -260,11 +258,11 @@ def cookies

# Returns binary content (downloadable file), converted to a String
def binary_content
raise "Response body is not a Proc: #{body_parts.inspect}" unless body_parts.kind_of?(Proc)
raise "Response body is not a Proc: #{body.inspect}" unless body.kind_of?(Proc)
require 'stringio'

sio = StringIO.new
body_parts.call(self, sio)
body.call(self, sio)

sio.rewind
sio.read
Expand Down
6 changes: 0 additions & 6 deletions vendor/rails/actionpack/lib/action_view/base.rb
Expand Up @@ -303,12 +303,6 @@ def with_template(current_template)
self.template = last_template
end

def punctuate_body!(part)
flush_output_buffer
response.body_parts << part
nil
end

private
# Evaluates the local assigns and controller ivars, pushes them to the view.
def _evaluate_assigns_and_ivars #:nodoc:
Expand Down
Expand Up @@ -131,14 +131,6 @@ def with_output_buffer(buf = '') #:nodoc:
ensure
self.output_buffer = old_buffer
end

# Add the output buffer to the response body and start a new one.
def flush_output_buffer #:nodoc:
if output_buffer && output_buffer != ''
response.body_parts << output_buffer
self.output_buffer = ''
end
end
end
end
end
35 changes: 14 additions & 21 deletions vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb
Expand Up @@ -628,23 +628,20 @@ def text_area(object_name, method, options = {})
#
# The HTML specification says unchecked check boxes are not successful, and
# thus web browsers do not send them. Unfortunately this introduces a gotcha:
# if an +Invoice+ model has a +paid+ flag, and in the form that edits a paid
# if an Invoice model has a +paid+ flag, and in the form that edits a paid
# invoice the user unchecks its check box, no +paid+ parameter is sent. So,
# any mass-assignment idiom like
#
# @invoice.update_attributes(params[:invoice])
#
# wouldn't update the flag.
#
# To prevent this the helper generates an auxiliary hidden field before
# the very check box. The hidden field has the same name and its
# attributes mimick an unchecked check box.
#
# This way, the client either sends only the hidden field (representing
# the check box is unchecked), or both fields. Since the HTML specification
# says key/value pairs have to be sent in the same order they appear in the
# form, and parameters extraction gets the last occurrence of any repeated
# key in the query string, that works for ordinary forms.
# To prevent this the helper generates a hidden field with the same name as
# the checkbox after the very check box. So, the client either sends only the
# hidden field (representing the check box is unchecked), or both fields.
# Since the HTML specification says key/value pairs have to be sent in the
# same order they appear in the form and Rails parameters extraction always
# gets the first occurrence of any given key, that works in ordinary forms.
#
# Unfortunately that workaround does not work when the check box goes
# within an array-like parameter, as in
Expand All @@ -655,26 +652,22 @@ def text_area(object_name, method, options = {})
# <% end %>
#
# because parameter name repetition is precisely what Rails seeks to distinguish
# the elements of the array. For each item with a checked check box you
# get an extra ghost item with only that attribute, assigned to "0".
#
# In that case it is preferable to either use +check_box_tag+ or to use
# hashes instead of arrays.
# the elements of the array.
#
# ==== Examples
# # Let's say that @post.validated? is 1:
# check_box("post", "validated")
# # => <input name="post[validated]" type="hidden" value="0" />
# # <input type="checkbox" id="post_validated" name="post[validated]" value="1" />
# # => <input type="checkbox" id="post_validated" name="post[validated]" value="1" />
# # <input name="post[validated]" type="hidden" value="0" />
#
# # Let's say that @puppy.gooddog is "no":
# check_box("puppy", "gooddog", {}, "yes", "no")
# # => <input name="puppy[gooddog]" type="hidden" value="no" />
# # <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
# # => <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
# # <input name="puppy[gooddog]" type="hidden" value="no" />
#
# check_box("eula", "accepted", { :class => 'eula_check' }, "yes", "no")
# # => <input name="eula[accepted]" type="hidden" value="no" />
# # <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
# # => <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
# # <input name="eula[accepted]" type="hidden" value="no" />
#
def check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
InstanceTag.new(object_name, method, self, options.delete(:object)).to_check_box_tag(options, checked_value, unchecked_value)
Expand Down
Expand Up @@ -324,7 +324,7 @@ def simple_format(text, html_options={})

# Turns all URLs and e-mail addresses into clickable links. The <tt>:link</tt> option
# will limit what should be linked. You can add HTML attributes to the links using
# <tt>:html</tt>. Possible values for <tt>:link</tt> are <tt>:all</tt> (default),
# <tt>:href_options</tt>. Possible values for <tt>:link</tt> are <tt>:all</tt> (default),
# <tt>:email_addresses</tt>, and <tt>:urls</tt>. If a block is given, each URL and
# e-mail address is yielded and the result is used as the link text.
#
Expand All @@ -341,7 +341,7 @@ def simple_format(text, html_options={})
# # => "Visit http://www.loudthinking.com/ or e-mail <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>"
#
# post_body = "Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com."
# auto_link(post_body, :html => { :target => '_blank' }) do |text|
# auto_link(post_body, :href_options => { :target => '_blank' }) do |text|
# truncate(text, 15)
# end
# # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.m...</a>.
Expand All @@ -359,7 +359,7 @@ def simple_format(text, html_options={})
# auto_link(post_body, :all, :target => "_blank") # => Once upon\na time
# # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.myblog.com</a>.
# Please e-mail me at <a href=\"mailto:me@email.com\">me@email.com</a>."
def auto_link(text, *args, &block)#link = :all, html = {}, &block)
def auto_link(text, *args, &block)#link = :all, href_options = {}, &block)
return '' if text.blank?

options = args.size == 2 ? {} : args.extract_options! # this is necessary because the old auto_link API has a Hash as its last parameter
Expand Down
2 changes: 1 addition & 1 deletion vendor/rails/actionpack/lib/action_view/paths.rb
Expand Up @@ -61,7 +61,7 @@ def find_template(original_template_path, format = nil, html_fallback = true)
end
end

return Template.new(original_template_path) if File.file?(original_template_path)
return Template.new(original_template_path, original_template_path.to_s =~ /\A\// ? "" : ".") if File.file?(original_template_path)

raise MissingTemplate.new(self, original_template_path, format)
end
Expand Down

0 comments on commit 1e18650

Please sign in to comment.