Class: ZergXcode::Plugins::Lstargets

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

Overview

Lists the build targets in an Xcode project.

Instance Method Summary collapse

Instance Method Details

#helpObject



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

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



35
36
37
38
39
# File 'lib/zerg_xcode/plugins/lstargets.rb', line 35

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

#run(args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/zerg_xcode/plugins/lstargets.rb', line 23

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