Module: JMV

Defined in:
lib/jmv.rb,
lib/jmv/version.rb

Defined Under Namespace

Classes: Servlet

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.start(options) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/jmv.rb', line 49

def self.start(options)
  source = File.expand_path(options[:source] || '')
  puts "\n         Source: #{source}"
   = File.join(source, '.jekyll-metadata') 

  if File.exist?() && !File.directory?()
    puts "  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 => 
  )
  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