Class: Rcov::Formatters::RubyAnnotation

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

Constant Summary collapse

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

#initialize(opts = {}) ⇒ RubyAnnotation

Returns a new instance of RubyAnnotation.



6
7
8
9
10
11
12
13
14
15
# File 'lib/rcov/formatters/ruby_annotation.rb', line 6

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

#executeObject



17
18
19
20
21
22
23
# File 'lib/rcov/formatters/ruby_annotation.rb', line 17

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