1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Ruby 1.9 compat, consistent load paths

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7719 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2007-10-02 05:32:14 +00:00
parent 9264bdc8f6
commit 0ee1cb2cd3
69 changed files with 307 additions and 278 deletions

View file

@ -49,7 +49,7 @@ module ActionMailer
begin
require_dependency(file_name)
rescue LoadError => load_error
requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1]
requiree = / -- (.*?)(\.rb)?$/.match(load_error.message).to_a[1]
msg = (requiree == file_name) ? "Missing helper file helpers/#{file_name}.rb" : "Can't load file: #{requiree}"
raise LoadError.new(msg).copy_blame!(load_error)
end
@ -72,7 +72,7 @@ module ActionMailer
methods.flatten.each do |method|
master_helper_module.module_eval <<-end_eval
def #{method}(*args, &block)
controller.send(%(#{method}), *args, &block)
controller.send!(%(#{method}), *args, &block)
end
end_eval
end
@ -92,7 +92,7 @@ module ActionMailer
inherited_without_helper(child)
begin
child.master_helper_module = Module.new
child.master_helper_module.send :include, master_helper_module
child.master_helper_module.send! :include, master_helper_module
child.helper child.name.underscore
rescue MissingSourceFile => e
raise unless e.is_missing?("helpers/#{child.name.underscore}_helper")
@ -108,4 +108,4 @@ module ActionMailer
end
end
end
end
end

View file

@ -46,7 +46,7 @@ module ActionController #:nodoc:
def self.included(klass)
%w(response selector tag dom routing model).each do |kind|
require "action_controller/assertions/#{kind}_assertions"
klass.send :include, const_get("#{kind.camelize}Assertions")
klass.module_eval { include const_get("#{kind.camelize}Assertions") }
end
end
@ -66,4 +66,4 @@ module Test #:nodoc:
include ActionController::Assertions
end
end
end
end

View file

@ -392,7 +392,7 @@ module ActionController #:nodoc:
# More methods can be hidden using <tt>hide_actions</tt>.
def hidden_actions
unless read_inheritable_attribute(:hidden_actions)
write_inheritable_attribute(:hidden_actions, ActionController::Base.public_instance_methods)
write_inheritable_attribute(:hidden_actions, ActionController::Base.public_instance_methods.map(&:to_s))
end
read_inheritable_attribute(:hidden_actions)
@ -400,12 +400,12 @@ module ActionController #:nodoc:
# Hide each of the given methods from being callable as actions.
def hide_action(*names)
write_inheritable_attribute(:hidden_actions, hidden_actions | names.collect { |n| n.to_s })
write_inheritable_attribute(:hidden_actions, hidden_actions | names.map(&:to_s))
end
@@view_paths = {}
# View load paths determine the bases from which template references can be made. So a call to
# render("test/template") will be looked up in the view load paths array and the closest match will be
# returned.
@ -844,19 +844,19 @@ module ActionController #:nodoc:
if collection = options[:collection]
render_for_text(
@template.send(:render_partial_collection, partial, collection,
@template.send!(:render_partial_collection, partial, collection,
options[:spacer_template], options[:locals]), options[:status]
)
else
render_for_text(
@template.send(:render_partial, partial,
@template.send!(:render_partial, partial,
ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals]), options[:status]
)
end
elsif options[:update]
add_variables_to_assigns
@template.send :evaluate_assigns
@template.send! :evaluate_assigns
generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(@template, &block)
response.content_type = Mime::JS
@ -1104,7 +1104,7 @@ module ActionController #:nodoc:
send(action_name)
render unless performed?
elsif respond_to? :method_missing
send(:method_missing, action_name)
method_missing action_name
render unless performed?
elsif template_exists? && template_public?
render
@ -1135,7 +1135,7 @@ module ActionController #:nodoc:
end
def self.action_methods
@action_methods ||= Set.new(public_instance_methods - hidden_actions)
@action_methods ||= Set.new(public_instance_methods.map(&:to_s)) - hidden_actions
end
def add_variables_to_assigns

View file

@ -238,7 +238,7 @@ module ActionController #:nodoc:
if cache = controller.read_fragment(cache_path.path)
controller.rendered_action_cache = true
set_content_type!(controller, cache_path.extension)
controller.send(:render_for_text, cache)
controller.send!(:render_for_text, cache)
false
else
controller.action_cache_path = cache_path
@ -470,7 +470,7 @@ module ActionController #:nodoc:
super
if ActionController::Base.allow_concurrency
@mutex = Mutex.new
MemoryStore.send(:include, ThreadSafety)
MemoryStore.module_eval { include ThreadSafety }
end
end
end
@ -560,7 +560,7 @@ module ActionController #:nodoc:
super(cache_path)
if ActionController::Base.allow_concurrency
@mutex = Mutex.new
FileStore.send(:include, ThreadSafety)
FileStore.module_eval { include ThreadSafety }
end
end
end
@ -642,13 +642,13 @@ module ActionController #:nodoc:
controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}"
action_callback_method_name = "#{controller_callback_method_name}_#{controller.action_name}"
send(controller_callback_method_name) if respond_to?(controller_callback_method_name)
send(action_callback_method_name) if respond_to?(action_callback_method_name)
send!(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
send!(action_callback_method_name) if respond_to?(action_callback_method_name, true)
end
def method_missing(method, *arguments)
return if @controller.nil?
@controller.send(method, *arguments)
@controller.send!(method, *arguments)
end
end
end

View file

@ -42,7 +42,7 @@ module ActionController #:nodoc:
def initialize(cgi, session_options = {})
@cgi = cgi
@session_options = session_options
@env = @cgi.send(:env_table)
@env = @cgi.send!(:env_table)
super()
end
@ -138,7 +138,7 @@ module ActionController #:nodoc:
end
def method_missing(method_id, *arguments)
@cgi.send(method_id, *arguments) rescue super
@cgi.send!(method_id, *arguments) rescue super
end
private
@ -191,7 +191,7 @@ end_msg
begin
output.write(@cgi.header(@headers))
if @cgi.send(:env_table)['REQUEST_METHOD'] == 'HEAD'
if @cgi.send!(:env_table)['REQUEST_METHOD'] == 'HEAD'
return
elsif @body.respond_to?(:call)
# Flush the output now in case the @body Proc uses

View file

@ -36,20 +36,20 @@ module ActionController #:nodoc:
# So to repeat: Components are a special-purpose approach that can often be replaced with better use of partials and filters.
module Components
def self.included(base) #:nodoc:
base.send :include, InstanceMethods
base.extend(ClassMethods)
base.helper do
def render_component(options)
@controller.send(:render_component_as_string, options)
end
end
# If this controller was instantiated to process a component request,
# +parent_controller+ points to the instantiator of this controller.
base.send :attr_accessor, :parent_controller
base.class_eval do
include InstanceMethods
extend ClassMethods
helper do
def render_component(options)
@controller.send!(:render_component_as_string, options)
end
end
# If this controller was instantiated to process a component request,
# +parent_controller+ points to the instantiator of this controller.
attr_accessor :parent_controller
alias_method_chain :process_cleanup, :components
alias_method_chain :set_session_options, :components
alias_method_chain :flash, :components
@ -162,4 +162,4 @@ module ActionController #:nodoc:
end
end
end
end
end

View file

@ -71,7 +71,7 @@ module ActionController
end
def log_failsafe_exception(status, exception)
message = "/!\ FAILSAFE /!\ #{Time.now}\n Status: #{status}\n"
message = "/!\\ FAILSAFE /!\\ #{Time.now}\n Status: #{status}\n"
message << " #{exception}\n #{exception.backtrace.join("\n ")}" if exception
failsafe_logger.fatal message
end
@ -136,7 +136,12 @@ module ActionController
end
def prepare_application(force = false)
require_dependency 'application' unless defined?(::ApplicationController)
begin
require_dependency 'application' unless defined?(::ApplicationController)
rescue LoadError => error
raise unless error.message =~ /application\.rb/
end
ActiveRecord::Base.verify_active_connections! if defined?(ActiveRecord)
if unprepared || force
@ -166,10 +171,10 @@ module ActionController
end
def run_callbacks(kind, enumerator = :each)
callbacks[kind].send(enumerator) do |callback|
callbacks[kind].send!(enumerator) do |callback|
case callback
when Proc; callback.call(self)
when String, Symbol; send(callback)
when String, Symbol; send!(callback)
when Array; callback[1].call(self)
else raise ArgumentError, "Unrecognized callback #{callback.inspect}"
end

View file

@ -1,8 +1,10 @@
module ActionController #:nodoc:
module Filters #:nodoc:
def self.included(base)
base.extend(ClassMethods)
base.send(:include, ActionController::Filters::InstanceMethods)
base.class_eval do
extend ClassMethods
include ActionController::Filters::InstanceMethods
end
end
# Filters enable controllers to run shared pre and post processing code for its actions. These filters can be used to do
@ -440,7 +442,7 @@ module ActionController #:nodoc:
def run(controller)
# only filters returning false are halted.
if false == @filter.call(controller)
controller.send :halt_filter_chain, @filter, :returned_false
controller.send! :halt_filter_chain, @filter, :returned_false
end
end
@ -466,7 +468,7 @@ module ActionController #:nodoc:
class SymbolFilter < Filter #:nodoc:
def call(controller, &block)
controller.send(@filter, &block)
controller.send!(@filter, &block)
end
end
@ -656,7 +658,7 @@ module ActionController #:nodoc:
return filter unless filter_responds_to_before_and_after(filter)
Proc.new do |controller, action|
if filter.before(controller) == false
controller.send :halt_filter_chain, filter, :returned_false
controller.send! :halt_filter_chain, filter, :returned_false
else
begin
action.call
@ -754,4 +756,4 @@ module ActionController #:nodoc:
end
end
end
end
end

View file

@ -25,9 +25,8 @@ module ActionController #:nodoc:
# See docs on the FlashHash class for more details about the flash.
module Flash
def self.included(base)
base.send :include, InstanceMethods
base.class_eval do
include InstanceMethods
alias_method_chain :assign_shortcuts, :flash
alias_method_chain :process_cleanup, :flash
alias_method_chain :reset_session, :flash
@ -175,4 +174,4 @@ module ActionController #:nodoc:
end
end
end
end
end

View file

@ -68,7 +68,7 @@ module ActionController #:nodoc:
# See ActionView::Helpers (link:classes/ActionView/Helpers.html) for more about making your own helper modules
# available to the templates.
def add_template_helper(helper_module) #:nodoc:
master_helper_module.send(:include, helper_module)
master_helper_module.module_eval { include helper_module }
end
# The +helper+ class method can take a series of helper module names, a block, or both.
@ -169,10 +169,12 @@ module ActionController #:nodoc:
private
def default_helper_module!
module_name = name.sub(/Controller$|$/, 'Helper')
module_path = module_name.split('::').map { |m| m.underscore }.join('/')
require_dependency module_path
helper module_name.constantize
unless name.blank?
module_name = name.sub(/Controller$|$/, 'Helper')
module_path = module_name.split('::').map { |m| m.underscore }.join('/')
require_dependency module_path
helper module_name.constantize
end
rescue MissingSourceFile => e
raise unless e.is_missing? module_path
logger.debug("#{name}: missing default helper path #{module_path}") if logger
@ -186,8 +188,8 @@ module ActionController #:nodoc:
begin
child.master_helper_module = Module.new
child.master_helper_module.send :include, master_helper_module
child.send :default_helper_module!
child.master_helper_module.send! :include, master_helper_module
child.send! :default_helper_module!
rescue MissingSourceFile => e
raise unless e.is_missing?("helpers/#{child.controller_path}_helper")
end
@ -200,4 +202,4 @@ module ActionController #:nodoc:
end
end
end
end
end

View file

@ -121,9 +121,9 @@ module ActionController
def authentication_request(controller, realm)
controller.headers["WWW-Authenticate"] = %(Basic realm="#{realm.gsub(/"/, "")}")
controller.send :render, :text => "HTTP Basic: Access denied.\n", :status => :unauthorized
return false
controller.send! :render, :text => "HTTP Basic: Access denied.\n", :status => :unauthorized
return false
end
end
end
end
end

View file

@ -83,7 +83,7 @@ module ActionController
# the helpers are made protected by default--we make them public for
# easier access during testing and troubleshooting.
klass.send(:public, *Routing::Routes.named_routes.helpers)
klass.module_eval { public *Routing::Routes.named_routes.helpers }
@named_routes_configured = true
end
end
@ -252,7 +252,7 @@ module ActionController
end
unless ActionController::Base.respond_to?(:clear_last_instantiation!)
ActionController::Base.send(:include, ControllerCapture)
ActionController::Base.module_eval { include ControllerCapture }
end
ActionController::Base.clear_last_instantiation!
@ -498,7 +498,7 @@ module ActionController
reset! unless @integration_session
# reset the html_document variable, but only for new get/post calls
@html_document = nil unless %w(cookies assigns).include?(method)
returning @integration_session.send(method, *args) do
returning @integration_session.send!(method, *args) do
copy_session_variables!
end
end
@ -522,11 +522,11 @@ module ActionController
self.class.fixture_table_names.each do |table_name|
name = table_name.tr(".", "_")
next unless respond_to?(name)
extras.send(:define_method, name) { |*args| delegate.send(name, *args) }
extras.send!(:define_method, name) { |*args| delegate.send(name, *args) }
end
# delegate add_assertion to the test case
extras.send(:define_method, :add_assertion) { test_result.add_assertion }
extras.send!(:define_method, :add_assertion) { test_result.add_assertion }
session.extend(extras)
session.delegate = self
session.test_result = @_result
@ -540,16 +540,16 @@ module ActionController
def copy_session_variables! #:nodoc:
return unless @integration_session
%w(controller response request).each do |var|
instance_variable_set("@#{var}", @integration_session.send(var))
instance_variable_set("@#{var}", @integration_session.send!(var))
end
end
# Delegate unhandled messages to the current session instance.
def method_missing(sym, *args, &block)
reset! unless @integration_session
returning @integration_session.send(sym, *args, &block) do
returning @integration_session.send!(sym, *args, &block) do
copy_session_variables!
end
end
end
end
end

View file

@ -194,8 +194,10 @@ module ActionController #:nodoc:
private
def inherited_with_layout(child)
inherited_without_layout(child)
layout_match = child.name.underscore.sub(/_controller$/, '').sub(/^controllers\//, '')
child.layout(layout_match, {}, true) unless child.layout_list.grep(%r{layouts/#{layout_match}(\.[a-z][0-9a-z]*)+$}).empty?
unless child.name.blank?
layout_match = child.name.underscore.sub(/_controller$/, '').sub(/^controllers\//, '')
child.layout(layout_match, {}, true) unless child.layout_list.grep(%r{layouts/#{layout_match}(\.[a-z][0-9a-z]*)+$}).empty?
end
end
def add_layout_conditions(conditions)
@ -230,7 +232,7 @@ module ActionController #:nodoc:
layout = passed_layout || self.class.default_layout(response.template.template_format)
active_layout = case layout
when String then layout
when Symbol then send(layout)
when Symbol then send!(layout)
when Proc then layout.call(self)
end
@ -316,7 +318,7 @@ module ActionController #:nodoc:
def layout_directory?(layout_name)
view_paths.find do |path|
next unless template_path = Dir[File.join(path, 'layouts', layout_name) + ".*"].first
self.class.send(:layout_directory_exists_cache)[File.dirname(template_path)]
self.class.send!(:layout_directory_exists_cache)[File.dirname(template_path)]
end
end
end

View file

@ -1,7 +1,9 @@
module ActionController #:nodoc:
module MimeResponds #:nodoc:
def self.included(base)
base.send(:include, ActionController::MimeResponds::InstanceMethods)
base.module_eval do
include ActionController::MimeResponds::InstanceMethods
end
end
module InstanceMethods
@ -176,4 +178,4 @@ module ActionController #:nodoc:
end
end
end
end
end

View file

@ -59,9 +59,9 @@ module Mime
end
def register(string, symbol, mime_type_synonyms = [], extension_synonyms = [], skip_lookup = false)
Mime.send :const_set, symbol.to_s.upcase, Type.new(string, symbol, mime_type_synonyms)
Mime.instance_eval { const_set symbol.to_s.upcase, Type.new(string, symbol, mime_type_synonyms) }
SET << Mime.send(:const_get, symbol.to_s.upcase)
SET << Mime.const_get(symbol.to_s.upcase)
([string] + mime_type_synonyms).each { |string| LOOKUP[string] = SET.last } unless skip_lookup
([symbol.to_s] + extension_synonyms).each { |ext| EXTENSION_LOOKUP[ext] = SET.last }
@ -160,4 +160,4 @@ module Mime
end
end
require 'action_controller/mime_types'
require 'action_controller/mime_types'

View file

@ -6,8 +6,8 @@ module ActionController
namespace = extract_namespace(record_or_hash_or_array)
args = case record_or_hash_or_array
when Hash: [ record_or_hash_or_array ]
when Array: record_or_hash_or_array.dup
when Hash; [ record_or_hash_or_array ]
when Array; record_or_hash_or_array.dup
else [ record_or_hash_or_array ]
end
@ -24,7 +24,7 @@ module ActionController
end
named_route = build_named_route_call(record_or_hash_or_array, namespace, inflection, options)
send(named_route, *args)
send!(named_route, *args)
end
def polymorphic_path(record_or_hash_or_array)
@ -55,10 +55,10 @@ module ActionController
def build_named_route_call(records, namespace, inflection, options = {})
records = Array.new([extract_record(records)]) unless records.is_a?(Array)
base_segment = "#{RecordIdentifier.send("#{inflection}_class_name", records.pop)}_"
base_segment = "#{RecordIdentifier.send!("#{inflection}_class_name", records.pop)}_"
method_root = records.reverse.inject(base_segment) do |string, name|
segment = "#{RecordIdentifier.send("singular_class_name", name)}_"
segment = "#{RecordIdentifier.send!("singular_class_name", name)}_"
segment << string
end
@ -67,8 +67,8 @@ module ActionController
def extract_record(record_or_hash_or_array)
case record_or_hash_or_array
when Array: record_or_hash_or_array.last
when Hash: record_or_hash_or_array[:id]
when Array; record_or_hash_or_array.last
when Hash; record_or_hash_or_array[:id]
else record_or_hash_or_array
end
end
@ -85,4 +85,4 @@ module ActionController
end
end
end
end
end

View file

@ -109,7 +109,7 @@ module ActionController
# "XMLHttpRequest". (The Prototype Javascript library sends this header with
# every Ajax request.)
def xml_http_request?
not /XMLHttpRequest/i.match(@env['HTTP_X_REQUESTED_WITH']).nil?
!(@env['HTTP_X_REQUESTED_WITH'] !~ /XMLHttpRequest/i)
end
alias xhr? :xml_http_request?
@ -120,13 +120,10 @@ module ActionController
# delimited list in the case of multiple chained proxies; the first is
# the originating IP.
#
# Security note: Be aware that since remote_ip will check regular HTTP headers,
# it can be tricked by anyone setting those manually. In other words, people can
# pose as whatever IP address they like to this method. That doesn't matter if
# all your doing is using IP addresses for statistical or geographical information,
# but if you want to, for example, limit access to an administrative area by IP,
# you should instead use Request#remote_addr, which can't be spoofed (but also won't
# survive proxy forwards).
# Security note: do not use if IP spoofing is a concern for your
# application. Since remote_ip checks HTTP headers for addresses forwarded
# by proxies, the client may send any IP. remote_addr can't be spoofed but
# also doesn't work behind a proxy, since it's always the proxy's IP.
def remote_ip
return @env['HTTP_CLIENT_IP'] if @env.include? 'HTTP_CLIENT_IP'
@ -222,7 +219,13 @@ module ActionController
unless (env_qs = @env['QUERY_STRING']).nil? || env_qs.empty?
uri << '?' << env_qs
end
@env['REQUEST_URI'] = uri
if uri.nil?
@env.delete('REQUEST_URI')
uri
else
@env['REQUEST_URI'] = uri
end
end
end
@ -682,4 +685,4 @@ module ActionController
raise TypeError, "Conflicting types for parameter containers. Expected an instance of #{klass} but found an instance of #{value.class}. This can be caused by colliding Array and Hash parameters like qs[]=value&qs[key]=value."
end
end
end
end

View file

@ -150,7 +150,7 @@ module ActionController #:nodoc:
add_variables_to_assigns
@template.instance_variable_set("@exception", exception)
@template.instance_variable_set("@rescues_path", File.dirname(rescues_path("stub")))
@template.send(:assign_variables_from_controller)
@template.send!(:assign_variables_from_controller)
@template.instance_variable_set("@contents", @template.render_file(template_path_for_local_rescue(exception), false))
@ -207,4 +207,4 @@ module ActionController #:nodoc:
end
end
end
end
end

View file

@ -513,15 +513,17 @@ module ActionController
default_options = { :action => action.to_s }
require_id = !resource.kind_of?(SingletonResource)
case default_options[:action]
when "index", "new" : default_options.merge(add_conditions_for(resource.conditions, method || :get)).merge(resource.requirements)
when "create" : default_options.merge(add_conditions_for(resource.conditions, method || :post)).merge(resource.requirements)
when "show", "edit" : default_options.merge(add_conditions_for(resource.conditions, method || :get)).merge(resource.requirements(require_id))
when "update" : default_options.merge(add_conditions_for(resource.conditions, method || :put)).merge(resource.requirements(require_id))
when "destroy" : default_options.merge(add_conditions_for(resource.conditions, method || :delete)).merge(resource.requirements(require_id))
when "index", "new"; default_options.merge(add_conditions_for(resource.conditions, method || :get)).merge(resource.requirements)
when "create"; default_options.merge(add_conditions_for(resource.conditions, method || :post)).merge(resource.requirements)
when "show", "edit"; default_options.merge(add_conditions_for(resource.conditions, method || :get)).merge(resource.requirements(require_id))
when "update"; default_options.merge(add_conditions_for(resource.conditions, method || :put)).merge(resource.requirements(require_id))
when "destroy"; default_options.merge(add_conditions_for(resource.conditions, method || :delete)).merge(resource.requirements(require_id))
else default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements)
end
end
end
end
ActionController::Routing::RouteSet::Mapper.send :include, ActionController::Resources
class ActionController::Routing::RouteSet::Mapper
include ActionController::Resources
end

View file

@ -1092,7 +1092,7 @@ module ActionController
@module ||= Module.new
@module.instance_methods.each do |selector|
@module.send :remove_method, selector
@module.class_eval { remove_method selector }
end
end
@ -1132,7 +1132,9 @@ module ActionController
def install(destinations = [ActionController::Base, ActionView::Base], regenerate = false)
reset! if regenerate
Array(destinations).each { |dest| dest.send :include, @module }
Array(destinations).each do |dest|
dest.send! :include, @module
end
end
private
@ -1154,12 +1156,12 @@ module ActionController
def define_hash_access(route, name, kind, options)
selector = hash_access_name(name, kind)
@module.send :module_eval, <<-end_eval # We use module_eval to avoid leaks
@module.module_eval <<-end_eval # We use module_eval to avoid leaks
def #{selector}(options = nil)
options ? #{options.inspect}.merge(options) : #{options.inspect}
end
protected :#{selector}
end_eval
@module.send(:protected, selector)
helpers << selector
end
@ -1182,7 +1184,7 @@ module ActionController
#
# foo_url(bar, baz, bang, :sort_by => 'baz')
#
@module.send :module_eval, <<-end_eval # We use module_eval to avoid leaks
@module.module_eval <<-end_eval # We use module_eval to avoid leaks
def #{selector}(*args)
#{generate_optimisation_block(route, kind)}
@ -1199,8 +1201,8 @@ module ActionController
url_for(#{hash_access_method}(opts))
end
protected :#{selector}
end_eval
@module.send(:protected, selector)
helpers << selector
end
end
@ -1232,7 +1234,7 @@ module ActionController
end
def install_helpers(destinations = [ActionController::Base, ActionView::Base], regenerate_code = false)
Array(destinations).each { |d| d.send :include, Helpers }
Array(destinations).each { |d| d.module_eval { include Helpers } }
named_routes.install(destinations, regenerate_code)
end
@ -1362,7 +1364,7 @@ module ActionController
if generate_all
# Used by caching to expire all paths for a resource
return routes.collect do |route|
route.send(method, options, merged, expire_on)
route.send!(method, options, merged, expire_on)
end.compact
end
@ -1370,7 +1372,7 @@ module ActionController
routes = routes_by_controller[controller][action][options.keys.sort_by { |x| x.object_id }]
routes.each do |route|
results = route.send(method, options, merged, expire_on)
results = route.send!(method, options, merged, expire_on)
return results if results && (!results.is_a?(Array) || results.first)
end
end

View file

@ -8,10 +8,11 @@ end
module ActionController #:nodoc:
module SessionManagement #:nodoc:
def self.included(base)
base.extend(ClassMethods)
base.send :alias_method_chain, :process, :session_management_support
base.send :alias_method_chain, :process_cleanup, :session_management_support
base.class_eval do
extend ClassMethods
alias_method_chain :process, :session_management_support
alias_method_chain :process_cleanup, :session_management_support
end
end
module ClassMethods

View file

@ -357,7 +357,7 @@ module ActionController #:nodoc:
alias local_path path
def method_missing(method_name, *args, &block) #:nodoc:
@tempfile.send(method_name, *args, &block)
@tempfile.send!(method_name, *args, &block)
end
end
@ -379,7 +379,7 @@ module ActionController #:nodoc:
# Sanity check for required instance variables so we can give an
# understandable error message.
%w(@controller @request @response).each do |iv_name|
if !instance_variables.include?(iv_name) || instance_variable_get(iv_name).nil?
if !(instance_variables.include?(iv_name) || instance_variables.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil?
raise "#{iv_name} is nil: make sure you set it in your test's setup method."
end
end
@ -402,7 +402,7 @@ module ActionController #:nodoc:
def xml_http_request(request_method, action, parameters = nil, session = nil, flash = nil)
@request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
@request.env['HTTP_ACCEPT'] = 'text/javascript, text/html, application/xml, text/xml, */*'
returning self.send(request_method, action, parameters, session, flash) do
returning send!(request_method, action, parameters, session, flash) do
@request.env.delete 'HTTP_X_REQUESTED_WITH'
@request.env.delete 'HTTP_ACCEPT'
end
@ -444,7 +444,7 @@ module ActionController #:nodoc:
def build_request_uri(action, parameters)
unless @request.env['REQUEST_URI']
options = @controller.send(:rewrite_options, parameters)
options = @controller.send!(:rewrite_options, parameters)
options.update(:only_path => true, :action => action)
url = ActionController::UrlRewriter.new(@request, parameters)
@ -466,7 +466,7 @@ module ActionController #:nodoc:
end
def method_missing(selector, *args)
return @controller.send(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
return @controller.send!(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
return super
end
@ -502,15 +502,15 @@ module ActionController #:nodoc:
#
def with_routing
real_routes = ActionController::Routing::Routes
ActionController::Routing.send :remove_const, :Routes
ActionController::Routing.module_eval { remove_const :Routes }
temporary_routes = ActionController::Routing::RouteSet.new
ActionController::Routing.send :const_set, :Routes, temporary_routes
ActionController::Routing.module_eval { const_set :Routes, temporary_routes }
yield temporary_routes
ensure
if ActionController::Routing.const_defined? :Routes
ActionController::Routing.send(:remove_const, :Routes)
ActionController::Routing.module_eval { remove_const :Routes }
end
ActionController::Routing.const_set(:Routes, real_routes) if real_routes
end

View file

@ -72,7 +72,7 @@ module ActionController #:nodoc:
def verify(options={})
filter_opts = { :only => options[:only], :except => options[:except] }
before_filter(filter_opts) do |c|
c.send :verify_action, options
c.send! :verify_action, options
end
end
end
@ -95,7 +95,7 @@ module ActionController #:nodoc:
response.headers.update(options[:add_headers]) if options[:add_headers]
unless performed?
render(options[:render]) if options[:render]
options[:redirect_to] = self.send(options[:redirect_to]) if options[:redirect_to].is_a? Symbol
options[:redirect_to] = self.send!(options[:redirect_to]) if options[:redirect_to].is_a? Symbol
redirect_to(options[:redirect_to]) if options[:redirect_to]
end
return false

View file

@ -164,11 +164,11 @@ module ActionView
def number_to_human_size(size, precision=1)
size = Kernel.Float(size)
case
when size.to_i == 1 : "1 Byte"
when size < 1.kilobyte: "%d Bytes" % size
when size < 1.megabyte: "%.#{precision}f KB" % (size / 1.0.kilobyte)
when size < 1.gigabyte: "%.#{precision}f MB" % (size / 1.0.megabyte)
when size < 1.terabyte: "%.#{precision}f GB" % (size / 1.0.gigabyte)
when size.to_i == 1; "1 Byte"
when size < 1.kilobyte; "%d Bytes" % size
when size < 1.megabyte; "%.#{precision}f KB" % (size / 1.0.kilobyte)
when size < 1.gigabyte; "%.#{precision}f MB" % (size / 1.0.megabyte)
when size < 1.terabyte; "%.#{precision}f GB" % (size / 1.0.gigabyte)
else "%.#{precision}f TB" % (size / 1.0.terabyte)
end.sub(/([0-9])\.?0+ /, '\1 ' )
rescue

View file

@ -580,7 +580,7 @@ module ActionView
# Specifies a Set of 'bad' tags that the #sanitize helper will remove completely, as opposed
# to just escaping harmless tags like &lt;font&gt;
@@sanitized_bad_tags = Set.new('script')
@@sanitized_bad_tags = Set.new(%w(script))
mattr_reader :sanitized_bad_tags
# Specifies the default Set of tags that the #sanitize helper will allow unscathed.

View file

@ -75,11 +75,11 @@ class ControllerInstanceTests < Test::Unit::TestCase
def test_action_methods
@empty_controllers.each do |c|
hide_mocha_methods_from_controller(c)
assert_equal Set.new, c.send(:action_methods), "#{c.controller_path} should be empty!"
assert_equal Set.new, c.send!(:action_methods), "#{c.controller_path} should be empty!"
end
@non_empty_controllers.each do |c|
hide_mocha_methods_from_controller(c)
assert_equal Set.new('public_action'), c.send(:action_methods), "#{c.controller_path} should not be empty!"
assert_equal Set.new(%w(public_action)), c.send!(:action_methods), "#{c.controller_path} should not be empty!"
end
end
@ -88,7 +88,7 @@ class ControllerInstanceTests < Test::Unit::TestCase
# considered actions, so explicitly hide_action them.
def hide_mocha_methods_from_controller(controller)
mocha_methods = [:expects, :metaclass, :mocha, :mocha_inspect, :reset_mocha, :stubba_object, :stubba_method, :stubs, :verify, :__metaclass__, :__is_a__]
controller.class.send(:hide_action, *mocha_methods)
controller.class.send!(:hide_action, *mocha_methods)
end
end
@ -116,7 +116,7 @@ class PerformActionTest < Test::Unit::TestCase
def test_method_missing_is_not_an_action_name
use_controller MethodMissingController
assert ! @controller.send(:action_methods).include?('method_missing')
assert ! @controller.send!(:action_methods).include?('method_missing')
get :method_missing
assert_response :success

View file

@ -52,12 +52,12 @@ class DispatcherTest < Test::Unit::TestCase
Dependencies.stubs(:load?).returns(false)
ActionController::Routing::Routes.expects(:reload).never
@dispatcher.unprepared = false
@dispatcher.send(:reload_application)
@dispatcher.send!(:reload_application)
assert !@dispatcher.unprepared
Dependencies.stubs(:load?).returns(true)
ActionController::Routing::Routes.expects(:reload).once
@dispatcher.send(:reload_application)
@dispatcher.send!(:reload_application)
assert @dispatcher.unprepared
end
@ -69,19 +69,19 @@ class DispatcherTest < Test::Unit::TestCase
# Skip the callbacks when already prepared.
@dispatcher.unprepared = false
@dispatcher.send :prepare_application
@dispatcher.send! :prepare_application
assert_nil a || b || c
# Perform the callbacks when unprepared.
@dispatcher.unprepared = true
@dispatcher.send :prepare_application
@dispatcher.send! :prepare_application
assert_equal 1, a
assert_equal 2, b
assert_equal 3, c
# But when not :load, make sure they are only run once
a = b = c = nil
@dispatcher.send :prepare_application
@dispatcher.send! :prepare_application
assert_nil a || b || c
end
@ -91,7 +91,7 @@ class DispatcherTest < Test::Unit::TestCase
Dispatcher.to_prepare(:unique_id) { a = 2 }
@dispatcher.unprepared = true
@dispatcher.send :prepare_application
@dispatcher.send! :prepare_application
assert_equal 2, a
assert_equal nil, b
end

View file

@ -332,7 +332,7 @@ class FilterTest < Test::Unit::TestCase
begin
yield
rescue ErrorToRescue => ex
controller.send :render, :text => "I rescued this: #{ex.inspect}"
controller.send! :render, :text => "I rescued this: #{ex.inspect}"
end
end
end

View file

@ -212,7 +212,7 @@ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
def test_integration_methods_called
%w( get post head put delete ).each do |verb|
assert_nothing_raised("'#{verb}' should use integration test methods") { send(verb, '/') }
assert_nothing_raised("'#{verb}' should use integration test methods") { send!(verb, '/') }
end
end

View file

@ -93,16 +93,16 @@ class ExemptFromLayoutTest < Test::Unit::TestCase
end
def test_rjs_exempt_from_layout
assert @controller.send(:template_exempt_from_layout?, 'test.rjs')
assert @controller.send!(:template_exempt_from_layout?, 'test.rjs')
end
def test_rhtml_and_rxml_not_exempt_from_layout
assert !@controller.send(:template_exempt_from_layout?, 'test.rhtml')
assert !@controller.send(:template_exempt_from_layout?, 'test.rxml')
assert !@controller.send!(:template_exempt_from_layout?, 'test.rhtml')
assert !@controller.send!(:template_exempt_from_layout?, 'test.rxml')
end
def test_other_extension_not_exempt_from_layout
assert !@controller.send(:template_exempt_from_layout?, 'test.random')
assert !@controller.send!(:template_exempt_from_layout?, 'test.random')
end
def test_add_extension_to_exempt_from_layout
@ -110,20 +110,20 @@ class ExemptFromLayoutTest < Test::Unit::TestCase
assert_nothing_raised do
ActionController::Base.exempt_from_layout ext
end
assert @controller.send(:template_exempt_from_layout?, "test.#{ext}")
assert @controller.send!(:template_exempt_from_layout?, "test.#{ext}")
end
end
def test_add_regexp_to_exempt_from_layout
ActionController::Base.exempt_from_layout /\.rdoc/
assert @controller.send(:template_exempt_from_layout?, 'test.rdoc')
assert @controller.send!(:template_exempt_from_layout?, 'test.rdoc')
end
def test_rhtml_exempt_from_layout_status_should_prevent_layout_render
ActionController::Base.exempt_from_layout :rhtml
assert @controller.send(:template_exempt_from_layout?, 'test.rhtml')
assert @controller.send(:template_exempt_from_layout?, 'hello.rhtml')
assert @controller.send!(:template_exempt_from_layout?, 'test.rhtml')
assert @controller.send!(:template_exempt_from_layout?, 'hello.rhtml')
get :hello
assert_equal 'hello.rhtml', @response.body

View file

@ -85,8 +85,8 @@ class RespondToController < ActionController::Base
type.html { render :text => "HTML" }
type.mobile { render :text => "Mobile" }
end
Mime.send :remove_const, :MOBILE
ensure
Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) }
end
def custom_constant_handling_without_block
@ -97,7 +97,8 @@ class RespondToController < ActionController::Base
type.mobile
end
Mime.send :remove_const, :MOBILE
ensure
Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) }
end
def handle_any
@ -123,7 +124,8 @@ class RespondToController < ActionController::Base
type.iphone { @type = "iPhone" }
end
Mime.send :remove_const, :IPHONE
ensure
Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) }
end
def iphone_with_html_response_type_without_layout
@ -135,7 +137,8 @@ class RespondToController < ActionController::Base
type.iphone { @type = "iPhone" ; render :action => "iphone_with_html_response_type" }
end
Mime.send :remove_const, :IPHONE
ensure
Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) }
end
def rescue_action(e)
@ -444,24 +447,23 @@ end
# For testing layouts which are set automatically
class PostController < AbstractPostController
around_filter :with_iphone
def index
respond_to do |type|
type.html
type.iphone
end
end
protected
def with_iphone
Mime::Type.register_alias("text/html", :iphone)
request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone"
yield
Mime.send :remove_const, :IPHONE
end
end
def with_iphone
Mime::Type.register_alias("text/html", :iphone)
request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone"
yield
ensure
Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) }
end
end
class SuperPostController < PostController
def index
@ -501,4 +503,4 @@ class MimeControllerLayoutsTest < Test::Unit::TestCase
assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body
end
end

View file

@ -35,7 +35,8 @@ class MimeTypeTest < Test::Unit::TestCase
Mime::GIF
assert_equal Mime::GIF, Mime::SET.last
end
Mime.send :remove_const, :GIF
ensure
Mime.module_eval { remove_const :GIF if const_defined?(:GIF) }
end
def test_type_convenience_methods

View file

@ -157,9 +157,9 @@ class TestController < ActionController::Base
private
def determine_layout
case action_name
when "layout_test": "layouts/standard"
when "builder_layout_test": "layouts/builder"
when "render_symbol_json": "layouts/standard" # to make sure layouts don't interfere
when "layout_test"; "layouts/standard"
when "builder_layout_test"; "layouts/builder"
when "render_symbol_json"; "layouts/standard" # to make sure layouts don't interfere
end
end
end

View file

@ -214,4 +214,4 @@ class FreeCookieControllerTest < Test::Unit::TestCase
assert_nothing_raised { send(method, :index)}
end
end
end
end

View file

@ -60,9 +60,8 @@ rescue LoadError
$stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again."
end
ActiveRecord::Base.connection.class.class_eval do
if not (const_get('IGNORED_SQL') rescue nil)
ActiveRecord::Base.connection.class.class_eval do
unless defined? IGNORED_SQL
IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/]
def execute_with_counting(sql, name = nil, &block)

View file

@ -604,7 +604,7 @@ module ActiveResource
# next_invoice.customer
# # => That Company
def dup
returning new do |resource|
returning self.class.new do |resource|
resource.attributes = @attributes
resource.prefix_options = @prefix_options
end
@ -848,7 +848,7 @@ module ActiveResource
end
def split_options(options = {})
self.class.send(:split_options, options)
self.class.send!(:split_options, options)
end
def method_missing(method_symbol, *arguments) #:nodoc:

View file

@ -33,23 +33,24 @@ module ActiveResource
module CustomMethods
def self.included(within)
within.class_eval do
extend ActiveResource::CustomMethods::ClassMethods
include ActiveResource::CustomMethods::InstanceMethods
class << self
include ActiveResource::CustomMethods::ClassMethods
alias :orig_delete :delete
def get(method_name, options = {})
connection.get(custom_method_collection_url(method_name, options), headers)
end
def post(method_name, options = {}, body = '')
connection.post(custom_method_collection_url(method_name, options), body, headers)
end
def put(method_name, options = {}, body = '')
connection.put(custom_method_collection_url(method_name, options), body, headers)
end
# Need to jump through some hoops to retain the original class 'delete' method
def delete(custom_method_name, options = {})
if (custom_method_name.is_a?(Symbol))
@ -59,12 +60,9 @@ module ActiveResource
end
end
end
end
within.send(:include, ActiveResource::CustomMethods::InstanceMethods)
end
module ClassMethods
def custom_method_collection_url(method_name, options = {})
prefix_options, query_options = split_options(options)
@ -96,12 +94,12 @@ module ActiveResource
private
def custom_method_element_url(method_name, options = {})
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.xml#{self.class.send(:query_string, options)}"
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.xml#{self.class.send!(:query_string, options)}"
end
def custom_method_new_element_url(method_name, options = {})
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}.xml#{self.class.send(:query_string, options)}"
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}.xml#{self.class.send!(:query_string, options)}"
end
end
end
end
end

