Class: GitObjectBrowser::Server::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/git-object-browser/server/main.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Main

Returns a new instance of Main.



9
10
11
# File 'lib/git-object-browser/server/main.rb', line 9

def initialize(target)
  @target = target
end

Class Method Details

.execute(target, host, port) ⇒ Object



25
26
27
# File 'lib/git-object-browser/server/main.rb', line 25

def self.execute(target, host, port)
  self.new(target).start(host, port)
end

Instance Method Details

#start(host, port) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/git-object-browser/server/main.rb', line 13

def start(host, port)
  root = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
  root = File.expand_path(File.join(root, "htdocs"))
  opts = { :BindAddress => host, :Port => port, :DocumentRoot => root }
  server = WEBrick::HTTPServer.new(opts)
  server.mount('/json', GitServlet, @target)
  trap 'INT' do
    server.shutdown
  end
  server.start
end