aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails_generator/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:45:35 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:45:35 +0000
commitb1999be5a7efd67e2602c37ed898aa8433661863 (patch)
tree03bc833276075d802d0ce0ad261baed3d7232533 /railties/lib/rails_generator/base.rb
parent88a3343ed57c01ca358da8473d15fc4d2b4a5bff (diff)
downloadrails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.gz
rails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.bz2
rails-b1999be5a7efd67e2602c37ed898aa8433661863.zip
A hopefully more successful attempt at the Routing branch merge
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@617 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/rails_generator/base.rb')
-rw-r--r--railties/lib/rails_generator/base.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/railties/lib/rails_generator/base.rb b/railties/lib/rails_generator/base.rb
index 065ce63966..92a54e2453 100644
--- a/railties/lib/rails_generator/base.rb
+++ b/railties/lib/rails_generator/base.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../support/class_attribute_accessors'
-require File.dirname(__FILE__) + '/../support/inflector'
+require File.dirname(__FILE__) + '/support/class_attribute_accessors'
+require File.dirname(__FILE__) + '/support/inflector'
require File.dirname(__FILE__) + '/options'
require File.dirname(__FILE__) + '/manifest'
require File.dirname(__FILE__) + '/spec'
@@ -69,8 +69,8 @@ module Rails
@source_root = options[:source] || File.join(spec.path, 'templates')
if options[:destination]
@destination_root = options[:destination]
- elsif Object.const_defined?(:RAILS_ROOT)
- @destination_root = Object.const_get(:RAILS_ROOT)
+ elsif defined? ::RAILS_ROOT
+ @destination_root = ::RAILS_ROOT
end
# Silence the logger if requested.
@@ -173,11 +173,20 @@ module Rails
def assign_names!(name)
@name = name
base_name, @class_path, @class_nesting = extract_modules(@name)
- @class_name, @singular_name, @plural_name = inflect_names(base_name)
+ @class_name_without_nesting, @singular_name, @plural_name = inflect_names(base_name)
+ if @class_nesting.empty?
+ @class_name = @class_name_without_nesting
+ else
+ @class_name = "#{@class_nesting}::#{@class_name_without_nesting}"
+ end
end
+ # Extract modules from filesystem-style or ruby-style path:
+ # good/fun/stuff
+ # Good::Fun::Stuff
+ # produce the same results.
def extract_modules(name)
- modules = name.split('/')
+ modules = name.include?('/') ? name.split('/') : name.split('::')
name = modules.pop
path = modules.map { |m| m.underscore }
nesting = modules.map { |m| m.camelize }.join('::')