diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2010-06-09 17:14:47 -0400 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2010-06-09 17:14:53 -0400 |
commit | 983815632cc1d316c7c803a47be28f1abe6698fb (patch) | |
tree | 6e92dfb12ef5bfa8889b325086eb4b84767e6d45 /railties | |
parent | 211799450d25c3e6a42a48a5146af5bed78cd66d (diff) | |
download | rails-983815632cc1d316c7c803a47be28f1abe6698fb.tar.gz rails-983815632cc1d316c7c803a47be28f1abe6698fb.tar.bz2 rails-983815632cc1d316c7c803a47be28f1abe6698fb.zip |
Cut down even further on rake -T noise
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/tasks/documentation.rake | 47 | ||||
-rw-r--r-- | railties/lib/rails/tasks/misc.rake | 4 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/testing.rake | 50 |
3 files changed, 78 insertions, 23 deletions
diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index c7de6783a7..492f05e3cc 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,13 +1,43 @@ require 'rake/rdoctask' +# Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise +class RDocTaskWithoutDescriptions < Rake::RDocTask + def define + task rdoc_task_name + + task rerdoc_task_name => [clobber_task_name, rdoc_task_name] + + task clobber_task_name do + rm_r rdoc_dir rescue nil + end + + task :clobber => [clobber_task_name] + + directory @rdoc_dir + task rdoc_task_name => [rdoc_target] + file rdoc_target => @rdoc_files + [Rake.application.rakefile] do + rm_r @rdoc_dir rescue nil + @before_running_rdoc.call if @before_running_rdoc + args = option_list + @rdoc_files + if @external + argstring = args.join(' ') + sh %{ruby -Ivendor vendor/rd #{argstring}} + else + require 'rdoc/rdoc' + RDoc::RDoc.new.document(args) + end + end + self + end +end + namespace :doc do def gem_path(gem_name) path = $LOAD_PATH.grep(/#{gem_name}[\w.-]*\/lib$/).first yield File.dirname(path) if path end - desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" - Rake::RDocTask.new("app") { |rdoc| + RDocTaskWithoutDescriptions.new("app") { |rdoc| rdoc.rdoc_dir = 'doc/app' rdoc.template = ENV['template'] if ENV['template'] rdoc.title = ENV['title'] || "Rails Application Documentation" @@ -17,9 +47,10 @@ namespace :doc do rdoc.rdoc_files.include('app/**/*.rb') rdoc.rdoc_files.include('lib/**/*.rb') } + Rake::Task['doc:app'].comment = "Generate docs for the app -- also availble doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")" - desc 'Generate documentation for the Rails framework.' - Rake::RDocTask.new("rails") { |rdoc| + # desc 'Generate documentation for the Rails framework.' + RDocTaskWithoutDescriptions.new("rails") { |rdoc| rdoc.rdoc_dir = 'doc/api' rdoc.template = "#{ENV['template']}.rb" if ENV['template'] rdoc.title = "Rails Framework Documentation" @@ -71,15 +102,15 @@ namespace :doc do plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } - desc "Generate documentation for all installed plugins" + # desc "Generate documentation for all installed plugins" task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" } - desc "Remove plugin documentation" + # desc "Remove plugin documentation" task :clobber_plugins do rm_rf 'doc/plugins' rescue nil end - desc "Generate Rails Guides" + # desc "Generate Rails Guides" task :guides do # FIXME: Reaching outside lib directory is a bad idea require File.expand_path('../../../../guides/rails_guides', __FILE__) @@ -89,7 +120,7 @@ namespace :doc do namespace :plugins do # Define doc tasks for each plugin plugins.each do |plugin| - desc "Generate documentation for the #{plugin} plugin" + # desc "Generate documentation for the #{plugin} plugin" task(plugin => :environment) do plugin_base = "vendor/plugins/#{plugin}" options = [] diff --git a/railties/lib/rails/tasks/misc.rake b/railties/lib/rails/tasks/misc.rake index 09c8a1a223..c6c22d83bf 100644 --- a/railties/lib/rails/tasks/misc.rake +++ b/railties/lib/rails/tasks/misc.rake @@ -7,13 +7,13 @@ task :rails_env do end end -desc 'Generate a crytographically secure secret key (rhis is typically used to generate a secret for cookie sessions).' +desc 'Generate a crytographically secure secret key (this is typically used to generate a secret for cookie sessions).' task :secret do require 'active_support/secure_random' puts ActiveSupport::SecureRandom.hex(64) end -desc 'Explain the current environment' +desc 'List versions of all Rails frameworks and the environment' task :about do puts Rails::Info end diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 79fa667ed1..4bddf7600a 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -1,5 +1,35 @@ require 'rake/testtask' +# Monkey-patch to silence the description from Rake::TestTask to cut down on rake -T noise +class TestTaskWithoutDescription < Rake::TestTask + # Create the tasks defined by this task lib. + def define + lib_path = @libs.join(File::PATH_SEPARATOR) + task @name do + run_code = '' + RakeFileUtils.verbose(@verbose) do + run_code = + case @loader + when :direct + "-e 'ARGV.each{|f| load f}'" + when :testrb + "-S testrb #{fix}" + when :rake + rake_loader + end + @ruby_opts.unshift( "-I\"#{lib_path}\"" ) + @ruby_opts.unshift( "-w" ) if @warning + ruby @ruby_opts.join(" ") + + " \"#{run_code}\" " + + file_list.collect { |fn| "\"#{fn}\"" }.join(' ') + + " #{option_list}" + end + end + self + end +end + + TEST_CHANGES_SINCE = Time.now - 600 # Look up tests for recently modified sources. @@ -40,7 +70,7 @@ module Kernel end end -desc 'Run all unit, functional and integration tests' +desc 'Runs test:unit, test:functional, test:integration together (also available: test:benchmark, test:profile, test:plugins)' task :test do errors = %w(test:units test:functionals test:integration).collect do |task| begin @@ -92,38 +122,33 @@ namespace :test do end Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)" - Rake::TestTask.new(:units => "test:prepare") do |t| + TestTaskWithoutDescription.new(:units => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/unit/**/*_test.rb' end - Rake::Task['test:units'].comment = "Run the unit tests in test/unit" - Rake::TestTask.new(:functionals => "test:prepare") do |t| + TestTaskWithoutDescription.new(:functionals => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/functional/**/*_test.rb' end - Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional" - Rake::TestTask.new(:integration => "test:prepare") do |t| + TestTaskWithoutDescription.new(:integration => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/integration/**/*_test.rb' end - Rake::Task['test:integration'].comment = "Run the integration tests in test/integration" - Rake::TestTask.new(:benchmark => 'test:prepare') do |t| + TestTaskWithoutDescription.new(:benchmark => 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' t.options = '-- --benchmark' end - Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests' - Rake::TestTask.new(:profile => 'test:prepare') do |t| + TestTaskWithoutDescription.new(:profile => 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' end - Rake::Task['test:profile'].comment = 'Profile the performance tests' - Rake::TestTask.new(:plugins => :environment) do |t| + TestTaskWithoutDescription.new(:plugins => :environment) do |t| t.libs << "test" if ENV['PLUGIN'] @@ -132,5 +157,4 @@ namespace :test do t.pattern = 'vendor/plugins/*/**/test/**/*_test.rb' end end - Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN=name)" end |