Class: RakeCommandFilter::CommandDefinition
- Inherits:
-
Object
- Object
- RakeCommandFilter::CommandDefinition
- Defined in:
- lib/command_definition.rb
Overview
Base class for commands that get executed, and their output filtered rubocop:disable ClassLength
Direct Known Subclasses
Instance Attribute Summary collapse
-
#default_line_handling ⇒ Object
Returns the value of attribute default_line_handling.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.find_worst_result(results) ⇒ Object
The most severe result from an array of results.
Instance Method Summary collapse
-
#add_filter(id, pattern) { ... } ⇒ Object
add a new filter for output from this command.
-
#add_parameter(param) ⇒ Object
add a parameter to be passed to the command when executed.
-
#execute ⇒ Object
override this method.
-
#initialize(name) ⇒ CommandDefinition
constructor
if a line doesn’t match any of the patterns, then.
Constructor Details
#initialize(name) ⇒ CommandDefinition
if a line doesn’t match any of the patterns, then
11 12 13 14 15 16 |
# File 'lib/command_definition.rb', line 11 def initialize(name) @name = name @default_line_handling = LINE_HANDLING_HIDE_UNTIL_ERROR @filters = [] @parameters = [] end |
Instance Attribute Details
#default_line_handling ⇒ Object
Returns the value of attribute default_line_handling.
6 7 8 |
# File 'lib/command_definition.rb', line 6 def default_line_handling @default_line_handling end |
#filter ⇒ Object
Returns the value of attribute filter.
7 8 9 |
# File 'lib/command_definition.rb', line 7 def filter @filter end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/command_definition.rb', line 5 def name @name end |
Class Method Details
.find_worst_result(results) ⇒ Object
Returns the most severe result from an array of results.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/command_definition.rb', line 39 def self.find_worst_result(results) worst = [] results.each do |result| if worst.empty? || worst.first.severity < result.severity worst = [result] elsif worst.first.severity == result.severity worst << result end end return worst end |
Instance Method Details
#add_filter(id, pattern) { ... } ⇒ Object
add a new filter for output from this command
23 24 25 26 |
# File 'lib/command_definition.rb', line 23 def add_filter(id, pattern, &block) filter = LineFilter.new(id, pattern, block) @filters << filter end |
#add_parameter(param) ⇒ Object
add a parameter to be passed to the command when executed
29 30 31 |
# File 'lib/command_definition.rb', line 29 def add_parameter(param) @parameters << param end |
#execute ⇒ Object
override this method
34 35 36 |
# File 'lib/command_definition.rb', line 34 def execute return execute_system(@name) end |