View file

@ -75,7 +75,7 @@ module ActiveResource
attr_accessor :path, :method, :body, :headers
def initialize(method, path, body = nil, headers = {})
@method, @path, @body, @headers = method, path, body, headers
@method, @path, @body, @headers = method, path, body, headers.dup
@headers.update('Content-Type' => 'application/xml')
end

View file

@ -20,7 +20,7 @@ class AuthorizationTest < Test::Unit::TestCase
end
def test_authorization_header
authorization_header = @authenticated_conn.send(:authorization_header)
authorization_header = @authenticated_conn.send!(:authorization_header)
assert_equal @authorization_request_header['Authorization'], authorization_header['Authorization']
authorization = authorization_header["Authorization"].to_s.split
@ -30,7 +30,7 @@ class AuthorizationTest < Test::Unit::TestCase
def test_authorization_header_with_username_but_no_password
@conn = ActiveResource::Connection.new("http://david:@localhost")
authorization_header = @conn.send(:authorization_header)
authorization_header = @conn.send!(:authorization_header)
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
@ -39,7 +39,7 @@ class AuthorizationTest < Test::Unit::TestCase
def test_authorization_header_with_password_but_no_username
@conn = ActiveResource::Connection.new("http://:test123@localhost")
authorization_header = @conn.send(:authorization_header)
authorization_header = @conn.send!(:authorization_header)
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
@ -76,7 +76,7 @@ class AuthorizationTest < Test::Unit::TestCase
protected
def assert_response_raises(klass, code)
assert_raise(klass, "Expected response code #{code} to raise #{klass}") do
@conn.send(:handle_response, Response.new(code))
@conn.send!(:handle_response, Response.new(code))
end
end
end

