0

I am trying to programmatically launch a console such that:

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.

  1. ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
  2. iteractive_editor (0.0.10)
  3. irbtools (2.0.1, 1.7.1)
  4. ripl (0.7.1)
  5. 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.

Community
  • 1
  • 1
Nicolas De Jay
  • 444
  • 4
  • 16

1 Answers1

0

I found a way around this:

def edit(*args)
  system("$EDITOR #{args.join(' ')")
end

This still doesn't explain why I can't get this example to work with interactive_prompt.

Nicolas De Jay
  • 444
  • 4
  • 16