diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-05 16:11:52 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-05 16:12:02 -0800 |
commit | cb9a1759c0b8ad104b8e591b952bc440f9e06dc0 (patch) | |
tree | 504e389d8cdcb4f9dfb49314a97c8c0829761cef /railties/lib | |
parent | 1c047be0fc06c74d4b5b9e1682c79749f47109f5 (diff) | |
download | rails-cb9a1759c0b8ad104b8e591b952bc440f9e06dc0.tar.gz rails-cb9a1759c0b8ad104b8e591b952bc440f9e06dc0.tar.bz2 rails-cb9a1759c0b8ad104b8e591b952bc440f9e06dc0.zip |
Fix generators tests that expect a class name
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators/base.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index e6baf2fc79..af1bf26f4a 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -211,9 +211,8 @@ module Rails # def self.inherited(base) #:nodoc: super - base.source_root # Cache source root - if Rails.root && base.name !~ /Base$/ + if base.name && base.name !~ /Base$/ && defined?(Rails.root) && Rails.root path = File.expand_path(File.join(Rails.root, 'lib', 'templates')) if base.name.include?('::') base.source_paths << File.join(path, base.base_name, base.generator_name) @@ -273,17 +272,21 @@ module Rails # Sets the base_name taking into account the current class namespace. # def self.base_name - @base_name ||= self.name.split('::').first.underscore + if name + @base_name ||= name.split('::').first.underscore + end end # Removes the namespaces and get the generator name. For example, # Rails::Generators::MetalGenerator will return "metal" as generator name. # def self.generator_name - @generator_name ||= begin - klass_name = self.name.split('::').last - klass_name.sub!(/Generator$/, '') - klass_name.underscore + if name + @generator_name ||= begin + klass_name = name.to_s.split('::').last + klass_name.sub!(/Generator$/, '') + klass_name.underscore + end end end |