Class: UIAutoMonkey::LogDecoder

Inherits:
Object
  • Object
show all
Defined in:
lib/crash_monkey/monkey_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(log_list) ⇒ LogDecoder

Returns a new instance of LogDecoder.



333
334
335
# File 'lib/crash_monkey/monkey_runner.rb', line 333

def initialize(log_list)
  @log_list = log_list
end

Instance Method Details

#decode_latest(num = 10) ⇒ Object



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/crash_monkey/monkey_runner.rb', line 337

def decode_latest(num=10)
  hash = {}
  ret = []
  @log_list.reverse.each do |log|
    break if num == 0
    if log[LOG_TYPE] == 'Screenshot'
      if log[MESSAGE] =~ /^action/
        hash[:action_image] = log[MESSAGE]
      elsif log[MESSAGE] =~ /^monkey/
        hash[:screen_image] = log[MESSAGE]
        hash[:timestamp] = log[TIMESTAMP]
        # emit and init
        if block_given?
          yield(hash)
        else
          ret << hash
        end
        hash = {}
        num -= 1
      end
    elsif log[LOG_TYPE] == 'Debug' && log[MESSAGE] =~ /^target./
      hash[:message] = log[MESSAGE] unless log[MESSAGE] =~ /^target.captureRectWithName/ && log[MESSAGE] =~ /switcherScrollView/
    end
  end
  ret
end