View file

@ -61,7 +61,7 @@ class BaseLoadTest < Test::Unit::TestCase
end
def test_load_collection_with_unknown_resource
Person.send(:remove_const, :Address) if Person.const_defined?(:Address)
Person.send!(:remove_const, :Address) if Person.const_defined?(:Address)
assert !Person.const_defined?(:Address), "Address shouldn't exist until autocreated"
addresses = silence_warnings { @person.load(:addresses => @addresses).addresses }
assert Person.const_defined?(:Address), "Address should have been autocreated"
@ -77,7 +77,7 @@ class BaseLoadTest < Test::Unit::TestCase
end
def test_load_collection_with_single_unknown_resource
Person.send(:remove_const, :Address) if Person.const_defined?(:Address)
Person.send!(:remove_const, :Address) if Person.const_defined?(:Address)
assert !Person.const_defined?(:Address), "Address shouldn't exist until autocreated"
addresses = silence_warnings { @person.load(:addresses => [ @first_address ]).addresses }
assert Person.const_defined?(:Address), "Address should have been autocreated"
@ -108,4 +108,4 @@ class BaseLoadTest < Test::Unit::TestCase
n = Highrise::Note.new(:comments => [{ :name => "1" }])
assert_kind_of Highrise::Comment, n.comments.first
end
end
end

