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

Make invoke output white and use padding.

This commit is contained in:
José Valim 2009-07-02 15:55:21 +02:00
parent a08a8cd8d2
commit 528d555e37
3 changed files with 14 additions and 6 deletions

View file

@ -11,10 +11,6 @@ module ActiveRecord
class_option :timestamps, :type => :boolean
class_option :parent, :type => :string, :desc => "The parent class for the generated model"
def create_model_file
template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
end
def create_migration_file
if options[:migration] && options[:parent].nil?
file_name = "create_#{file_path.gsub(/\//, '_').pluralize}"
@ -22,6 +18,10 @@ module ActiveRecord
end
end
def create_model_file
template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
end
hook_for :test_framework
protected

View file

@ -118,7 +118,7 @@ module Rails
def self.hook_for(*names, &block)
options = names.extract_options!
as = options.fetch(:as, generator_name)
verbose = options.fetch(:verbose, :blue)
verbose = options.fetch(:verbose, :white)
names.each do |name|
default = { :desc => "#{name.to_s.humanize} to be invoked", :banner => "NAME" }
@ -196,7 +196,7 @@ module Rails
def self.invoke_if(*names, &block)
options = names.extract_options!.merge(:type => :boolean)
as = options.fetch(:as, generator_name)
verbose = options.fetch(:verbose, :blue)
verbose = options.fetch(:verbose, :white)
names.each do |name|
class_option name, options
@ -267,11 +267,13 @@ module Rails
# in case the user wants to customize how the class is invoked.
#
def invoke_class_with_block(name, klass) #:nodoc:
shell.padding += 1
if block = self.class.invocation_blocks[name]
block.call(self, klass)
else
invoke klass
end
shell.padding -= 1
end
# Check whether the given class names are already taken by user

View file

@ -131,6 +131,12 @@ class ScaffoldGeneratorTest < GeneratorsTestCase
assert_file "public/stylesheets/scaffold.css"
end
def test_invoke_output
output = run_generator
assert_match /invoke.{4} active_record/, output
assert_match /create.{4} app\/models\/product_line\.rb/, output
end
protected
def run_generator(config={})