Class: Yardstick::Rake::Verify

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/yardstick/rake/verify.rb

Overview

A rake task for verifying the doc thresholds

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :verify_measurements) {|task| ... } ⇒ Yardstick::Rake::Verify

Initialize a Verify task

Examples:

task = Yardstick::Rake::Verify.new do |task|
  task.threshold = 100
end

Parameters:

  • name (Symbol) (defaults to: :verify_measurements)

    optional task name

Yields:

  • (task)

    yield to self

Yield Parameters:



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/yardstick/rake/verify.rb', line 62

def initialize(name = :verify_measurements)
  @name                    = name
  @require_exact_threshold = true
  @path                    = 'lib/**/*.rb'
  @verbose                 = true

  yield self

  assert_threshold
  define
end

Instance Attribute Details

#path=(value) ⇒ undefined (writeonly)

List of paths to measure

Returns:

  • (undefined)


33
34
35
# File 'lib/yardstick/rake/verify.rb', line 33

def path=(value)
  @path = value
end

#require_exact_threshold=(value) ⇒ undefined (writeonly)

Specify if the threshold should match the coverage

Returns:

  • (undefined)


26
27
28
# File 'lib/yardstick/rake/verify.rb', line 26

def require_exact_threshold=(value)
  @require_exact_threshold = value
end

#threshold=(value) ⇒ undefined (writeonly)

Set the threshold

Returns:

  • (undefined)


19
20
21
# File 'lib/yardstick/rake/verify.rb', line 19

def threshold=(value)
  @threshold = value
end

#verbose=(value) ⇒ undefined (writeonly)

Specify if the coverage summary should be displayed

Returns:

  • (undefined)


40
41
42
# File 'lib/yardstick/rake/verify.rb', line 40

def verbose=(value)
  @verbose = value
end

Instance Method Details

#verify_measurementsundefined

Verify the YARD coverage measurements

Examples:

task.verify_measurements  # output coverage and threshold

Returns:

  • (undefined)

Raises:

  • (RuntimeError)

    raised if threshold is not met

  • (RuntimeError)

    raised if threshold is not equal to the coverage



87
88
89
90
91
# File 'lib/yardstick/rake/verify.rb', line 87

def verify_measurements
  puts "YARD-Coverage: #{total_coverage}% (threshold: #{@threshold}%)" if verbose
  assert_meets_threshold
  assert_matches_threshold
end