Unverified Commit f64b8171 authored by D. Koutsogiorgas's avatar D. Koutsogiorgas Committed by GitHub

Merge pull request #7681 from dnkoutso/analyzer_immutability

Remove analyzer `attr_accessor` properties
parents 4f8ffc7b eb272e33
......@@ -241,15 +241,13 @@ module Pod
# @return [void]
#
def analyze(analyzer = create_analyzer)
analyzer.update = update
@analysis_result = analyzer.analyze
@aggregate_targets = analyzer.result.targets
@aggregate_targets = @analysis_result.targets
end
def create_analyzer(plugin_sources = nil)
Analyzer.new(sandbox, podfile, lockfile, plugin_sources).tap do |analyzer|
Analyzer.new(sandbox, podfile, lockfile, plugin_sources, has_dependencies?, update).tap do |analyzer|
analyzer.installation_options = installation_options
analyzer.has_dependencies = has_dependencies?
end
end
......@@ -684,9 +682,9 @@ module Pod
plugin_sources = run_source_provider_hooks
analyzer = create_analyzer(plugin_sources)
analyze(analyzer)
if analyzer.podfile_needs_install?(analyzer.result)
if analysis_result.podfile_needs_install?
raise Pod::Informative, 'The Podfile has changed, you must run `pod install`'
elsif analyzer.sandbox_needs_install?(analyzer.result)
elsif analysis_result.sandbox_needs_install?
raise Pod::Informative, 'The `Pods` directory is out-of-date, you must run `pod install`'
end
......
This diff is collapsed.
module Pod
class Installer
class Analyzer
# A simple container produced after a analysis is completed by the {Analyzer}.
#
class AnalysisResult
# @return [SpecsState] the states of the Podfile specs.
#
attr_accessor :podfile_state
attr_reader :podfile_state
# @return [Hash{TargetDefinition => Array<Specification>}] the
# specifications grouped by target.
# @return [Hash{TargetDefinition => Array<Specification>}] the specifications grouped by target.
#
attr_accessor :specs_by_target
attr_reader :specs_by_target
# @return [Hash{Source => Array<Specification>}] the
# specifications grouped by spec repo source.
# @return [Hash{Source => Array<Specification>}] the specifications grouped by spec repo source.
#
attr_accessor :specs_by_source
attr_reader :specs_by_source
# @return [Array<Specification>] the specifications of the resolved
# version of Pods that should be installed.
# @return [Array<Specification>] the specifications of the resolved version of Pods that should be installed.
#
attr_accessor :specifications
attr_reader :specifications
# @return [SpecsState] the states of the {Sandbox} respect the resolved
# specifications.
# @return [SpecsState] the states of the {Sandbox} respect the resolved specifications.
#
attr_accessor :sandbox_state
# @return [Array<AggregateTarget>] The aggregate targets created for each
# {TargetDefinition} from the {Podfile}.
# @return [Array<AggregateTarget>] The aggregate targets created for each {TargetDefinition} from the {Podfile}.
#
attr_accessor :targets
attr_reader :targets
# @return [Hash{TargetDefinition => Array<TargetInspectionResult>}] the
# results of inspecting the user targets
# @return [PodfileDependencyCache] the cache of all dependencies in the podfile.
#
attr_accessor :target_inspections
attr_reader :podfile_dependency_cache
# @return [PodfileDependencyCache] the cache of all dependencies in the
# podfile.
#
attr_accessor :podfile_dependency_cache
def initialize(podfile_state, specs_by_target, specs_by_source, specifications, sandbox_state, targets,
podfile_dependency_cache)
@podfile_state = podfile_state
@specs_by_target = specs_by_target
@specs_by_source = specs_by_source
@specifications = specifications
@sandbox_state = sandbox_state
@targets = targets
@podfile_dependency_cache = podfile_dependency_cache
end
# @return [Hash{String=>Symbol}] A hash representing all the user build
# configurations across all integration targets. Each key
......@@ -51,6 +53,29 @@ module Pod
result.merge(target.user_build_configurations)
end
end
# @return [Bool] Whether an installation should be performed or this
# CocoaPods project is already up to date.
#
def needs_install?
podfile_needs_install? || sandbox_needs_install?
end
# @return [Bool] Whether the podfile has changes respect to the lockfile.
#
def podfile_needs_install?
state = podfile_state
needing_install = state.added.length + state.changed.length + state.deleted.length
needing_install > 0
end
# @return [Bool] Whether the sandbox is in synch with the lockfile.
#
def sandbox_needs_install?
state = sandbox_state
needing_install = state.added.length + state.changed.length + state.deleted.length
needing_install > 0
end
end
end
end
......
......@@ -20,7 +20,9 @@ module Pod
@sources = []
end
# @param [Source] Source object to be added to the installer
# @param [Source] source object to be added to the installer
#
# @return [void]
#
def add_source(source)
unless source.nil?
......
This diff is collapsed.
......@@ -63,8 +63,10 @@ module Pod
aggregate_targets = [@ios_target, @osx_target]
@analysis_result = Pod::Installer::Analyzer::AnalysisResult.new
@analysis_result.targets = aggregate_targets
@analysis_result = Pod::Installer::Analyzer::AnalysisResult.new(Pod::Installer::Analyzer::SpecsState.new,
{}, {}, [],
Pod::Installer::Analyzer::SpecsState.new,
aggregate_targets, nil)
@installation_options = Pod::Installer::InstallationOptions.new
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment