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
- #child_directories_of(dir) ⇒ Object private
- #clean! ⇒ Object
-
#initialize(sandbox, pod_targets, aggregate_targets) ⇒ SandboxDirCleaner
constructor
Initialize a new instance.
- #remove_dir(path) ⇒ Object private
- #sandbox_private_headers(pod_targets) ⇒ Object private
- #sandbox_project_dir_names ⇒ Object private
- #sandbox_public_headers ⇒ Object private
- #sandbox_target_support_dirs ⇒ Object private
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
#child_directories_of(dir) ⇒ Object (private)
95 96 97 98 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 95 def child_directories_of(dir) return [] unless dir.exist? dir.children.select(&:directory?) end |
#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 |
#remove_dir(path) ⇒ Object (private)
100 101 102 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 100 def remove_dir(path) FileUtils.rm_rf(path) end |
#sandbox_private_headers(pod_targets) ⇒ Object (private)
83 84 85 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 83 def sandbox_private_headers(pod_targets) pod_targets.flat_map { |pod_target| child_directories_of(pod_target.build_headers.root) }.uniq end |
#sandbox_project_dir_names ⇒ Object (private)
87 88 89 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 87 def sandbox_project_dir_names child_directories_of(sandbox.root).select { |d| d.extname == '.xcodeproj' } end |
#sandbox_public_headers ⇒ Object (private)
91 92 93 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 91 def sandbox_public_headers child_directories_of(sandbox.public_headers.root) end |
#sandbox_target_support_dirs ⇒ Object (private)
79 80 81 |
# File 'lib/cocoapods/installer/sandbox_dir_cleaner.rb', line 79 def sandbox_target_support_dirs child_directories_of(sandbox.target_support_files_root) end |