Rakefile in haml-4.1.0.beta.1 vs Rakefile in haml-5.0.0.beta.2
- old
+ new
@@ -1,21 +1,14 @@
require "rake/clean"
require "rake/testtask"
-require "rubygems/package_task"
+require "bundler/gem_tasks"
task :default => :test
CLEAN.replace %w(pkg doc coverage .yardoc test/haml vendor)
-def silence_warnings
- the_real_stderr, $stderr = $stderr, StringIO.new
- yield
-ensure
- $stderr = the_real_stderr
-end
-
-desc "Benchmark Haml against ERb. TIMES=n sets the number of runs, default is 1000."
+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
Rake::TestTask.new do |t|
@@ -34,47 +27,43 @@
end
desc "Run Simplecov"
task :coverage => [:set_coverage_env, :test]
-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}
sh %{git submodule update --init --recursive}
end
end
-begin
- silence_warnings do
- require 'yard'
+namespace :doc do
+ task :sass do
+ require 'sass'
+ Dir["yard/default/**/*.sass"].each do |sass|
+ File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
+ f.write(Sass::Engine.new(File.read(sass)).render)
+ end
+ end
end
- namespace :doc do
- desc "List all undocumented methods and classes."
- task :undocumented do
- command = 'yard --list --query '
- command << '"object.docstring.blank? && '
- command << '!(object.type == :method && object.is_alias?)"'
- sh command
- end
+ desc "List all undocumented methods and classes."
+ task :undocumented do
+ command = 'yard --list --query '
+ command << '"object.docstring.blank? && '
+ command << '!(object.type == :method && object.is_alias?)"'
+ sh command
end
+end
- desc "Generate documentation"
- task(:doc) {sh "yard"}
+desc "Generate documentation"
+task(:doc => 'doc:sass') {sh "yard"}
- desc "Generate documentation incrementally"
- task(:redoc) {sh "yard -c"}
+desc "Generate documentation incrementally"
+task(:redoc) {sh "yard -c"}
-rescue LoadError
-end
-
- desc <<END
+desc <<END
Profile Haml.
TIMES=n sets the number of runs. Defaults to 1000.
FILE=str sets the file to profile. Defaults to 'standard'
OUTPUT=str sets the ruby-prof output format.
Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
@@ -84,14 +73,13 @@
file = ENV['FILE'] || 'test/templates/standard.haml'
require 'bundler/setup'
require 'ruby-prof'
require 'haml'
- default =
file = File.read(File.expand_path("../#{file}", __FILE__))
obj = Object.new
- Haml::Engine.new(file, :ugly => true).def_method(obj, :render)
+ Haml::Engine.new(file).def_method(obj, :render)
result = RubyProf.profile { times.times { obj.render } }
RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
end
@@ -102,17 +90,16 @@
reject {|f| RUBY_VERSION < '1.9.3' && f =~ /Gemfile.rails-(\d+).\d+.x/ && $1.to_i > 3}
end
end
def with_each_gemfile
- old_env = ENV['BUNDLE_GEMFILE']
gemfiles.each do |gemfile|
- puts "Using gemfile: #{gemfile}"
- ENV['BUNDLE_GEMFILE'] = gemfile
- yield
+ Bundler.with_clean_env do
+ puts "Using gemfile: #{gemfile}"
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ yield
+ end
end
-ensure
- ENV['BUNDLE_GEMFILE'] = old_env
end
namespace :test do
namespace :bundles do
desc "Install all dependencies necessary to test Haml."