Class: Rcov::RubyAnnotation

Inherits:
BaseFormatter show all
Defined in:
lib/rcov/formatters/html_coverage.rb

Overview

:nodoc:

Constant Summary

DEFAULT_OPTS =
{ :destdir => "coverage" }

Constants inherited from BaseFormatter

BaseFormatter::RCOV_IGNORE_REGEXPS

Instance Method Summary (collapse)

Methods inherited from BaseFormatter

#add_file, #code_coverage, #each_file_pair_sorted, #mangle_filename, #normalize_filename, #num_code_lines, #num_lines, #sorted_file_pairs, #total_coverage

Constructor Details

- (RubyAnnotation) initialize(opts = {})



172
173
174
175
176
177
178
179
180
181
182
# File 'lib/rcov/formatters/html_coverage.rb', line 172

def initialize(opts = {})
  options = DEFAULT_OPTS.clone.update(opts)
  super(options)
  @dest = options[:destdir]
  @do_callsites = true
  @do_cross_references = true

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

Instance Method Details

- (Object) execute



184
185
186
187
188
189
190
# File 'lib/rcov/formatters/html_coverage.rb', line 184

def execute
  return if @files.empty?
  FileUtils.mkdir_p @dest
  each_file_pair_sorted do |filename, fileinfo|
    create_file(File.join(@dest, mangle_filename(filename)), fileinfo)
  end
end