Class: Pod::Installer::Analyzer::SpecsState

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/installer/analyzer/specs_state.rb

Overview

Note:

The names of the pods stored by this class are always the root name of the specification.

Note:

The motivation for this class is to ensure that the names of the subspecs are added instead of the name of the Pods.

This class represents the state of a collection of Pods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pods_by_state = nil) ⇒ SpecsState

Initialize a new instance

Parameters:

  • pods_by_state (Hash{Symbol=>String}) (defaults to: nil)

    The name of the pods grouped by their state (‘:added`, `:removed`, `:changed` or `:unchanged`).



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 37

def initialize(pods_by_state = nil)
  @added     = Set.new
  @deleted   = Set.new
  @changed   = Set.new
  @unchanged = Set.new

  if pods_by_state
    {
      :added => :added,
      :changed => :changed,
      :removed => :deleted,
      :unchanged => :unchanged,
    }.each do |state, spec_state|
      Array(pods_by_state[state]).each do |name|
        add_name(name, spec_state)
      end
    end
  end
end

Instance Attribute Details

#addedSet<String> (readonly)

Returns the names of the pods that were added.

Returns:

  • (Set<String>)

    the names of the pods that were added.



17
18
19
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 17

def added
  @added
end

#changedSet<String> (readonly)

Returns the names of the pods that were changed.

Returns:

  • (Set<String>)

    the names of the pods that were changed.



21
22
23
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 21

def changed
  @changed
end

#deletedSet<String> (readonly)

Returns the names of the pods that were deleted.

Returns:

  • (Set<String>)

    the names of the pods that were deleted.



25
26
27
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 25

def deleted
  @deleted
end

#unchangedSet<String> (readonly)

Returns the names of the pods that were unchanged.

Returns:

  • (Set<String>)

    the names of the pods that were unchanged.



29
30
31
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 29

def unchanged
  @unchanged
end

Instance Method Details

#add_name(name, state) ⇒ void

This method returns an undefined value.

Adds the name of a Pod to the give state.

Parameters:

  • name (String)

    the name of the Pod.

  • state (Symbol)

    the state of the Pod.



82
83
84
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 82

def add_name(name, state)
  send(state) << Specification.root_name(name)
end

This method returns an undefined value.

Displays the state of each pod.



61
62
63
64
65
66
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 61

def print
  states = %i(added deleted changed unchanged)
  lines(states).each do |line|
    UI.message(line, '', 2)
  end
end

#to_s(states: %i(added deleted changed unchanged)) ⇒ Object



68
69
70
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 68

def to_s(states: %i(added deleted changed unchanged))
  lines(states).join("\n")
end