Class: Pod::Command::Dependmanager::List

Inherits:
Pod::Command::Dependmanager show all
Defined in:
lib/cocoapods-dependManager/command/list.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ List

Returns a new instance of List.



18
19
20
21
22
# File 'lib/cocoapods-dependManager/command/list.rb', line 18

def initialize(argv)
  @target = argv.option('target')
  @podfile_name = argv.option('podfile')
  super
end

Class Method Details

.optionsObject



11
12
13
14
15
16
# File 'lib/cocoapods-dependManager/command/list.rb', line 11

def self.options
  [
    ['--target=TARGET', 'list all dependencies in `TARGET`'],
    ['--podfile=PODFILE', 'podfile name, defalut Podfile'],
  ].concat(super)
end

Instance Method Details



47
48
49
50
51
52
53
54
# File 'lib/cocoapods-dependManager/command/list.rb', line 47

def print_target_dependencies(target_definition)
  UI.title "Target #{target_definition.name}" do
    target_definition.dependencies.each do |dependency|
      UI.puts "- #{dependency.to_s}"
    end
  end
  UI.puts "\n"
end

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cocoapods-dependManager/command/list.rb', line 24

def run
  podfile_path = ''
  if @podfile_name
    podfile_path = Pathname.pwd + @podfile_name 
  else
    podfile_path = Pathname.pwd + 'Podfile'  
  end
  target_definitions = Podfile.from_file(podfile_path).target_definitions
  if @target
    unless target_definitions.has_key?(@target)
      help! 'The target is not exist'
    else
      print_target_dependencies(target_definitions[@target])
    end
  else
    target_definitions.each do |name, definition|
      unless name == 'Pods'
        print_target_dependencies(definition)
      end
    end
  end
end