Class: UIAutoMonkey::LogDecoder
- Inherits:
-
Object
- Object
- UIAutoMonkey::LogDecoder
- Defined in:
- lib/smart_monkey/monkey_runner.rb
Instance Method Summary collapse
- #decode_latest(num = 10, drop_useless_img, drop_dir) ⇒ Object
-
#initialize(log_list) ⇒ LogDecoder
constructor
A new instance of LogDecoder.
- #rm_unused_imgs(used_imgs, dir) ⇒ Object
Constructor Details
#initialize(log_list) ⇒ LogDecoder
Returns a new instance of LogDecoder.
586 587 588 |
# File 'lib/smart_monkey/monkey_runner.rb', line 586 def initialize(log_list) @log_list = log_list end |
Instance Method Details
#decode_latest(num = 10, drop_useless_img, drop_dir) ⇒ Object
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
# File 'lib/smart_monkey/monkey_runner.rb', line 595 def decode_latest(num=10, drop_useless_img, drop_dir) hash = {} ret = [] used_imgs = [] @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[^external]*$/ hash[:screen_image] = log[MESSAGE] used_imgs << 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/ hash[:message] = log[MESSAGE] unless log[MESSAGE] =~ /size:{height:0.00,width:0.00}/ || log[MESSAGE] =~ /switcherScrollView/ end end #drop unused imgs if drop_useless_img puts "Drop useless images..." rm_unused_imgs(used_imgs, drop_dir) end if !@log_list.empty? #add screen_size hash = {} hash[:screen_size] = @log_list[0][MESSAGE] ret << hash end ret end |
#rm_unused_imgs(used_imgs, dir) ⇒ Object
590 591 592 593 |
# File 'lib/smart_monkey/monkey_runner.rb', line 590 def rm_unused_imgs(used_imgs, dir) used_strs = used_imgs.join("\\|") `cd "#{dir}";find . -type 'f' -name '*.png' | grep -v "#{used_strs}" | xargs -I{} rm {}` end |