# Rakefile for pyrosoma. -*-ruby-*- require 'rake/rdoctask' require 'rake/testtask' desc "Run all the tests" task :default => [:test] desc "Do predistribution stuff" task :predist => [:chmod, :changelog, :rdoc] desc "Run all the tests" task :test => :chmod do system "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}" end desc "Make an archive as .tar.gz" task :dist => :test do system "export DARCS_REPO=#{File.expand_path "."}; " + "darcs dist -d pyrosoma#{get_darcs_tree_version}" end desc "Make binaries executable" task :chmod do Dir["bin/*"].each { |binary| File.chmod(0775, binary) } end desc "Generate a ChangeLog" task :changelog do system "darcs changes --repo=#{ENV["DARCS_REPO"] || "."} >ChangeLog" end desc "Generate RDoc documentation" Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.options << '--line-numbers' << '--inline-source' rdoc.rdoc_dir = "rdoc" rdoc.rdoc_files.include 'README' rdoc.rdoc_files.include 'SPECS' rdoc.rdoc_files.include('lib/**/*.rb') end task :rdoc => "SPECS" desc "Generate RDox" task "SPECS" do system "specrb -Ilib:test -a --rdox >SPECS" end begin require 'rcov/rcovtask' Rcov::RcovTask.new do |t| t.test_files = FileList['test/spec_*.rb'] + ['--', '-rs'] # evil t.verbose = true # uncomment to see the executed command t.rcov_opts = ["--text-report", "-x", "xoxo-rb"] end rescue LoadError end # Helper to retrieve the "revision number" of the darcs tree. def get_darcs_tree_version return "" unless File.directory? "_darcs" changes = `darcs changes` count = 0 tag = "0.0" changes.each("\n\n") { |change| head, title, desc = change.split("\n", 3) if title =~ /^ \*/ # Normal change. count += 1 elsif title =~ /tagged (.*)/ # Tag. We look for these. tag = $1 break else warn "Unparsable change: #{change}" end } "-" + tag + "." + count.to_s end