1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Splitting base into several files.

This commit is contained in:
José Valim 2009-06-23 19:45:50 +02:00
parent a7ba4b95e9
commit d7bab3a43a
4 changed files with 38 additions and 13 deletions

View file

@ -12,6 +12,7 @@ require 'rails/version' unless defined?(Rails::VERSION)
require 'generators/base'
require 'generators/named_base'
require 'generators/test_unit'
module Rails
module Generators

View file

@ -1,11 +1,8 @@
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 @@ module Rails
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'
end
end
# 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

View file

@ -0,0 +1,6 @@
module Rails
module Generators
class Error < Thor::Error
end
end
end

View file

@ -0,0 +1,12 @@
require 'generators/named_base'
module Rails
module Generators
class TestUnit < NamedBase
protected
def self.base_name
'test_unit'
end
end
end
end