class Pod::Installer::Analyzer::SandboxAnalyzer


- If none of the above conditions match.
Unchanged
specs.
- If a specification is present in the lockfile but not in the resolved
Removed
- The Pod has been pre-downloaded.
- The directory of the Pod is empty.
installation process is in update mode.
- The specification is in head mode or from an external source and the
- The specific installed (sub)specs of the same Pod changed.
- The SHA of the specification file changed.
- The version of the Pod changed.
Changed
- The directory of the Pod doesn’t exits.
- If not present in the sandbox lockfile.
Added
The logic is the following:
ones should be reinstalled.
Analyze the sandbox to detect which Pods should be removed, and which

def analyze

Returns:
  • (SpecsState) - the state of the sandbox.
def analyze
  state = SpecsState.new
  if sandbox_manifest
    all_names = (resolved_pods + sandbox_pods).uniq.sort
    all_names.sort.each do |name|
      state.add_name(name, pod_state(name))
    end
  else
    state.added.concat(resolved_pods)
  end
  state
end

def folder_empty?(pod)

def folder_empty?(pod)
  Dir.glob(sandbox.pod_dir(pod) + '*').empty?
end

def folder_exist?(pod)

def folder_exist?(pod)
  sandbox.pod_dir(pod).exist?
end

def initialize(sandbox, specs, update_mode, lockfile = nil)

Parameters:
  • lockfile (Lockfile) -- @see lockfile
  • update_mode (Bool) -- @see update_mode
  • specs (Array) -- @see specs
  • sandbox (Sandbox) -- @see sandbox
def initialize(sandbox, specs, update_mode, lockfile = nil)
  @sandbox = sandbox
  @specs = specs
  @update_mode = update_mode
  @lockfile = lockfile
end

def pod_added?(pod)

Returns:
  • (Bool) - Whether the Pod is added.

Parameters:
  • pod (String) --

Other tags:
    Note: - A Pod whose folder doesn't exists is considered added.
def pod_added?(pod)
  return true if resolved_pods.include?(pod) && !sandbox_pods.include?(pod)
  return true if !folder_exist?(pod)
  return false
end

def pod_changed?(pod)

Returns:
  • (Bool) - Whether the Pod is changed.

Parameters:
  • pod (String) --

Other tags:
    Note: - A Pod whose folder is empty is considered changed.
    Note: - In update mode, as there is no way to know if a remote source
def pod_changed?(pod)
  spec = root_spec(pod)
  return true if spec.version != sandbox_version(pod)
  return true if spec.checksum != sandbox_checksum(pod)
  return true if resolved_spec_names(pod) != sandbox_spec_names(pod)
  return true if sandbox.predownloaded?(pod)
  return true if folder_empty?(pod)
  return true if sandbox.head_pod?(pod) != sandbox_head_version?(pod)
  if update_mode
    return true if sandbox.head_pod?(pod)
  end
  return false
end

def pod_deleted?(pod)

Returns:
  • (Bool) - Whether the Pod is deleted.

Parameters:
  • pod (String) --
def pod_deleted?(pod)
  return true if !resolved_pods.include?(pod) && sandbox_pods.include?(pod)
  return false
end

def pod_state(pod)

Returns:
  • (Symbol) - The state

Parameters:
  • pod (String) --
def pod_state(pod)
  return :added   if pod_added?(pod)
  return :deleted if pod_deleted?(pod)
  return :changed if pod_changed?(pod)
  return :unchanged
end

def resolved_pods

Returns:
  • (Array) - The name of the resolved Pods.
def resolved_pods
  specs.map { |spec| spec.root.name }.uniq
end

def resolved_spec_names(pod)

Parameters:
  • pod (String) --

Returns:
  • (Array) - The name of the resolved specifications
def resolved_spec_names(pod)
  specs.select { |s| s.root.name == pod }.map(&:name).uniq.sort
end

def root_spec(pod)

Parameters:
  • pod (String) --

Returns:
  • (Specification) - The root specification for the Pod with the
def root_spec(pod)
  specs.find { |s| s.root.name == pod }.root
end

def sandbox_checksum(pod)

Parameters:
  • pod (String) --

Returns:
  • (String) - The checksum of the specification of the Pod with
def sandbox_checksum(pod)
  sandbox_manifest.checksum(pod)
end

def sandbox_head_version?(pod)

Returns:
  • (Bool) - Wether the Pod is installed in the sandbox is in head
def sandbox_head_version?(pod)
  sandbox_version(pod).head? == true
end

def sandbox_manifest

Returns:
  • (Lockfile) - The manifest to use for the sandbox.
def sandbox_manifest
  sandbox.manifest || lockfile
end

def sandbox_pods

Returns:
  • (Array) - The name of the Pods stored in the sandbox
def sandbox_pods
  sandbox_manifest.pod_names.map { |name| Specification.root_name(name) }.uniq
end

def sandbox_spec_names(pod)

Parameters:
  • pod (String) --

Returns:
  • (Array) - The name of the specifications stored in the
def sandbox_spec_names(pod)
  sandbox_manifest.pod_names.select { |name| Specification.root_name(name) == pod }.uniq.sort
end

def sandbox_version(pod)

Parameters:
  • pod (String) --

Returns:
  • (Version) - The version of Pod with the given name stored in
def sandbox_version(pod)
  sandbox_manifest.version(pod)
end