Class: Pod::Installer::Analyzer
- Inherits:
-
Object
- Object
- Pod::Installer::Analyzer
- Includes:
- Config::Mixin
- Defined in:
- lib/cocoapods/installer/analyzer.rb,
lib/cocoapods/installer/analyzer/specs_state.rb,
lib/cocoapods/installer/analyzer/analysis_result.rb,
lib/cocoapods/installer/analyzer/sandbox_analyzer.rb,
lib/cocoapods/installer/analyzer/target_inspector.rb,
lib/cocoapods/installer/analyzer/target_inspection_result.rb,
lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb
Overview
Analyzes the Podfile, the Lockfile, and the sandbox manifest to generate the information relative to a CocoaPods installation.
Defined Under Namespace
Modules: LockingDependencyAnalyzer Classes: AnalysisResult, SandboxAnalyzer, SpecsState, TargetInspectionResult, TargetInspector
Configuration collapse
-
#allow_pre_downloads ⇒ Bool
(also: #allow_pre_downloads?)
Whether the analysis allows pre-downloads and thus modifications to the sandbox.
-
#update ⇒ Hash, ...
Pods that have been requested to be updated or true if all Pods should be updated.
Instance Attribute Summary collapse
-
#lockfile ⇒ Lockfile
readonly
The Lockfile that stores the information about the Pods previously installed on any machine.
-
#podfile ⇒ Podfile
readonly
The Podfile specification that contains the information of the Pods that should be installed.
-
#result ⇒ Object
Returns the value of attribute result.
-
#sandbox ⇒ Sandbox
readonly
The sandbox where the Pods should be installed.
Configuration collapse
-
#update_mode ⇒ Symbol
Whether and how the dependencies in the Podfile should be updated.
-
#update_mode? ⇒ Bool
Whether the version of the dependencies which did not change in the Podfile should be locked.
Analysis steps collapse
-
#update_repositories ⇒ Object
Updates the git source repositories unless the config indicates to skip it.
Analysis internal products collapse
-
#sources ⇒ Array<Source>
Returns the sources used to query for specifications.
Instance Method Summary collapse
-
#analyze(allow_fetches = true) ⇒ AnalysisResult
Performs the analysis.
-
#initialize(sandbox, podfile, lockfile = nil) ⇒ Analyzer
constructor
Initialize a new instance.
-
#needs_install? ⇒ Bool
Whether an installation should be performed or this CocoaPods project is already up to date.
-
#podfile_needs_install?(analysis_result) ⇒ Bool
Whether the podfile has changes respect to the lockfile.
-
#sandbox_needs_install?(analysis_result) ⇒ Bool
Whether the sandbox is in synch with the lockfile.
Methods included from Config::Mixin
Constructor Details
#initialize(sandbox, podfile, lockfile = nil) ⇒ Analyzer
Initialize a new instance
36 37 38 39 40 41 42 43 |
# File 'lib/cocoapods/installer/analyzer.rb', line 36 def initialize(sandbox, podfile, lockfile = nil) @sandbox = sandbox @podfile = podfile @lockfile = lockfile @update = false @allow_pre_downloads = true end |
Instance Attribute Details
#allow_pre_downloads ⇒ Bool Also known as: allow_pre_downloads?
This flag should not be used in installations.
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.
146 147 148 |
# File 'lib/cocoapods/installer/analyzer.rb', line 146 def allow_pre_downloads @allow_pre_downloads end |
#lockfile ⇒ Lockfile (readonly)
Returns The Lockfile that stores the information about the Pods previously installed on any machine.
28 29 30 |
# File 'lib/cocoapods/installer/analyzer.rb', line 28 def lockfile @lockfile end |
#podfile ⇒ Podfile (readonly)
Returns The Podfile specification that contains the information of the Pods that should be installed.
23 24 25 |
# File 'lib/cocoapods/installer/analyzer.rb', line 23 def podfile @podfile end |
#result ⇒ Object
Returns the value of attribute result.
77 78 79 |
# File 'lib/cocoapods/installer/analyzer.rb', line 77 def result @result end |
#sandbox ⇒ Sandbox (readonly)
Returns The sandbox where the Pods should be installed.
18 19 20 |
# File 'lib/cocoapods/installer/analyzer.rb', line 18 def sandbox @sandbox end |
#update ⇒ Hash, ...
Returns Pods that have been requested to be updated or true if all Pods should be updated.
116 117 118 |
# File 'lib/cocoapods/installer/analyzer.rb', line 116 def update @update 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.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cocoapods/installer/analyzer.rb', line 56 def analyze(allow_fetches = true) validate_podfile! validate_lockfile_version! @result = AnalysisResult.new if config.integrate_targets? @result.target_inspections = inspect_targets_to_integrate else verify_platforms_specified! end @result.podfile_state = generate_podfile_state @locked_dependencies = generate_version_locking_dependencies fetch_external_sources if allow_fetches @result.specs_by_target = validate_platforms(resolve_dependencies) @result.specifications = generate_specifications @result.targets = generate_targets @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.
82 83 84 85 |
# File 'lib/cocoapods/installer/analyzer.rb', line 82 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.
92 93 94 95 96 |
# File 'lib/cocoapods/installer/analyzer.rb', line 92 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.
103 104 105 106 107 |
# File 'lib/cocoapods/installer/analyzer.rb', line 103 def sandbox_needs_install?(analysis_result) state = analysis_result.sandbox_state needing_install = state.added + state.changed + state.deleted !needing_install.empty? end |
#sources ⇒ Array<Source>
Returns the sources used to query for specifications
When no explicit Podfile sources are defined, this defaults to the master spec repository. available sources (SourcesManager.all).
608 609 610 611 612 613 614 615 616 617 618 619 620 |
# File 'lib/cocoapods/installer/analyzer.rb', line 608 def sources @sources ||= begin sources = podfile.sources if sources.empty? url = 'https://github.com/CocoaPods/Specs.git' [SourcesManager.find_or_create_source_with_url(url)] else sources.map do |source_url| SourcesManager.find_or_create_source_with_url(source_url) end end end end |
#update_mode ⇒ Symbol
Returns Whether and how the dependencies in the Podfile should be updated.
128 129 130 131 132 133 134 135 136 |
# File 'lib/cocoapods/installer/analyzer.rb', line 128 def update_mode if !update :none elsif update == true :all elsif !update[:pods].nil? :selected end end |
#update_mode? ⇒ Bool
Returns Whether the version of the dependencies which did not change in the Podfile should be locked.
121 122 123 |
# File 'lib/cocoapods/installer/analyzer.rb', line 121 def update_mode? update != nil end |
#update_repositories ⇒ Object
Updates the git source repositories unless the config indicates to skip it.
210 211 212 213 214 215 216 217 218 |
# File 'lib/cocoapods/installer/analyzer.rb', line 210 def update_repositories sources.each do |source| if SourcesManager.git_repo?(source.repo) SourcesManager.update(source.name) else UI. "Skipping `#{source.name}` update because the repository is not a git source repository." end end end |