Class: ZergXcode::Plugins::Lstargets

Inherits:
Object
  • Object
show all
Defined in:
lib/zerg_xcode/plugins/lstargets.rb

Instance Method Summary collapse

Instance Method Details

#helpObject



2
3
4
5
6
7
8
9
10
# File 'lib/zerg_xcode/plugins/lstargets.rb', line 2

def help
  {:short => 'shows the targets in a project',
   :long => <<"END" }
Usage: ls [path]

Lists all the targets in the project at the given path. If no path is given,
looks for a project in the current directory.
END
end

#list_for(project_name) ⇒ Object



24
25
26
27
28
# File 'lib/zerg_xcode/plugins/lstargets.rb', line 24

def list_for(project_name)    
  ZergXcode.load(project_name)['targets'].map do |target|
    [target['name'], target['productName'], target['productType']]
  end
end

#run(args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/zerg_xcode/plugins/lstargets.rb', line 12

def run(args)
  list = list_for(args.shift || '.')
  output = ""
  list.each do |entry|
    type_match = /^com\.apple\.product\-type\.(.*)$/.match entry[2]
    target_type = type_match ? type_match[1] : entry[2]
    output << "%-20s %s > %s\n" % [target_type, entry[0], entry[1]]
  end
  print output
  output
end