I am trying to programmatically launch a console such that:
- Its context is bound to a particular object (link to Stack Overflow).
- It allows me to use tools (i.e.
vim
command) provided by theinteractive_editor
Gem (link to GitHub).
It would be appear that the two conditions I am trying to meet are mutually exclusive. Below I write a script that fires up a REPL that is bound to the context of a [1,2,3]
list.
# test.rb
require 'ripl'
require 'interactive_editor'
Ripl.start :binding => [1,2,3].instance_eval { binding }
If you run ruby test.rb
, you can see that you are in the context of [1,2,3]
:
>> self
=> [1, 2, 3]
>> map { |a| a * 2 }
=> [2, 4, 6]
But if you try using interactive_editor
's features:
>> vim "something"
=> [1, 2, 3]
This last line fires up vim
and actually writes to the file "something" (without my explicit saving):
# something
---
- 1
- 2
- 3
Is there any way for me to resolve this problem? Should I file this as an issue on the interactive_editor
Gem? The same kinds of error occur when I use IRB
along with interactive_editor
or irbtools
.
My guess is that changing the context makes it rather difficult for interactive_editor
to resolve its object definitions but I am not sure how this works.
Thanks in advance and please let me know if I omitted important information.
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
iteractive_editor (0.0.10)
irbtools (2.0.1, 1.7.1)
ripl (0.7.1)
ripltools (0.7.0)
I am running OS X Yosemite 10.10.3 but have managed to replicate this issue on several other Linux boxes.