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:
parent
a7ba4b95e9
commit
d7bab3a43a
4 changed files with 38 additions and 13 deletions
|
@ -12,6 +12,7 @@ require 'rails/version' unless defined?(Rails::VERSION)
|
||||||
|
|
||||||
require 'generators/base'
|
require 'generators/base'
|
||||||
require 'generators/named_base'
|
require 'generators/named_base'
|
||||||
|
require 'generators/test_unit'
|
||||||
|
|
||||||
module Rails
|
module Rails
|
||||||
module Generators
|
module Generators
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
require 'generators/actions'
|
require 'generators/actions'
|
||||||
|
require 'generators/error'
|
||||||
|
|
||||||
module Rails
|
module Rails
|
||||||
module Generators
|
module Generators
|
||||||
|
|
||||||
class Error < Thor::Error
|
|
||||||
end
|
|
||||||
|
|
||||||
class Base < Thor::Group
|
class Base < Thor::Group
|
||||||
include Rails::Generators::Actions
|
include Rails::Generators::Actions
|
||||||
include Thor::Actions
|
include Thor::Actions
|
||||||
|
@ -64,21 +61,30 @@ module Rails
|
||||||
class_option :ruby, :type => :string, :aliases => "-r", :default => default,
|
class_option :ruby, :type => :string, :aliases => "-r", :default => default,
|
||||||
:desc => "Path to the Ruby binary of your choice"
|
:desc => "Path to the Ruby binary of your choice"
|
||||||
|
|
||||||
class_eval do
|
no_tasks do
|
||||||
protected
|
define_method :shebang do
|
||||||
def shebang
|
|
||||||
"#!#{options[:ruby] || "/usr/bin/env ruby"}"
|
"#!#{options[:ruby] || "/usr/bin/env ruby"}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
class TestUnit < Base
|
# Small macro to add test_framework option and invoke it.
|
||||||
protected
|
#
|
||||||
def self.base_name
|
def self.add_test_framework_option!
|
||||||
'testunit'
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
6
railties/lib/generators/error.rb
Normal file
6
railties/lib/generators/error.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module Rails
|
||||||
|
module Generators
|
||||||
|
class Error < Thor::Error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
12
railties/lib/generators/test_unit.rb
Normal file
12
railties/lib/generators/test_unit.rb
Normal 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
|
Loading…
Reference in a new issue