Class: Pod::Config

Inherits:
Object
  • Object
show all
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,
  :aggressive_cache    => false,

  :clean               => true,
  :integrate_targets   => true,
  :new_version_message => true,
}

UI collapse

Installation collapse

Initialization collapse

Paths collapse

UI collapse

Installation collapse

Initialization collapse

Paths collapse

Helpers collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



88
89
90
91
92
93
94
95
96
# File 'lib/cocoapods/config.rb', line 88

def initialize
  configure_with(DEFAULTS)

  if .exist?
    require 'yaml'
     = YAML.load_file()
    configure_with()
  end
end

Instance Attribute Details

#aggressive_cache=(value) ⇒ Object (writeonly)

Note:

The aggressive cache has lead to issues if a tag is updated to point to another commit.

Allows to set whether the downloader should use more aggressive caching options.



75
76
77
# File 'lib/cocoapods/config.rb', line 75

def aggressive_cache=(value)
  @aggressive_cache = value
end

#cleanBool Also known as: clean?

Returns Whether the installer should clean after the installation.

Returns:

  • (Bool)

    Whether the installer should clean after the installation.



54
55
56
# File 'lib/cocoapods/config.rb', line 54

def clean
  @clean
end

#installation_rootPathname Also known as: project_root

Returns the root of the CocoaPods installation where the Podfile is located.

Returns:

  • (Pathname)

    the root of the CocoaPods installation where the Podfile is located.



117
118
119
# File 'lib/cocoapods/config.rb', line 117

def installation_root
  @installation_root ||= Pathname.pwd
end

#integrate_targetsBool Also known as: integrate_targets?

Returns Whether CocoaPods should integrate a user target and build the workspace or just create the Pods project.

Returns:

  • (Bool)

    Whether CocoaPods should integrate a user target and build the workspace or just create the Pods project.



60
61
62
# File 'lib/cocoapods/config.rb', line 60

def integrate_targets
  @integrate_targets
end

#new_version_messageBool Also known as: new_version_message?

Returns Whether a message should be printed when a new version of CocoaPods is available.

Returns:

  • (Bool)

    Whether a message should be printed when a new version of CocoaPods is available.



45
46
47
# File 'lib/cocoapods/config.rb', line 45

def new_version_message
  @new_version_message
end

#podfilePodfile

Returns The Podfile to use for the current execution.

Returns:

  • (Podfile)

    The Podfile to use for the current execution.



141
142
143
# File 'lib/cocoapods/config.rb', line 141

def podfile
  @podfile ||= Podfile.from_file(podfile_path) if podfile_path.exist?
end

#repos_dirPathname

Returns the directory where the CocoaPods sources are stored.

Returns:

  • (Pathname)

    the directory where the CocoaPods sources are stored.



108
109
110
# File 'lib/cocoapods/config.rb', line 108

def repos_dir
  @repos_dir ||= Pathname.new(ENV['CP_REPOS_DIR'] || "~/.cocoapods").expand_path
end

#sandbox_rootPathname Also known as: project_pods_root

Returns The root of the sandbox.

Returns:

  • (Pathname)

    The root of the sandbox.



126
127
128
# File 'lib/cocoapods/config.rb', line 126

def sandbox_root
  @sandbox_root ||= installation_root + 'Pods'
end

#silentBool Also known as: silent?

Returns Whether CocoaPods should produce not output.

Returns:

  • (Bool)

    Whether CocoaPods should produce not output.



39
40
41
# File 'lib/cocoapods/config.rb', line 39

def silent
  @silent
end

#skip_repo_updateBool Also known as: skip_repo_update?

Returns Whether the installer should skip the repos update.

Returns:

  • (Bool)

    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

#verboseBool

Returns Whether CocoaPods should provide detailed output about the performed actions.

Returns:

  • (Bool)

    Whether CocoaPods should provide detailed output about the performed actions.



34
35
36
# File 'lib/cocoapods/config.rb', line 34

def verbose
  @verbose
end

Class Method Details

.instanceConfig

Returns the current config instance creating one if needed.

Returns:

  • (Config)

    the current config instance creating one if needed.



205
206
207
# File 'lib/cocoapods/config.rb', line 205

def self.instance
  @instance ||= new
end

.instance=(instance) ⇒ void

This method returns an undefined value.

Sets the current config instance. If set to nil the config will be recreated when needed.

Parameters:

  • the (Config, Nil)

    instance.



216
217
218
# File 'lib/cocoapods/config.rb', line 216

def self.instance=(instance)
  @instance = instance
end

Instance Method Details

#aggressive_cache?Bool

Returns Whether the downloader should use more aggressive caching options.

Returns:

  • (Bool)

    Whether the downloader should use more aggressive caching options.



80
81
82
# File 'lib/cocoapods/config.rb', line 80

def aggressive_cache?
  @aggressive_cache || (ENV['CP_AGGRESSIVE_CACHE'] != 'FALSE')
end

#configure_with(values_by_key) ⇒ void

This method returns an undefined value.

Sets the values of the attributes with the given hash.

Parameters:

  • values_by_key (Hash{String,Symbol => Object})

    The values of the attributes grouped by key.



171
172
173
174
175
176
# File 'lib/cocoapods/config.rb', line 171

def configure_with(values_by_key)
  return unless values_by_key
  values_by_key.each do |key, value|
    self.instance_variable_set("@#{key}", value)
  end
end

#lockfileLockfile

Returns The Lockfile to use for the current execution.

Returns:

  • (Lockfile)

    The Lockfile to use for the current execution.



148
149
150
# File 'lib/cocoapods/config.rb', line 148

def lockfile
  @lockfile ||= Lockfile.from_file(lockfile_path) if lockfile_path.exist?
end

#lockfile_pathObject

Note:

The Lockfile is named ‘Podfile.lock`.

Returns the path of the Lockfile.



197
198
199
# File 'lib/cocoapods/config.rb', line 197

def lockfile_path
  @lockfile_path ||= installation_root + 'Podfile.lock'
end

#podfile_pathObject

Note:

The Podfile can be named either ‘CocoaPods.podfile` or `Podfile`. The first is preferred as it allows to specify an OS X UTI.

Returns the path of the Podfile.



183
184
185
186
187
188
189
190
191
# File 'lib/cocoapods/config.rb', line 183

def podfile_path
  unless @podfile_path
    path = installation_root + 'CocoaPods.podfile.yaml'
    path = installation_root + 'CocoaPods.podfile' unless path.exist?
    path = installation_root + 'Podfile' unless path.exist?
    @podfile_path = path
  end
  @podfile_path
end

#sandboxSandbox

Returns The sandbox of the current project.

Returns:

  • (Sandbox)

    The sandbox of the current project.



135
136
137
# File 'lib/cocoapods/config.rb', line 135

def sandbox
  @sandbox ||= Sandbox.new(sandbox_root)
end

#user_settings_filePathname

Returns The path of the file which contains the user settings.

Returns:

  • (Pathname)

    The path of the file which contains the user settings.



160
161
162
# File 'lib/cocoapods/config.rb', line 160

def 
  repos_dir + "config.yaml"
end

#verbose?Bool

Returns Whether CocoaPods should provide detailed output about the performed actions.

Returns:

  • (Bool)

    Whether CocoaPods should provide detailed output about the performed actions.



35
36
37
# File 'lib/cocoapods/config.rb', line 35

def verbose
  @verbose
end