Class: SimpleCov::Formatter::SublimeRubyCoverageFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov-sublime-ruby-coverage.rb

Instance Method Summary collapse

Instance Method Details

#format(result) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/simplecov-sublime-ruby-coverage.rb', line 6

def format(result)

  @path_relativizer = Hash.new{|h,base|
    h[base] = Pathname.new(base).cleanpath.to_s.gsub(%r{^\w:[/\\]}, "").gsub(/\./, "_").gsub(/[\\\/]/, "-") + ".csv"
  }

  FileUtils.mkdir_p output_path

  result.files.each do |file|
    data = []

    file.lines.each do |line|
      data << ((line.covered? || line.status == 'never') ? '1' : '0')
    end

    csv = data.join("\n")

    result_file_path = File.join(output_path, relative_filename(shortened_filename(file)))
    File.open(result_file_path, "w") do |file_result|
      file_result.write csv
    end
  end

  puts "Coverage report generated for #{result.command_name} to #{output_path}"
end

#output_pathObject



32
33
34
# File 'lib/simplecov-sublime-ruby-coverage.rb', line 32

def output_path
  File.join SimpleCov.coverage_path, 'sublime-ruby-coverage'
end