mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Refactoring out descriptions.
This commit is contained in:
@@ -15,16 +15,27 @@ module Rails
|
||||
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), base_name, generator_name, 'templates'))
|
||||
end
|
||||
|
||||
# Tries to get the description from a USAGE file one folder above the source
|
||||
# root otherwise uses a default description.
|
||||
#
|
||||
def self.desc(description=nil)
|
||||
return super if description
|
||||
usage = File.join(source_root, "..", "USAGE")
|
||||
|
||||
@desc ||= if File.exist?(usage)
|
||||
File.read(usage)
|
||||
else
|
||||
"Description:\n Create #{base_name.humanize.downcase} files for #{generator_name} generator."
|
||||
end
|
||||
end
|
||||
|
||||
# Convenience method to get the namespace from the class name. It's the
|
||||
# same as Thor default except that the Generator at the end of the class
|
||||
# is removed.
|
||||
#
|
||||
def self.namespace(name=nil) #:nodoc:
|
||||
if name
|
||||
super
|
||||
else
|
||||
@namespace ||= "#{base_name}:generators:#{generator_name}"
|
||||
end
|
||||
def self.namespace(name=nil)
|
||||
return super if name
|
||||
@namespace ||= "#{base_name}:generators:#{generator_name}"
|
||||
end
|
||||
|
||||
protected
|
||||
@@ -70,7 +81,7 @@ module Rails
|
||||
|
||||
# Sets the base_name taking into account the current class namespace.
|
||||
#
|
||||
def self.base_name #:nodoc:
|
||||
def self.base_name
|
||||
@base_name ||= self.name.split('::').first.underscore
|
||||
end
|
||||
|
||||
|
||||
@@ -3,11 +3,6 @@ module Erb
|
||||
class MailerGenerator < Base
|
||||
argument :actions, :type => :array, :default => []
|
||||
|
||||
desc <<DESC
|
||||
Description:
|
||||
Create Template engine files for mailer generator.
|
||||
DESC
|
||||
|
||||
def create_view_files
|
||||
actions.each do |action|
|
||||
@action, @path = action, File.join(file_path, action)
|
||||
|
||||
@@ -3,11 +3,6 @@ module TestUnit
|
||||
class MailerGenerator < Base
|
||||
argument :actions, :type => :array, :default => []
|
||||
|
||||
desc <<DESC
|
||||
Description:
|
||||
Create TestUnit files for mailer generator.
|
||||
DESC
|
||||
|
||||
def create_test_files
|
||||
template "unit_test.rb", File.join('test', 'unit', class_path, "#{file_name}_test.rb")
|
||||
end
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
module TestUnit
|
||||
module Generators
|
||||
class ObserverGenerator < Base
|
||||
desc <<DESC
|
||||
Description:
|
||||
Create TestUnit files for observer generator.
|
||||
DESC
|
||||
|
||||
def create_test_files
|
||||
template 'unit_test.rb', File.join('test', 'unit', class_path, "#{file_name}_observer_test.rb")
|
||||
end
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
module TestUnit
|
||||
module Generators
|
||||
class PluginGenerator < Base
|
||||
desc <<DESC
|
||||
Description:
|
||||
Create TestUnit files for plugin generator.
|
||||
DESC
|
||||
|
||||
def create_test_files
|
||||
directory 'test'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user