diff options
Diffstat (limited to 'railties/lib/generator/base.rb')
-rw-r--r-- | railties/lib/generator/base.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/railties/lib/generator/base.rb b/railties/lib/generator/base.rb new file mode 100644 index 0000000000..ea1e5a0402 --- /dev/null +++ b/railties/lib/generator/base.rb @@ -0,0 +1,36 @@ +require File.dirname(__FILE__) + '/actions' + +# TODO Use vendored Thor +require 'rubygems' +gem 'josevalim-thor' +require 'thor' + +module Rails + module Generators + class Base < Thor::Group + include Rails::Generators::Actions + include Thor::Actions + + # Make aliases for backwards compatibily. Usa no_tasks to avoid aliases + # from becoming tasks. + # + no_tasks { + alias :file :create_file + alias :log :say_status + } + + # Automatically sets the source root based on the class name. + # + def self.source_root + @source_root ||= begin + klass_name = self.name + klass_name.gsub!(/^Rails::Generators::/, '') + klass_name.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') + klass_name.gsub!(/([a-z\d])([A-Z])/,'\1_\2') + File.join(File.dirname(__FILE__), 'templates', klass_name.downcase) + end + end + + end + end +end |