Sha256: b7e58187532ba7c877fe54b85e8dd502d323652472a8405e4c3fdd5199b9a962

Contents?: true

Size: 693 Bytes

Versions: 3

Compression:

Stored size: 693 Bytes

Contents

require 'json'

module TestR
module Server

  def quit
    throw :testr_server_quit
  end

  def loop
    (@upstream = STDOUT.dup).sync = true
    STDOUT.reopen(STDERR).sync = true

    catch :testr_server_quit do
      while line = STDIN.gets
        warn "#{caller[2]} RECV #{line.chomp}" if $DEBUG

        command = JSON.load(line)
        method = command.first

        if respond_to? method and method != __method__ # prevent loops
          @command, @command_line = command, line
          __send__(*command)
        else
          warn "#{self}: bad command: #{method}"
        end
      end
    end
  end

  def self.extended server
    trap(:SIGTERM){ server.quit }
  end

end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
testr-14.1.3 lib/testr/server.rb
testr-14.1.2 lib/testr/server.rb
testr-14.1.1 lib/testr/server.rb