Module: Xctracker

Defined in:
lib/xctracker.rb,
lib/xctracker/tracker.rb,
lib/xctracker/version.rb,
lib/xctracker/execution.rb,
lib/xctracker/exceptions.rb,
lib/xctracker/derived_data.rb,
lib/xctracker/reporters/json_reporter.rb,
lib/xctracker/reporters/abstract_reporter.rb,
lib/xctracker/reporters/standard_output_reporter.rb

Defined Under Namespace

Classes: AbstractReporter, BuildFlagIsNotEnabled, DerivedData, DerivedDataNotFound, Execution, JSONReporter, OutputPathIsNotSpecified, StandardOutputReporter, Tracker

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.execute(args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/xctracker.rb', line 15

def execute(args)
  options = OpenStruct.new
  options.order = :time
  options.reporters = [:standard_output]

  parser = OptionParser.new do |opts|
    opts.banner = "Usage: xctracker [product name or .xcactivitylog file] [options]".red

    opts.on("--[no-]show-invalids", "Show invalid location results") { |v| options.show_invalid_locations = v }
    opts.on("-o [ORDER]", [:default, :time, :file], "Sort order") { |v| options.order = v }
    opts.on("-l", "--limit [LIMIT]", Integer, "Limit for display") { |v| options.limit = v }
    opts.on_tail("-h", "--help", "Show this message") do
      puts opts
      exit
    end
  end
  parser.parse!(args)

  target = args.pop
  unless target
    puts parser
    exit 1
  end

  order = options[:order] or :time

  begin
    if target.end_with?('.xcactivitylog')
      tracker = Tracker.by_path(target)
    else
      tracker = Tracker.by_product_name(target)
    end
    tracker.reporters = [
      StandardOutputReporter.new(limit: options[:limit],
                                 order: order,
                                 show_invalid_locations: options[:show_invalid_locations])
    ]
    tracker.report!
  rescue Exception => e
    puts e.message.red
  end
end