Class: RakeCommandFilter::YardCommandDefinition

Inherits:
RakeCommandDefinition show all
Defined in:
lib/yard_command_definition.rb

Overview

default way to run rubocop and parse its output

Instance Attribute Summary collapse

Attributes inherited from RakeCommandDefinition

#test_command

Attributes inherited from CommandDefinition

#default_line_handling, #filter, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RakeCommandDefinition

#execute

Methods inherited from CommandDefinition

#add_filter, #add_parameter, #execute, find_worst_result

Constructor Details

#initialize(threshold = 95, id = :yard) ⇒ YardCommandDefinition

Default parser for yard output.

Parameters:

  • threshold (defaults to: 95)

    override this if you want to require less than 95% documentation

  • id (defaults to: :yard)

    override this if you want to do something other than ‘rake spec’



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/yard_command_definition.rb', line 19

def initialize(threshold = 95, id = :yard)
  super(id, 'yard')
  # just use sensible defaults here.
  add_filter(:yard_percentage, /(\d+.?\d+)%\s+document/) do |matches|
    percent = matches[0].to_f
    msg = YardCommandDefinition.percent_msg(percent)
    (percent >= threshold) ? result_success(msg) : result_failure(msg)
  end
  add_filter(:yard_warning, /\[warn\]:(.*)/) do |_matches|
    result_warning(YardCommandDefinition.warning_msg)
  end
end

Instance Attribute Details

#thresholdObject

Returns the value of attribute threshold.



4
5
6
# File 'lib/yard_command_definition.rb', line 4

def threshold
  @threshold
end

Class Method Details

.percent_msg(percent) ⇒ Object

for testing



7
8
9
# File 'lib/yard_command_definition.rb', line 7

def self.percent_msg(percent)
  "#{percent} documented"
end

.warning_msgObject

for testing



12
13
14
# File 'lib/yard_command_definition.rb', line 12

def self.warning_msg
  'One or more yard warnings, see above'
end