Sha256: 3b1ef4d0ce9af365003520b51b9d0f8192c09f32d3bf6c9f555c5193b55abbef

Contents?: true

Size: 1.37 KB

Versions: 14

Compression:

Stored size: 1.37 KB

Contents

# An array of SimpleCov SourceFile instances with additional collection helper
# methods for calculating coverage across them etc.
class SimpleCov::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? or lines_of_code == 0
    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? or lines_of_code == 0
    Float(map {|f| f.covered_strength * f.lines_of_code }.inject(&:+) / lines_of_code)
  end
end

Version data entries

14 entries across 11 versions & 3 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/file_list.rb
tdiary-5.0.7 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/file_list.rb
tdiary-5.0.6 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/file_list.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/file_list.rb
tdiary-5.0.5 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/file_list.rb
tdiary-5.0.4 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/file_list.rb
tdiary-5.0.2 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/file_list.rb
tdiary-5.0.1 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/file_list.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/simplecov-0.9.0/lib/simplecov/file_list.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/simplecov-0.9.0/lib/simplecov/file_list.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/simplecov-0.9.0/lib/simplecov/file_list.rb
simplecov-0.9.2 lib/simplecov/file_list.rb
simplecov-0.9.1 lib/simplecov/file_list.rb
simplecov-0.9.0 lib/simplecov/file_list.rb