Class: ExportHTTP

Inherits:
WEBrick::HTTPServer
  • Object
show all
Defined in:
lib/export_http.rb

Class Method Summary collapse

Class Method Details

.killObject



17
18
19
# File 'lib/export_http.rb', line 17

def self.kill
  @server.stop
end

.runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/export_http.rb', line 3

def self.run
  dir = Dir.pwd
  port = (dir.hash % 1000) + 6000
  host = `hostname`
  host = '0.0.0.0' if host == ''
  @server = self.new(
    :DocumentRoot => dir,
    :Port => port,
    :Host => host)
  trap("INT") {self.kill}
  puts "Sharing #{File.expand_path(dir)} on http://#{host}:#{port}/"
  @server.start
end