lib/covered/source.rb in covered-0.3.0 vs lib/covered/source.rb in covered-0.4.0

- old
+ new

@@ -75,19 +75,19 @@ def ignore?(node) # NODE_ARGS Ruby doesn't report execution of arguments in :line tracepoint. node.type =~ @ignore end - def expand(node, lines) + def expand(node, counts) # puts "#{node.first_lineno}: #{node.inspect}" - lines[node.first_lineno] ||= 0 if executable?(node) + counts[node.first_lineno] ||= 0 if executable?(node) node.children.each do |child| next if child.nil? or ignore?(child) - expand(child, lines) + expand(child, counts) end end def parse(path) # puts "Parse #{path}" @@ -100,17 +100,16 @@ warn "Couldn't parse #{path}, file doesn't exist?" end end def each(&block) - @output.each do |path, lines| - lines = lines.dup - - if top = parse(path) - expand(top, lines) + @output.each do |coverage| + # This is a little bit inefficient, perhaps add a cache layer? + if top = parse(coverage.path) + expand(top, coverage.counts) end - yield path, lines + yield coverage.freeze end end end end