Class: Pod::Command::RepoArt::List

Inherits:
Pod::Command::RepoArt show all
Defined in:
lib/pod/command/repo_art/list.rb

Constant Summary collapse

UTIL =
Pod::RepoArt::RepoUtil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ List

Returns a new instance of List.



22
23
24
25
# File 'lib/pod/command/repo_art/list.rb', line 22

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

Class Method Details

.optionsObject



16
17
18
19
20
# File 'lib/pod/command/repo_art/list.rb', line 16

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

Instance Method Details

#art_sourcesSource

Returns The list of the Artifactory sources.

Returns:

  • (Source)

    The list of the Artifactory sources.



50
51
52
53
54
# File 'lib/pod/command/repo_art/list.rb', line 50

def art_sources
  SourcesManager.all.select do |source|
    UTIL.art_repo?(source.repo)
  end
end


33
34
35
36
37
38
39
40
# File 'lib/pod/command/repo_art/list.rb', line 33

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


42
43
44
45
46
# File 'lib/pod/command/repo_art/list.rb', line 42

def print_source(source)
  UI.puts '- Type: Artifactory'
  UI.puts "- URL:  #{UTIL.get_art_url(source.repo)}" if UTIL.artpodrc_file_exists(source.repo)
  UI.puts "- Path: #{source.repo}"
end


56
57
58
59
60
# File 'lib/pod/command/repo_art/list.rb', line 56

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

#runObject



27
28
29
30
31
# File 'lib/pod/command/repo_art/list.rb', line 27

def run
  sources = art_sources
  print_art_sources(sources) unless @count_only
  print_source_count(sources)
end