Class: UIAuto::Reporter
- Inherits:
-
Object
- Object
- UIAuto::Reporter
- Defined in:
- lib/uiauto/reporter.rb
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
- #formatter=(formatter) ⇒ Object
-
#initialize ⇒ Reporter
constructor
A new instance of Reporter.
- #load_simulator_data(data) ⇒ Object
- #parse_instruments_output(output) ⇒ Object
- #run_finish ⇒ Object
- #run_start ⇒ Object
- #script_finish(script) ⇒ Object
- #script_start(script) ⇒ Object
Constructor Details
#initialize ⇒ Reporter
Returns a new instance of Reporter.
3 4 5 6 |
# File 'lib/uiauto/reporter.rb', line 3 def initialize @listeners = [] @element_tree = "" end |
Instance Method Details
#add_listener(listener) ⇒ Object
8 9 10 |
# File 'lib/uiauto/reporter.rb', line 8 def add_listener(listener) @listeners << listener end |
#formatter=(formatter) ⇒ Object
12 13 14 |
# File 'lib/uiauto/reporter.rb', line 12 def formatter=(formatter) add_listener(formatter) end |
#load_simulator_data(data) ⇒ Object
71 72 73 |
# File 'lib/uiauto/reporter.rb', line 71 def load_simulator_data(data) notify_listeners(:load_simulator_data, data) end |
#parse_instruments_output(output) ⇒ Object
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 |
# 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 = $2 notify_listeners("log_#{log_type.downcase}".to_sym, ) 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 ⇒ Object
59 60 61 |
# File 'lib/uiauto/reporter.rb', line 59 def run_finish notify_listeners(:run_finish) end |
#run_start ⇒ Object
55 56 57 |
# File 'lib/uiauto/reporter.rb', line 55 def run_start notify_listeners(:run_start) end |
#script_finish(script) ⇒ Object
67 68 69 |
# File 'lib/uiauto/reporter.rb', line 67 def script_finish(script) notify_listeners(:script_finish, script) end |
#script_start(script) ⇒ Object
63 64 65 |
# File 'lib/uiauto/reporter.rb', line 63 def script_start(script) notify_listeners(:script_start, script) end |