Class: Docter::Server
- Inherits:
-
Object
- Object
- Docter::Server
- Defined in:
- lib/docter/server.rb
Constant Summary collapse
- PORT =
3000
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#options ⇒ Object
Returns the value of attribute options.
-
#port ⇒ Object
Returns the value of attribute port.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(collection, template, *args) ⇒ Server
constructor
A new instance of Server.
- #start(wait = true) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(collection, template, *args) ⇒ Server
Returns a new instance of Server.
72 73 74 75 76 77 |
# File 'lib/docter/server.rb', line 72 def initialize(collection, template, *args) @collection, @template = collection, template @options = Hash === args.last ? args.pop.clone : {} args.each { |arg| @options[arg.to_sym] = true } @port = @options[:port] || PORT end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
69 70 71 |
# File 'lib/docter/server.rb', line 69 def collection @collection end |
#options ⇒ Object
Returns the value of attribute options.
70 71 72 |
# File 'lib/docter/server.rb', line 70 def @options end |
#port ⇒ Object
Returns the value of attribute port.
70 71 72 |
# File 'lib/docter/server.rb', line 70 def port @port end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
69 70 71 |
# File 'lib/docter/server.rb', line 69 def template @template end |
Instance Method Details
#start(wait = true) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/docter/server.rb', line 79 def start(wait = true) puts "Starting Mongrel on port #{port}" @mongrel = Mongrel::HttpServer.new("0.0.0.0", port, 4) @mongrel.register("/", MongrelHandler.new(collection, template, )) if wait @mongrel.run.join rescue nil else @mongrel.run end end |
#stop ⇒ Object
90 91 92 93 |
# File 'lib/docter/server.rb', line 90 def stop() puts "Stopping Mongrel" @mongrel.stop if @mongrel end |