Class: Sbom::Cyclonedx::Parser
- Inherits:
-
Object
- Object
- Sbom::Cyclonedx::Parser
- Defined in:
- lib/sbom/cyclonedx/parser.rb
Constant Summary collapse
- FORMAT_JSON =
:json- FORMAT_XML =
:xml
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse(content, format = nil) ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
12 13 14 15 16 17 18 19 |
# File 'lib/sbom/cyclonedx/parser.rb', line 12 def initialize @document = Data::Document.new @packages = {} @files = {} @relationships = [] @licenses = [] @version = nil end |
Instance Method Details
#parse(content, format = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sbom/cyclonedx/parser.rb', line 21 def parse(content, format = nil) format ||= detect_format(content) case format when FORMAT_JSON parse_json(content) when FORMAT_XML parse_xml(content) else raise ParserError, "Unknown CycloneDX format" end build_sbom end |