Class: Jekyll::Commands::Serve

Inherits:
Jekyll::Command show all
Defined in:
lib/jekyll/commands/serve.rb

Class Method Summary collapse

Methods inherited from Jekyll::Command

globs, process_site

Class Method Details

.process(options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jekyll/commands/serve.rb', line 5

def self.process(options)
  require 'webrick'
  include WEBrick

  destination = options['destination']

  FileUtils.mkdir_p(destination)

  mime_types_file = File.expand_path('../mime.types', File.dirname(__FILE__))
  mime_types = WEBrick::HTTPUtils::load_mime_types(mime_types_file)

  # recreate NondisclosureName under utf-8 circumstance
  fh_option = WEBrick::Config::FileHandler
  fh_option[:NondisclosureName] = ['.ht*','~*']

  s = HTTPServer.new(
    :Port => options['port'],
    :BindAddress => options['host'],
    :MimeTypes => mime_types
  )

  s.mount(options['baseurl'], HTTPServlet::FileHandler, destination, fh_option)
  t = Thread.new { s.start }
  trap("INT") { s.shutdown }
  t.join()
end