File: rbtrace.rb

package info (click to toggle)
ruby-rbtrace 0.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 756 kB
  • sloc: ruby: 1,128; ansic: 925; sh: 42; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 382 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module RBTrace
  class << self
    def eval_and_inspect(code)
      t = Thread.new do
        Thread.current.name = '__RBTrace__'
        Thread.current[:output] = eval_context.eval(code).inspect
      end
      t.join
      t[:output]
    end

    private

    def eval_context
      @eval_context ||= binding
    end
  end
end

require 'rbtrace.so'