Sha256: aae83434b99fdfbcb762f8b3231fd2f6089302bb406cf61c75b4365851c69df5

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

module Stack
  class Server
    attr_accessor :source, :target
    attr_accessor :generator
    attr_accessor :http_server
    attr_accessor :thread
    
    def initialize(generator)
      self.generator = generator
      self.source = self.generator.source
      self.target = self.generator.target
    end
    
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stack-0.0.9 lib/stack/server.rb
stack-0.0.8 lib/stack/server.rb