From cbb38bbdba0f7cfb628a0f8716e79d0d079fd7bf Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 10 Nov 2008 21:39:05 -0800 Subject: Only track new constant definitions when we're reloading dependencies --- activesupport/lib/active_support/dependencies.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/dependencies.rb') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 3d871eec11..fe568d6127 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -138,14 +138,22 @@ module ActiveSupport #:nodoc: end def load_with_new_constant_marking(file, *extras) #:nodoc: - Dependencies.new_constants_in(Object) { load_without_new_constant_marking(file, *extras) } + if Dependencies.load? + Dependencies.new_constants_in(Object) { load_without_new_constant_marking(file, *extras) } + else + load_without_new_constant_marking(file, *extras) + end rescue Exception => exception # errors from loading file exception.blame_file! file raise end def require(file, *extras) #:nodoc: - Dependencies.new_constants_in(Object) { super } + if Dependencies.load? + Dependencies.new_constants_in(Object) { super } + else + super + end rescue Exception => exception # errors from required file exception.blame_file! file raise -- cgit v1.2.3 From fcce1f17eaf9993b0210fe8e2a8117b61a1f0f69 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 17 Nov 2008 19:16:31 +0100 Subject: BACKWARDS INCOMPATIBLE: Renamed application.rb to application_controller.rb and removed all the special casing that was in place to support the former. You must do this rename in your own application when you upgrade to this version [DHH] --- activesupport/lib/active_support/dependencies.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'activesupport/lib/active_support/dependencies.rb') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index fe568d6127..5dbe466b7b 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -314,11 +314,7 @@ module ActiveSupport #:nodoc: nesting = nesting[1..-1] if nesting && nesting[0] == ?/ next if nesting.blank? - [ - nesting.camelize, - # Special case: application.rb might define ApplicationControlller. - ('ApplicationController' if nesting == 'application') - ] + [ nesting.camelize ] end.flatten.compact.uniq end -- cgit v1.2.3 From 45ba4ec626b79dda8534f13b3eb01524e0734781 Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Mon, 17 Nov 2008 14:03:46 -0500 Subject: add vendor/ back to load paths; catch errors in constant loading Signed-off-by: David Heinemeier Hansson --- activesupport/lib/active_support/dependencies.rb | 34 +++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'activesupport/lib/active_support/dependencies.rb') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 5dbe466b7b..67620e1789 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -485,24 +485,28 @@ module ActiveSupport #:nodoc: # Build the watch frames. Each frame is a tuple of # [module_name_as_string, constants_defined_elsewhere] watch_frames = descs.collect do |desc| - if desc.is_a? Module - mod_name = desc.name - initial_constants = desc.local_constant_names - elsif desc.is_a?(String) || desc.is_a?(Symbol) - mod_name = desc.to_s - - # Handle the case where the module has yet to be defined. - initial_constants = if qualified_const_defined?(mod_name) - mod_name.constantize.local_constant_names + begin + if desc.is_a? Module + mod_name = desc.name + initial_constants = desc.local_constant_names + elsif desc.is_a?(String) || desc.is_a?(Symbol) + mod_name = desc.to_s + + # Handle the case where the module has yet to be defined. + initial_constants = if qualified_const_defined?(mod_name) + mod_name.constantize.local_constant_names + else + [] + end else - [] + raise Argument, "#{desc.inspect} does not describe a module!" end - else - raise Argument, "#{desc.inspect} does not describe a module!" + [mod_name, initial_constants] + rescue NameError + # mod_name isn't a valid constant name + nil end - - [mod_name, initial_constants] - end + end.compact constant_watch_stack.concat watch_frames -- cgit v1.2.3 From fb1eebac940d0648d1640d20a24f085d901d6f30 Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Wed, 19 Nov 2008 12:13:52 -0500 Subject: alternative resolution to vendor load problem Signed-off-by: David Heinemeier Hansson --- activesupport/lib/active_support/dependencies.rb | 43 ++++++++++++------------ 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'activesupport/lib/active_support/dependencies.rb') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 67620e1789..293450c180 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -313,8 +313,13 @@ module ActiveSupport #:nodoc: nesting = expanded_path[(expanded_root.size)..-1] nesting = nesting[1..-1] if nesting && nesting[0] == ?/ next if nesting.blank? - - [ nesting.camelize ] + nesting_camel = nesting.camelize + begin + qualified_const_defined?(nesting_camel) + rescue NameError + next + end + [ nesting_camel ] end.flatten.compact.uniq end @@ -485,28 +490,24 @@ module ActiveSupport #:nodoc: # Build the watch frames. Each frame is a tuple of # [module_name_as_string, constants_defined_elsewhere] watch_frames = descs.collect do |desc| - begin - if desc.is_a? Module - mod_name = desc.name - initial_constants = desc.local_constant_names - elsif desc.is_a?(String) || desc.is_a?(Symbol) - mod_name = desc.to_s - - # Handle the case where the module has yet to be defined. - initial_constants = if qualified_const_defined?(mod_name) - mod_name.constantize.local_constant_names - else - [] - end + if desc.is_a? Module + mod_name = desc.name + initial_constants = desc.local_constant_names + elsif desc.is_a?(String) || desc.is_a?(Symbol) + mod_name = desc.to_s + + # Handle the case where the module has yet to be defined. + initial_constants = if qualified_const_defined?(mod_name) + mod_name.constantize.local_constant_names else - raise Argument, "#{desc.inspect} does not describe a module!" + [] end - [mod_name, initial_constants] - rescue NameError - # mod_name isn't a valid constant name - nil + else + raise Argument, "#{desc.inspect} does not describe a module!" end - end.compact + + [mod_name, initial_constants] + end constant_watch_stack.concat watch_frames -- cgit v1.2.3