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.
92 93 94 95 96 97 |
# File 'lib/docter/server.rb', line 92 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.
89 90 91 |
# File 'lib/docter/server.rb', line 89 def collection @collection end |
#options ⇒ Object
Returns the value of attribute options.
90 91 92 |
# File 'lib/docter/server.rb', line 90 def @options end |
#port ⇒ Object
Returns the value of attribute port.
90 91 92 |
# File 'lib/docter/server.rb', line 90 def port @port end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
89 90 91 |
# File 'lib/docter/server.rb', line 89 def template @template end |
Instance Method Details
#start(wait = true) ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/docter/server.rb', line 99 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
110 111 112 113 |
# File 'lib/docter/server.rb', line 110 def stop puts 'Stopping Mongrel' @mongrel.stop if @mongrel end |