View file

@ -29,13 +29,13 @@ class BaseErrorsTest < Test::Unit::TestCase
def test_should_iterate_over_errors
errors = []
@person.errors.each { |attribute, message| errors << [attribute, message] }
assert_equal ["name", "can't be blank"], errors.first
assert errors.include?(["name", "can't be blank"])
end
def test_should_iterate_over_full_errors
errors = []
@person.errors.each_full { |message| errors << message }
assert_equal "Name can't be blank", errors.first
assert errors.include?("Name can't be blank")
end
def test_should_format_full_errors
@ -45,4 +45,4 @@ class BaseErrorsTest < Test::Unit::TestCase
assert full.include?("Name must start with a letter")
assert full.include?("Person quota full for today.")
end
end
end

View file

@ -181,7 +181,7 @@ class BaseTest < Test::Unit::TestCase
def test_prefix
assert_equal "/", Person.prefix
assert_equal Set.new, Person.send(:prefix_parameters)
assert_equal Set.new, Person.send!(:prefix_parameters)
end
def test_set_prefix
@ -208,7 +208,7 @@ class BaseTest < Test::Unit::TestCase
def test_custom_prefix
assert_equal '/people//', StreetAddress.prefix
assert_equal '/people/1/', StreetAddress.prefix(:person_id => 1)
assert_equal [:person_id].to_set, StreetAddress.send(:prefix_parameters)
assert_equal [:person_id].to_set, StreetAddress.send!(:prefix_parameters)
end
def test_find_by_id
@ -305,10 +305,10 @@ class BaseTest < Test::Unit::TestCase
def test_id_from_response
p = Person.new
resp = {'Location' => '/foo/bar/1'}
assert_equal '1', p.send(:id_from_response, resp)
assert_equal '1', p.send!(:id_from_response, resp)
resp['Location'] << '.xml'
assert_equal '1', p.send(:id_from_response, resp)
assert_equal '1', p.send!(:id_from_response, resp)
end
def test_create_with_custom_prefix
@ -439,6 +439,9 @@ class BaseTest < Test::Unit::TestCase
def test_to_xml
matz = Person.find(1)
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Matz</name>\n <id type=\"integer\">1</id>\n</person>\n", matz.to_xml
xml = matz.to_xml
assert xml.starts_with?('<?xml version="1.0" encoding="UTF-8"?>')
assert xml.include?('<name>Matz</name>')
assert xml.include?('<id type="integer">1</id>')
end
end

