Sha256: b6f6c6193a93296f662bb1dbdb5f3b0f5b23d1f8e004e5b69f9a4be46698671a

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

module Cucover
  class Recording < Struct.new(
      :file_colon_line, 
      :exception, 
      :additional_covered_files, 
      :analyzer, 
      :start_time, :end_time)
    
    def feature_filename
      file_colon_line.split(':').first
    end
    
    def covers_file?(source_file)
      covered_files.include?(source_file)
    end
    
    def covers_line?(source_file, line_number)
      covered_files.detect{ |f| f.file == source_file }.covers_line?(line_number)
    end
    
    def covered_files
      @covered_files ||= analyzed_covered_files + additional_covered_files
    end
    
    def failed?
      !!exception
    end
    
    private
    
    def additional_covered_files
      super.map do |filename|
        CoveredFile.new(filename, nil, self)
      end
    end
    
    def analyzed_covered_files
      filtered_analyzed_files.map do |filename| 
        lines, marked_info, count_info = analyzer.data(filename)
        CoveredFile.new(filename, marked_info, self)
      end
    end
    
    def boring?(file)
      [
        /gem/,
        /vendor/,
        /lib\/ruby/,
        /cucover/
      ].any? do |expression|
        file.match expression
      end
    end
    
    def filtered_analyzed_files
      analyzer.analyzed_files.reject{ |f| boring?(f) }
    end

    def normalized_files
      cleaned_analyzed_files + additional_covered_files
    end
  end
end
require 'cucover/recording/covered_file'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mattwynne-cucover-0.1.0 lib/cucover/recording.rb
mattwynne-cucover-0.1.1 lib/cucover/recording.rb