class DeepCover::Reporter::Base
Attributes
options[R]
Public Class Methods
new(coverage, **options)
click to toggle source
# File lib/deep_cover/reporter/base.rb, line 13 def initialize(coverage, **options) @coverage = coverage @options = options end
Public Instance Methods
analysis()
click to toggle source
# File lib/deep_cover/reporter/base.rb, line 18 def analysis @analysis ||= Coverage::Analysis.new(@coverage.covered_codes, **options) end
each() { |relative_path(path), covered_code| ... }
click to toggle source
# File lib/deep_cover/reporter/base.rb, line 22 def each(&block) return to_enum :each unless block_given? @coverage.each do |covered_code| yield relative_path(covered_code.path), covered_code end self end
populate_stats() { |relative_path(full_path), relative_path(partial_path), data, children| ... }
click to toggle source
Same as populate, but also yields data, which is either the analysis data (for leaves) of the sum of the children (for subtrees)
# File lib/deep_cover/reporter/base.rb, line 32 def populate_stats return to_enum(__method__) unless block_given? Tree::Util.populate_from_map( tree: tree, map: map, merge: ->(child_data) { Tools.merge(*child_data, :+) } ) do |full_path, partial_path, data, children| yield relative_path(full_path), relative_path(partial_path), data, children end end
Private Instance Methods
map()
click to toggle source
# File lib/deep_cover/reporter/base.rb, line 59 def map analysis.stat_map.transform_keys(&:path).transform_keys(&:to_s) end
relative_path(path)
click to toggle source
# File lib/deep_cover/reporter/base.rb, line 45 def relative_path(path) path = path.to_s path = path.slice(root_path.length + 1..-1) if path.start_with?(root_path) path end
root_path()
click to toggle source
# File lib/deep_cover/reporter/base.rb, line 51 def root_path return '' if tree.size > 1 path = tree.first.first root = File.dirname(path) root = File.dirname(root) if File.basename(path) == 'dir' root end
tree()
click to toggle source
# File lib/deep_cover/reporter/base.rb, line 63 def tree Tree::Util.paths_to_tree(map.keys) end