View file

@ -13,7 +13,7 @@ class ConnectionTest < Test::Unit::TestCase
@people_empty = [ ].to_xml(:root => 'people-empty-elements')
@matz = @matz.to_xml(:root => 'person')
@david = @david.to_xml(:root => 'person')
@header = {'key' => 'value'}
@header = {'key' => 'value'}.freeze
@default_request_headers = { 'Content-Type' => 'application/xml' }
ActiveResource::HttpMock.respond_to do |mock|
@ -156,6 +156,6 @@ class ConnectionTest < Test::Unit::TestCase
end
def handle_response(response)
@conn.send(:handle_response, response)
@conn.send!(:handle_response, response)
end
end

View file

@ -1,3 +1,3 @@
class Person < ActiveResource::Base
self.site = "http://37s.sunrise.i:3000"
end
end

View file

@ -1,5 +1,5 @@
require 'logger'
require File.dirname(__FILE__) + '/core_ext/class/attribute_accessors'
require 'active_support/core_ext/class/attribute_accessors'
# Extensions to the built in Ruby logger.
#

View file

@ -1 +1,4 @@
Dir[File.dirname(__FILE__) + "/core_ext/*.rb"].sort.each { |file| require(file) }
Dir[File.dirname(__FILE__) + "/core_ext/*.rb"].sort.each do |path|
filename = File.basename(path)
require "active_support/core_ext/#{filename}"
end

