class UIAuto::Reporter
Public Class Methods
new()
click to toggle source
# File lib/uiauto/reporter.rb, line 3 def initialize @listeners = [] @element_tree = "" end
Public Instance Methods
add_listener(listener)
click to toggle source
# File lib/uiauto/reporter.rb, line 8 def add_listener(listener) @listeners << listener end
formatter=(formatter)
click to toggle source
# File lib/uiauto/reporter.rb, line 12 def formatter=(formatter) add_listener(formatter) end
load_simulator_data(data)
click to toggle source
# File lib/uiauto/reporter.rb, line 71 def load_simulator_data(data) notify_listeners(:load_simulator_data, data) end
parse_instruments_output(output)
click to toggle source
# File lib/uiauto/reporter.rb, line 16 def parse_instruments_output(output) lines = output.split("\n") lines.each do |line| notify_listeners(:instruments_line, line) case line when /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} \+\d{4} (\w+): (.*)$/ log_type = $1 message = $2 notify_listeners("log_#{log_type.downcase}".to_sym, message) when /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} \+\d{4} logElementTree:$/ @element_tree = "" notify_listeners(:element_tree_start) when /^UIATarget .+$/ @element_tree << line + "\n" notify_listeners(:element_tree_line, line) when /^elements: \{$/ @element_tree << line + "\n" notify_listeners(:element_tree_line, line) when /^\t+.+$/ @element_tree << line + "\n" notify_listeners(:element_tree_line, line) when /^\}$/ @element_tree << line notify_listeners(:element_tree, @element_tree) notify_listeners(:element_tree_line, line) notify_listeners(:element_tree_finish) when /^Instruments Trace Complete \(Duration : (.+); Output : (.+)$/ duration = $1 trace_location = $2 notify_listeners(:script_summary, duration, trace_location) else notify_listeners(:unknown, line) end end end
run_finish()
click to toggle source
# File lib/uiauto/reporter.rb, line 59 def run_finish notify_listeners(:run_finish) end
run_start()
click to toggle source
# File lib/uiauto/reporter.rb, line 55 def run_start notify_listeners(:run_start) end
script_finish(script)
click to toggle source
# File lib/uiauto/reporter.rb, line 67 def script_finish(script) notify_listeners(:script_finish, script) end
script_start(script)
click to toggle source
# File lib/uiauto/reporter.rb, line 63 def script_start(script) notify_listeners(:script_start, script) end
Protected Instance Methods
notify_listeners(event, *args)
click to toggle source
# File lib/uiauto/reporter.rb, line 77 def notify_listeners(event, *args) @listeners.each do |listener| listener.send(event, *args) end end