Class: MockServerThin

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

Defined Under Namespace

Modules: Methods Classes: App, Config

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}, &block) ⇒ MockServerThin

Returns a new instance of MockServerThin.



40
41
42
43
44
45
46
47
# File 'lib/mock_server_thin.rb', line 40

def initialize(app, opts = {}, &block)
  @app = app
  options = config.to_hash.merge!(opts)
  puts "SERVER OPTIONS: %s" % options.inspect
  @port = options[:port]
  @timeout = options[:timeout]
  @host = options[:host]
end

Class Attribute Details

.configObject

Returns the value of attribute config.



11
12
13
# File 'lib/mock_server_thin.rb', line 11

def config
  @config
end

Class Method Details

.configure {|config| ... } ⇒ Object

Yields:



28
29
30
# File 'lib/mock_server_thin.rb', line 28

def self.configure
  yield(config)
end

Instance Method Details

#configObject



36
37
38
# File 'lib/mock_server_thin.rb', line 36

def config
  self.class.config
end

#startObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/mock_server_thin.rb', line 49

def start
  Thread.new do
    with_quiet_logger do |logger|
      Rack::Handler::Thin.run(@app, :Port => @port, :Logger => logger, :AccessLog => [])
    end
  end

  wait_for_service(@host, @port)

  self
end