Commit eb272e33 authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by Dimitris Koutsogiorgas

Remove analyzer `attr_accessor` properties

parent 4f8ffc7b
...@@ -241,15 +241,13 @@ module Pod ...@@ -241,15 +241,13 @@ module Pod
# @return [void] # @return [void]
# #
def analyze(analyzer = create_analyzer) def analyze(analyzer = create_analyzer)
analyzer.update = update
@analysis_result = analyzer.analyze @analysis_result = analyzer.analyze
@aggregate_targets = analyzer.result.targets @aggregate_targets = @analysis_result.targets
end end
def create_analyzer(plugin_sources = nil) 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.installation_options = installation_options
analyzer.has_dependencies = has_dependencies?
end end
end end
...@@ -684,9 +682,9 @@ module Pod ...@@ -684,9 +682,9 @@ module Pod
plugin_sources = run_source_provider_hooks plugin_sources = run_source_provider_hooks
analyzer = create_analyzer(plugin_sources) analyzer = create_analyzer(plugin_sources)
analyze(analyzer) 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`' 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`' raise Pod::Informative, 'The `Pods` directory is out-of-date, you must run `pod install`'
end end
......
This diff is collapsed.
module Pod module Pod
class Installer class Installer
class Analyzer class Analyzer
# A simple container produced after a analysis is completed by the {Analyzer}.
#
class AnalysisResult class AnalysisResult
# @return [SpecsState] the states of the Podfile specs. # @return [SpecsState] the states of the Podfile specs.
# #
attr_accessor :podfile_state attr_reader :podfile_state
# @return [Hash{TargetDefinition => Array<Specification>}] the # @return [Hash{TargetDefinition => Array<Specification>}] the specifications grouped by target.
# specifications grouped by target.
# #
attr_accessor :specs_by_target attr_reader :specs_by_target
# @return [Hash{Source => Array<Specification>}] the # @return [Hash{Source => Array<Specification>}] the specifications grouped by spec repo source.
# specifications grouped by spec repo source.
# #
attr_accessor :specs_by_source attr_reader :specs_by_source
# @return [Array<Specification>] the specifications of the resolved # @return [Array<Specification>] the specifications of the resolved version of Pods that should be installed.
# version of Pods that should be installed.
# #
attr_accessor :specifications attr_reader :specifications
# @return [SpecsState] the states of the {Sandbox} respect the resolved # @return [SpecsState] the states of the {Sandbox} respect the resolved specifications.
# specifications.
# #
attr_accessor :sandbox_state attr_accessor :sandbox_state
# @return [Array<AggregateTarget>] The aggregate targets created for each # @return [Array<AggregateTarget>] The aggregate targets created for each {TargetDefinition} from the {Podfile}.
# {TargetDefinition} from the {Podfile}.
# #
attr_accessor :targets attr_reader :targets
# @return [Hash{TargetDefinition => Array<TargetInspectionResult>}] the # @return [PodfileDependencyCache] the cache of all dependencies in the podfile.
# results of inspecting the user targets
# #
attr_accessor :target_inspections attr_reader :podfile_dependency_cache
# @return [PodfileDependencyCache] the cache of all dependencies in the def initialize(podfile_state, specs_by_target, specs_by_source, specifications, sandbox_state, targets,
# podfile. podfile_dependency_cache)
# @podfile_state = podfile_state
attr_accessor :podfile_dependency_cache @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 # @return [Hash{String=>Symbol}] A hash representing all the user build
# configurations across all integration targets. Each key # configurations across all integration targets. Each key
...@@ -51,6 +53,29 @@ module Pod ...@@ -51,6 +53,29 @@ module Pod
result.merge(target.user_build_configurations) result.merge(target.user_build_configurations)
end end
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 end
end end
......
...@@ -20,7 +20,9 @@ module Pod ...@@ -20,7 +20,9 @@ module Pod
@sources = [] @sources = []
end 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) def add_source(source)
unless source.nil? unless source.nil?
......
This diff is collapsed.
...@@ -63,8 +63,10 @@ module Pod ...@@ -63,8 +63,10 @@ module Pod
aggregate_targets = [@ios_target, @osx_target] aggregate_targets = [@ios_target, @osx_target]
@analysis_result = Pod::Installer::Analyzer::AnalysisResult.new @analysis_result = Pod::Installer::Analyzer::AnalysisResult.new(Pod::Installer::Analyzer::SpecsState.new,
@analysis_result.targets = aggregate_targets {}, {}, [],
Pod::Installer::Analyzer::SpecsState.new,
aggregate_targets, nil)
@installation_options = Pod::Installer::InstallationOptions.new @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