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`).



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 19

def initialize(pods_by_state = nil)
  @added     = []
  @deleted   = []
  @changed   = []
  @unchanged = []

  if pods_by_state
    @added     = pods_by_state[:added]     || []
    @deleted   = pods_by_state[:removed]   || []
    @changed   = pods_by_state[:changed]   || []
    @unchanged = pods_by_state[:unchanged] || []
  end
end

Instance Attribute Details

#addedArray<String>

Returns the names of the pods that were added.

Returns:

  • (Array<String>)

    the names of the pods that were added.



35
36
37
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 35

def added
  @added
end

#changedArray<String>

Returns the names of the pods that were changed.

Returns:

  • (Array<String>)

    the names of the pods that were changed.



39
40
41
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 39

def changed
  @changed
end

#deletedArray<String>

Returns the names of the pods that were deleted.

Returns:

  • (Array<String>)

    the names of the pods that were deleted.



43
44
45
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 43

def deleted
  @deleted
end

#unchangedArray<String>

Returns the names of the pods that were unchanged.

Returns:

  • (Array<String>)

    the names of the pods that were unchanged.



47
48
49
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 47

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.



70
71
72
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 70

def add_name(name, state)
  send(state) << name
end

This method returns an undefined value.

Displays the state of each pod.



53
54
55
56
57
58
# File 'lib/cocoapods/installer/analyzer/specs_state.rb', line 53

def print
  added    .sort.each { |pod| UI.message('A'.green  + " #{pod}", '', 2) }
  deleted  .sort.each { |pod| UI.message('R'.red    + " #{pod}", '', 2) }
  changed  .sort.each { |pod| UI.message('M'.yellow + " #{pod}", '', 2) }
  unchanged.sort.each { |pod| UI.message('-'        + " #{pod}", '', 2) }
end