2006-10-14 19:50:07 -04:00
|
|
|
require 'rubygems'
|
2006-06-30 11:14:44 -04:00
|
|
|
require 'rake'
|
|
|
|
require 'rake/testtask'
|
|
|
|
require 'rake/rdoctask'
|
2006-10-14 19:50:07 -04:00
|
|
|
|
|
|
|
volatile_requires = ['rcov/rcovtask']
|
|
|
|
not_loaded = []
|
|
|
|
volatile_requires.each do |file|
|
|
|
|
begin
|
|
|
|
require file
|
|
|
|
rescue LoadError
|
|
|
|
not_loaded.push file
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# ----- Default: Testing ------
|
2006-08-05 23:18:54 -04:00
|
|
|
|
2006-06-30 11:14:44 -04:00
|
|
|
desc 'Default: run unit tests.'
|
|
|
|
task :default => :test
|
|
|
|
|
2006-09-12 10:50:13 -04:00
|
|
|
desc 'Test the HAML plugin'
|
2006-06-30 11:14:44 -04:00
|
|
|
Rake::TestTask.new(:test) do |t|
|
|
|
|
t.libs << 'lib'
|
|
|
|
t.pattern = 'test/**/*_test.rb'
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
2006-10-14 19:50:07 -04:00
|
|
|
# ----- Benchmarking -----
|
|
|
|
|
|
|
|
temp_desc = <<END
|
|
|
|
Benchmark HAML against ERb.
|
|
|
|
TIMES=n sets the number of runs. Defaults to 100.
|
|
|
|
END
|
|
|
|
desc temp_desc.chomp
|
2006-09-12 10:50:13 -04:00
|
|
|
task :benchmark do
|
2006-10-14 19:50:07 -04:00
|
|
|
require 'test/benchmark'
|
|
|
|
|
|
|
|
puts '-'*51, "Benchmark: HAML vs. ERb", '-'*51
|
2006-09-12 10:50:13 -04:00
|
|
|
puts "Running benchmark #{ENV['TIMES']} times..." if ENV['TIMES']
|
2006-10-14 19:50:07 -04:00
|
|
|
args = []
|
|
|
|
args.push ENV['TIMES'].to_i if ENV['TIMES']
|
|
|
|
benchmarker = Haml::Benchmarker.new
|
|
|
|
puts benchmarker.benchmark(*args)
|
2006-09-12 10:50:13 -04:00
|
|
|
puts '-'*51
|
|
|
|
end
|
|
|
|
|
2006-10-14 19:50:07 -04:00
|
|
|
# ----- Documentation -----
|
|
|
|
|
|
|
|
rdoc_task = Proc.new do |rdoc|
|
2006-06-30 11:14:44 -04:00
|
|
|
rdoc.title = 'Haml'
|
|
|
|
rdoc.options << '--line-numbers' << '--inline-source'
|
2006-10-22 17:42:45 -04:00
|
|
|
rdoc.rdoc_files.include('REFERENCE')
|
2006-06-30 11:14:44 -04:00
|
|
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
2006-10-14 19:50:07 -04:00
|
|
|
rdoc.rdoc_files.exclude('lib/haml/buffer.rb')
|
2006-06-30 11:14:44 -04:00
|
|
|
end
|
2006-08-08 18:46:19 -04:00
|
|
|
|
2006-10-14 19:50:07 -04:00
|
|
|
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')
|
|
|
|
end
|
|
|
|
|
|
|
|
# ----- Coverage -----
|
|
|
|
|
|
|
|
unless not_loaded.include? 'rcov/rcovtask'
|
|
|
|
Rcov::RcovTask.new do |t|
|
|
|
|
t.libs << "test"
|
|
|
|
t.test_files = FileList['test/*_test.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# ----- Profiling -----
|
|
|
|
|
|
|
|
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
|
2006-08-08 18:46:19 -04:00
|
|
|
end
|