Class: JsSpec::Server
- Inherits:
-
Object
- Object
- JsSpec::Server
- Defined in:
- lib/js_spec/server.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Instance Attribute Summary collapse
-
#core_path ⇒ Object
readonly
Returns the value of attribute core_path.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#implementation_root_path ⇒ Object
readonly
Returns the value of attribute implementation_root_path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#public_path ⇒ Object
readonly
Returns the value of attribute public_path.
-
#spec_root_path ⇒ Object
readonly
Returns the value of attribute spec_root_path.
Class Method Summary collapse
- .connection ⇒ Object
- .core_path ⇒ Object
- .implementation_root_path ⇒ Object
- .public_path ⇒ Object
- .request ⇒ Object
- .response ⇒ Object
- .root_url ⇒ Object
- .run(spec_root_path, implementation_root_path, public_path, server_options = {}) ⇒ Object
- .spec_root_path ⇒ Object
Instance Method Summary collapse
- #call(env) ⇒ Object
- #connection ⇒ Object
-
#initialize(spec_root_path, implementation_root_path, public_path, host = DEFAULT_HOST, port = DEFAULT_PORT) ⇒ Server
constructor
A new instance of Server.
- #request ⇒ Object
- #response ⇒ Object
- #root_url ⇒ Object
- #run(options) ⇒ Object
Constructor Details
#initialize(spec_root_path, implementation_root_path, public_path, host = DEFAULT_HOST, port = DEFAULT_PORT) ⇒ Server
Returns a new instance of Server.
25 26 27 28 29 30 31 32 33 |
# File 'lib/js_spec/server.rb', line 25 def initialize(spec_root_path, implementation_root_path, public_path, host=DEFAULT_HOST, port=DEFAULT_PORT) dir = ::File.dirname(__FILE__) @core_path = ::File.("#{dir}/../../core") @spec_root_path = ::File.(spec_root_path) @implementation_root_path = ::File.(implementation_root_path) @public_path = ::File.(public_path) @host = host @port = port end |
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
4 5 6 |
# File 'lib/js_spec/server.rb', line 4 def instance @instance end |
Instance Attribute Details
#core_path ⇒ Object (readonly)
Returns the value of attribute core_path.
23 24 25 |
# File 'lib/js_spec/server.rb', line 23 def core_path @core_path end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
23 24 25 |
# File 'lib/js_spec/server.rb', line 23 def host @host end |
#implementation_root_path ⇒ Object (readonly)
Returns the value of attribute implementation_root_path.
23 24 25 |
# File 'lib/js_spec/server.rb', line 23 def implementation_root_path @implementation_root_path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
23 24 25 |
# File 'lib/js_spec/server.rb', line 23 def port @port end |
#public_path ⇒ Object (readonly)
Returns the value of attribute public_path.
23 24 25 |
# File 'lib/js_spec/server.rb', line 23 def public_path @public_path end |
#spec_root_path ⇒ Object (readonly)
Returns the value of attribute spec_root_path.
23 24 25 |
# File 'lib/js_spec/server.rb', line 23 def spec_root_path @spec_root_path end |
Class Method Details
.connection ⇒ Object
17 |
# File 'lib/js_spec/server.rb', line 17 def connection; instance.connection; end |
.core_path ⇒ Object
16 |
# File 'lib/js_spec/server.rb', line 16 def core_path; instance.core_path; end |
.implementation_root_path ⇒ Object
14 |
# File 'lib/js_spec/server.rb', line 14 def implementation_root_path; instance.implementation_root_path; end |
.public_path ⇒ Object
15 |
# File 'lib/js_spec/server.rb', line 15 def public_path; instance.public_path; end |
.request ⇒ Object
18 |
# File 'lib/js_spec/server.rb', line 18 def request; instance.request; end |
.response ⇒ Object
19 |
# File 'lib/js_spec/server.rb', line 19 def response; instance.response; end |
.root_url ⇒ Object
20 |
# File 'lib/js_spec/server.rb', line 20 def root_url; instance.root_url; end |
.run(spec_root_path, implementation_root_path, public_path, server_options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/js_spec/server.rb', line 6 def run(spec_root_path, implementation_root_path, public_path, = {}) [:Host] ||= DEFAULT_HOST [:Port] ||= DEFAULT_PORT @instance = new(spec_root_path, implementation_root_path, public_path, [:Host], [:Port]) instance.run end |
.spec_root_path ⇒ Object
13 |
# File 'lib/js_spec/server.rb', line 13 def spec_root_path; instance.spec_root_path; end |
Instance Method Details
#call(env) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/js_spec/server.rb', line 43 def call(env) self.connection = env['js_spec.connection'] self.request = Rack::Request.new(env) self.response = Rack::Response.new method = request.request_method.downcase.to_sym get_resource(request).send(method, request, response) response.finish ensure self.connection = nil self.request = nil self.response = nil end |
#connection ⇒ Object
56 57 58 |
# File 'lib/js_spec/server.rb', line 56 def connection Thread.current[:connection] end |
#request ⇒ Object
60 61 62 |
# File 'lib/js_spec/server.rb', line 60 def request Thread.current[:request] end |
#response ⇒ Object
64 65 66 |
# File 'lib/js_spec/server.rb', line 64 def response Thread.current[:response] end |
#root_url ⇒ Object
68 69 70 |
# File 'lib/js_spec/server.rb', line 68 def root_url "http://#{host}:#{port}" end |
#run(options) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/js_spec/server.rb', line 35 def run() ::Thin::Server.start( ::Thin::Backends::JsSpecServer.new([:Host], [:Port]), [:Port], self ) end |