Class: QUnited::Server

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

Constant Summary collapse

DEFAULT_PORT =
3040
ASSETS_PATH =
File.expand_path('../server', __FILE__)
SOURCE_FILE_PREFIX =
'qunited-source-file'
TEST_FILE_PREFIX =
'qunited-test-file'
QUNITED_ASSET_FILE_PREFIX =
'qunited-asset'
COFFEESCRIPT_EXTENSIONS =
['coffee', 'cs']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Server

Returns a new instance of Server.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/qunited/server.rb', line 21

def initialize(opts={})
  @source_files = opts[:source_files]
  @test_files = opts[:test_files]
  @fixture_files = opts[:fixture_files]
  @port = opts[:port] || DEFAULT_PORT

  server_options = {
    :Port => @port
  }

  unless opts[:verbose]
    server_options[:AccessLog] = []

    dev_null = '/dev/null'
    if File.exist?(dev_null) && File.writable?(dev_null)
      server_options[:Logger] = WEBrick::Log.new(dev_null)
    end
  end

  @server = create_server(server_options)
end

Instance Attribute Details

#fixture_filesObject

Returns the value of attribute fixture_files.



19
20
21
# File 'lib/qunited/server.rb', line 19

def fixture_files
  @fixture_files
end

#source_filesObject

Returns the value of attribute source_files.



19
20
21
# File 'lib/qunited/server.rb', line 19

def source_files
  @source_files
end

#test_filesObject

Returns the value of attribute test_files.



19
20
21
# File 'lib/qunited/server.rb', line 19

def test_files
  @test_files
end

Instance Method Details

#startObject



43
44
45
46
47
48
49
50
# File 'lib/qunited/server.rb', line 43

def start
  ['INT', 'TERM'].each do |signal|
    trap(signal) { @server.shutdown }
  end

  $stderr.puts "Serving QUnit test suite on port #{@port}\nCtrl-C to shutdown"
  @server.start
end