Rake tasks no longer collide with each other.

git-svn-id: svn://hamptoncatlin.com/haml/branches/1.5dev@179 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2006-11-29 02:16:51 +00:00
parent 4d4ffb178c
commit 485197ade8
1 changed files with 81 additions and 59 deletions

140
Rakefile
View File

@ -1,7 +1,5 @@
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
volatile_requires = ['rcov/rcovtask']
not_loaded = []
@ -13,94 +11,118 @@ volatile_requires.each do |file|
end
end
# For some crazy reason,
# some Rake tasks interfere with others
# (specifically, benchmarking).
# Thus, it's advantageous to only show
# the task currently being used.
def is_task?(*tasks)
ARGV[0].nil? || tasks.include?(ARGV[0])
end
# ----- Default: Testing ------
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the HAML plugin'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
if is_task?('test', 'default')
require 'rake/testtask'
desc 'Test the HAML plugin'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
end
# ----- Benchmarking -----
temp_desc = <<END
if is_task?('benchmark')
temp_desc = <<END
Benchmark HAML against ERb.
TIMES=n sets the number of runs. Defaults to 100.
END
desc temp_desc.chomp
task :benchmark do
require 'test/benchmark'
desc temp_desc.chomp
task :benchmark do
require 'test/benchmark'
puts '-'*51, "Benchmark: HAML vs. ERb", '-'*51
puts "Running benchmark #{ENV['TIMES']} times..." if ENV['TIMES']
args = []
args.push ENV['TIMES'].to_i if ENV['TIMES']
benchmarker = Haml::Benchmarker.new
puts benchmarker.benchmark(*args)
puts '-'*51
puts '-'*51, "Benchmark: HAML vs. ERb", '-'*51
puts "Running benchmark #{ENV['TIMES']} times..." if ENV['TIMES']
args = []
args.push ENV['TIMES'].to_i if ENV['TIMES']
benchmarker = Haml::Benchmarker.new
puts benchmarker.benchmark(*args)
puts '-'*51
end
end
# ----- Documentation -----
rdoc_task = Proc.new do |rdoc|
rdoc.title = 'Haml'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('REFERENCE')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.exclude('lib/haml/buffer.rb')
end
if is_task?('rdoc', 'rerdoc', 'clobber_rdoc', 'rdoc_devel', 'rerdoc_devel', 'clobber_rdoc_devel')
require 'rake/rdoctask'
rdoc_task = Proc.new do |rdoc|
rdoc.title = 'Haml'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('REFERENCE')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.exclude('lib/haml/buffer.rb')
end
Rake::RDocTask.new do |rdoc|
rdoc_task.call(rdoc)
rdoc.rdoc_dir = 'rdoc'
end
Rake::RDocTask.new do |rdoc|
rdoc_task.call(rdoc)
rdoc.rdoc_dir = 'rdoc'
end
Rake::RDocTask.new(:rdoc_devel) do |rdoc|
rdoc_task.call(rdoc)
rdoc.rdoc_dir = 'rdoc_devel'
rdoc.options << '--all'
rdoc.rdoc_files.include('test/*.rb')
rdoc.rdoc_files = Rake::FileList.new(*rdoc.rdoc_files.to_a)
rdoc.rdoc_files.include('lib/haml/buffer.rb')
Rake::RDocTask.new(:rdoc_devel) do |rdoc|
rdoc_task.call(rdoc)
rdoc.rdoc_dir = 'rdoc_devel'
rdoc.options << '--all'
rdoc.rdoc_files.include('test/*.rb')
rdoc.rdoc_files = Rake::FileList.new(*rdoc.rdoc_files.to_a)
rdoc.rdoc_files.include('lib/haml/buffer.rb')
end
end
# ----- Coverage -----
unless not_loaded.include? 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*_test.rb']
if ENV['NON_NATIVE']
t.rcov_opts << "--no-rcovrt"
if is_task?('rcov', 'clobber_rcov')
unless not_loaded.include? 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*_test.rb']
if ENV['NON_NATIVE']
t.rcov_opts << "--no-rcovrt"
end
t.verbose = true
end
t.verbose = true
end
end
# ----- Profiling -----
temp_desc = <<END
if is_task?('profile')
temp_desc = <<END
Run a profile of HAML.
TIMES=n sets the number of runs. Defaults to 100.
FILE=n sets the file to profile. Defaults to 'standard'.
END
desc temp_desc.chomp
task :profile do
require 'test/profile'
puts '-'*51, "Profiling HAML::Template", '-'*51
args = []
args.push ENV['TIMES'].to_i if ENV['TIMES']
args.push ENV['FILE'] if ENV['FILE']
profiler = Haml::Profiler.new
res = profiler.profile(*args)
puts res
puts '-'*51
desc temp_desc.chomp
task :profile do
require 'test/profile'
puts '-'*51, "Profiling HAML::Template", '-'*51
args = []
args.push ENV['TIMES'].to_i if ENV['TIMES']
args.push ENV['FILE'] if ENV['FILE']
profiler = Haml::Profiler.new
res = profiler.profile(*args)
puts res
puts '-'*51
end
end