Skip to content

Commit

Permalink
fixes problems with controllers and models in a namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
monde committed Jul 29, 2008
1 parent 13551a2 commit caad0c0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/railroad/aasm_diagram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def generate
files += Dir.glob("vendor/plugins/**/app/models/*.rb") if @options.plugins_models
files -= @options.exclude
files.each do |f|
process_class extract_class_name(f).constantize
process_class extract_class_name('app/models/', f).constantize
end
end

Expand Down
7 changes: 3 additions & 4 deletions lib/railroad/app_diagram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ def load_environment
end

# Extract class name from filename
def extract_class_name(filename)
#filename.split('/')[2..-1].join('/').split('.').first.camelize
# Fixed by patch from ticket #12742
File.basename(filename).chomp(".rb").camelize
def extract_class_name(base, filename)
# this is will handle directory names as namespace names
filename.reverse.chomp(base.reverse).reverse.chomp(".rb").camelize
end

end # class AppDiagram
2 changes: 1 addition & 1 deletion lib/railroad/controllers_diagram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def generate
files = Dir.glob("app/controllers/**/*_controller.rb") - @options.exclude
files << 'app/controllers/application.rb'
files.each do |f|
class_name = extract_class_name(f)
class_name = extract_class_name('app/controllers/', f)
# ApplicationController's file is 'application.rb'
class_name += 'Controller' if class_name == 'Application'
process_class class_name.constantize
Expand Down

0 comments on commit caad0c0

Please sign in to comment.