Sha256: e47dd8237368d6decfea14a6593e5a7db560cb2abc792ce53ee7b35eb885e853

Contents?: true

Size: 629 Bytes

Versions: 4

Compression:

Stored size: 629 Bytes

Contents

# coding: utf-8

class BaseServer
  attr_accessor :server, :port, :logger, :io
  
  def u(str = '')
    "http://localhost:#{@port}/#{str}"
  end
  
  def set_logger
    @io = StringIO.new
    @logger = Logger.new(@io)
    @logger.level = Logger::Severity::DEBUG
  end
  
  def start
    @port = @server.config[:Port]
    @thread = start_server_thread(@server)
  end
  
  def start_server_thread(server)
    t = Thread.new {
      Thread.current.abort_on_exception = true
      server.start
    }
    while server.status != :Running
      Thread.pass
      unless t.alive?
    t.join
    raise
      end
    end
    t
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glebtv-httpclient-3.3.0 spec/support/base_server.rb
glebtv-httpclient-3.2.8 spec/support/base_server.rb
glebtv-httpclient-3.2.7 spec/support/base_server.rb
glebtv-httpclient-3.2.6 spec/support/base_server.rb