Class: RunLoop::CLI::Instruments

Inherits:
Thor
  • Object
show all
Defined in:
lib/run_loop/cli/instruments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#signalObject

Returns the value of attribute signal


9
10
11
# File 'lib/run_loop/cli/instruments.rb', line 9

def signal
  @signal
end

Instance Method Details

#launchObject


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/run_loop/cli/instruments.rb', line 96

def launch

  debug = options[:debug]
  original_value = ENV['DEBUG']

  ENV['DEBUG'] = '1' if debug

  begin
    launch_options = {
          :args => parse_app_launch_args(options),
          :udid => detect_device_udid_from_options(options),
          :bundle_dir_or_bundle_id => detect_bundle_id_or_bundle_path(options)
    }
    run_loop = RunLoop.run(launch_options)
    puts JSON.generate(run_loop)
  ensure
    ENV['DEBUG'] = original_value if debug
  end
end

#quitObject


28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/run_loop/cli/instruments.rb', line 28

def quit
  signal = options[:signal]
  ENV['DEBUG'] = '1' if options[:debug]
  instruments = RunLoop::Instruments.new
  instruments.instruments_pids.each do |pid|
    terminator = RunLoop::ProcessTerminator.new(pid, signal, 'instruments')
    unless terminator.kill_process
      terminator = RunLoop::ProcessTerminator.new(pid, 'KILL', 'instruments')
      terminator.kill_process
    end
  end
end