View file

@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/array/conversions'
require File.dirname(__FILE__) + '/array/extract_options'
require File.dirname(__FILE__) + '/array/grouping'
require File.dirname(__FILE__) + '/array/random_access'
require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/array/grouping'
require 'active_support/core_ext/array/random_access'
class Array #:nodoc:
include ActiveSupport::CoreExtensions::Array::Conversions

View file

@ -1,3 +1,2 @@
require 'bigdecimal'
require File.dirname(__FILE__) + '/bigdecimal/formatting.rb'
require 'active_support/core_ext/bigdecimal/conversions'

View file

@ -1,7 +1,6 @@
class BigDecimal #:nodoc:
alias :_original_to_s :to_s
def to_s(format="F")
_original_to_s(format)
end
end
end

View file

@ -1,5 +1,5 @@
require File.dirname(__FILE__) + '/cgi/escape_skipping_slashes'
require 'active_support/core_ext/cgi/escape_skipping_slashes'
class CGI #:nodoc:
extend(ActiveSupport::CoreExtensions::CGI::EscapeSkippingSlashes)
extend ActiveSupport::CoreExtensions::CGI::EscapeSkippingSlashes
end

View file

@ -1,3 +1,3 @@
require File.dirname(__FILE__) + '/class/attribute_accessors'
require File.dirname(__FILE__) + '/class/inheritable_attributes'
require File.dirname(__FILE__) + '/class/removal'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/class/inheritable_attributes'
require 'active_support/core_ext/class/removal'

