mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
47616c9c97
task because I was getting a segmentation fault with the native. git-svn-id: svn://hamptoncatlin.com/haml/branches/edge@101 7063305b-7217-0410-af8c-cdc13e5119b9
106 lines
2.3 KiB
Ruby
106 lines
2.3 KiB
Ruby
require 'rubygems'
|
|
require 'rake'
|
|
require 'rake/testtask'
|
|
require 'rake/rdoctask'
|
|
|
|
volatile_requires = ['rcov/rcovtask']
|
|
not_loaded = []
|
|
volatile_requires.each do |file|
|
|
begin
|
|
require file
|
|
rescue LoadError
|
|
not_loaded.push file
|
|
end
|
|
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
|
|
end
|
|
|
|
# ----- Benchmarking -----
|
|
|
|
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'
|
|
|
|
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
|
|
|
|
# ----- 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
|
|
|
|
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']
|
|
if ENV['NON_NATIVE']
|
|
t.rcov_opts << "--no-rcovrt"
|
|
end
|
|
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
|
|
end
|