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.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/jasmine/server.rb', line 86 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({'/' => Rack::File.new(@config.src_dir)}), 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.
84 85 86 |
# File 'lib/jasmine/server.rb', line 84 def thin @thin end |
Instance Method Details
#start ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/jasmine/server.rb', line 112 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
121 122 123 |
# File 'lib/jasmine/server.rb', line 121 def stop thin.stop end |