1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/Rakefile

131 lines
3.1 KiB
Text
Raw Normal View History

2012-04-27 12:46:28 -04:00
require "rake/clean"
2012-05-07 14:44:42 -04:00
require "rake/testtask"
require "rubygems/package_task"
2012-04-27 12:46:28 -04:00
task :default => :test
CLEAN.replace %w(pkg doc coverage .yardoc test/haml vendor)
2012-05-07 14:44:42 -04:00
def silence_warnings
the_real_stderr, $stderr = $stderr, StringIO.new
yield
ensure
$stderr = the_real_stderr
end
2012-04-27 12:46:28 -04:00
desc "Benchmark Haml against ERb. TIMES=n sets the number of runs, default is 1000."
task :benchmark do
sh "ruby benchmark.rb #{ENV['TIMES']}"
end
2008-05-06 03:43:43 -04:00
Rake::TestTask.new do |t|
t.libs << 'lib' << 'test'
t.test_files = Dir["test/**/*_test.rb"]
2008-05-06 03:43:43 -04:00
t.verbose = true
end
2012-05-22 15:03:27 -04:00
task :set_coverage_env do
ENV["COVERAGE"] = "true"
end
desc "Run Simplecov (only works on 1.9)"
task :coverage => [:set_coverage_env, :test]
2012-04-27 12:46:28 -04:00
gemspec = File.expand_path("../haml.gemspec", __FILE__)
if File.exist? gemspec
Gem::PackageTask.new(eval(File.read(gemspec))) { |pkg| }
end
task :submodules do
if File.exist?(File.dirname(__FILE__) + "/.git")
sh %{git submodule sync}
2010-10-03 20:04:11 -04:00
sh %{git submodule update --init --recursive}
end
end
2009-03-30 04:27:08 -04:00
begin
2012-05-07 14:44:42 -04:00
silence_warnings do
require 'yard'
end
2009-03-30 04:27:08 -04:00
namespace :doc do
desc "List all undocumented methods and classes."
task :undocumented do
2012-04-27 12:46:28 -04:00
command = 'yard --list --query '
command << '"object.docstring.blank? && '
command << '!(object.type == :method && object.is_alias?)"'
sh command
end
end
2012-04-27 12:46:28 -04:00
desc "Generate documentation"
task(:doc) {sh "yard"}
2012-04-27 12:46:28 -04:00
desc "Generate documentation incrementally"
task(:redoc) {sh "yard -c"}
2009-03-30 04:27:08 -04:00
rescue LoadError
2008-05-06 03:43:43 -04:00
end
2008-05-15 18:43:32 -04:00
desc <<END
Profile Haml.
2008-05-15 18:43:32 -04:00
TIMES=n sets the number of runs. Defaults to 1000.
2010-08-22 19:04:02 -04:00
FILE=str sets the file to profile. Defaults to 'standard'
2008-05-15 18:43:32 -04:00
OUTPUT=str sets the ruby-prof output format.
Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
2008-05-15 18:02:45 -04:00
END
task :profile do
times = (ENV['TIMES'] || '1000').to_i
file = ENV['FILE']
2008-05-15 18:43:32 -04:00
require 'bundler/setup'
require 'ruby-prof'
require 'haml'
2008-05-15 18:43:32 -04:00
2012-04-27 13:27:14 -04:00
file = File.read(File.expand_path("../test/templates/#{file || 'standard'}.haml", __FILE__))
obj = Object.new
Haml::Engine.new(file, :ugly => true).def_method(obj, :render)
result = RubyProf.profile { times.times { obj.render } }
RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
end
def gemfiles
@gemfiles ||= begin
Dir[File.dirname(__FILE__) + '/test/gemfiles/Gemfile.*'].
reject {|f| f =~ /\.lock$/}.
reject {|f| RUBY_VERSION < '1.9.3' && f =~ /master/}
end
end
def with_each_gemfile
old_env = ENV['BUNDLE_GEMFILE']
gemfiles.each do |gemfile|
puts "Using gemfile: #{gemfile}"
ENV['BUNDLE_GEMFILE'] = gemfile
yield
end
ensure
ENV['BUNDLE_GEMFILE'] = old_env
end
namespace :test do
namespace :bundles do
desc "Install all dependencies necessary to test Haml."
task :install do
2012-04-26 16:44:48 -04:00
with_each_gemfile {sh "bundle"}
end
desc "Update all dependencies for testing Haml."
task :update do
with_each_gemfile {sh "bundle update"}
end
end
desc "Test all supported versions of rails. This takes a while."
task :rails_compatibility => 'test:bundles:install' do
with_each_gemfile {sh "bundle exec rake test"}
end
task :rc => :rails_compatibility
end