Class: Pod::Command::Repo::List

Inherits:
Pod::Command::Repo show all
Defined in:
lib/cocoapods/command/repo/list.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::Repo

#dir

Methods included from Executable

capture_command, capture_command!, #executable, execute_command, popen3, reader, which, which!

Methods inherited from Pod::Command

#ensure_master_spec_repo_exists!, ensure_not_root_or_allowed!, git_version, #installer_for_config, report_error, run, #verify_lockfile_exists!, verify_minimum_git_version!, #verify_podfile_exists!, verify_xcode_license_approved!

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ List

Returns a new instance of List.



15
16
17
18
# File 'lib/cocoapods/command/repo/list.rb', line 15

def initialize(argv)
  @count_only = argv.flag?('count-only')
  super
end

Class Method Details

.optionsObject



11
12
13
# File 'lib/cocoapods/command/repo/list.rb', line 11

def self.options
  [['--count-only', 'Show the total number of repos']].concat(super)
end

Instance Method Details

This method returns an undefined value.

Pretty-prints the number of sources.

Parameters:

  • sources (Array<Source>)

    The sources whose count should be printed.



86
87
88
89
90
# File 'lib/cocoapods/command/repo/list.rb', line 86

def print_count_of_sources(sources)
  number_of_repos = sources.length
  repo_string = number_of_repos != 1 ? 'repos' : 'repo'
  UI.puts "#{number_of_repos} #{repo_string}".green
end

This method returns an undefined value.

Pretty-prints the source at the given path.

Parameters:

  • source (Source)

    The source repository to be printed.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cocoapods/command/repo/list.rb', line 47

def print_source(source)
  if source.is_a?(Pod::CDNSource)
    UI.puts '- Type: CDN'
  elsif source.git?
    branch_name, = Executable.capture_command('git', %w(name-rev --name-only HEAD), :capture => :out, :chdir => source.repo)
    branch_name.strip!
    branch_name = 'unknown' if branch_name.empty?
    UI.puts "- Type: git (#{branch_name})"
  else
    UI.puts "- Type: #{source.type}"
  end

  UI.puts "- URL:  #{source.url}"
  UI.puts "- Path: #{source.repo}"
end

This method returns an undefined value.

Pretty-prints the given sources.

Parameters:

  • sources (Array<Source>)

    The sources that should be printed.



70
71
72
73
74
75
76
77
# File 'lib/cocoapods/command/repo/list.rb', line 70

def print_sources(sources)
  sources.each do |source|
    UI.title source.name do
      print_source(source)
    end
  end
  UI.puts "\n"
end

#runObject



32
33
34
35
36
# File 'lib/cocoapods/command/repo/list.rb', line 32

def run
  sources = config.sources_manager.all
  print_sources(sources) unless @count_only
  print_count_of_sources(sources)
end