module Hoe::RCov

def define_rcov_tasks

def define_rcov_tasks
  begin # take a whack at defining rcov tasks
    task :isolate # ensure it exists
    task :rcov => :isolate do
      sh(*make_rcov_cmd)
    end
    task :clobber_rcov do
      rm_rf "coverage"
    end
    task :clobber => :clobber_rcov
    # this is for my emacs rcov overlay stuff on emacswiki.
    task :rcov_overlay do
      path = ENV["FILE"]
      rcov, eol = Marshal.load(File.read("coverage.info")).last[path], 1
      puts rcov[:lines].zip(rcov[:coverage]).map { |line, coverage|
        bol, eol = eol, eol + line.length
        [bol, eol, "#ffcccc"] unless coverage
      }.compact.inspect
    end
  rescue LoadError
    # skip
    task :clobber_rcov # in case rcov didn't load
  end
end