Class: Pod::Installer::Analyzer

Inherits:
Object
  • Object
show all
Includes:
Config::Mixin
Defined in:
lib/cocoapods/installer/analyzer.rb,
lib/cocoapods/installer/analyzer/sandbox_analyzer.rb

Overview

Analyzes the Podfile, the Lockfile, and the sandbox manifest to generate the information relative to a CocoaPods installation.

Defined Under Namespace

Classes: AnalysisResult, SandboxAnalyzer, SpecsState

Configuration collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Config::Mixin

#config

Constructor Details

#initialize(sandbox, podfile, lockfile = nil) ⇒ Analyzer

Returns a new instance of Analyzer.

Parameters:

  • sandbox (Sandbox)

    @see sandbox

  • podfile (Podfile)

    @see podfile

  • lockfile (Lockfile) (defaults to: nil)

    @see lockfile



31
32
33
34
35
36
37
38
# File 'lib/cocoapods/installer/analyzer.rb', line 31

def initialize(sandbox, podfile, lockfile = nil)
  @sandbox  = sandbox
  @podfile  = podfile
  @lockfile = lockfile

  @update_mode = false
  @allow_pre_downloads = true
end

Instance Attribute Details

#allow_pre_downloadsBool Also known as: allow_pre_downloads?

Note:

This flag should not be used in installations.

Note:

This is used by the ‘pod outdated` command to prevent modification of the sandbox in the resolution process.

Returns Whether the analysis allows pre-downloads and thus modifications to the sandbox.

Returns:

  • (Bool)

    Whether the analysis allows pre-downloads and thus modifications to the sandbox.



106
107
108
# File 'lib/cocoapods/installer/analyzer.rb', line 106

def allow_pre_downloads
  @allow_pre_downloads
end

#lockfileLockfile (readonly)

Returns The Lockfile that stores the information about the Pods previously installed on any machine.

Returns:

  • (Lockfile)

    The Lockfile that stores the information about the Pods previously installed on any machine.



25
26
27
# File 'lib/cocoapods/installer/analyzer.rb', line 25

def lockfile
  @lockfile
end

#podfilePodfile (readonly)

Returns The Podfile specification that contains the information of the Pods that should be installed.

Returns:

  • (Podfile)

    The Podfile specification that contains the information of the Pods that should be installed.



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

def podfile
  @podfile
end

#resultObject

Returns the value of attribute result.



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

def result
  @result
end

#sandboxSandbox (readonly)

Returns The sandbox where the Pods should be installed.

Returns:

  • (Sandbox)

    The sandbox where the Pods should be installed.



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

def sandbox
  @sandbox
end

#update_modeBool Also known as: update_mode?

Returns Whether the version of the dependencies which did non change in the Podfile should be locked.

Returns:

  • (Bool)

    Whether the version of the dependencies which did non change in the Podfile should be locked.



95
96
97
# File 'lib/cocoapods/installer/analyzer.rb', line 95

def update_mode
  @update_mode
end

Instance Method Details

#analyze(allow_fetches = true) ⇒ AnalysisResult

Performs the analysis.

The Podfile and the Lockfile provide the information necessary to compute which specification should be installed. The manifest of the sandbox returns which specifications are installed.

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cocoapods/installer/analyzer.rb', line 48

def analyze(allow_fetches = true)
  update_repositories_if_needed if allow_fetches
  @result = AnalysisResult.new
  @result.podfile_state = generate_podfile_state
  @locked_dependencies  = generate_version_locking_dependencies

  @result.libraries       = generated_libraries
  fetch_external_sources if allow_fetches
  @result.specs_by_target = resolve_dependencies
  @result.specifications  = generate_specifications
  @result.sandbox_state   = generate_sandbox_state
  @result
end

#needs_install?Bool

Returns Whether an installation should be performed or this CocoaPods project is already up to date.

Returns:

  • (Bool)

    Whether an installation should be performed or this CocoaPods project is already up to date.



67
68
69
70
# File 'lib/cocoapods/installer/analyzer.rb', line 67

def needs_install?
  analysis_result = analyze(false)
  podfile_needs_install?(analysis_result) || sandbox_needs_install?(analysis_result)
end

#podfile_needs_install?(analysis_result) ⇒ Bool

Returns Whether the podfile has changes respect to the lockfile.

Returns:

  • (Bool)

    Whether the podfile has changes respect to the lockfile.



74
75
76
77
78
# File 'lib/cocoapods/installer/analyzer.rb', line 74

def podfile_needs_install?(analysis_result)
  state = analysis_result.podfile_state
  needing_install = state.added + state.changed + state.deleted
  !needing_install.empty?
end

#sandbox_needs_install?(analysis_result) ⇒ Bool

Returns Whether the sandbox is in synch with the lockfile.

Returns:

  • (Bool)

    Whether the sandbox is in synch with the lockfile.



82
83
84
85
86
# File 'lib/cocoapods/installer/analyzer.rb', line 82

def sandbox_needs_install?(analysis_result)
  state = analysis_result.sandbox_state
  needing_install = state.added + state.changed + state.deleted
  !needing_install.empty?
end