Class: Pod::Installer::SandboxDirCleaner
- Inherits:
-
Object
- Object
- Pod::Installer::SandboxDirCleaner
- Defined in:
- lib/cocoapods/installer/sandbox_dir_cleaner.rb
Overview
Cleans up the sandbox directory by removing stale target support files and headers.
Instance Attribute Summary collapse
-
#aggregate_targets ⇒ Array<AggregateTarget>
readonly
The list of all aggregate targets that will be installed into the Sandbox.
-
#pod_targets ⇒ Array<PodTarget>
readonly
The list of all pod targets that will be installed into the Sandbox.
-
#sandbox ⇒ Sandbox
readonly
The sandbox directory that will be cleaned.
Instance Method Summary collapse
- #clean! ⇒ Object
-
#initialize(sandbox, pod_targets, aggregate_targets) ⇒ SandboxDirCleaner
constructor
Initialize a new instance.
Constructor Details
#initialize(sandbox, pod_targets, aggregate_targets) ⇒ SandboxDirCleaner
Initialize a new instance
26 27 28 29 30 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 26 def initialize(sandbox, pod_targets, aggregate_targets) @sandbox = sandbox @pod_targets = pod_targets @aggregate_targets = aggregate_targets end |
Instance Attribute Details
#aggregate_targets ⇒ Array<AggregateTarget> (readonly)
Returns The list of all aggregate targets that will be installed into the Sandbox.
18 19 20 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 18 def aggregate_targets @aggregate_targets end |
#pod_targets ⇒ Array<PodTarget> (readonly)
Returns The list of all pod targets that will be installed into the Sandbox.
13 14 15 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 13 def pod_targets @pod_targets end |
#sandbox ⇒ Sandbox (readonly)
Returns The sandbox directory that will be cleaned.
8 9 10 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 8 def sandbox @sandbox end |
Instance Method Details
#clean! ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 32 def clean! UI.('Cleaning up sandbox directory') do # Clean up Target Support Files Directory target_support_dirs_to_install = (pod_targets + aggregate_targets).map(&:support_files_dir) target_support_dirs = sandbox_target_support_dirs removed_target_support_dirs = target_support_dirs - target_support_dirs_to_install removed_target_support_dirs.each { |dir| remove_dir(dir) } # Clean up Sandbox Headers Directory sandbox_private_headers_to_install = pod_targets.flat_map do |pod_target| if pod_target.header_mappings_by_file_accessor.empty? [] else [pod_target.build_headers.root.join(pod_target.headers_sandbox)] end end sandbox_public_headers_to_install = pod_targets.flat_map do |pod_target| if pod_target.public_header_mappings_by_file_accessor.empty? [] else [ sandbox.public_headers.root.join(pod_target.headers_sandbox), pod_target.module_map_path.dirname, ].uniq end end removed_sandbox_public_headers = sandbox_public_headers - sandbox_public_headers_to_install removed_sandbox_public_headers.each { |path| remove_dir(path) } removed_sandbox_private_headers = sandbox_private_headers(pod_targets) - sandbox_private_headers_to_install removed_sandbox_private_headers.each { |path| remove_dir(path) } project_dir_names_to_install = pod_targets.map do |pod_target| sandbox.pod_target_project_path(pod_target.project_name) end project_dir_names = sandbox_project_dir_names - [sandbox.project_path] user_project_dir_names = aggregate_targets.map(&:user_project_path).uniq removed_project_dir_names = project_dir_names - user_project_dir_names - project_dir_names_to_install removed_project_dir_names.each { |dir| remove_dir(dir) } end end |