Class: CC::Analyzer::EngineOutput
- Inherits:
-
Object
- Object
- CC::Analyzer::EngineOutput
- Defined in:
- lib/cc/analyzer/engine_output.rb
Instance Method Summary collapse
- #as_issue ⇒ Object
- #error ⇒ Object
-
#initialize(name, raw_output) ⇒ EngineOutput
constructor
A new instance of EngineOutput.
- #issue? ⇒ Boolean
- #measurement? ⇒ Boolean
- #to_json ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(name, raw_output) ⇒ EngineOutput
Returns a new instance of EngineOutput.
6 7 8 9 |
# File 'lib/cc/analyzer/engine_output.rb', line 6 def initialize(name, raw_output) @name = name @raw_output = raw_output end |
Instance Method Details
#as_issue ⇒ Object
19 20 21 |
# File 'lib/cc/analyzer/engine_output.rb', line 19 def as_issue Issue.new(name, raw_output) end |
#error ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/cc/analyzer/engine_output.rb', line 35 def error if !valid_json? { message: "Invalid JSON", output: raw_output } elsif !validator.present? { message: "Unsupported document type", output: raw_output } else validator.error end end |
#issue? ⇒ Boolean
11 12 13 |
# File 'lib/cc/analyzer/engine_output.rb', line 11 def issue? valid_with_type?("issue") end |
#measurement? ⇒ Boolean
15 16 17 |
# File 'lib/cc/analyzer/engine_output.rb', line 15 def measurement? valid_with_type?("measurement") end |
#to_json ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/cc/analyzer/engine_output.rb', line 23 def to_json if issue? as_issue.to_json elsif measurement? Measurement.new(name, raw_output).to_json end end |
#valid? ⇒ Boolean
31 32 33 |
# File 'lib/cc/analyzer/engine_output.rb', line 31 def valid? valid_json? && validator && validator.valid? end |