blob: 5f51f935205fff06a7bf8283578681c43017c2bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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.expand_path(File.join(File.dirname(__FILE__), 'templates', klass_name.downcase))
end
end
end
end
end
|