diff options
author | José Valim <jose.valim@gmail.com> | 2009-07-02 15:55:21 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-07-02 15:55:21 +0200 |
commit | 528d555e378e9900ffda40c8ff3627e0609a048c (patch) | |
tree | 4f00ff742efbbe1fd732cdea57c9556467fc817d | |
parent | a08a8cd8d24dd1a8342e0fd133c5e8ed09e1f56d (diff) | |
download | rails-528d555e378e9900ffda40c8ff3627e0609a048c.tar.gz rails-528d555e378e9900ffda40c8ff3627e0609a048c.tar.bz2 rails-528d555e378e9900ffda40c8ff3627e0609a048c.zip |
Make invoke output white and use padding.
-rw-r--r-- | railties/lib/generators/active_record/model/model_generator.rb | 8 | ||||
-rw-r--r-- | railties/lib/generators/base.rb | 6 | ||||
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 6 |
3 files changed, 14 insertions, 6 deletions
diff --git a/railties/lib/generators/active_record/model/model_generator.rb b/railties/lib/generators/active_record/model/model_generator.rb index 149ce281f3..d337ca4eec 100644 --- a/railties/lib/generators/active_record/model/model_generator.rb +++ b/railties/lib/generators/active_record/model/model_generator.rb @@ -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 diff --git a/railties/lib/generators/base.rb b/railties/lib/generators/base.rb index aeb79dd339..4b47ebc49b 100644 --- a/railties/lib/generators/base.rb +++ b/railties/lib/generators/base.rb @@ -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 diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index 85c039a9cb..dfa11fd84b 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -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={}) |