Class: Rcov::RubyAnnotation

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

Overview

:nodoc:

Constant Summary collapse

DEFAULT_OPTS =
{ :destdir => "coverage" }

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.



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/rcov/formatters/html_coverage.rb', line 142

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



154
155
156
157
158
159
160
# File 'lib/rcov/formatters/html_coverage.rb', line 154

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