Sha256: 37aa37068c04022e84a6772743710743d13b265df040697e0efa652403c37c56
Contents?: true
Size: 903 Bytes
Versions: 1
Compression:
Stored size: 903 Bytes
Contents
# frozen_string_literal: true require_relative 'trace_eval/version' # Use trace point to print lines of code during eval. A randomized # sigil value is used to only print lines from this invocation of eval, # but nonsense could still ensure if this eval also evals. # module TraceEval def trace_eval(code) __wzpxmnrjafemvlrwflblbbyenywk__ = rand lines = [ "__wzpxmnrjafemvlrwflblbbyenywk__ = #{__wzpxmnrjafemvlrwflblbbyenywk__}\n" ] + code.lines tp = TracePoint.new(:line) do |tp| tp.disable next unless tp.path == '(eval)' next unless tp.binding.local_variable_get( :__wzpxmnrjafemvlrwflblbbyenywk__ )==__wzpxmnrjafemvlrwflblbbyenywk__ print lines[tp.lineno] rescue NameError ensure tp.enable end begin tp.enable eval code ensure tp.disable end end end Kernel.send :extend, TraceEval
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trace_eval-0.1.0 | lib/trace_eval.rb |