Class: FakeS3::Server
- Inherits:
-
Object
- Object
- FakeS3::Server
- Defined in:
- lib/fakes3/server.rb
Instance Method Summary collapse
-
#initialize(address, port, store, hostname, ssl_cert_path, ssl_key_path, extra_options = {}) ⇒ Server
constructor
A new instance of Server.
- #serve ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(address, port, store, hostname, ssl_cert_path, ssl_key_path, extra_options = {}) ⇒ Server
Returns a new instance of Server.
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/fakes3/server.rb', line 558 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 @cors_options = [:cors_options] or {} 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 if [:quiet] webrick_config.merge!( :Logger => WEBrick::Log.new("/dev/null"), :AccessLog => [] ) end @server = WEBrick::HTTPServer.new(webrick_config) end |
Instance Method Details
#serve ⇒ Object
590 591 592 593 594 595 596 |
# File 'lib/fakes3/server.rb', line 590 def serve @server.mount "/", Servlet, @store, @hostname, @cors_options shutdown = proc { @server.shutdown } trap "INT", &shutdown trap "TERM", &shutdown @server.start end |
#shutdown ⇒ Object
598 599 600 |
# File 'lib/fakes3/server.rb', line 598 def shutdown @server.shutdown end |