class Pod::Installer::PodSourceInstaller


@note This class needs to consider all the activated specs of a Pod.
of a single Pod.
Controller class responsible of installing the activated specifications

def clean!

Returns:
  • (void) -

Other tags:
    Todo: - As the pre install hooks need to run before cleaning this
def clean!
  clean_installation  if !local?
end

def clean_installation

Returns:
  • (void) -
def clean_installation
  clean_paths.each { |path| FileUtils.rm_rf(path) }
end

def clean_paths

Returns:
  • (Array) - The paths that can be deleted.

Other tags:
    Todo: - The paths are down-cased for the comparison as issues similar

Other tags:
    Note: - Implementation detail: Don't use `Dir#glob` as there is an
def clean_paths
  cached_used = used_files
  glob_options = File::FNM_DOTMATCH | File::FNM_CASEFOLD
  files = Pathname.glob(root + "**/*", glob_options).map(&:to_s)
  files.reject! do |candidate|
    candidate = candidate.downcase
    candidate.end_with?('.', '..') || cached_used.any? do |path|
      path = path.downcase
      path.include?(candidate) || candidate.include?(path)
    end
  end
  files
end

def download_source

Returns:
  • (void) -
def download_source
  root.rmtree if root.exist?
  if head_pod?
    downloader.download_head
    @specific_source = downloader.checkout_options
  else
    downloader.download
    unless downloader.options_specific?
      @specific_source = downloader.checkout_options
    end
  end
  if specific_source
  sandbox.store_checkout_source(root_spec.name, specific_source)
  end
end

def downloader

Returns:
  • (Downloader) - The downloader to use for the retrieving the
def downloader
  @downloader ||= Config.instance.downloader(root, root_spec.source.dup)
end

def file_accessors

Returns:
  • (Array) - the file accessors for all the
def file_accessors
  return @file_accessors if @file_accessors
  @file_accessors = []
  specs_by_platform.each do |platform, specs|
    specs.each do |spec|
      @file_accessors << Sandbox::FileAccessor.new(path_list, spec.consumer(platform))
    end
  end
  @file_accessors
end

def head_pod?

def head_pod?
  sandbox.head_pod?(root_spec.name)
end

def initialize(sandbox, specs_by_platform)

Parameters:
  • specs_by_platform (Hash{Symbol=>Array}) -- @see specs_by_platform
  • sandbox (Sandbox) -- @see sandbox
def initialize(sandbox, specs_by_platform)
  @sandbox = sandbox
  @specs_by_platform = specs_by_platform
  @aggressive_cache = false
end

def inspect

Returns:
  • (String) - A string suitable for debugging.
def inspect
  "<#{self.class} sandbox=#{sandbox.root} pod=#{root_spec.name}"
end

def install!

Returns:
  • (void) -
def install!
  download_source unless predownloaded? || local?
  run_prepare_command
end

def local?

Returns:
  • (Boolean) - whether the pod uses the local option and thus
def local?
  sandbox.local?(root_spec.name)
end

def path_list

Returns:
  • (Sandbox::PathList) - The path list for this Pod.
def path_list
  @path_list ||= Sandbox::PathList.new(root)
end

def predownloaded?

Returns:
  • (Boolean) - whether the source has been pre downloaded in the
def predownloaded?
  sandbox.predownloaded_pods.include?(root_spec.name)
end

def root

Returns:
  • (Pathname) - the folder where the source of the Pod is located.
def root
  sandbox.pod_dir(root_spec.name)
end

def root_spec

Returns:
  • (Specification) - the root specification of the Pod.
def root_spec
  specs.first.root
end

def run_prepare_command

Returns:
  • (void) -
def run_prepare_command
  return unless root_spec.prepare_command
  UI.section(" > Running prepare command", '', 1) do
    Dir.chdir(root) do
      prepare_command = root_spec.prepare_command.strip_heredoc.chomp
      full_command = "\nset -e\n" + prepare_command
      bash!(full_command)
    end
  end
end

def specs

Returns:
  • (Array) - the specification of the Pod used in
def specs
  specs_by_platform.values.flatten
end

def used_files

Returns:
  • (Array) - The absolute path of all the files used by the
def used_files
  files = [
    file_accessors.map(&:vendored_frameworks),
    file_accessors.map(&:vendored_libraries),
    file_accessors.map(&:resource_bundle_files),
    file_accessors.map(&:license),
    file_accessors.map(&:prefix_header),
    file_accessors.map(&:preserve_paths),
    file_accessors.map(&:readme),
    file_accessors.map(&:resources),
    file_accessors.map(&:source_files),
  ]
  files.flatten.compact.map{ |path| path.to_s }.uniq
end