Sha256: dcb453fa5e565b2b8ff16f562fea1a632b2dfc0d4a08f1edb9aebc1c0cefb06e

Contents?: true

Size: 1.14 KB

Versions: 15

Compression:

Stored size: 1.14 KB

Contents

require_relative 'extension_constants'
require WEBCONSOLE_FILE

module WebConsole::REPL
  require_relative "repl/lib/input_controller"
  require_relative "repl/lib/output_controller"
  require_relative "repl/lib/view"

  class Wrapper
    require 'pty'
    def initialize(command)

      PTY.spawn(command) do |output, input, pid|
        Thread.new do
          output.each { |line|
            output_controller.parse_output(line)
          }
        end
        @input = input
      end
    end

    def parse_input(input)
      input_controller.parse_input(input)
      write_input(input)
    end

    def write_input(input)
      @input.write(input)
    end

    private

    def input_controller
      if !@input_controller
        @input_controller = InputController.new
        @input_controller.view = view
      end
      return @input_controller
    end
    
    def output_controller
      if !@output_controller
        @output_controller = OutputController.new
        @output_controller.view = view
      end
      return @output_controller
    end
    
    def view
      if !@view
        @view = View.new
      end
      return @view
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
webconsole-0.1.18 lib/webconsole/repl.rb
webconsole-0.1.17 lib/webconsole/repl.rb
webconsole-0.1.16 lib/webconsole/repl.rb
webconsole-0.1.15 lib/webconsole/repl.rb
webconsole-0.1.14 lib/webconsole/repl.rb
webconsole-0.1.13 lib/webconsole/repl.rb
webconsole-0.1.12 lib/webconsole/repl.rb
webconsole-0.1.11 lib/webconsole/repl.rb
webconsole-0.1.10 lib/webconsole/repl.rb
webconsole-0.1.5 lib/webconsole/repl.rb
webconsole-0.1.4 lib/webconsole/repl.rb
webconsole-0.1.3 lib/webconsole/repl.rb
webconsole-0.1.2 lib/webconsole/repl.rb
webconsole-0.1.1 lib/webconsole/repl.rb
webconsole-0.1.0 lib/webconsole/repl.rb