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

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/installer/analyzer.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.

Analysis sub-steps collapse

Analysis sub-steps collapse

Constructor Details

#initialize(pods_by_state = nil) ⇒ SpecsState

Returns a new instance of SpecsState.

Parameters:

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

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



498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/cocoapods/installer/analyzer.rb', line 498

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.



514
515
516
# File 'lib/cocoapods/installer/analyzer.rb', line 514

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.



518
519
520
# File 'lib/cocoapods/installer/analyzer.rb', line 518

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.



522
523
524
# File 'lib/cocoapods/installer/analyzer.rb', line 522

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.



526
527
528
# File 'lib/cocoapods/installer/analyzer.rb', line 526

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:

  • the (String)

    name of the Pod.

  • the (Symbol)

    state of the Pod.

Raises:

  • If there is an attempt to add the name of a subspec.



551
552
553
554
# File 'lib/cocoapods/installer/analyzer.rb', line 551

def add_name(name, state)
  raise "[Bug] Attempt to add subspec to the pods state" if name.include?('/')
  self.send(state) << name
end

This method returns an undefined value.

Displays the state of each pod.



532
533
534
535
536
537
# File 'lib/cocoapods/installer/analyzer.rb', line 532

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