Class: CycloneDX::CocoaPods::Source::CocoaPodsRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/cyclonedx/cocoapods/source.rb,
lib/cyclonedx/cocoapods/bom_builder.rb,
lib/cyclonedx/cocoapods/pod_attributes.rb

Constant Summary collapse

LEGACY_REPOSITORY =
'https://github.com/CocoaPods/Specs.git'
CDN_REPOSITORY =
'trunk'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:) ⇒ CocoaPodsRepository

Returns a new instance of CocoaPodsRepository.



28
29
30
# File 'lib/cyclonedx/cocoapods/source.rb', line 28

def initialize(url:)
  @url = url
end

Instance Attribute Details

#source_managerObject

Returns the value of attribute source_manager.



28
29
30
# File 'lib/cyclonedx/cocoapods/pod_attributes.rb', line 28

def source_manager
  @source_manager
end

#urlObject (readonly)

Returns the value of attribute url.



26
27
28
# File 'lib/cyclonedx/cocoapods/source.rb', line 26

def url
  @url
end

Class Method Details

.searchable_source(url:, source_manager:) ⇒ Object



30
31
32
33
34
# File 'lib/cyclonedx/cocoapods/pod_attributes.rb', line 30

def self.searchable_source(url:, source_manager:)
  source = CocoaPodsRepository.new(url: url)
  source.source_manager = source_manager
  source
end

Instance Method Details

#attributes_for(pod:) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cyclonedx/cocoapods/pod_attributes.rb', line 36

def attributes_for(pod:)
  specification_sets = @source_manager.search_by_name("^#{Regexp.escape(pod.root_name)}$")
  validate_spec_sets(specification_sets, pod)

  paths = specification_sets[0].specification_paths_for_version(pod.version)
  if paths.empty?
    raise SearchError,
          "Version #{pod.version} not found for pod #{pod.name}; run 'pod repo update' and try again"
  end

  ::Pod::Specification.from_file(paths[0]).attributes_hash
end

#source_qualifierObject



34
35
36
# File 'lib/cyclonedx/cocoapods/bom_builder.rb', line 34

def source_qualifier
  url == LEGACY_REPOSITORY || url == CDN_REPOSITORY ? {} : { repository_url: url }
end