Skip to content

Commit

Permalink
[SpecsState] Track pods in a Set
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Jan 28, 2016
1 parent 30d814c commit 29e0172
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/cocoapods/installer/analyzer.rb
Expand Up @@ -202,7 +202,7 @@ def generate_podfile_state
pods_state
else
state = SpecsState.new
state.added.concat(podfile.dependencies.map(&:name).uniq)
state.added.merge(podfile.dependencies.map(&:root_name))
state
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cocoapods/installer/analyzer/sandbox_analyzer.rb
Expand Up @@ -78,7 +78,7 @@ def analyze
state.add_name(name, pod_state(name))
end
else
state.added.concat(resolved_pods)
state.added.merge(resolved_pods)
end
state
end
Expand Down
18 changes: 10 additions & 8 deletions lib/cocoapods/installer/analyzer/specs_state.rb
@@ -1,3 +1,5 @@
require 'set'

module Pod
class Installer
class Analyzer
Expand All @@ -17,10 +19,10 @@ class SpecsState
# (`:added`, `:removed`, `:changed` or `:unchanged`).
#
def initialize(pods_by_state = nil)
@added = []
@deleted = []
@changed = []
@unchanged = []
@added = Set.new
@deleted = Set.new
@changed = Set.new
@unchanged = Set.new

if pods_by_state
{
Expand All @@ -36,19 +38,19 @@ def initialize(pods_by_state = nil)
end
end

# @return [Array<String>] the names of the pods that were added.
# @return [Set<String>] the names of the pods that were added.
#
attr_accessor :added

# @return [Array<String>] the names of the pods that were changed.
# @return [Set<String>] the names of the pods that were changed.
#
attr_accessor :changed

# @return [Array<String>] the names of the pods that were deleted.
# @return [Set<String>] the names of the pods that were deleted.
#
attr_accessor :deleted

# @return [Array<String>] the names of the pods that were unchanged.
# @return [Set<String>] the names of the pods that were unchanged.
#
attr_accessor :unchanged

Expand Down
4 changes: 2 additions & 2 deletions spec/unit/installer/analyzer/sandbox_analyzer_spec.rb
Expand Up @@ -22,12 +22,12 @@ module Pod
@analyzer.stubs(:sandbox_checksum).returns(@spec.checksum)
state = @analyzer.analyze
state.class.should == Installer::Analyzer::SpecsState
state.unchanged.should == ['BananaLib']
state.unchanged.should == Set.new(%w(BananaLib))
end

it 'marks all the pods as added if no sandbox manifest is available' do
@sandbox.stubs(:manifest)
@analyzer.analyze.added.should == ['BananaLib']
@analyzer.analyze.added.should == Set.new(%w(BananaLib))
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/unit/installer/analyzer_spec.rb
Expand Up @@ -52,10 +52,10 @@ module Pod

it 'computes the state of the Podfile respect to the Lockfile' do
state = @analyzer.analyze.podfile_state
state.added.should == %w(AFNetworking libextobjc libextobjc)
state.changed.should == %w()
state.unchanged.should == %w(JSONKit SVPullToRefresh)
state.deleted.should == %w(NUI)
state.added.should == Set.new(%w(AFNetworking libextobjc libextobjc))
state.changed.should == Set.new(%w())
state.unchanged.should == Set.new(%w(JSONKit SVPullToRefresh))
state.deleted.should == Set.new(%w(NUI))
end

#--------------------------------------#
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/installer_spec.rb
Expand Up @@ -396,7 +396,7 @@ def @installer.analyze(*)

it 'analyzes the Podfile, the Lockfile and the Sandbox' do
@installer.send(:analyze)
@installer.analysis_result.sandbox_state.added.should == ['JSONKit']
@installer.analysis_result.sandbox_state.added.should == Set.new(%w(JSONKit))
end

it 'stores the targets created by the analyzer' do
Expand Down

0 comments on commit 29e0172

Please sign in to comment.