Class: Pod::Config
- Inherits:
-
Object
- Object
- Pod::Config
- Defined in:
- lib/cocoapods/config.rb
Overview
Stores the global configuration of CocoaPods.
Defined Under Namespace
Modules: Mixin
Constant Summary collapse
- DEFAULTS =
The default settings for the configuration.
Users can specify custom settings in ‘~/.cocoapods/config.yaml`. An example of the contents of this file might look like:
--- skip_repo_update: true new_version_message: false
{ :verbose => false, :silent => false, :skip_repo_update => false, :skip_download_cache => !ENV['COCOAPODS_SKIP_CACHE'].nil?, :clean => true, :integrate_targets => true, :deduplicate_targets => true, :deterministic_uuids => ENV['COCOAPODS_DISABLE_DETERMINISTIC_UUIDS'].nil?, :lock_pod_source => true, :new_version_message => ENV['COCOAPODS_SKIP_UPDATE_MESSAGE'].nil?, :cache_root => Pathname.new(Dir.home) + 'Library/Caches/CocoaPods', }
UI collapse
-
#new_version_message ⇒ Bool
(also: #new_version_message?)
Whether a message should be printed when a new version of CocoaPods is available.
-
#silent ⇒ Bool
(also: #silent?)
Whether CocoaPods should produce not output.
Installation collapse
-
#clean ⇒ Bool
(also: #clean?)
Whether the installer should clean after the installation.
-
#deduplicate_targets ⇒ Bool
(also: #deduplicate_targets?)
Whether CocoaPods should deduplicate pod targets.
-
#deterministic_uuids ⇒ Bool
(also: #deterministic_uuids?)
Whether CocoaPods should give the pods project deterministic UUIDs.
-
#integrate_targets ⇒ Bool
(also: #integrate_targets?)
Whether CocoaPods should integrate a user target and build the workspace or just create the Pods project.
-
#lock_pod_source ⇒ Bool
(also: #lock_pod_source?)
Whether the installer should remove write permissions for installed pod source files after the installation.
-
#skip_download_cache ⇒ Bool
(also: #skip_download_cache?)
Whether the installer should skip the download cache.
-
#skip_repo_update ⇒ Bool
(also: #skip_repo_update?)
Whether the installer should skip the repos update.
Cache collapse
-
#cache_root ⇒ Pathname
The directory where CocoaPods should cache remote data and other expensive to compute information.
Initialization collapse
-
#verbose ⇒ Bool
Whether CocoaPods should provide detailed output about the performed actions.
Paths collapse
-
#installation_root ⇒ Pathname
(also: #project_root)
The root of the CocoaPods installation where the Podfile is located.
- #podfile ⇒ Podfile, Nil
-
#repos_dir ⇒ Pathname
The directory where the CocoaPods sources are stored.
-
#sandbox_root ⇒ Pathname
(also: #project_pods_root)
The root of the sandbox.
Singleton collapse
-
.instance ⇒ Config
The current config instance creating one if needed.
UI collapse
-
#verbose? ⇒ Bool
Whether CocoaPods should provide detailed output about the performed actions.
Initialization collapse
-
#initialize(use_user_settings = true) ⇒ Config
constructor
A new instance of Config.
Paths collapse
-
#default_podfile_path ⇒ Pathname
Returns the path of the default Podfile pods.
-
#default_test_podfile_path ⇒ Pathname
Returns the path of the default Podfile test pods.
-
#home_dir ⇒ Pathname
The directory where repos, templates and configuration files are stored.
- #lockfile ⇒ Lockfile, Nil
-
#lockfile_path ⇒ Object
Returns the path of the Lockfile.
-
#podfile_path ⇒ Pathname, Nil
Returns the path of the Podfile.
-
#sandbox ⇒ Sandbox
The sandbox of the current project.
-
#search_index_file ⇒ Pathname
The file to use to cache the search data.
-
#templates_dir ⇒ Pathname
The directory where the CocoaPods templates are stored.
Private helpers collapse
-
#podfile_path_in_dir(dir) ⇒ Pathname, Nil
Returns the path of the Podfile in the given dir if any exists.
Instance Method Summary collapse
-
#with_changes(changes) { ... } ⇒ Object
Applies the given changes to the config for the duration of the given block.
Constructor Details
#initialize(use_user_settings = true) ⇒ Config
Returns a new instance of Config.
137 138 139 140 141 142 143 144 145 |
# File 'lib/cocoapods/config.rb', line 137 def initialize(use_user_settings = true) configure_with(DEFAULTS) if use_user_settings && user_settings_file.exist? require 'yaml' user_settings = YAML.load_file(user_settings_file) configure_with(user_settings) end end |
Class Attribute Details
.instance ⇒ Config
Returns the current config instance creating one if needed.
343 344 345 |
# File 'lib/cocoapods/config.rb', line 343 def self.instance @instance ||= new end |
Instance Attribute Details
#cache_root ⇒ Pathname
Returns The directory where CocoaPods should cache remote data and other expensive to compute information.
124 125 126 |
# File 'lib/cocoapods/config.rb', line 124 def cache_root @cache_root end |
#clean ⇒ Bool Also known as: clean?
Returns Whether the installer should clean after the installation.
79 80 81 |
# File 'lib/cocoapods/config.rb', line 79 def clean @clean end |
#deduplicate_targets ⇒ Bool Also known as: deduplicate_targets?
Returns Whether CocoaPods should deduplicate pod targets.
96 97 98 |
# File 'lib/cocoapods/config.rb', line 96 def deduplicate_targets @deduplicate_targets end |
#deterministic_uuids ⇒ Bool Also known as: deterministic_uuids?
Returns Whether CocoaPods should give the pods project deterministic UUIDs.
102 103 104 |
# File 'lib/cocoapods/config.rb', line 102 def deterministic_uuids @deterministic_uuids end |
#installation_root ⇒ Pathname Also known as: project_root
Returns the root of the CocoaPods installation where the Podfile is located.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/cocoapods/config.rb', line 181 def installation_root current_path = Pathname.pwd unless @installation_root until current_path.root? if podfile_path_in_dir(current_path) @installation_root = current_path unless current_path == Pathname.pwd UI.puts("[in #{current_path}]") end break else current_path = current_path.parent end end @installation_root ||= Pathname.pwd end @installation_root end |
#integrate_targets ⇒ Bool Also known as: integrate_targets?
Returns Whether CocoaPods should integrate a user target and build the workspace or just create the Pods project.
91 92 93 |
# File 'lib/cocoapods/config.rb', line 91 def integrate_targets @integrate_targets end |
#lock_pod_source ⇒ Bool Also known as: lock_pod_source?
Returns Whether the installer should remove write permissions for installed pod source files after the installation.
85 86 87 |
# File 'lib/cocoapods/config.rb', line 85 def lock_pod_source @lock_pod_source end |
#new_version_message ⇒ Bool Also known as: new_version_message?
Returns Whether a message should be printed when a new version of CocoaPods is available.
70 71 72 |
# File 'lib/cocoapods/config.rb', line 70 def @new_version_message end |
#podfile ⇒ Podfile, Nil
221 222 223 |
# File 'lib/cocoapods/config.rb', line 221 def podfile @podfile ||= Podfile.from_file(podfile_path) if podfile_path end |
#repos_dir ⇒ Pathname
Returns the directory where the CocoaPods sources are stored.
166 167 168 |
# File 'lib/cocoapods/config.rb', line 166 def repos_dir @repos_dir ||= Pathname.new(ENV['CP_REPOS_DIR'] || '~/.cocoapods/repos'). end |
#sandbox_root ⇒ Pathname Also known as: project_pods_root
Returns The root of the sandbox.
205 206 207 |
# File 'lib/cocoapods/config.rb', line 205 def sandbox_root @sandbox_root ||= installation_root + 'Pods' end |
#silent ⇒ Bool Also known as: silent?
Returns Whether CocoaPods should produce not output.
64 65 66 |
# File 'lib/cocoapods/config.rb', line 64 def silent @silent end |
#skip_download_cache ⇒ Bool Also known as: skip_download_cache?
Returns Whether the installer should skip the download cache.
112 113 114 |
# File 'lib/cocoapods/config.rb', line 112 def skip_download_cache @skip_download_cache end |
#skip_repo_update ⇒ Bool Also known as: skip_repo_update?
Returns Whether the installer should skip the repos update.
107 108 109 |
# File 'lib/cocoapods/config.rb', line 107 def skip_repo_update @skip_repo_update end |
#verbose ⇒ Bool
Returns Whether CocoaPods should provide detailed output about the performed actions.
59 60 61 |
# File 'lib/cocoapods/config.rb', line 59 def verbose @verbose end |
Instance Method Details
#default_podfile_path ⇒ Pathname
The file is expected to be named Podfile.default
Returns the path of the default Podfile pods.
260 261 262 |
# File 'lib/cocoapods/config.rb', line 260 def default_podfile_path @default_podfile_path ||= templates_dir + 'Podfile.default' end |
#default_test_podfile_path ⇒ Pathname
The file is expected to be named Podfile.test
Returns the path of the default Podfile test pods.
270 271 272 |
# File 'lib/cocoapods/config.rb', line 270 def default_test_podfile_path @default_test_podfile_path ||= templates_dir + 'Podfile.test' end |
#home_dir ⇒ Pathname
Returns the directory where repos, templates and configuration files are stored.
160 161 162 |
# File 'lib/cocoapods/config.rb', line 160 def home_dir @home_dir ||= Pathname.new(ENV['CP_HOME_DIR'] || '~/.cocoapods'). end |
#lockfile ⇒ Lockfile, Nil
229 230 231 |
# File 'lib/cocoapods/config.rb', line 229 def lockfile @lockfile ||= Lockfile.from_file(lockfile_path) if lockfile_path end |
#lockfile_path ⇒ Object
The Lockfile is named ‘Podfile.lock`.
Returns the path of the Lockfile.
250 251 252 |
# File 'lib/cocoapods/config.rb', line 250 def lockfile_path @lockfile_path ||= installation_root + 'Podfile.lock' end |
#podfile_path ⇒ Pathname, Nil
The Podfile can be named either ‘CocoaPods.podfile.yaml`, `CocoaPods.podfile` or `Podfile`. The first two are preferred as they allow to specify an OS X UTI.
Returns the path of the Podfile.
242 243 244 |
# File 'lib/cocoapods/config.rb', line 242 def podfile_path @podfile_path ||= podfile_path_in_dir(installation_root) end |
#podfile_path_in_dir(dir) ⇒ Pathname, Nil
Returns the path of the Podfile in the given dir if any exists.
325 326 327 328 329 330 331 332 333 |
# File 'lib/cocoapods/config.rb', line 325 def podfile_path_in_dir(dir) PODFILE_NAMES.each do |filename| candidate = dir + filename if candidate.exist? return candidate end end nil end |
#sandbox ⇒ Sandbox
Returns The sandbox of the current project.
214 215 216 |
# File 'lib/cocoapods/config.rb', line 214 def sandbox @sandbox ||= Sandbox.new(sandbox_root) end |
#search_index_file ⇒ Pathname
Returns The file to use to cache the search data.
276 277 278 |
# File 'lib/cocoapods/config.rb', line 276 def search_index_file cache_root + 'search_index.yaml' end |
#templates_dir ⇒ Pathname
Returns the directory where the CocoaPods templates are stored.
174 175 176 |
# File 'lib/cocoapods/config.rb', line 174 def templates_dir @templates_dir ||= Pathname.new(ENV['CP_TEMPLATES_DIR'] || '~/.cocoapods/templates'). end |
#verbose? ⇒ Bool
Returns Whether CocoaPods should provide detailed output about the performed actions.
60 61 62 |
# File 'lib/cocoapods/config.rb', line 60 def verbose @verbose end |
#with_changes(changes) { ... } ⇒ Object
Applies the given changes to the config for the duration of the given block.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cocoapods/config.rb', line 38 def with_changes(changes) old = {} changes.keys.each do |key| key = key.to_sym old[key] = send(key) if respond_to?(key) end configure_with(changes) yield if block_given? ensure configure_with(old) end |