class Servethis2::Server

Attributes

options[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/servethis2/server.rb, line 8
def initialize(options = {})
  @options = options
  prepare
end

Public Instance Methods

prepare() click to toggle source
# File lib/servethis2/server.rb, line 13
def prepare
  doc_root = options[:DocumentRoot].gsub(::File::ALT_SEPARATOR, ::File::SEPARATOR)
  puts "Working with #{doc_root}"
  puts "Warning! Path does not exist!" unless Dir.exists? doc_root

  builder = Rack::Builder.new do
    use Rack::CommonLogger
    use Rack::ShowExceptions
    use Rack::Nocache

    run Rack::File.new(doc_root)
  end

  options[:app] = builder
end
start() click to toggle source
# File lib/servethis2/server.rb, line 30
def start
  Rack::Server.start(options)
end