class UIAutoMonkey::LogDecoder

Public Class Methods

new(log_list) click to toggle source
# File lib/crash_monkey/monkey_runner.rb, line 333
def initialize(log_list)
  @log_list = log_list
end

Public Instance Methods

decode_latest(num=10) { |hash| ... } click to toggle source
# 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