Module: Hoe::RCov

Defined in:
lib/hoe/rcov.rb

Overview

RCov plugin for hoe.

Tasks Provided:

rcov

Analyze code coverage with tests

Instance Method Summary collapse

Instance Method Details

#activate_rcov_depsObject

Activate the rcov dependencies.



13
14
15
# File 'lib/hoe/rcov.rb', line 13

def activate_rcov_deps
  dependency "rcov", "~> 0.9", :development
end

#define_rcov_tasksObject

Define tasks for plugin.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/hoe/rcov.rb', line 20

def define_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
  # TODO: didn't load? this must be terribly historical
end

#make_rcov_cmdObject

:nodoc:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/hoe/rcov.rb', line 48

def make_rcov_cmd # :nodoc:
  rcov  = Gem.bin_wrapper "rcov"
  tests = test_globs.sort.map { |g| Dir.glob(g) }.flatten.map(&:inspect)

  cmd = %W[#{rcov}
           #{Hoe::RUBY_FLAGS}
           --text-report
           --no-color
           --save coverage.info
           -x ^/
           -x tmp/isolate
           --sort coverage
           --sort-reverse
           -o coverage
          ] + tests

  cmd
end