module JMV

Constants

VERSION

Public Class Methods

start(options) click to toggle source
# File lib/jmv.rb, line 49
def self.start(options)
  source = File.expand_path(options[:source] || '')
  puts "\n         Source: #{source}"
  metadata_file = File.join(source, '.jekyll-metadata') 

  if File.exist?(metadata_file) && !File.directory?(metadata_file)
    puts "  Metadata file: #{metadata_file}"
    puts ''
    puts '  Processing..'
  else
    puts "  Error: Could not find the '.jekyll-metadata' file at source. Aborting.."
    puts '         Build or serve a Jekyll source either with `--incremental` CLI option or'
    puts '         with `incremental: true` config setting to generate the metadata file.'
    return
  end

  server = WEBrick::HTTPServer.new(
    :Port         => options[:port] || 3000,
    :Logger       => WEBrick::Log.new($stdout, WEBrick::Log::WARN),
    :AccessLog    => [],
    :ResourcePath => metadata_file
  )
  server.mount('/', Servlet)
  trap('INT') do
    puts '  Shutting down server..'
    puts ''
    server.shutdown
  end
  puts '  Starting server..'
  puts "  Server mounted at http://localhost:#{server.config[:Port]}."
  puts ''
  server.start
end