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, :clean => true, :integrate_targets => true, :new_version_message => true, :cache_root => Pathname.new(File.join(ENV['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.
-
#integrate_targets ⇒ Bool
(also: #integrate_targets?)
Whether CocoaPods should integrate a user target and build the workspace or just create the Pods project.
-
#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.
-
#statistics_cache_file ⇒ Pathname
The file to use a cache of the statistics provider.
-
#templates_dir ⇒ Pathname
The directory where the CocoaPods templates are stored.
Dependency Injection collapse
-
#spec_statistics_provider ⇒ Specification::Set::Statistics
The statistic provider to use for specifications.
Private helpers collapse
-
#podfile_path_in_dir(dir) ⇒ Pathname, Nil
Returns the path of the Podfile in the given dir if any exists.
Constructor Details
#initialize(use_user_settings = true) ⇒ Config
Returns a new instance of Config.
91 92 93 94 95 96 97 98 99 |
# File 'lib/cocoapods/config.rb', line 91 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.
316 317 318 |
# File 'lib/cocoapods/config.rb', line 316 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.
78 79 80 |
# File 'lib/cocoapods/config.rb', line 78 def cache_root @cache_root end |
#clean ⇒ Bool Also known as: clean?
Returns Whether the installer should clean after the installation.
55 56 57 |
# File 'lib/cocoapods/config.rb', line 55 def clean @clean end |
#installation_root ⇒ Pathname Also known as: project_root
Returns the root of the CocoaPods installation where the Podfile is located.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/cocoapods/config.rb', line 135 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.
61 62 63 |
# File 'lib/cocoapods/config.rb', line 61 def integrate_targets @integrate_targets 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.
46 47 48 |
# File 'lib/cocoapods/config.rb', line 46 def @new_version_message end |
#podfile ⇒ Podfile, Nil
175 176 177 |
# File 'lib/cocoapods/config.rb', line 175 def podfile @podfile ||= Podfile.from_file(podfile_path) if podfile_path end |
#repos_dir ⇒ Pathname
Returns the directory where the CocoaPods sources are stored.
120 121 122 |
# File 'lib/cocoapods/config.rb', line 120 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.
159 160 161 |
# File 'lib/cocoapods/config.rb', line 159 def sandbox_root @sandbox_root ||= installation_root + 'Pods' end |
#silent ⇒ Bool Also known as: silent?
Returns Whether CocoaPods should produce not output.
40 41 42 |
# File 'lib/cocoapods/config.rb', line 40 def silent @silent end |
#skip_repo_update ⇒ Bool Also known as: skip_repo_update?
Returns Whether the installer should skip the repos update.
66 67 68 |
# File 'lib/cocoapods/config.rb', line 66 def skip_repo_update @skip_repo_update end |
#verbose ⇒ Bool
Returns Whether CocoaPods should provide detailed output about the performed actions.
35 36 37 |
# File 'lib/cocoapods/config.rb', line 35 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.
214 215 216 |
# File 'lib/cocoapods/config.rb', line 214 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.
224 225 226 |
# File 'lib/cocoapods/config.rb', line 224 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.
114 115 116 |
# File 'lib/cocoapods/config.rb', line 114 def home_dir @home_dir ||= Pathname.new(ENV['CP_HOME_DIR'] || '~/.cocoapods'). end |
#lockfile ⇒ Lockfile, Nil
183 184 185 |
# File 'lib/cocoapods/config.rb', line 183 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.
204 205 206 |
# File 'lib/cocoapods/config.rb', line 204 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.
196 197 198 |
# File 'lib/cocoapods/config.rb', line 196 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.
298 299 300 301 302 303 304 305 306 |
# File 'lib/cocoapods/config.rb', line 298 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.
168 169 170 |
# File 'lib/cocoapods/config.rb', line 168 def sandbox @sandbox ||= Sandbox.new(sandbox_root) end |
#search_index_file ⇒ Pathname
Returns The file to use to cache the search data.
236 237 238 |
# File 'lib/cocoapods/config.rb', line 236 def search_index_file cache_root + 'search_index.yaml' end |
#spec_statistics_provider ⇒ Specification::Set::Statistics
Returns The statistic provider to use for specifications.
249 250 251 |
# File 'lib/cocoapods/config.rb', line 249 def spec_statistics_provider Specification::Set::Statistics.new(statistics_cache_file) end |
#statistics_cache_file ⇒ Pathname
Returns The file to use a cache of the statistics provider.
230 231 232 |
# File 'lib/cocoapods/config.rb', line 230 def statistics_cache_file cache_root + 'statistics.yml' end |
#templates_dir ⇒ Pathname
Returns the directory where the CocoaPods templates are stored.
128 129 130 |
# File 'lib/cocoapods/config.rb', line 128 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.
36 37 38 |
# File 'lib/cocoapods/config.rb', line 36 def verbose @verbose end |