Class: CycloneDX::CocoaPods::PodspecAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/cyclonedx/cocoapods/podspec_analyzer.rb

Overview

Analyzes CocoaPods podspec files to extract component information for CycloneDX BOM generation

The PodspecAnalyzer is responsible for:

  • Validating and loading podspec files from a given path

  • Parsing podspec contents to extract pod metadata

  • Converting podspec source information into standardized Source objects

Examples:

analyzer = PodspecAnalyzer.new(logger: Logger.new(STDOUT))
podspec = analyzer.ensure_podspec_is_present(path: '/path/to/project')
pod = analyzer.parse_podspec(podspec)

Instance Method Summary collapse

Constructor Details

#initialize(logger:) ⇒ PodspecAnalyzer



47
48
49
# File 'lib/cyclonedx/cocoapods/podspec_analyzer.rb', line 47

def initialize(logger:)
  @logger = logger
end

Instance Method Details

#ensure_podspec_is_present(options) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/cyclonedx/cocoapods/podspec_analyzer.rb', line 51

def ensure_podspec_is_present(options)
  project_dir = Pathname.new(options[:path] || Dir.pwd)
  validate_options(project_dir, options)
  initialize_cocoapods_config(project_dir)

  options[:podspec_path].nil? ? nil : ::Pod::Specification.from_file(options[:podspec_path])
end

#parse_podspec(podspec) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/cyclonedx/cocoapods/podspec_analyzer.rb', line 59

def parse_podspec(podspec)
  return nil if podspec.nil?

  @logger.debug "Parsing podspec from #{podspec.defined_in_file}"

  Pod.new(
    name: podspec.name,
    version: podspec.version.to_s,
    source: source_from_podspec(podspec),
    checksum: nil
  )
end