Class: Sarif::Conversion
- Inherits:
-
Object
- Object
- Sarif::Conversion
- Defined in:
- lib/sarif/conversion.rb
Overview
Describes how a converter transformed the output of a static analysis tool from the analysis tool’s native output format into the SARIF format.
Instance Attribute Summary collapse
-
#analysis_tool_log_files ⇒ Object
Returns the value of attribute analysis_tool_log_files.
-
#invocation ⇒ Object
Returns the value of attribute invocation.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#tool ⇒ Object
Returns the value of attribute tool.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(tool:, invocation: nil, analysis_tool_log_files: [], properties: nil) ⇒ Conversion
constructor
A new instance of Conversion.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(tool:, invocation: nil, analysis_tool_log_files: [], properties: nil) ⇒ Conversion
Returns a new instance of Conversion.
8 9 10 11 12 13 |
# File 'lib/sarif/conversion.rb', line 8 def initialize(tool:, invocation: nil, analysis_tool_log_files: [], properties: nil) @tool = tool @invocation = invocation @analysis_tool_log_files = analysis_tool_log_files @properties = properties end |
Instance Attribute Details
#analysis_tool_log_files ⇒ Object
Returns the value of attribute analysis_tool_log_files.
6 7 8 |
# File 'lib/sarif/conversion.rb', line 6 def analysis_tool_log_files @analysis_tool_log_files end |
#invocation ⇒ Object
Returns the value of attribute invocation.
6 7 8 |
# File 'lib/sarif/conversion.rb', line 6 def invocation @invocation end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/conversion.rb', line 6 def properties @properties end |
#tool ⇒ Object
Returns the value of attribute tool.
6 7 8 |
# File 'lib/sarif/conversion.rb', line 6 def tool @tool end |
Class Method Details
.from_hash(h) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/sarif/conversion.rb', line 28 def self.from_hash(h) return nil if h.nil? new( tool: Tool.from_hash(h["tool"]), invocation: Invocation.from_hash(h["invocation"]), analysis_tool_log_files: h["analysisToolLogFiles"]&.map { |v| ArtifactLocation.from_hash(v) } || [], properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
38 39 40 41 |
# File 'lib/sarif/conversion.rb', line 38 def ==(other) return false unless other.is_a?(Conversion) @tool == other.tool && @invocation == other.invocation && @analysis_tool_log_files == other.analysis_tool_log_files && @properties == other.properties end |
#hash ⇒ Object
45 46 47 |
# File 'lib/sarif/conversion.rb', line 45 def hash [@tool, @invocation, @analysis_tool_log_files, @properties].hash end |
#to_h ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/sarif/conversion.rb', line 15 def to_h h = {} h["tool"] = @tool&.to_h h["invocation"] = @invocation&.to_h unless @invocation.nil? h["analysisToolLogFiles"] = @analysis_tool_log_files&.map(&:to_h) if @analysis_tool_log_files&.any? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
24 25 26 |
# File 'lib/sarif/conversion.rb', line 24 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |