Sha256: 317fa81bc29ce5042b78d8c256d36fb992925feffce5d82ba2c756442128adc1

Contents?: true

Size: 1018 Bytes

Versions: 1

Compression:

Stored size: 1018 Bytes

Contents

require 'socket'

module AsProject

  # TODO: Add new task as a clean dependency
  # That will call the fcshs and tell it to release
  # all in-memory compilations
  class FCSH < MXMLC
    attr_accessor :ip,
                  :port

    def initialize(name=:fcsh)
      @ip = (ip.nil?) ? "127.0.0.1" : ip
      @port = (port.nil?) ? 20569 : port
      super(name)
    end
    
    def execute(cmd, args, retries=0)
      retries = retries+1
      if(retries > 3)
        puts "fcsh task was unable to connect to fcshs, please try starting this service by opening a new terminal and typing 'fcshs' (without quotes)"
        return
      end
      begin
        @socket = TCPSocket.open(@ip, @port) do |s|
          s.puts Dir.pwd
          s.puts "#{cmd} #{args}"
          s.close_write
          while(line = s.gets)
            puts line
          end
        end
        puts 'finished!'
      rescue StandardError
#        IO.popen("fcshs &", "r")
#        execute(cmd, args, retries)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
asproject-0.1.84 lib/tasks/fcsh.rb