Sha256: a0c72823440848b7b1779e652f082b0d4348c6b0e1118a8e7c694d22f9618393
Contents?: true
Size: 871 Bytes
Versions: 3
Compression:
Stored size: 871 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trace_eval-0.1.3 | lib/trace_eval.rb |
trace_eval-0.1.2 | lib/trace_eval.rb |
trace_eval-0.1.1 | lib/trace_eval.rb |