Sha256: a200b38b16bea00ff97f2b7ef6e5bab908de64da622df6128762a2dfaaf22a00

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

module Mutant
  # Line tracer
  class LineTrace
    include Adamantium::Flat, Concord.new(:contents)

    private_class_method :new

    # Test if trace coveres file at lineno
    #
    # @param [String] file
    # @param [Fixnum] lineno
    #
    # @return [Boolean]
    #
    def cover?(file, lineno)
      contents.fetch(file) { return false }.include?(lineno)
    end

    # Run block
    #
    # @return [Traces]
    #
    # @api private
    #
    def self.call(&block)
      traces = Hash.new { |hash, file| hash[file] = Set.new }
      TracePoint.trace(:return, :line) do |point|
        traces[point.path] << point.lineno
      end.tap(&block).disable
      new(IceNine.deep_freeze(traces))
    end

  end # LineTrace
end # Mutant

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mutant-0.7.4 lib/mutant/line_trace.rb
mutant-0.7.3 lib/mutant/line_trace.rb
mutant-0.7.2 lib/mutant/line_trace.rb