Class: Stack::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(generator) ⇒ Server

Returns a new instance of Server.



8
9
10
11
12
# File 'lib/stack/server.rb', line 8

def initialize(generator)
  self.generator = generator
  self.source = self.generator.source
  self.target = self.generator.target
end

Instance Attribute Details

#generatorObject

Returns the value of attribute generator.



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

def generator
  @generator
end

#http_serverObject

Returns the value of attribute http_server.



5
6
7
# File 'lib/stack/server.rb', line 5

def http_server
  @http_server
end

#sourceObject

Returns the value of attribute source.



3
4
5
# File 'lib/stack/server.rb', line 3

def source
  @source
end

#targetObject

Returns the value of attribute target.



3
4
5
# File 'lib/stack/server.rb', line 3

def target
  @target
end

#threadObject

Returns the value of attribute thread.



6
7
8
# File 'lib/stack/server.rb', line 6

def thread
  @thread
end

Instance Method Details

#observeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/stack/server.rb', line 14

def observe
  self.http_server = WEBrick::HTTPServer.new(
    :Port => Stack::runner.configuration.server_port,
    :DocumentRoot => self.target
  )
  
  self.thread = Thread.new {
    self.http_server.start
  }
  
  trap("INT") { self.http_server.shutdown }
  
  self.thread.join()
end