Sha256: d9ffd8a001c4426b5d4607b0b1f6395b0347e26b72e9901f662b1bcc65d73a33
Contents?: true
Size: 879 Bytes
Versions: 1
Compression:
Stored size: 879 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__ $stderr.print lines[tp.lineno] rescue NameError ensure tp.enable end begin tp.enable eval code ensure tp.disable end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trace_eval-0.1.4 | lib/trace_eval.rb |