Class: Pod::Installer::PodSourceInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/installer/pod_source_installer.rb

Overview

Note:

This class needs to consider all the activated specs of a Pod.

Controller class responsible of installing the activated specifications of a single Pod.

Constant Summary collapse

UNENCRYPTED_PROTOCOLS =
%w(http git).freeze

Instance Attribute Summary collapse

Installation collapse

Instance Method Summary collapse

Constructor Details

#initialize(sandbox, specs_by_platform, can_cache: true) ⇒ PodSourceInstaller

Initialize a new instance

Parameters:

  • sandbox (Sandbox)

    @see #sandbox

  • specs_by_platform (Hash{Symbol=>Array})

    @see #specs_by_platform

  • can_cache (Boolean) (defaults to: true)

    @see #can_cache



33
34
35
36
37
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 33

def initialize(sandbox, specs_by_platform, can_cache: true)
  @sandbox = sandbox
  @specs_by_platform = specs_by_platform
  @can_cache = can_cache
end

Instance Attribute Details

#can_cacheBoolean (readonly) Also known as: can_cache?

Returns Whether the installer is allowed to touch the cache.

Returns:

  • (Boolean)

    Whether the installer is allowed to touch the cache.



24
25
26
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 24

def can_cache
  @can_cache
end

#sandboxSandbox (readonly)

Returns The installation target.

Returns:

  • (Sandbox)

    The installation target.



15
16
17
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 15

def sandbox
  @sandbox
end

#specs_by_platformHash{Symbol=>Array} (readonly)

Returns The specifications that need to be installed grouped by platform.

Returns:

  • (Hash{Symbol=>Array})

    The specifications that need to be installed grouped by platform.



20
21
22
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 20

def specs_by_platform
  @specs_by_platform
end

Instance Method Details

#clean!void

This method returns an undefined value.

Cleans the installations if appropriate.



70
71
72
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 70

def clean!
  clean_installation unless local?
end

#inspectString

Returns A string suitable for debugging.

Returns:

  • (String)

    A string suitable for debugging.



41
42
43
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 41

def inspect
  "<#{self.class} sandbox=#{sandbox.root} pod=#{root_spec.name}"
end

#install!void

This method returns an undefined value.

Creates the target in the Pods project and the relative support files.



61
62
63
64
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 61

def install!
  download_source unless predownloaded? || local?
  PodSourcePreparer.new(root_spec, root).prepare! if local?
end

#lock_files!(file_accessors) ⇒ void

This method returns an undefined value.

Locks the source files if appropriate.



78
79
80
81
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 78

def lock_files!(file_accessors)
  return if local?
  FileUtils.chmod('u-w', source_files(file_accessors))
end

#nameString

Returns The name of the pod this installer is installing.

Returns:

  • (String)

    The name of the pod this installer is installing.



47
48
49
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 47

def name
  root_spec.name
end

#unlock_files!(file_accessors) ⇒ void

This method returns an undefined value.

Unlocks the source files if appropriate.



87
88
89
90
# File 'lib/cocoapods/installer/pod_source_installer.rb', line 87

def unlock_files!(file_accessors)
  return if local?
  FileUtils.chmod('u+w', source_files(file_accessors))
end