diff options
author | José Valim <jose.valim@gmail.com> | 2009-06-23 19:45:50 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-06-23 19:45:50 +0200 |
commit | d7bab3a43a72b94775c857865817004408549e70 (patch) | |
tree | dc357e7724f434ce404d8a686af14a2d6617569f /railties | |
parent | a7ba4b95e9e9f9bd6a542903d8af5500edab3a39 (diff) | |
download | rails-d7bab3a43a72b94775c857865817004408549e70.tar.gz rails-d7bab3a43a72b94775c857865817004408549e70.tar.bz2 rails-d7bab3a43a72b94775c857865817004408549e70.zip |
Splitting base into several files.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/generators.rb | 1 | ||||
-rw-r--r-- | railties/lib/generators/base.rb | 32 | ||||
-rw-r--r-- | railties/lib/generators/error.rb | 6 | ||||
-rw-r--r-- | railties/lib/generators/test_unit.rb | 12 |
4 files changed, 38 insertions, 13 deletions
diff --git a/railties/lib/generators.rb b/railties/lib/generators.rb index 5d22ff5e62..4743409f0c 100644 --- a/railties/lib/generators.rb +++ b/railties/lib/generators.rb @@ -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 diff --git a/railties/lib/generators/base.rb b/railties/lib/generators/base.rb index fe4ec2a19a..c888316df7 100644 --- a/railties/lib/generators/base.rb +++ b/railties/lib/generators/base.rb @@ -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' + # 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 diff --git a/railties/lib/generators/error.rb b/railties/lib/generators/error.rb new file mode 100644 index 0000000000..79b8be59cf --- /dev/null +++ b/railties/lib/generators/error.rb @@ -0,0 +1,6 @@ +module Rails + module Generators + class Error < Thor::Error + end + end +end diff --git a/railties/lib/generators/test_unit.rb b/railties/lib/generators/test_unit.rb new file mode 100644 index 0000000000..69bc2f573c --- /dev/null +++ b/railties/lib/generators/test_unit.rb @@ -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 |