Class: Pod::Installer::Analyzer
- Inherits:
-
Object
- Object
- Pod::Installer::Analyzer
- Includes:
- Config::Mixin, InstallationOptions::Mixin
- Defined in:
- lib/cocoapods/installer/analyzer.rb,
lib/cocoapods/installer/analyzer/pod_variant.rb,
lib/cocoapods/installer/analyzer/specs_state.rb,
lib/cocoapods/installer/analyzer/analysis_result.rb,
lib/cocoapods/installer/analyzer/pod_variant_set.rb,
lib/cocoapods/installer/analyzer/sandbox_analyzer.rb,
lib/cocoapods/installer/analyzer/target_inspector.rb,
lib/cocoapods/installer/analyzer/podfile_dependency_cache.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, PodVariant, PodVariantSet, PodfileDependencyCache, SandboxAnalyzer, SpecsState, TargetInspectionResult, TargetInspector
Instance Attribute Summary collapse
-
#has_dependencies ⇒ Bool
(also: #has_dependencies?)
readonly
Whether the analysis has dependencies and thus sources must be configured.
-
#lockfile ⇒ Lockfile
readonly
The Lockfile, if available, that stores the information about the Pods previously installed.
-
#plugin_sources ⇒ Array<Source>
readonly
Sources provided by plugins or ‘nil`.
-
#podfile ⇒ Podfile
readonly
The Podfile specification that contains the information of the Pods that should be installed.
-
#pods_to_update ⇒ Hash, ...
readonly
Pods that have been requested to be updated or true if all Pods should be updated.
-
#sandbox ⇒ Sandbox
readonly
The sandbox to use for this analysis.
Attributes included from InstallationOptions::Mixin
Instance Method Summary collapse
-
#analyze(allow_fetches = true) ⇒ AnalysisResult
Performs the analysis.
-
#initialize(sandbox, podfile, lockfile = nil, plugin_sources = nil, has_dependencies = true, pods_to_update = false) ⇒ Analyzer
constructor
Initialize a new instance.
-
#sources ⇒ Array<Source>
Returns the sources used to query for specifications.
-
#update_repositories ⇒ Object
Updates the git source repositories.
Methods included from InstallationOptions::Mixin
Methods included from Config::Mixin
Constructor Details
#initialize(sandbox, podfile, lockfile = nil, plugin_sources = nil, has_dependencies = true, pods_to_update = false) ⇒ Analyzer
Initialize a new instance
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cocoapods/installer/analyzer.rb', line 59 def initialize(sandbox, podfile, lockfile = nil, plugin_sources = nil, has_dependencies = true, pods_to_update = false) @sandbox = sandbox @podfile = podfile @lockfile = lockfile @plugin_sources = plugin_sources @has_dependencies = has_dependencies @pods_to_update = pods_to_update @podfile_dependency_cache = PodfileDependencyCache.from_podfile(podfile) @result = nil end |
Instance Attribute Details
#has_dependencies ⇒ Bool (readonly) 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.
42 43 44 |
# File 'lib/cocoapods/installer/analyzer.rb', line 42 def has_dependencies @has_dependencies end |
#lockfile ⇒ Lockfile (readonly)
Returns The Lockfile, if available, that stores the information about the Pods previously installed.
32 33 34 |
# File 'lib/cocoapods/installer/analyzer.rb', line 32 def lockfile @lockfile end |
#plugin_sources ⇒ Array<Source> (readonly)
Returns Sources provided by plugins or ‘nil`.
36 37 38 |
# File 'lib/cocoapods/installer/analyzer.rb', line 36 def plugin_sources @plugin_sources end |
#podfile ⇒ Podfile (readonly)
Returns The Podfile specification that contains the information of the Pods that should be installed.
28 29 30 |
# File 'lib/cocoapods/installer/analyzer.rb', line 28 def podfile @podfile end |
#pods_to_update ⇒ Hash, ... (readonly)
Returns Pods that have been requested to be updated or true if all Pods should be updated. This can be false if no pods should be updated.
48 49 50 |
# File 'lib/cocoapods/installer/analyzer.rb', line 48 def pods_to_update @pods_to_update end |
#sandbox ⇒ Sandbox (readonly)
Returns The sandbox to use for this analysis.
24 25 26 |
# File 'lib/cocoapods/installer/analyzer.rb', line 24 def sandbox @sandbox 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.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/cocoapods/installer/analyzer.rb', line 82 def analyze(allow_fetches = true) return @result if @result validate_podfile! validate_lockfile_version! if .integrate_targets? target_inspections = inspect_targets_to_integrate else verify_platforms_specified! target_inspections = {} end podfile_state = generate_podfile_state fetch_external_sources(podfile_state) if allow_fetches locked_dependencies = generate_version_locking_dependencies(podfile_state) resolver_specs_by_target = resolve_dependencies(locked_dependencies) validate_platforms(resolver_specs_by_target) specifications = generate_specifications(resolver_specs_by_target) targets = generate_targets(resolver_specs_by_target, target_inspections) pod_targets = calculate_pod_targets(targets) sandbox_state = generate_sandbox_state(specifications) 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 specs_by_source = Hash[resolver_specs_by_target.values.flatten(1).group_by(&:source).map do |source, specs| [source, specs.map(&:spec).uniq] end] sources.each { |s| specs_by_source[s] ||= [] } @result = AnalysisResult.new(podfile_state, specs_by_target, specs_by_source, specifications, sandbox_state, targets, pod_targets, @podfile_dependency_cache) 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.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/cocoapods/installer/analyzer.rb', line 135 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_dependencies.map(&:podspec_repo).compact all_dependencies_have_sources = dependency_sources.count == 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_repositories ⇒ Object
Updates the git source repositories.
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/cocoapods/installer/analyzer.rb', line 117 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 |