$rubyforge_project = "'module import'"
$project = 'module-import'
$rcov_index_html = 'coverage/lib-module-import_rb.html'
require 'tasks/helpers'
def __DIR__; "#{File.dirname(__FILE__)}" end
desc "test run all tests"
task :test => [:spec, 'test:readme', :rcov]
namespace :test do
# run README through xmp
desc "run README code through xmp filter"
task :readme do
cd_tmp do
example_file = "#{__DIR__}/example.rb"
File.write(example_file, (
File.read("#{__DIR__}/lib/module-import.rb") <<
File.readlines('../README').grep(/^ / ).
reject {|l| l =~ /^\s*require/ or l.include?('Error')}.
join ))
command = "ruby ../bin/xmpfilter -c #{example_file}"
Dir.chdir '/home/greg/src/head/lib' do
run "#{command}"
end
puts "README code successfully evaluated"
end
end
end
namespace :readme do
desc "create html for website using coderay, use --silent option"
task :html do
rm_rf 'doc'
fail unless system 'rdoc --force-update --quiet README'
require 'hpricot'
require 'htmlentities'
doc = open( 'doc/files/README.html' ) { |f| Hpricot(f) }
# find example code
doc.at('#description').search('pre').
select {|elem| elem.inner_html =~ /class |module /}.each do |ex|
# add coderay and undo what rdoc has done in the example code
ex.swap("