View file

@ -1,7 +1,7 @@
require 'date'
require File.dirname(__FILE__) + '/date/behavior'
require File.dirname(__FILE__) + '/date/calculations'
require File.dirname(__FILE__) + '/date/conversions'
require 'active_support/core_ext/date/behavior'
require 'active_support/core_ext/date/calculations'
require 'active_support/core_ext/date/conversions'
class Date#:nodoc:
include ActiveSupport::CoreExtensions::Date::Behavior

View file

@ -1,7 +1,7 @@
require 'date'
require "#{File.dirname(__FILE__)}/time/behavior"
require "#{File.dirname(__FILE__)}/date_time/calculations"
require "#{File.dirname(__FILE__)}/date_time/conversions"
require 'active_support/core_ext/time/behavior'
require 'active_support/core_ext/date_time/calculations'
require 'active_support/core_ext/date_time/conversions'
class DateTime
include ActiveSupport::CoreExtensions::Time::Behavior

View file

@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/float/rounding'
require 'active_support/core_ext/float/rounding'
class Float #:nodoc:
include ActiveSupport::CoreExtensions::Float::Rounding

View file

@ -1,5 +1,5 @@
%w(keys indifferent_access reverse_merge conversions diff slice except).each do |ext|
require "#{File.dirname(__FILE__)}/hash/#{ext}"
require "active_support/core_ext/hash/#{ext}"
end
class Hash #:nodoc:

