Class: Jscon::Repl
Defined Under Namespace
Classes: NoServer
Instance Method Summary collapse
- #after_input ⇒ Object
- #before_input ⇒ Object
-
#initialize(phantom_options) ⇒ Repl
constructor
A new instance of Repl.
- #process_input(input) ⇒ Object
- #setup ⇒ Object
- #teardown ⇒ Object
Constructor Details
Instance Method Details
#after_input ⇒ Object
32 33 34 35 |
# File 'lib/jscon/repl.rb', line 32 def after_input @asset_server.close @asset_server = NoServer end |
#before_input ⇒ Object
20 21 22 |
# File 'lib/jscon/repl.rb', line 20 def before_input @asset_server = Jscon::AssetServer.start if @asset_server == NoServer end |
#process_input(input) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/jscon/repl.rb', line 24 def process_input(input) File.open(@pipe_in, "w+") do |pipe| pipe.write(input) pipe.flush end puts IO.read(@pipe_out) end |
#setup ⇒ Object
13 14 15 16 17 18 |
# File 'lib/jscon/repl.rb', line 13 def setup @pipe_in, @pipe_out = Jscon::Pipes.create_set("js_repl") puts "loading" @asset_server = Jscon::AssetServer.start @phantom_pid = Jscon::Phantom.run_exec(Jscon::Dir.path, @phantom_options) end |
#teardown ⇒ Object
37 38 39 |
# File 'lib/jscon/repl.rb', line 37 def teardown Process.kill(term=15, @phantom_pid) end |