ruby - How to use interactive_editor when REPL console is run in context of a particular object -
i trying programmatically launch console such that:
- its context bound particular object (link stack overflow).
- it allows me use tools (i.e.
vim
command) providedinteractive_editor
gem (link github).
it appear 2 conditions trying meet mutually exclusive. below write script fires repl bound context of [1,2,3]
list.
# test.rb require 'ripl' require 'interactive_editor' ripl.start :binding => [1,2,3].instance_eval { binding }
if run ruby test.rb
, can see in context of [1,2,3]
:
>> self => [1, 2, 3] >> map { |a| * 2 } => [2, 4, 6]
but if try using interactive_editor
's features:
>> vim "something" => [1, 2, 3]
this last line fires vim
, writes file "something" (without explicit saving):
# --- - 1 - 2 - 3
is there way me resolve problem? should file issue on interactive_editor
gem? same kinds of error occur when use irb
along interactive_editor
or irbtools
.
my guess changing context makes rather difficult interactive_editor
resolve object definitions not sure how works.
thanks in advance , please let me know if 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 running os x yosemite 10.10.3 have managed replicate issue on several other linux boxes.
i found way around this:
def edit(*args) system("$editor #{args.join(' ')") end
this still doesn't explain why can't example work interactive_prompt
.
Comments
Post a Comment