Class: Jasmine::Server
- Inherits:
-
Object
- Object
- Jasmine::Server
- Defined in:
- lib/jasmine/server.rb
Instance Attribute Summary collapse
-
#thin ⇒ Object
readonly
Returns the value of attribute thin.
Instance Method Summary collapse
-
#initialize(port, config) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(port, config) ⇒ Server
Returns a new instance of Server.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/jasmine/server.rb', line 92 def initialize(port, config) @port = port @config = config require 'thin' thin_config = { '/__suite__' => Jasmine::FocusedSuite.new(@config), '/run.html' => Jasmine::Redirect.new('/'), '/' => Jasmine::RunAdapter.new(@config) } @config.mappings.each do |from, to| thin_config[from] = Rack::File.new(to) end thin_config["/__JASMINE_ROOT__"] = Rack::File.new(Jasmine.root) app = Rack::Cascade.new([ Rack::URLMap.new(thin_config), JsAlert.new ]) @thin = Thin::Server.new('0.0.0.0', @port, app) end |
Instance Attribute Details
#thin ⇒ Object (readonly)
Returns the value of attribute thin.
90 91 92 |
# File 'lib/jasmine/server.rb', line 90 def thin @thin end |
Instance Method Details
#start ⇒ Object
117 118 119 120 121 122 123 124 |
# File 'lib/jasmine/server.rb', line 117 def start begin thin.start rescue RuntimeError => e raise e unless e. == 'no acceptor' raise RuntimeError.new("A server is already running on port #{@port}") end end |
#stop ⇒ Object
126 127 128 |
# File 'lib/jasmine/server.rb', line 126 def stop thin.stop end |