Class: Pod::DyInstaller::Analyzer
- Inherits:
-
Object
- Object
- Pod::DyInstaller::Analyzer
- Includes:
- Config::Mixin, InstallationOptions::Mixin
- Defined in:
- lib/pod/installer/analyzer.rb,
lib/pod/installer/analyzer/pod_variant.rb,
lib/pod/installer/analyzer/specs_state.rb,
lib/pod/installer/analyzer/analysis_result.rb,
lib/pod/installer/analyzer/pod_variant_set.rb,
lib/pod/installer/analyzer/sandbox_analyzer.rb,
lib/pod/installer/analyzer/target_inspector.rb,
lib/pod/installer/analyzer/podfile_dependency_cache.rb,
lib/pod/installer/analyzer/target_inspection_result.rb,
lib/pod/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, PodVariant, PodVariantSet, PodfileDependencyCache, 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.
-
#has_dependencies ⇒ Bool
(also: #has_dependencies?)
Whether the analysis has dependencies and thus sources must be configured.
-
#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.
-
#plugin_sources ⇒ Array<Source>
readonly
Sources provided by plugins.
-
#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.
Attributes included from InstallationOptions::Mixin
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.
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, plugin_sources = 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 InstallationOptions::Mixin
Constructor Details
#initialize(sandbox, podfile, lockfile = nil, plugin_sources = nil) ⇒ Analyzer
Initialize a new instance
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pod/installer/analyzer.rb', line 49 def initialize(sandbox, podfile, lockfile = nil, plugin_sources = nil) @sandbox = sandbox @podfile = podfile @lockfile = lockfile @plugin_sources = plugin_sources @update = false @allow_pre_downloads = true @has_dependencies = true @test_pod_target_analyzer_cache = {} @test_pod_target_key = Struct.new(:name, :pod_targets) @podfile_dependency_cache = PodfileDependencyCache.from_podfile(podfile) 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.
172 173 174 |
# File 'lib/pod/installer/analyzer.rb', line 172 def allow_pre_downloads @allow_pre_downloads end |
#has_dependencies ⇒ Bool Also known as: has_dependencies?
This is used by the ‘pod lib lint` command to prevent update of specs when not needed.
Returns Whether the analysis has dependencies and thus sources must be configured.
181 182 183 |
# File 'lib/pod/installer/analyzer.rb', line 181 def has_dependencies @has_dependencies end |
#lockfile ⇒ Lockfile (readonly)
Returns The Lockfile that stores the information about the Pods previously installed on any machine.
36 37 38 |
# File 'lib/pod/installer/analyzer.rb', line 36 def lockfile @lockfile end |
#plugin_sources ⇒ Array<Source> (readonly)
Returns Sources provided by plugins.
40 41 42 |
# File 'lib/pod/installer/analyzer.rb', line 40 def plugin_sources @plugin_sources end |
#podfile ⇒ Podfile (readonly)
Returns The Podfile specification that contains the information of the Pods that should be installed.
31 32 33 |
# File 'lib/pod/installer/analyzer.rb', line 31 def podfile @podfile end |
#result ⇒ Object
Returns the value of attribute result.
103 104 105 |
# File 'lib/pod/installer/analyzer.rb', line 103 def result @result end |
#sandbox ⇒ Sandbox (readonly)
Returns The sandbox where the Pods should be installed.
26 27 28 |
# File 'lib/pod/installer/analyzer.rb', line 26 def sandbox @sandbox end |
#update ⇒ Hash, ...
Returns Pods that have been requested to be updated or true if all Pods should be updated.
142 143 144 |
# File 'lib/pod/installer/analyzer.rb', line 142 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.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/pod/installer/analyzer.rb', line 74 def analyze(allow_fetches = true) validate_podfile! validate_lockfile_version! @result = AnalysisResult.new @result.podfile_dependency_cache = @podfile_dependency_cache if .integrate_targets? @result.target_inspections = inspect_targets_to_integrate else verify_platforms_specified! end @result.podfile_state = generate_podfile_state fetch_external_sources if allow_fetches @locked_dependencies = generate_version_locking_dependencies resolver_specs_by_target = resolve_dependencies validate_platforms(resolver_specs_by_target) @result.specifications = generate_specifications(resolver_specs_by_target) @result.targets = generate_targets(resolver_specs_by_target) @result.sandbox_state = generate_sandbox_state @result.specs_by_target = resolver_specs_by_target.each_with_object({}) do |rspecs_by_target, hash| hash[rspecs_by_target[0]] = rspecs_by_target[1].map(&:spec) end @result.specs_by_source = Hash[resolver_specs_by_target.values.flatten(1).group_by(&:source).map { |source, specs| [source, specs.map(&:spec).uniq] }] sources.each { |s| @result.specs_by_source[s] ||= [] } @result end |
#needs_install? ⇒ Bool
Returns Whether an installation should be performed or this CocoaPods project is already up to date.
108 109 110 111 |
# File 'lib/pod/installer/analyzer.rb', line 108 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.
118 119 120 121 122 |
# File 'lib/pod/installer/analyzer.rb', line 118 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.
129 130 131 132 133 |
# File 'lib/pod/installer/analyzer.rb', line 129 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 or plugin sources are defined, this defaults to the master spec repository. available sources (Pod::DyInstaller::Analyzer.configconfig.sources_managerconfig.sources_manager.all).
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
# File 'lib/pod/installer/analyzer.rb', line 857 def sources @sources ||= begin sources = podfile.sources plugin_sources = @plugin_sources || [] # Add any sources specified using the :source flag on individual dependencies. dependency_sources = @podfile_dependency_cache.podfile_dependencies.map(&:podspec_repo).compact all_dependencies_have_sources = dependency_sources.count == @podfile_dependency_cache.podfile_dependencies.count if all_dependencies_have_sources sources = dependency_sources elsif has_dependencies? && sources.empty? && plugin_sources.empty? sources = ['https://github.com/CocoaPods/Specs.git'] else sources += dependency_sources end result = sources.uniq.map do |source_url| config.sources_manager.find_or_create_source_with_url(source_url) end unless plugin_sources.empty? result.insert(0, *plugin_sources) end result end end |
#update_mode ⇒ Symbol
Returns Whether and how the dependencies in the Podfile should be updated.
154 155 156 157 158 159 160 161 162 |
# File 'lib/pod/installer/analyzer.rb', line 154 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.
147 148 149 |
# File 'lib/pod/installer/analyzer.rb', line 147 def update_mode? update != nil end |
#update_repositories ⇒ Object
Updates the git source repositories.
251 252 253 254 255 256 257 258 259 260 |
# File 'lib/pod/installer/analyzer.rb', line 251 def update_repositories sources.each do |source| if source.git? config.sources_manager.update(source.name, true) else UI. "Skipping `#{source.name}` update because the repository is not a git source repository." end end @specs_updated = true end |