Class: RakeCommandFilter::YardCommandDefinition
- Inherits:
-
RakeCommandDefinition
- Object
- CommandDefinition
- RakeCommandDefinition
- RakeCommandFilter::YardCommandDefinition
- Defined in:
- lib/yard_command_definition.rb
Overview
default way to run rubocop and parse its output
Instance Attribute Summary collapse
-
#threshold ⇒ Object
Returns the value of attribute threshold.
Attributes inherited from RakeCommandDefinition
Attributes inherited from CommandDefinition
#default_line_handling, #filter, #name
Class Method Summary collapse
-
.percent_msg(percent) ⇒ Object
for testing.
-
.warning_msg ⇒ Object
for testing.
Instance Method Summary collapse
-
#initialize(threshold = 95, id = :yard) ⇒ YardCommandDefinition
constructor
Default parser for yard output.
Methods inherited from RakeCommandDefinition
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.
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
#threshold ⇒ Object
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_msg ⇒ Object
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 |