Sha256: 43e039d516a316521ba656e9aea890ca9e813029e4d963f0fb3b711c82146ae8

Contents?: true

Size: 1.46 KB

Versions: 12

Compression:

Stored size: 1.46 KB

Contents

# An array of SimpleCov SourceFile instances with additional collection helper
# methods for calculating coverage across them etc.
module SimpleCov
  class FileList < Array
    # Returns the count of lines that have coverage
    def covered_lines
      return 0.0 if empty?
      map { |f| f.covered_lines.count }.inject(&:+)
    end

    # Returns the count of lines that have been missed
    def missed_lines
      return 0.0 if empty?
      map { |f| f.missed_lines.count }.inject(&:+)
    end

    # Returns the count of lines that are not relevant for coverage
    def never_lines
      return 0.0 if empty?
      map { |f| f.never_lines.count }.inject(&:+)
    end

    # Returns the count of skipped lines
    def skipped_lines
      return 0.0 if empty?
      map { |f| f.skipped_lines.count }.inject(&:+)
    end

    # Returns the overall amount of relevant lines of code across all files in this list
    def lines_of_code
      covered_lines + missed_lines
    end

    # Computes the coverage based upon lines covered and lines missed
    # @return [Float]
    def covered_percent
      return 100.0 if empty? || lines_of_code.zero?
      Float(covered_lines * 100.0 / lines_of_code)
    end

    # Computes the strength (hits / line) based upon lines covered and lines missed
    # @return [Float]
    def covered_strength
      return 0.0 if empty? || lines_of_code.zero?
      Float(map { |f| f.covered_strength * f.lines_of_code }.inject(&:+) / lines_of_code)
    end
  end
end

Version data entries

12 entries across 12 versions & 5 rubygems

Version Path
suzuko-0.1.8 vendor/bundle/ruby/2.0.0/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
suzuko-0.1.7 vendor/bundle/ruby/2.0.0/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/file_list.rb
simplecov-0.10.0 lib/simplecov/file_list.rb