class BaseChip::OutFile

Attributes

totals[RW]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/base_chip/out_file.rb, line 33
def initialize
  super
  @totals = {}
end

Public Instance Methods

go(name) click to toggle source

def find_parent_values

super 
@warning_regex = to_regex(@warning_regex) if @warning_regex
@error_regex   = to_regex(@error_regex  ) if @error_regex  
@pass_regex    = to_regex(@pass_regex   ) if @pass_regex

end

# File lib/base_chip/out_file.rb, line 43
def go(name)
  sleep(@file_delay || 0)
  files = Dir.glob(@name.to_s)
  error!(@name,"Could not find any files matching #{@name}") unless files[0] || @optional

  # FIXME fault if file doesn't exist
  files.each do |fname|
    f = File.open(fname,'r')
    f.each do |l| 
      if @warning_regex && (match = @warning_regex.match(l)); warning!(fname,match.to_s) end 
      if @error_regex   && (match = @error_regex  .match(l)); error!(  fname,match.to_s) end 
      if @pass_regex    && (match = @pass_regex   .match(l)); pass!                      end 
      if @statistics
        @statistics.each_value do |s|
          fault("statistic '#{s.full_name}' has no regex defined") unless s.regex
          if match = s.regex.match(l); @totals[s.name] = (match[1] && match[1].to_i) || 1 end
        end
      end
    end
    if @pass_regex && @state.nil?
      error!(fname,"passing banner /#{@pass_regex}/ could not be found")
    end
  end
end