Class: JsTestCore::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/js_test_core/server.rb

Direct Known Subclasses

RailsServer

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec_root_path, implementation_root_path, public_path, host = DEFAULT_HOST, port = DEFAULT_PORT) ⇒ Server

Returns a new instance of Server.



24
25
26
27
28
29
30
31
# File 'lib/js_test_core/server.rb', line 24

def initialize(spec_root_path, implementation_root_path, public_path, host=DEFAULT_HOST, port=DEFAULT_PORT)
  dir = ::File.dirname(__FILE__)
  @spec_root_path = ::File.expand_path(spec_root_path)
  @implementation_root_path = ::File.expand_path(implementation_root_path)
  @public_path = ::File.expand_path(public_path)
  @host = host
  @port = port
end

Class Attribute Details

.instanceObject

Returns the value of attribute instance.



4
5
6
# File 'lib/js_test_core/server.rb', line 4

def instance
  @instance
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



22
23
24
# File 'lib/js_test_core/server.rb', line 22

def host
  @host
end

#implementation_root_pathObject (readonly)

Returns the value of attribute implementation_root_path.



22
23
24
# File 'lib/js_test_core/server.rb', line 22

def implementation_root_path
  @implementation_root_path
end

#portObject (readonly)

Returns the value of attribute port.



22
23
24
# File 'lib/js_test_core/server.rb', line 22

def port
  @port
end

#public_pathObject (readonly)

Returns the value of attribute public_path.



22
23
24
# File 'lib/js_test_core/server.rb', line 22

def public_path
  @public_path
end

#spec_root_pathObject (readonly)

Returns the value of attribute spec_root_path.



22
23
24
# File 'lib/js_test_core/server.rb', line 22

def spec_root_path
  @spec_root_path
end

Class Method Details

.core_pathObject



16
# File 'lib/js_test_core/server.rb', line 16

def core_path; instance.core_path; end

.implementation_root_pathObject



14
# File 'lib/js_test_core/server.rb', line 14

def implementation_root_path; instance.implementation_root_path; end

.public_pathObject



15
# File 'lib/js_test_core/server.rb', line 15

def public_path; instance.public_path; end

.requestObject



17
# File 'lib/js_test_core/server.rb', line 17

def request; instance.request; end

.responseObject



18
# File 'lib/js_test_core/server.rb', line 18

def response; instance.response; end

.root_urlObject



19
# File 'lib/js_test_core/server.rb', line 19

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_test_core/server.rb', line 6

def run(spec_root_path, implementation_root_path, public_path, server_options = {})
  server_options[:Host] ||= DEFAULT_HOST
  server_options[:Port] ||= DEFAULT_PORT
  @instance = new(spec_root_path, implementation_root_path, public_path, server_options[:Host], server_options[:Port])
  instance.run server_options
end

.spec_root_pathObject



13
# File 'lib/js_test_core/server.rb', line 13

def spec_root_path; instance.spec_root_path; end

Instance Method Details

#core_pathObject



46
47
48
# File 'lib/js_test_core/server.rb', line 46

def core_path
  JsTestCore.core_path
end

#root_urlObject



42
43
44
# File 'lib/js_test_core/server.rb', line 42

def root_url
  "http://#{host}:#{port}"
end

#run(options) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/js_test_core/server.rb', line 33

def run(options)
  server = ::Thin::Server.new(options[:Host], options[:Port]) do
    use Rack::CommonLogger
  end
  server.backend = ::Thin::Backends::JsTestCoreServer.new(options[:Host], options[:Port])
  server.backend.server = server
  server.start!
end