Sha256: 288a4758876a5ba93b557fa58d69883d9d162e38f9d3028fbb81507a8e4bb927
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
require 'rubygems' gem('tracepoint') require 'tracepoint' require 'uncool/analysis' module Uncool # class Trace # attr :targets # attr :log # def initialize(targets, options={}) @targets = [targets].compact.flatten @options = options @log = [] end # def setup tracker = self TracePoint.trace do |tp| #puts "#{tp.self.class}\t#{tp.callee}\t#{tp.event}\t#{tp.return?}" if tp.event == 'call' or tp.event == 'c-call' if tracker.target?(tp.self.class) tracker.log << [tp.self, tp.callee] end end end end # def target?(mod) return true if targets.empty? targets.find do |target| begin target_class = eval(target, TOPLEVEL_BINDING) #Object.const_get(target) rescue nil else target_class == mod end end end # def activate setup TracePoint.activate end # def deactivate TracePoint.deactivate end # def to_analysis Analysis.new(self, @options) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uncool-1.0.1 | lib/uncool/trace.rb |
uncool-1.0.0 | lib/uncool/trace.rb |