Permalink
Browse files

Handle mutual dependencies with .rb suffix.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3193 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent ca7341d commit e47c8381e127fe36aa20f8343e46d065045a6445 @jeremy jeremy committed Nov 28, 2005
@@ -27,13 +27,9 @@ def load?
end
def depend_on(file_name, swallow_load_errors = false)
- unless loaded.include?(file_name)
- begin
- require_or_load(file_name)
- rescue LoadError
- raise unless swallow_load_errors
- end
- end
+ require_or_load(file_name)
+ rescue LoadError
+ raise unless swallow_load_errors
end
def associate_with(file_name)
@@ -45,21 +41,21 @@ def clear
end
def require_or_load(file_name)
- if load?
- # Append .rb if we have a bare file name.
- load_file_name = (file_name =~ /\.rb$/ ? file_name : "#{file_name}.rb")
+ file_name = $1 if file_name =~ /^(.*)\.rb$/
+ return if loaded.include?(file_name)
- # Record that we've seen this file *before* loading it to avoid an
- # infinite loop with mutual dependencies.
- loaded << file_name
+ # Record that we've seen this file *before* loading it to avoid an
+ # infinite loop with mutual dependencies.
+ loaded << file_name
+ if load?
begin
# Enable warnings iff this file has not been loaded before and
# warnings_on_first_load is set.
if !warnings_on_first_load or history.include?(file_name)
- load load_file_name
+ load "#{file_name}.rb"
else
- enable_warnings { load load_file_name }
+ enable_warnings { load "#{file_name}.rb" }
end
rescue
loaded.delete file_name
@@ -1,2 +1,4 @@
$mutual_dependencies_count += 1
require_dependency 'mutual_two'
+require_dependency 'mutual_two.rb'
+require_dependency 'mutual_two'
@@ -1,2 +1,4 @@
$mutual_dependencies_count += 1
+require_dependency 'mutual_one.rb'
require_dependency 'mutual_one'
+require_dependency 'mutual_one.rb'

0 comments on commit e47c838

Please sign in to comment.