提交 d7bab3a4 编写于 作者: J José Valim

Splitting base into several files.

上级 a7ba4b95
......@@ -12,6 +12,7 @@
require 'generators/base'
require 'generators/named_base'
require 'generators/test_unit'
module Rails
module Generators
......
require 'generators/actions'
require 'generators/error'
module Rails
module Generators
class Error < Thor::Error
end
class Base < Thor::Group
include Rails::Generators::Actions
include Thor::Actions
......@@ -64,21 +61,30 @@ def self.add_shebang_option!
class_option :ruby, :type => :string, :aliases => "-r", :default => default,
:desc => "Path to the Ruby binary of your choice"
class_eval do
protected
def shebang
no_tasks do
define_method :shebang do
"#!#{options[:ruby] || "/usr/bin/env ruby"}"
end
end
end
end
class TestUnit < Base
protected
def self.base_name
'testunit'
# Small macro to add test_framework option and invoke it.
#
def self.add_test_framework_option!
class_option :test_framework, :type => :string, :aliases => "-t", :default => "testunit",
:desc => "Test framework to be invoked by this generator"
define_method :invoke_test_framework do
return unless options[:test_framework]
name = "#{options[:test_framework]}:#{self.class.generator_name}"
begin
invoke name
rescue Thor::UndefinedTaskError
say "Could not find and/or invoke #{name}."
end
end
end
end
end
end
module Rails
module Generators
class Error < Thor::Error
end
end
end
require 'generators/named_base'
module Rails
module Generators
class TestUnit < NamedBase
protected
def self.base_name
'test_unit'
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册