2008-08-23 17:00:46 +00:00
|
|
|
require 'rubygems'
|
2010-09-12 16:19:29 +00:00
|
|
|
require 'bundler'
|
|
|
|
Bundler.setup
|
2009-09-03 02:47:01 +00:00
|
|
|
require 'compass'
|
2008-08-23 17:00:46 +00:00
|
|
|
|
|
|
|
# ----- Default: Testing ------
|
|
|
|
|
2010-11-28 00:58:04 +00:00
|
|
|
task :default => [:test, :features]
|
2008-08-23 17:00:46 +00:00
|
|
|
|
|
|
|
require 'rake/testtask'
|
|
|
|
require 'fileutils'
|
2010-11-28 00:58:04 +00:00
|
|
|
require 'cucumber'
|
|
|
|
require 'cucumber/rake/task'
|
|
|
|
|
|
|
|
Cucumber::Rake::Task.new(:features) do |t|
|
2011-04-29 04:34:36 +00:00
|
|
|
t.cucumber_opts = "features --format progress"
|
2010-11-28 00:58:04 +00:00
|
|
|
end
|
2008-08-23 17:00:46 +00:00
|
|
|
|
2010-09-12 16:19:29 +00:00
|
|
|
Rake::TestTask.new :test do |t|
|
2008-08-23 17:00:46 +00:00
|
|
|
t.libs << 'lib'
|
2009-11-19 10:26:35 +00:00
|
|
|
t.libs << 'test'
|
2008-08-23 17:00:46 +00:00
|
|
|
test_files = FileList['test/**/*_test.rb']
|
|
|
|
test_files.exclude('test/rails/*', 'test/haml/*')
|
|
|
|
t.test_files = test_files
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
Rake::Task[:test].send(:add_comment, <<END)
|
|
|
|
To run with an alternate version of Rails, make test/rails a symlink to that version.
|
|
|
|
To run with an alternate version of Haml & Sass, make test/haml a symlink to that version.
|
|
|
|
END
|
|
|
|
|
|
|
|
desc "Compile Examples into HTML and CSS"
|
|
|
|
task :examples do
|
|
|
|
linked_haml = "tests/haml"
|
|
|
|
if File.exists?(linked_haml) && !$:.include?(linked_haml + '/lib')
|
|
|
|
puts "[ using linked Haml ]"
|
|
|
|
$:.unshift linked_haml + '/lib'
|
|
|
|
end
|
|
|
|
require 'haml'
|
|
|
|
require 'sass'
|
|
|
|
require 'pathname'
|
2010-11-12 17:54:06 +00:00
|
|
|
require 'compass'
|
|
|
|
require 'compass/exec'
|
2008-08-23 17:00:46 +00:00
|
|
|
FileList['examples/*'].each do |example|
|
2009-07-09 19:48:36 +00:00
|
|
|
next unless File.directory?(example)
|
2009-03-12 16:54:20 +00:00
|
|
|
puts "\nCompiling #{example}"
|
|
|
|
puts "=" * "Compiling #{example}".length
|
2009-08-29 22:52:21 +00:00
|
|
|
Dir.chdir example do
|
|
|
|
load "bootstrap.rb" if File.exists?("bootstrap.rb")
|
2010-12-20 02:02:49 +00:00
|
|
|
Compass::Exec::SubCommandUI.new(%w(compile --force)).run!
|
2009-08-29 22:52:21 +00:00
|
|
|
end
|
2008-08-23 17:00:46 +00:00
|
|
|
# compile any haml templates to html
|
2009-06-05 17:44:57 +00:00
|
|
|
FileList["#{example}/**/*.haml"].each do |haml_file|
|
2009-03-12 16:54:20 +00:00
|
|
|
basename = haml_file[0..-6]
|
2008-08-23 17:00:46 +00:00
|
|
|
engine = Haml::Engine.new(open(haml_file).read, :filename => haml_file)
|
2009-03-12 16:54:20 +00:00
|
|
|
puts " haml #{File.basename(basename)}"
|
|
|
|
output = open(basename,'w')
|
2008-08-23 17:00:46 +00:00
|
|
|
output.write(engine.render)
|
|
|
|
output.close
|
|
|
|
end
|
|
|
|
end
|
2008-10-31 20:07:35 +00:00
|
|
|
end
|
|
|
|
|
2010-04-12 07:12:35 +00:00
|
|
|
namespace :examples do
|
|
|
|
desc "clean up the example directories"
|
|
|
|
task :clean do
|
|
|
|
puts "Cleaning Examples"
|
|
|
|
Dir.glob('examples/*/clean.rb').each do |cleaner|
|
|
|
|
load cleaner
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task "gemspec:generate" => "examples:clean"
|
|
|
|
|
2008-12-17 21:13:55 +00:00
|
|
|
namespace :git do
|
|
|
|
task :clean do
|
|
|
|
sh "git", "clean", "-fdx"
|
|
|
|
end
|
2008-10-31 20:07:35 +00:00
|
|
|
end
|
2009-10-26 03:14:09 +00:00
|
|
|
|
|
|
|
|
2010-04-26 08:32:39 +00:00
|
|
|
begin
|
2010-04-27 06:55:51 +00:00
|
|
|
require 'cucumber/rake/task'
|
|
|
|
require 'rcov/rcovtask'
|
|
|
|
namespace :rcov do
|
|
|
|
Cucumber::Rake::Task.new(:cucumber) do |t|
|
|
|
|
t.rcov = true
|
|
|
|
t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
|
|
|
|
t.rcov_opts << %[-o "coverage"]
|
|
|
|
end
|
|
|
|
|
|
|
|
Rcov::RcovTask.new(:units) do |rcov|
|
|
|
|
rcov.libs << 'lib'
|
|
|
|
test_files = FileList['test/**/*_test.rb']
|
|
|
|
test_files.exclude('test/rails/*', 'test/haml/*')
|
|
|
|
rcov.pattern = test_files
|
|
|
|
rcov.output_dir = 'coverage'
|
|
|
|
rcov.verbose = true
|
|
|
|
rcov.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
|
|
|
|
rcov.rcov_opts << %[-o "coverage" --sort coverage]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
desc "Run both specs and features to generate aggregated coverage"
|
|
|
|
task :all do |t|
|
|
|
|
rm "coverage.data" if File.exist?("coverage.data")
|
|
|
|
Rake::Task["rcov:units"].invoke
|
|
|
|
Rake::Task["rcov:cucumber"].invoke
|
|
|
|
end
|
2009-10-26 03:14:09 +00:00
|
|
|
end
|
2010-04-27 06:55:51 +00:00
|
|
|
rescue LoadError => e
|
|
|
|
puts "WARNING: #{e}"
|
2010-04-26 08:32:39 +00:00
|
|
|
end
|
2009-10-26 03:14:09 +00:00
|
|
|
|