Class: CycloneDX::CocoaPods::PodfileAnalyzer
- Inherits:
-
Object
- Object
- CycloneDX::CocoaPods::PodfileAnalyzer
- Defined in:
- lib/cyclonedx/cocoapods/podfile_analyzer.rb
Overview
Uses cocoapods to analyze the Podfile and Podfile.lock for component dependency information
Instance Method Summary collapse
- #ensure_podfile_and_lock_are_present(options) ⇒ Object
-
#initialize(logger:, exclude_test_targets: false) ⇒ PodfileAnalyzer
constructor
A new instance of PodfileAnalyzer.
- #parse_pods(podfile, lockfile) ⇒ Object
- #populate_pods_with_additional_info(pods) ⇒ Object
- #top_level_deps(podfile, lockfile) ⇒ Object
Constructor Details
#initialize(logger:, exclude_test_targets: false) ⇒ PodfileAnalyzer
Returns a new instance of PodfileAnalyzer.
36 37 38 39 |
# File 'lib/cyclonedx/cocoapods/podfile_analyzer.rb', line 36 def initialize(logger:, exclude_test_targets: false) @logger = logger @exclude_test_targets = exclude_test_targets end |
Instance Method Details
#ensure_podfile_and_lock_are_present(options) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cyclonedx/cocoapods/podfile_analyzer.rb', line 41 def ensure_podfile_and_lock_are_present() project_dir = Pathname.new([:path] || Dir.pwd) (project_dir, ) initialize_cocoapods_config(project_dir) lockfile = ::Pod::Lockfile.from_file([:podfile_lock_path]) verify_synced_sandbox(lockfile) load_plugins([:podfile_path]) [::Pod::Podfile.from_file([:podfile_path]), lockfile] end |
#parse_pods(podfile, lockfile) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cyclonedx/cocoapods/podfile_analyzer.rb', line 55 def parse_pods(podfile, lockfile) @logger.debug "Parsing pods from #{podfile.defined_in_file}" included_pods, dependencies = create_list_of_included_pods(podfile, lockfile) pods = lockfile.pod_names.select { |name| included_pods.include?(name) }.map do |name| Pod.new(name: name, version: lockfile.version(name), source: source_for_pod(podfile, lockfile, name), checksum: lockfile.checksum(name)) end pod_dependencies = parse_dependencies(dependencies, podfile, lockfile) [pods, pod_dependencies] end |
#populate_pods_with_additional_info(pods) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/cyclonedx/cocoapods/podfile_analyzer.rb', line 69 def populate_pods_with_additional_info(pods) pods.each do |pod| @logger.debug "Completing information for #{pod.name}" pod.complete_information_from_source end pods end |
#top_level_deps(podfile, lockfile) ⇒ Object
77 78 79 80 |
# File 'lib/cyclonedx/cocoapods/podfile_analyzer.rb', line 77 def top_level_deps(podfile, lockfile) pods_used = top_level_pods(podfile) dependencies_for_pod(pods_used, podfile, lockfile) end |