View file

@ -1,5 +1,5 @@
require File.dirname(__FILE__) + '/integer/even_odd'
require File.dirname(__FILE__) + '/integer/inflections'
require 'active_support/core_ext/integer/even_odd'
require 'active_support/core_ext/integer/inflections'
class Integer #:nodoc:
include ActiveSupport::CoreExtensions::Integer::EvenOdd

View file

@ -1,5 +1,5 @@
require File.dirname(__FILE__) + '/kernel/daemonizing'
require File.dirname(__FILE__) + '/kernel/reporting'
require File.dirname(__FILE__) + '/kernel/agnostics'
require File.dirname(__FILE__) + '/kernel/requires'
require File.dirname(__FILE__) + '/kernel/debugger'
require 'active_support/core_ext/kernel/daemonizing'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/kernel/agnostics'
require 'active_support/core_ext/kernel/requires'
require 'active_support/core_ext/kernel/debugger'

View file

@ -1,8 +1,8 @@
require File.dirname(__FILE__) + '/module/inclusion'
require File.dirname(__FILE__) + '/module/attribute_accessors'
require File.dirname(__FILE__) + '/module/attr_internal'
require File.dirname(__FILE__) + '/module/attr_accessor_with_default'
require File.dirname(__FILE__) + '/module/delegation'
require File.dirname(__FILE__) + '/module/introspection'
require File.dirname(__FILE__) + '/module/loading'
require File.dirname(__FILE__) + '/module/aliasing'
require 'active_support/core_ext/module/inclusion'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/attr_accessor_with_default'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/module/introspection'
require 'active_support/core_ext/module/loading'
require 'active_support/core_ext/module/aliasing'

View file

@ -1,5 +1,5 @@
require File.dirname(__FILE__) + '/numeric/time'
require File.dirname(__FILE__) + '/numeric/bytes'
require 'active_support/core_ext/numeric/time'
require 'active_support/core_ext/numeric/bytes'
class Numeric #:nodoc:
include ActiveSupport::CoreExtensions::Numeric::Time

View file

@ -1,3 +1,3 @@
require File.dirname(__FILE__) + '/object/extending'
require File.dirname(__FILE__) + '/object/instance_variables'
require File.dirname(__FILE__) + '/object/misc'
require 'active_support/core_ext/object/extending'
require 'active_support/core_ext/object/instance_variables'
require 'active_support/core_ext/object/misc'

View file

@ -1,5 +1,5 @@
require 'pathname'
require File.dirname(__FILE__) + '/pathname/clean_within'
require 'active_support/core_ext/pathname/clean_within'
class Pathname#:nodoc:
extend ActiveSupport::CoreExtensions::Pathname::CleanWithin

View file

@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/range/conversions'
require 'active_support/core_ext/range/conversions'
class Range #:nodoc:
include ActiveSupport::CoreExtensions::Range::Conversions

View file

@ -1,9 +1,9 @@
require File.dirname(__FILE__) + '/string/inflections'
require File.dirname(__FILE__) + '/string/conversions'
require File.dirname(__FILE__) + '/string/access'
require File.dirname(__FILE__) + '/string/starts_ends_with'
require File.dirname(__FILE__) + '/string/iterators' unless 'test'.respond_to?(:each_char)
require File.dirname(__FILE__) + '/string/unicode'
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/string/conversions'
require 'active_support/core_ext/string/access'
require 'active_support/core_ext/string/starts_ends_with'
require 'active_support/core_ext/string/iterators' unless 'test'.respond_to?(:each_char)
require 'active_support/core_ext/string/unicode'
class String #:nodoc:
include ActiveSupport::CoreExtensions::String::Access

View file

@ -1,2 +1 @@
require File.dirname(__FILE__) + '/test/difference'
require 'active_support/core_ext/test/unit/assertions'

View file

@ -8,9 +8,9 @@ class Time
end
end
require File.dirname(__FILE__) + '/time/behavior'
require File.dirname(__FILE__) + '/time/calculations'
require File.dirname(__FILE__) + '/time/conversions'
require 'active_support/core_ext/time/behavior'
require 'active_support/core_ext/time/calculations'
require 'active_support/core_ext/time/conversions'
class Time#:nodoc:
include ActiveSupport::CoreExtensions::Time::Behavior

View file

@ -1,7 +1,7 @@
require 'set'
require File.dirname(__FILE__) + '/core_ext/module/attribute_accessors'
require File.dirname(__FILE__) + '/core_ext/load_error'
require File.dirname(__FILE__) + '/core_ext/kernel'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/load_error'
require 'active_support/core_ext/kernel'
module Dependencies #:nodoc:
extend self

View file

@ -63,9 +63,9 @@ class HashExtTest < Test::Unit::TestCase
hashes.each do |name, hash|
method_map.sort_by { |m| m.to_s }.each do |meth, expected|
assert_equal(expected, hash.send(meth, 'a'),
assert_equal(expected, hash.send!(meth, 'a'),
"Calling #{name}.#{meth} 'a'")
assert_equal(expected, hash.send(meth, :a),
assert_equal(expected, hash.send!(meth, :a),
"Calling #{name}.#{meth} :a")
end
end
@ -640,7 +640,7 @@ class HashToXmlTest < Test::Unit::TestCase
def test_empty_string_works_for_typecast_xml_value
assert_nothing_raised do
Hash.send(:typecast_xml_value, "")
Hash.send!(:typecast_xml_value, "")
end
end

View file

@ -120,8 +120,14 @@ class InflectorTest < Test::Unit::TestCase
assert_raises(NameError) { Inflector.constantize("InvalidClass\n") }
end
def test_constantize_doesnt_look_in_parent
assert_raises(NameError) { Inflector.constantize("Ace::Base::InflectorTest") }
if RUBY_VERSION < '1.9.0'
def test_constantize_does_lexical_lookup
assert_raises(NameError) { Inflector.constantize("Ace::Base::InflectorTest") }
end
else
def test_constantize_does_dynamic_lookup
assert_equal self.class, Inflector.constantize("Ace::Base::InflectorTest")
end
end
def test_ordinal