Class: Pod::Sandbox
- Inherits:
-
Object
- Object
- Pod::Sandbox
- Defined in:
- lib/cocoapods/sandbox.rb,
lib/cocoapods/sandbox/path_list.rb,
lib/cocoapods/sandbox/file_accessor.rb,
lib/cocoapods/sandbox/headers_store.rb,
lib/cocoapods/sandbox/podspec_finder.rb,
lib/cocoapods/sandbox/pod_dir_cleaner.rb
Overview
The sandbox provides support for the directory that CocoaPods uses for an installation. In this directory the Pods projects, the support files and the sources of the Pods are stored.
CocoaPods assumes to have control of the sandbox.
Once completed the sandbox will have the following file structure:
Pods
|
+-- Headers
| +-- Private
| | +-- [Pod Name]
| +-- Public
| +-- [Pod Name]
|
+-- Local Podspecs
| +-- External Sources
| +-- Normal Sources
|
+-- Target Support Files
| +-- [Target Name]
| +-- Pods-acknowledgements.markdown
| +-- Pods-acknowledgements.plist
| +-- Pods-dummy.m
| +-- Pods-prefix.pch
| +-- Pods.xcconfig
|
+-- [Pod Name]
|
+-- Manifest.lock
|
+-- Pods.xcodeproj
Defined Under Namespace
Classes: FileAccessor, HeadersStore, PathList, PodDirCleaner, PodspecFinder
Pods information collapse
-
#checkout_sources ⇒ Hash{String=>Hash}
readonly
The options necessary to recreate the exact checkout of a given Pod grouped by its name.
-
#development_pods ⇒ Hash{String=>Pathname}
readonly
The path of the Pods’ podspecs with a local source grouped by their root name.
-
#predownloaded_pods ⇒ Array<String>
readonly
The names of the pods that have been pre-downloaded from an external source.
Instance Attribute Summary collapse
-
#manifest ⇒ Lockfile
The manifest which contains the information about the installed pods.
-
#project ⇒ Project
The Pods project.
-
#public_headers ⇒ HeadersStore
readonly
The header directory for the user targets.
-
#root ⇒ Pathname
readonly
The root of the sandbox.
Paths collapse
-
#headers_root ⇒ Pathname
The directory where headers are stored.
-
#local_path_was_absolute?(name) ⇒ Bool
Returns true if the path as originally specified was absolute.
-
#manifest_path ⇒ Pathname
The path of the manifest.
-
#pod_dir(name) ⇒ Pathname
Returns the path where the Pod with the given name is stored, taking into account whether the Pod is locally sourced.
-
#project_path ⇒ Pathname
The path of the Pods project.
-
#sources_root ⇒ Pathname
The directory where the downloaded sources of the Pods are stored.
-
#specifications_root ⇒ Pathname
The path for the directory where the specifications are stored.
-
#target_support_files_dir(name) ⇒ Pathname
Returns the path for the directory where the support files of a target are stored.
-
#target_support_files_root ⇒ Pathname
The directory where the files generated by CocoaPods to support the umbrella targets are stored.
Specification store collapse
-
#specification(name) ⇒ Specification
Returns the specification for the Pod with the given name.
-
#specification_path(name) ⇒ Pathname, Nil
Returns the path of the specification for the Pod with the given name, if one is stored.
-
#store_podspec(name, podspec, _external_source = false, json = false) ⇒ void
Stores a specification in the ‘Local Podspecs` folder.
Pods information collapse
-
#local?(name) ⇒ Bool
Checks if a Pod is locally sourced?.
-
#local_podspec(name) ⇒ Pathname
Path to the local Podspec of the Pod.
-
#predownloaded?(name) ⇒ Bool
Checks if a Pod has been pre-downloaded by the resolver in order to fetch the podspec.
-
#remove_checkout_source(name) ⇒ void
Removes the checkout source of a Pod.
-
#store_checkout_source(name, source) ⇒ void
Stores the local path of a Pod.
-
#store_local_path(name, path, was_absolute = false) ⇒ void
Stores the local path of a Pod.
-
#store_pre_downloaded_pod(name) ⇒ void
Marks a Pod as pre-downloaded.
Instance Method Summary collapse
-
#clean_pod(name) ⇒ void
Removes the files of the Pod with the given name from the sandbox.
-
#initialize(root) ⇒ Sandbox
constructor
Initialize a new instance.
-
#inspect ⇒ String
A string representation suitable for debugging.
-
#prepare ⇒ Object
Prepares the sandbox for a new installation removing any file that will be regenerated and ensuring that the directories exists.
Constructor Details
#initialize(root) ⇒ Sandbox
Initialize a new instance
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/cocoapods/sandbox.rb', line 57 def initialize(root) FileUtils.mkdir_p(root) @root = Pathname.new(root).realpath @public_headers = HeadersStore.new(self, 'Public', :public) @predownloaded_pods = [] @checkout_sources = {} @development_pods = {} @pods_with_absolute_path = [] @stored_podspecs = {} end |
Instance Attribute Details
#checkout_sources ⇒ Hash{String=>Hash} (readonly)
Returns The options necessary to recreate the exact checkout of a given Pod grouped by its name.
352 353 354 |
# File 'lib/cocoapods/sandbox.rb', line 352 def checkout_sources @checkout_sources end |
#development_pods ⇒ Hash{String=>Pathname} (readonly)
Returns The path of the Pods’ podspecs with a local source grouped by their root name.
379 380 381 |
# File 'lib/cocoapods/sandbox.rb', line 379 def development_pods @development_pods end |
#manifest ⇒ Lockfile
Returns the manifest which contains the information about the installed pods.
71 72 73 |
# File 'lib/cocoapods/sandbox.rb', line 71 def manifest @manifest end |
#predownloaded_pods ⇒ Array<String> (readonly)
Returns The names of the pods that have been pre-downloaded from an external source.
304 305 306 |
# File 'lib/cocoapods/sandbox.rb', line 304 def predownloaded_pods @predownloaded_pods end |
#project ⇒ Project
Returns the Pods project.
81 82 83 |
# File 'lib/cocoapods/sandbox.rb', line 81 def project @project end |
#public_headers ⇒ HeadersStore (readonly)
Returns the header directory for the user targets.
51 52 53 |
# File 'lib/cocoapods/sandbox.rb', line 51 def public_headers @public_headers end |
#root ⇒ Pathname (readonly)
Returns the root of the sandbox.
47 48 49 |
# File 'lib/cocoapods/sandbox.rb', line 47 def root @root end |
Instance Method Details
#clean_pod(name) ⇒ void
This method returns an undefined value.
Removes the files of the Pod with the given name from the sandbox.
87 88 89 90 91 92 93 94 95 |
# File 'lib/cocoapods/sandbox.rb', line 87 def clean_pod(name) root_name = Specification.root_name(name) unless local?(root_name) path = pod_dir(name) path.rmtree if path.exist? end podspec_path = specification_path(name) podspec_path.rmtree if podspec_path end |
#headers_root ⇒ Pathname
Returns The directory where headers are stored.
174 175 176 |
# File 'lib/cocoapods/sandbox.rb', line 174 def headers_root root + 'Headers' end |
#inspect ⇒ String
Returns a string representation suitable for debugging.
111 112 113 |
# File 'lib/cocoapods/sandbox.rb', line 111 def inspect "#<#{self.class}> with root #{root}" end |
#local?(name) ⇒ Bool
Checks if a Pod is locally sourced?
388 389 390 |
# File 'lib/cocoapods/sandbox.rb', line 388 def local?(name) !local_podspec(name).nil? end |
#local_path_was_absolute?(name) ⇒ Bool
Returns true if the path as originally specified was absolute.
168 169 170 |
# File 'lib/cocoapods/sandbox.rb', line 168 def local_path_was_absolute?(name) @pods_with_absolute_path.include? name end |
#local_podspec(name) ⇒ Pathname
Returns Path to the local Podspec of the Pod.
397 398 399 400 |
# File 'lib/cocoapods/sandbox.rb', line 397 def local_podspec(name) root_name = Specification.root_name(name) development_pods[root_name] end |
#manifest_path ⇒ Pathname
Returns the path of the manifest.
123 124 125 |
# File 'lib/cocoapods/sandbox.rb', line 123 def manifest_path root + 'Manifest.lock' end |
#pod_dir(name) ⇒ Pathname
Returns the path where the Pod with the given name is stored, taking into account whether the Pod is locally sourced.
153 154 155 156 157 158 159 160 |
# File 'lib/cocoapods/sandbox.rb', line 153 def pod_dir(name) root_name = Specification.root_name(name) if local?(root_name) Pathname.new(development_pods[root_name].dirname) else sources_root + root_name end end |
#predownloaded?(name) ⇒ Bool
Checks if a Pod has been pre-downloaded by the resolver in order to fetch the podspec.
314 315 316 317 |
# File 'lib/cocoapods/sandbox.rb', line 314 def predownloaded?(name) root_name = Specification.root_name(name) predownloaded_pods.include?(root_name) end |
#prepare ⇒ Object
Prepares the sandbox for a new installation removing any file that will be regenerated and ensuring that the directories exists.
100 101 102 103 104 105 106 107 |
# File 'lib/cocoapods/sandbox.rb', line 100 def prepare FileUtils.rm_rf(headers_root) FileUtils.mkdir_p(headers_root) FileUtils.mkdir_p(sources_root) FileUtils.mkdir_p(specifications_root) FileUtils.mkdir_p(target_support_files_root) end |
#project_path ⇒ Pathname
Returns the path of the Pods project.
129 130 131 |
# File 'lib/cocoapods/sandbox.rb', line 129 def project_path root + 'Pods.xcodeproj' end |
#remove_checkout_source(name) ⇒ void
This method returns an undefined value.
Removes the checkout source of a Pod.
344 345 346 347 |
# File 'lib/cocoapods/sandbox.rb', line 344 def remove_checkout_source(name) root_name = Specification.root_name(name) checkout_sources.delete(root_name) end |
#sources_root ⇒ Pathname
Returns The directory where the downloaded sources of the Pods are stored.
181 182 183 |
# File 'lib/cocoapods/sandbox.rb', line 181 def sources_root root end |
#specification(name) ⇒ Specification
Returns the specification for the Pod with the given name.
212 213 214 215 216 217 |
# File 'lib/cocoapods/sandbox.rb', line 212 def specification(name) @stored_podspecs[name] ||= if file = specification_path(name) original_path = development_pods[name] Specification.from_file(original_path || file) end end |
#specification_path(name) ⇒ Pathname, Nil
Returns the path of the specification for the Pod with the given name, if one is stored.
228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/cocoapods/sandbox.rb', line 228 def specification_path(name) name = Specification.root_name(name) path = specifications_root + "#{name}.podspec" if path.exist? path else path = specifications_root + "#{name}.podspec.json" if path.exist? path end end end |
#specifications_root ⇒ Pathname
Returns the path for the directory where the specifications are stored.
188 189 190 |
# File 'lib/cocoapods/sandbox.rb', line 188 def specifications_root root + 'Local Podspecs' end |
#store_checkout_source(name, source) ⇒ void
This method returns an undefined value.
Stores the local path of a Pod.
332 333 334 335 |
# File 'lib/cocoapods/sandbox.rb', line 332 def store_checkout_source(name, source) root_name = Specification.root_name(name) checkout_sources[root_name] = source end |
#store_local_path(name, path, was_absolute = false) ⇒ void
This method returns an undefined value.
Stores the local path of a Pod.
369 370 371 372 373 374 |
# File 'lib/cocoapods/sandbox.rb', line 369 def store_local_path(name, path, was_absolute = false) root_name = Specification.root_name(name) path = Pathname.new(path) unless path.is_a?(Pathname) development_pods[root_name] = path @pods_with_absolute_path << root_name if was_absolute end |
#store_podspec(name, podspec, _external_source = false, json = false) ⇒ void
This method returns an undefined value.
Stores a specification in the ‘Local Podspecs` folder.
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/cocoapods/sandbox.rb', line 253 def store_podspec(name, podspec, _external_source = false, json = false) file_name = json ? "#{name}.podspec.json" : "#{name}.podspec" output_path = specifications_root + file_name case podspec when String output_path.open('w') { |f| f.puts(podspec) } when Pathname unless podspec.exist? raise Informative, "No podspec found for `#{name}` in #{podspec}" end spec = Specification.from_file(podspec) FileUtils.copy(podspec, output_path) when Specification raise ArgumentError, 'can only store Specification objects as json' unless json output_path.open('w') { |f| f.puts(podspec.to_pretty_json) } spec = podspec.dup else raise ArgumentError, "Unknown type for podspec: #{podspec.inspect}" end spec ||= Specification.from_file(output_path) spec.defined_in_file ||= output_path unless spec.name == name raise Informative, "The name of the given podspec `#{spec.name}` doesn't match the expected one `#{name}`" end @stored_podspecs[spec.name] = spec end |
#store_pre_downloaded_pod(name) ⇒ void
This method returns an undefined value.
Marks a Pod as pre-downloaded
296 297 298 299 |
# File 'lib/cocoapods/sandbox.rb', line 296 def store_pre_downloaded_pod(name) root_name = Specification.root_name(name) predownloaded_pods << root_name end |
#target_support_files_dir(name) ⇒ Pathname
Returns the path for the directory where the support files of a target are stored.
141 142 143 |
# File 'lib/cocoapods/sandbox.rb', line 141 def target_support_files_dir(name) target_support_files_root + name end |
#target_support_files_root ⇒ Pathname
Returns The directory where the files generated by CocoaPods to support the umbrella targets are stored.
195 196 197 |
# File 'lib/cocoapods/sandbox.rb', line 195 def target_support_files_root root + 'Target Support Files' end |