Sha256: 0a1f6ce05e3edd5d241c6b1a6ddeeee8257139f9010d630beb7caf976d91fc4d

Contents?: true

Size: 821 Bytes

Versions: 17

Compression:

Stored size: 821 Bytes

Contents

require 'socket'
require 'sprout/fcsh_service'

module Sprout #:nodoc

  class FCSHSocket

    def self.server(port=12321, out=nil)
      out = out || $stdout
      server = TCPServer.new(port)
      @fcsh = FCSHService.new(out)
      out.puts ">> fcsh started, waiting for connections on port #{port}"
      while(session = server.accept)
        response = @fcsh.execute(session.gets)
        session.puts(response)
        session.flush
        session.close
      end
    end
    
    def self.execute(command, port=12321)
      session = TCPSocket.new('localhost', port)
      session.puts(command)
      response = session.read
      
      error = response =~ /(.*Error:.*\^.*)\n/m
      if(error)
        raise FCSHError.new(response)
      end
      
      session.close
      return response
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sprout-as3-bundle-1.0.37 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.36 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.32 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.31 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.29 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.30 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.12 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.14 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.20 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.10 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.21 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.11 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.22 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.24 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.8 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.23 lib/sprout/fcsh_socket.rb
sprout-as3-bundle-1.0.9 lib/sprout/fcsh_socket.rb