class Bibliothecary::MultiParsers::CycloneDX::ManifestEntries
Attributes
manifests[R]
Public Class Methods
new(parse_queue:)
click to toggle source
# File lib/bibliothecary/multi_parsers/cyclonedx.rb, line 22 def initialize(parse_queue:) @manifests = {} # Instead of recursing, we'll work through a queue of components # to process, letting the different parser add components to the # queue however they need to pull them from the source document. @parse_queue = parse_queue.dup end
Public Instance Methods
<<(purl)
click to toggle source
# File lib/bibliothecary/multi_parsers/cyclonedx.rb, line 31 def <<(purl) mapping = PurlUtil::PURL_TYPE_MAPPING[purl.type] return unless mapping @manifests[mapping] ||= Set.new @manifests[mapping] << Dependency.new( name: PurlUtil.full_name(purl), requirement: purl.version, type: "lockfile", ) end
[](key)
click to toggle source
# File lib/bibliothecary/multi_parsers/cyclonedx.rb, line 60 def [](key) @manifests[key]&.to_a end
parse!(&block)
click to toggle source
Iterates over each manifest entry in the parse_queue, and accepts a block which will be called on each component. The block has two jobs: 1) add more sub-components to parse (if they exist), and 2) return the components purl.
# File lib/bibliothecary/multi_parsers/cyclonedx.rb, line 46 def parse!(&block) while @parse_queue.length > 0 component = @parse_queue.shift purl_text = block.call(component, @parse_queue) next unless purl_text purl = PackageURL.parse(purl_text) self << purl end end