File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ module IRuby
3
3
4
4
module History
5
5
def eval ( code , store_history )
6
- b = TOPLEVEL_BINDING
6
+ b = eval_binding
7
7
8
8
b . local_variable_set ( :_ih , In ) unless b . local_variable_defined? ( :_ih )
9
9
b . local_variable_set ( :_oh , Out ) unless b . local_variable_defined? ( :_oh )
@@ -39,10 +39,17 @@ def initialize
39
39
require 'irb'
40
40
require 'irb/completion'
41
41
IRB . setup ( nil )
42
- @irb = IRB ::Irb . new
42
+ @main = TOPLEVEL_BINDING . eval ( "self" ) . dup
43
+ @workspace = IRB ::WorkSpace . new ( @main )
44
+ @irb = IRB ::Irb . new ( @workspace )
45
+ @eval_path = @irb . context . irb_path
43
46
IRB . conf [ :MAIN_CONTEXT ] = @irb . context
44
47
end
45
48
49
+ def eval_binding
50
+ @workspace . binding
51
+ end
52
+
46
53
def eval ( code , store_history )
47
54
@irb . context . evaluate ( code , 0 )
48
55
@irb . context . last_value
@@ -67,6 +74,10 @@ def initialize
67
74
reset
68
75
end
69
76
77
+ def eval_binding
78
+ TOPLEVEL_BINDING
79
+ end
80
+
70
81
def eval ( code , store_history )
71
82
Pry . current_line = 1
72
83
@pry . last_result = nil
@@ -99,7 +110,7 @@ def complete(code)
99
110
end
100
111
101
112
def reset
102
- @pry = Pry . new ( output : $stdout, target : TOPLEVEL_BINDING )
113
+ @pry = Pry . new ( output : $stdout, target : eval_binding )
103
114
end
104
115
end
105
116
end
You can’t perform that action at this time.
0 commit comments