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
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
|
+-- User
| +-- [Target Name]-configuration.h
| +-- Specs
| +-- Scripts
|
+-- Generated
+-- Headers
| +-- Private
| | +-- [Pod Name]
| +-- Public
| +-- [Pod Name]
|
+-- Sources
| +-- [Pod Name]
|
+-- Specs
| +-- External Sources
| +-- Normal Sources
|
+-- Target Support Files
| +-- [Target Name]
| +-- Pods-acknowledgements.markdown
| +-- Pods-acknowledgements.plist
| +-- Pods-dummy.m
| +-- Pods-prefix.pch
| +-- Pods.xcconfig
|
+-- Manifest.lock
|
+-- Pods.xcodeproj
See #833
Defined Under Namespace
Classes: FileAccessor, HeadersStore, PathList
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.
-
#local_pods ⇒ Hash{String=>String}
readonly
The path of the Pods with a local source grouped by their name.
-
#predownloaded_pods ⇒ Array<String>
readonly
The names of the pods that have been pre-downloaded from an external source.
Instance Attribute Summary collapse
-
#build_headers ⇒ HeadersStore
readonly
The header directory for the Pods libraries.
-
#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
-
#documentation_dir ⇒ Pathname
The directory where to store the documentation.
-
#library_support_files_dir(name) ⇒ Pathname
Returns the path for the directory where to store the support files of a target.
-
#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.
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.
-
#specifications_dir(external_source = false) ⇒ Pathname
The path for the directory where to store the specifications.
-
#store_podspec(name, podspec, external_source = false) ⇒ Object
Stores a specification in the ‘Local Podspecs` folder.
Pods information collapse
-
#local?(name) ⇒ Bool
Checks if a Pod is locally sourced?.
-
#predownloaded?(name) ⇒ Bool
Checks if a Pod has been pre-downloaded by the resolver in order to fetch the podspec.
-
#store_checkout_source(name, source) ⇒ void
Stores the local path of a Pod.
-
#store_local_path(name, path) ⇒ 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) ⇒ Object
-
#implode ⇒ void
Removes the sandbox.
-
#initialize(root) ⇒ Sandbox
constructor
A new instance of Sandbox.
-
#inspect ⇒ String
A string representation suitable for debugging.
-
#manifest ⇒ Lockfile
The manifest which contains the information about the installed pods.
Constructor Details
#initialize(root) ⇒ Sandbox
Returns a new instance of Sandbox.
68 69 70 71 72 73 74 75 76 |
# File 'lib/cocoapods/sandbox.rb', line 68 def initialize(root) @root = Pathname.new(root) @build_headers = HeadersStore.new(self, "BuildHeaders") @public_headers = HeadersStore.new(self, "Headers") @predownloaded_pods = [] @checkout_sources = {} @local_pods = {} FileUtils.mkdir_p(@root) end |
Instance Attribute Details
#build_headers ⇒ HeadersStore (readonly)
Returns the header directory for the Pods libraries.
60 61 62 |
# File 'lib/cocoapods/sandbox.rb', line 60 def build_headers @build_headers end |
#checkout_sources ⇒ Hash{String=>Hash} (readonly)
Returns The options necessary to recreate the exact checkout of a given Pod grouped by its name.
301 302 303 |
# File 'lib/cocoapods/sandbox.rb', line 301 def checkout_sources @checkout_sources end |
#local_pods ⇒ Hash{String=>String} (readonly)
Rename (e.g. ‘pods_with_local_path`)
Returns The path of the Pods with a local source grouped by their name.
325 326 327 |
# File 'lib/cocoapods/sandbox.rb', line 325 def local_pods @local_pods end |
#predownloaded_pods ⇒ Array<String> (readonly)
Returns The names of the pods that have been pre-downloaded from an external source.
265 266 267 |
# File 'lib/cocoapods/sandbox.rb', line 265 def predownloaded_pods @predownloaded_pods end |
#project ⇒ Project
Returns the Pods project.
87 88 89 |
# File 'lib/cocoapods/sandbox.rb', line 87 def project @project end |
#public_headers ⇒ HeadersStore (readonly)
Returns the header directory for the user targets.
64 65 66 |
# File 'lib/cocoapods/sandbox.rb', line 64 def public_headers @public_headers end |
#root ⇒ Pathname (readonly)
Returns the root of the sandbox.
56 57 58 |
# File 'lib/cocoapods/sandbox.rb', line 56 def root @root end |
Instance Method Details
#clean_pod(name) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/cocoapods/sandbox.rb', line 100 def clean_pod(name) root_name = Specification.root_name(name) unless local?(root_name) path = pod_dir(name) path.rmtree if path.exist? end podspe_path = specification_path(name) podspe_path.rmtree if podspe_path end |
#documentation_dir ⇒ Pathname
Returns the directory where to store the documentation.
167 168 169 |
# File 'lib/cocoapods/sandbox.rb', line 167 def documentation_dir root + 'Documentation' end |
#implode ⇒ void
This method returns an undefined value.
Removes the sandbox.
93 94 95 |
# File 'lib/cocoapods/sandbox.rb', line 93 def implode root.rmtree end |
#inspect ⇒ String
Returns a string representation suitable for debugging.
112 113 114 |
# File 'lib/cocoapods/sandbox.rb', line 112 def inspect "#<#{self.class}> with root #{root}" end |
#library_support_files_dir(name) ⇒ Pathname
Returns the path for the directory where to store the support files of a target.
142 143 144 145 |
# File 'lib/cocoapods/sandbox.rb', line 142 def library_support_files_dir(name) # root + "Target Support Files/#{name}" root end |
#local?(name) ⇒ Bool
Checks if a Pod is locally sourced?
334 335 336 337 |
# File 'lib/cocoapods/sandbox.rb', line 334 def local?(name) root_name = Specification.root_name(name) !local_pods[root_name].nil? end |
#manifest ⇒ Lockfile
Returns the manifest which contains the information about the installed pods.
81 82 83 |
# File 'lib/cocoapods/sandbox.rb', line 81 def manifest Lockfile.from_file(manifest_path) if manifest_path.exist? end |
#manifest_path ⇒ Pathname
Returns the path of the manifest.
124 125 126 |
# File 'lib/cocoapods/sandbox.rb', line 124 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.
155 156 157 158 159 160 161 162 163 |
# File 'lib/cocoapods/sandbox.rb', line 155 def pod_dir(name) root_name = Specification.root_name(name) if local?(root_name) Pathname.new(local_pods[root_name]) else # root + "Sources/#{name}" 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.
275 276 277 278 |
# File 'lib/cocoapods/sandbox.rb', line 275 def predownloaded?(name) root_name = Specification.root_name(name) predownloaded_pods.include?(root_name) end |
#project_path ⇒ Pathname
Returns the path of the Pods project.
130 131 132 |
# File 'lib/cocoapods/sandbox.rb', line 130 def project_path root + "Pods.xcodeproj" end |
#specification(name) ⇒ Specification
Returns the specification for the Pod with the given name.
184 185 186 187 188 |
# File 'lib/cocoapods/sandbox.rb', line 184 def specification(name) if file = specification_path(name) Specification.from_file(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.
210 211 212 213 |
# File 'lib/cocoapods/sandbox.rb', line 210 def specification_path(name) path = specifications_dir + "#{name}.podspec" path.exist? ? path : nil end |
#specifications_dir(external_source = false) ⇒ Pathname
Migrate old installations and store the for all the pods. Two folders should be created ‘External Sources` and `Podspecs`.
Returns the path for the directory where to store the specifications.
196 197 198 199 |
# File 'lib/cocoapods/sandbox.rb', line 196 def specifications_dir(external_source = false) # root + "Specifications" root + "Local Podspecs" end |
#store_checkout_source(name, source) ⇒ void
This method returns an undefined value.
Stores the local path of a Pod.
293 294 295 296 |
# File 'lib/cocoapods/sandbox.rb', line 293 def store_checkout_source(name, source) root_name = Specification.root_name(name) checkout_sources[root_name] = source end |
#store_local_path(name, path) ⇒ void
This method returns an undefined value.
Stores the local path of a Pod.
315 316 317 318 |
# File 'lib/cocoapods/sandbox.rb', line 315 def store_local_path(name, path) root_name = Specification.root_name(name) local_pods[root_name] = path.to_s end |
#store_podspec(name, podspec, external_source = false) ⇒ Object
Store all the specifications (including those not originating from external sources) so users can check them.
Stores a specification in the ‘Local Podspecs` folder.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/cocoapods/sandbox.rb', line 227 def store_podspec(name, podspec, external_source = false) output_path = specifications_dir(external_source) + "#{name}.podspec" output_path.dirname.mkpath if podspec.is_a?(String) output_path.open('w') { |f| f.puts(podspec) } else unless podspec.exist? raise Informative, "No podspec found for `#{name}` in #{podspec}" end FileUtils.copy(podspec, output_path) end spec = Specification.from_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 end |
#store_pre_downloaded_pod(name) ⇒ void
This method returns an undefined value.
Marks a Pod as pre-downloaded
257 258 259 260 |
# File 'lib/cocoapods/sandbox.rb', line 257 def store_pre_downloaded_pod(name) root_name = Specification.root_name(name) predownloaded_pods << root_name end |