Class: FakeS3::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/fakes3/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(address, port, store, hostname, ssl_cert_path, ssl_key_path) ⇒ Server

Returns a new instance of Server.



378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/fakes3/server.rb', line 378

def initialize(address,port,store,hostname,ssl_cert_path,ssl_key_path)
  @address = address
  @port = port
  @store = store
  @hostname = hostname
  @ssl_cert_path = ssl_cert_path
  @ssl_key_path = ssl_key_path
  webrick_config = {
    :BindAddress => @address,
    :Port => @port
  }
  if !@ssl_cert_path.to_s.empty?
    webrick_config.merge!(
      {
        :SSLEnable => true,
        :SSLCertificate => OpenSSL::X509::Certificate.new(File.read(@ssl_cert_path)),
        :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.read(@ssl_key_path))
      }
    )
  end
  @server = WEBrick::HTTPServer.new(webrick_config)
end

Instance Method Details

#serveObject



401
402
403
404
405
# File 'lib/fakes3/server.rb', line 401

def serve
  @server.mount "/", Servlet, @store,@hostname
  trap "INT" do @server.shutdown end
  @server.start
end

#shutdownObject



407
408
409
# File 'lib/fakes3/server.rb', line 407

def shutdown
  @server.shutdown
end