module Hoe::Cov

Coverage plugin for hoe. Uses simplecov.

Tasks Provided:

cov

Analyze code coverage with tests using simplecov.

Attributes

cov_branches[RW]

Set to true to enable branch level coverage reporting.

The default = false

cov_filter[RW]

Directories to filter out from coverage.

The default = tmp:test

Public Instance Methods

activate_cov_deps() click to toggle source

Activate the cov dependencies.

# File lib/hoe/cov.rb, line 32
def activate_cov_deps
  dependency "simplecov", "~> 0.21", :development
end
define_cov_tasks() click to toggle source

Define tasks for plugin.

# File lib/hoe/cov.rb, line 39
def define_cov_tasks
  task :isolate # ensure it exists

  self.clean_globs << "coverage"

  desc "Run tests and analyze code coverage"
  task :cov => :isolate do
    extra = cov_branches && "; enable_coverage :branch"
    test_task.test_prelude =
      %(require "simplecov"; SimpleCov.start { add_filter %p%s }) % [cov_filter, extra]

    Rake::Task[:test].invoke
  end
rescue LoadError
  warn "simplecov not found"
end