Class: Slather::CoverallsCoverageFile

Inherits:
CoverageFile show all
Defined in:
lib/slather/coveralls_coverage_file.rb

Instance Attribute Summary

Attributes inherited from CoverageFile

#gcno_file_pathname, #project

Instance Method Summary collapse

Methods inherited from CoverageFile

#coverage_for_line, #gcov_data, #initialize, #source_data, #source_file, #source_file_pathname, #source_file_pathname_relative_to_project_root

Constructor Details

This class inherits a constructor from Slather::CoverageFile

Instance Method Details

#as_jsonObject



12
13
14
15
16
17
18
# File 'lib/slather/coveralls_coverage_file.rb', line 12

def as_json
  {
    :name => source_file_pathname_relative_to_project_root.to_s,
    :source => source_data,
    :coverage => coverage_data
  }
end

#coverage_dataObject



4
5
6
7
8
9
10
# File 'lib/slather/coveralls_coverage_file.rb', line 4

def coverage_data
  first_line_start = gcov_data =~ /^\s+(-|#+|[0-9+]):\s+1:/

  gcov_data[first_line_start..-1].split("\n").map do |line|
    coverage_for_line(line)
  end
end