Class: CycloneDX::CocoaPods::Component
- Inherits:
-
Object
- Object
- CycloneDX::CocoaPods::Component
- Defined in:
- lib/cyclonedx/cocoapods/component.rb,
lib/cyclonedx/cocoapods/bom_builder.rb
Overview
Represents a software component in the CycloneDX BOM specification
A component is a self-contained unit of software that can be used as a building block in the architecture of a software system. Components can be of different types like libraries, frameworks, or applications.
Constant Summary collapse
- VALID_COMPONENT_TYPES =
%w[application framework library container operating-system device firmware file].freeze
Instance Attribute Summary collapse
-
#bomref ⇒ String
readonly
The unique reference ID for this component in the BOM.
-
#build_system ⇒ String?
readonly
The build system information.
-
#group ⇒ String?
readonly
The group/organization identifier of the component.
-
#name ⇒ String
readonly
The name of the component.
-
#type ⇒ String
readonly
The type of component (must be one of VALID_COMPONENT_TYPES).
-
#vcs ⇒ String?
readonly
The version control system information.
-
#version ⇒ String
readonly
The version string of the component.
Instance Method Summary collapse
- #add_to_bom(xml) ⇒ Object
-
#initialize(name:, version:, type:, group: nil, build_system: nil, vcs: nil) ⇒ Component
constructor
A new instance of Component.
- #to_json_component ⇒ Object
Constructor Details
#initialize(name:, version:, type:, group: nil, build_system: nil, vcs: nil) ⇒ Component
Returns a new instance of Component.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cyclonedx/cocoapods/component.rb', line 49 def initialize(name:, version:, type:, group: nil, build_system: nil, vcs: nil) # cocoapods is a special case to correctly build a purl package_type = type == 'cocoapods' ? 'cocoapods' : 'generic' @type = type == 'cocoapods' ? 'library' : type validate_attributes(name, version, @type, group) @group = group @name = name @version = version @build_system = build_system @vcs = vcs @bomref = build_purl(package_type, name, group, version) end |
Instance Attribute Details
#bomref ⇒ String (readonly)
The unique reference ID for this component in the BOM
44 45 46 |
# File 'lib/cyclonedx/cocoapods/component.rb', line 44 def bomref @bomref end |
#build_system ⇒ String? (readonly)
The build system information
44 45 46 |
# File 'lib/cyclonedx/cocoapods/component.rb', line 44 def build_system @build_system end |
#group ⇒ String? (readonly)
The group/organization identifier of the component
44 45 46 |
# File 'lib/cyclonedx/cocoapods/component.rb', line 44 def group @group end |
#name ⇒ String (readonly)
The name of the component
44 45 46 |
# File 'lib/cyclonedx/cocoapods/component.rb', line 44 def name @name end |
#type ⇒ String (readonly)
The type of component (must be one of VALID_COMPONENT_TYPES)
44 45 46 |
# File 'lib/cyclonedx/cocoapods/component.rb', line 44 def type @type end |
#vcs ⇒ String? (readonly)
The version control system information
44 45 46 |
# File 'lib/cyclonedx/cocoapods/component.rb', line 44 def vcs @vcs end |
#version ⇒ String (readonly)
The version string of the component
44 45 46 |
# File 'lib/cyclonedx/cocoapods/component.rb', line 44 def version @version end |
Instance Method Details
#add_to_bom(xml) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/cyclonedx/cocoapods/bom_builder.rb', line 230 def add_to_bom(xml) xml.component(type: type, 'bom-ref': bomref) do xml.group group unless group.nil? xml.name_ name xml.version version if !build_system.nil? || !vcs.nil? xml.externalReferences do if build_system xml.reference(type: 'build-system') do xml.url build_system end end if vcs xml.reference(type: 'vcs') do xml.url vcs end end end end xml.purl bomref end end |
#to_json_component ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/cyclonedx/cocoapods/bom_builder.rb', line 255 def to_json_component { type: type, 'bom-ref': bomref, group: group, name: name, version: version, purl: bomref, externalReferences: generate_json_external_references }.compact end |