aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-01-28 07:16:55 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-01-28 07:16:55 +0000
commit0eacdcf9a3e37e05f47a4ded7f0a4aff3b65fbe4 (patch)
tree74705adf7f9a35c750f74657f0c4a29a6dcce5ff /actionpack/lib
parent4ac332fa9a16ae86b948251e372999b9f4618dec (diff)
downloadrails-0eacdcf9a3e37e05f47a4ded7f0a4aff3b65fbe4.tar.gz
rails-0eacdcf9a3e37e05f47a4ded7f0a4aff3b65fbe4.tar.bz2
rails-0eacdcf9a3e37e05f47a4ded7f0a4aff3b65fbe4.zip
Use a consistent load path to avoid double requires. Fix some scattered Ruby warnings.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6057 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller.rb6
-rw-r--r--actionpack/lib/action_controller/assertions/response_assertions.rb2
-rw-r--r--actionpack/lib/action_controller/assertions/selector_assertions.rb2
-rw-r--r--actionpack/lib/action_controller/assertions/tag_assertions.rb4
-rw-r--r--actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb3
-rw-r--r--actionpack/lib/action_controller/integration.rb2
-rw-r--r--actionpack/lib/action_controller/mime_type.rb2
-rwxr-xr-xactionpack/lib/action_controller/request.rb1
-rw-r--r--actionpack/lib/action_controller/routing.rb4
-rw-r--r--actionpack/lib/action_controller/test_process.rb6
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/document.rb7
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb15
-rw-r--r--actionpack/lib/action_view.rb3
-rw-r--r--actionpack/lib/action_view/base.rb14
-rw-r--r--actionpack/lib/action_view/helpers/active_record_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/java_script_macros_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/scriptaculous_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb16
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb2
25 files changed, 57 insertions, 58 deletions
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb
index 283238bb93..90c23604db 100755
--- a/actionpack/lib/action_controller.rb
+++ b/actionpack/lib/action_controller.rb
@@ -26,14 +26,16 @@ $:.unshift(File.dirname(__FILE__)) unless
unless defined?(ActiveSupport)
begin
- $:.unshift(File.dirname(__FILE__) + "/../../activesupport/lib")
- require 'active_support'
+ $:.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
+ require 'active_support'
rescue LoadError
require 'rubygems'
require_gem 'activesupport'
end
end
+$:.unshift "#{File.dirname(__FILE__)}/action_controller/vendor/html-scanner"
+
require 'action_controller/base'
require 'action_controller/deprecated_redirects'
require 'action_controller/request'
diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb
index 0811920e4a..cf30569f36 100644
--- a/actionpack/lib/action_controller/assertions/response_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require File.dirname(__FILE__) + "/../vendor/html-scanner/html/document"
+require 'html/document'
module ActionController
module Assertions
diff --git a/actionpack/lib/action_controller/assertions/selector_assertions.rb b/actionpack/lib/action_controller/assertions/selector_assertions.rb
index f9d67fb5bd..a5e022662c 100644
--- a/actionpack/lib/action_controller/assertions/selector_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/selector_assertions.rb
@@ -4,7 +4,7 @@
#++
require 'rexml/document'
-require File.dirname(__FILE__) + "/../vendor/html-scanner/html/document"
+require 'html/document'
module ActionController
module Assertions
diff --git a/actionpack/lib/action_controller/assertions/tag_assertions.rb b/actionpack/lib/action_controller/assertions/tag_assertions.rb
index f5f7a23e61..df8e812b3c 100644
--- a/actionpack/lib/action_controller/assertions/tag_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/tag_assertions.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require File.dirname(__FILE__) + "/../vendor/html-scanner/html/document"
+require 'html/document'
module ActionController
module Assertions
@@ -114,4 +114,4 @@ module ActionController
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb b/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb
index 4c124cb266..3576f99a94 100644
--- a/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb
+++ b/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb
@@ -1,5 +1,8 @@
class CGI #:nodoc:
module QueryExtension
+ # Remove the old initialize_query method before redefining it.
+ remove_method :initialize_query
+
# Initialize the data from the query.
#
# Handles multipart forms (in particular, forms that involve file uploads).
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb
index d77540a297..c2f1fcf1f9 100644
--- a/actionpack/lib/action_controller/integration.rb
+++ b/actionpack/lib/action_controller/integration.rb
@@ -72,7 +72,7 @@ module ActionController
self.remote_addr = "127.0.0.1"
self.accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
- unless @named_routes_configured
+ unless defined? @named_routes_configured
# install the named routes in this session instance.
klass = class<<self; self; end
Routing::Routes.named_routes.install(klass)
diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb
index 9c4fe63ab0..79da49e789 100644
--- a/actionpack/lib/action_controller/mime_type.rb
+++ b/actionpack/lib/action_controller/mime_type.rb
@@ -142,4 +142,4 @@ module Mime
end
end
-require File.dirname(__FILE__) + "/mime_types" \ No newline at end of file
+require 'action_controller/mime_types'
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index 62ce9929da..b1c8692ce1 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -3,6 +3,7 @@ module ActionController
# CgiRequest and TestRequest
class AbstractRequest
cattr_accessor :relative_url_root
+ remove_method :relative_url_root
# Returns the hash of environment variables for this request,
# such as { 'RAILS_ENV' => 'production' }.
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index 4c6377eef7..333be93b6f 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -507,9 +507,9 @@ module ActionController
end
end
end
-
+
def matches_controller_and_action?(controller, action)
- unless @matching_prepared
+ unless defined? @matching_prepared
@controller_requirement = requirement_for(:controller)
@action_requirement = requirement_for(:action)
@matching_prepared = true
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 49a8a4a0e3..beccec6f94 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/assertions'
+require 'action_controller/assertions'
module ActionController #:nodoc:
class Base
@@ -90,11 +90,11 @@ module ActionController #:nodoc:
end
def request_uri
- @request_uri || super()
+ @request_uri || super
end
def path
- @path || super()
+ @path || super
end
def assign_parameters(controller_path, action, parameters)
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
index 19b349e886..29422937b2 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
@@ -1,9 +1,8 @@
-require File.dirname(__FILE__) + '/tokenizer'
-require File.dirname(__FILE__) + '/node'
-require File.dirname(__FILE__) + '/selector'
+require 'html/tokenizer'
+require 'html/node'
+require 'html/selector'
module HTML #:nodoc:
-
# A top-level HTMl document. You give it a body of text, and it will parse that
# text into a tree of nodes.
class Document #:nodoc:
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
index 287afcc3c4..7ffc1fcfa8 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
@@ -240,19 +240,24 @@ module HTML
raise ArgumentError, "CSS expression cannot be empty" if selector.empty?
@source = ""
values = values[0] if values.size == 1 && values[0].is_a?(Array)
+
# We need a copy to determine if we failed to parse, and also
# preserve the original pass by-ref statement.
statement = selector.strip.dup
+
# Create a simple selector, along with negation.
simple_selector(statement, values).each { |name, value| instance_variable_set("@#{name}", value) }
+ @alternates = []
+ @depends = nil
+
# Alternative selector.
if statement.sub!(/^\s*,\s*/, "")
second = Selector.new(statement, values)
- (@alternates ||= []) << second
+ @alternates << second
# If there are alternate selectors, we group them in the top selector.
if alternates = second.instance_variable_get(:@alternates)
- second.instance_variable_set(:@alternates, nil)
+ second.instance_variable_set(:@alternates, [])
@alternates.concat alternates
end
@source << " , " << second.to_s
@@ -412,7 +417,7 @@ module HTML
# If this selector is part of the group, try all the alternative
# selectors (unless first_only).
- if @alternates && (!first_only || !matches)
+ if !first_only || !matches
@alternates.each do |alternate|
break if matches && first_only
if subset = alternate.match(element, first_only)
@@ -796,8 +801,8 @@ module HTML
second = Selector.new(statement, values)
# If there are alternate selectors, we group them in the top selector.
if alternates = second.instance_variable_get(:@alternates)
- second.instance_variable_set(:@alternates, nil)
- (@alternates ||= []).concat alternates
+ second.instance_variable_set(:@alternates, [])
+ @alternates.concat alternates
end
second
end
diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb
index 72ef810bd9..db7820ca0b 100644
--- a/actionpack/lib/action_view.rb
+++ b/actionpack/lib/action_view.rb
@@ -21,7 +21,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
-$:.unshift(File.dirname(__FILE__) + "/action_view/vendor")
require 'action_view/base'
require 'action_view/partials'
@@ -29,4 +28,4 @@ ActionView::Base.class_eval do
include ActionView::Partials
end
-ActionView::Base.load_helpers(File.dirname(__FILE__) + "/action_view/helpers/")
+ActionView::Base.load_helpers
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index dfe421c312..303a946186 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -157,7 +157,7 @@ module ActionView #:nodoc:
attr_accessor :controller
attr_reader :logger, :response, :headers
- attr_internal *ActionController::Base::DEPRECATED_INSTANCE_VARIABLES
+ attr_internal(*ActionController::Base::DEPRECATED_INSTANCE_VARIABLES)
# Specify trim mode for the ERB compiler. Defaults to '-'.
# See ERB documentation for suitable values.
@@ -210,12 +210,14 @@ module ActionView #:nodoc:
class ObjectWrapper < Struct.new(:value) #:nodoc:
end
- def self.load_helpers(helper_dir)#:nodoc:
- Dir.entries(helper_dir).sort.each do |helper_file|
- next unless helper_file =~ /^([a-z][a-z_]*_helper).rb$/
- require File.join(helper_dir, $1)
+ def self.load_helpers #:nodoc:
+ Dir.entries("#{File.dirname(__FILE__)}/helpers").sort.each do |file|
+ next unless file =~ /^([a-z][a-z_]*_helper).rb$/
+ require "action_view/helpers/#{$1}"
helper_module_name = $1.camelize
- class_eval("include ActionView::Helpers::#{helper_module_name}") if Helpers.const_defined?(helper_module_name)
+ if Helpers.const_defined?(helper_module_name)
+ include Helpers.const_get(helper_module_name)
+ end
end
end
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb
index 33eaa13898..dcaf54be46 100644
--- a/actionpack/lib/action_view/helpers/active_record_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -1,5 +1,5 @@
require 'cgi'
-require File.dirname(__FILE__) + '/form_helper'
+require 'action_view/helpers/form_helper'
module ActionView
class Base
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index fedbf262a1..b2a0d5344a 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -1,6 +1,6 @@
require 'cgi'
-require File.dirname(__FILE__) + '/url_helper'
-require File.dirname(__FILE__) + '/tag_helper'
+require 'action_view/helpers/url_helper'
+require 'action_view/helpers/tag_helper'
module ActionView
module Helpers #:nodoc:
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index dc9ef4f9ef..045852d8db 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -1,6 +1,6 @@
require 'cgi'
-require File.dirname(__FILE__) + '/date_helper'
-require File.dirname(__FILE__) + '/tag_helper'
+require 'action_view/helpers/date_helper'
+require 'action_view/helpers/tag_helper'
module ActionView
module Helpers
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 6b3da64f7d..4dafc471f8 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -1,6 +1,6 @@
require 'cgi'
require 'erb'
-require File.dirname(__FILE__) + '/form_helper'
+require 'action_view/helpers/form_helper'
module ActionView
module Helpers
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 3de3a9372b..3b0e555bbd 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -1,5 +1,5 @@
require 'cgi'
-require File.dirname(__FILE__) + '/tag_helper'
+require 'action_view/helpers/tag_helper'
module ActionView
module Helpers
diff --git a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb
index 463fe0e120..6304a1a8b2 100644
--- a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb
+++ b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/tag_helper'
+require 'action_view/helpers/tag_helper'
module ActionView
module Helpers
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb
index 7bce6b91eb..ad74a85584 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/tag_helper'
-require File.dirname(__FILE__) + '/prototype_helper'
+require 'action_view/helpers/tag_helper'
+require 'action_view/helpers/prototype_helper'
module ActionView
module Helpers
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 43d04baf8d..ed3f7b7d7f 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -860,7 +860,7 @@ module ActionView
add_variable_assignment!(options[:variable]) if options[:variable]
append_enumerable_function!("#{enumerable.to_s.camelize(:lower)}(#{method_args}function(#{yield_args}) {")
# only yield as many params as were passed in the block
- yield *options[:yield_args].collect { |p| JavaScriptVariableProxy.new(@generator, p) }[0..block.arity-1]
+ yield(*options[:yield_args].collect { |p| JavaScriptVariableProxy.new(@generator, p) }[0..block.arity-1])
add_return_statement! if options[:return]
@generator << '});'
end
@@ -889,4 +889,4 @@ module ActionView
end
end
-require File.dirname(__FILE__) + '/javascript_helper'
+require 'action_view/helpers/javascript_helper'
diff --git a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb
index 2c416b0026..f79a3c50e3 100644
--- a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb
+++ b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/javascript_helper'
+require 'action_view/helpers/javascript_helper'
module ActionView
module Helpers
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 236e1492ac..e60f6c2986 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -1,4 +1,5 @@
-require File.dirname(__FILE__) + '/tag_helper'
+require 'action_view/helpers/tag_helper'
+require 'html/document'
module ActionView
module Helpers #:nodoc:
@@ -192,19 +193,6 @@ module ActionView
text.gsub(/<a\b.*?>(.*?)<\/a>/mi, '\1')
end
- # Try to require the html-scanner library
- begin
- require 'html/tokenizer'
- require 'html/node'
- rescue LoadError
- # if there isn't a copy installed, use the vendor version in
- # ActionController
- $:.unshift File.join(File.dirname(__FILE__), "..", "..",
- "action_controller", "vendor", "html-scanner")
- require 'html/tokenizer'
- require 'html/node'
- end
-
VERBOTEN_TAGS = %w(form script plaintext) unless defined?(VERBOTEN_TAGS)
VERBOTEN_ATTRS = /^on/i unless defined?(VERBOTEN_ATTRS)
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 6a66585387..4e911b94bf 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/javascript_helper'
+require 'action_view/helpers/javascript_helper'
module ActionView
module Helpers #:nodoc: