Update Jekyll.configuration to convert symbol keys

Because Commander uses symbol keys in the options hash and I don't want to go
back backport every hash string key to symbols in Jekyll. 
This commit is contained in:
Tom Bell 2012-12-18 21:55:00 +00:00
parent 5b2e95b443
commit bd1c8fe760
4 changed files with 17 additions and 19 deletions

View File

@ -28,7 +28,7 @@ command :build do |c|
c.description = 'Build your site with the option of auto-renegeration'
c.option '-w', '--watch', 'Watch for changes and rebuild'
c.action do |args, options|
Jekyll::BuildCommand.process(options)
Jekyll::BuildCommand.process(options.__hash__)
end
end
@ -55,7 +55,7 @@ command :serve do |c|
:baseurl => '/',
:serving => true
Jekyll::BuildCommand.process(options)
Jekyll::ServeCommand.process(options)
Jekyll::BuildCommand.process(options.__hash__)
Jekyll::ServeCommand.process(options.__hash__)
end
end

View File

@ -123,6 +123,9 @@ module Jekyll
#
# Returns the final configuration Hash.
def self.configuration(override)
# Convert any symbol keys to strings and remove the old key/values
override.keys.each { |k| override[k.to_s] = override.delete(k) }
# _config.yml may override default source location, but until
# then, we need to know where to look for _config.yml
source = override['source'] || Jekyll::DEFAULTS['source']

View File

@ -2,21 +2,16 @@ module Jekyll
class BuildCommand < Command
def self.process(options)
opts = {}
options.__hash__.map do |k,v|
opts[k.to_s] = v
end
options = Jekyll.configuration(options)
site = Jekyll::Site.new(options)
opts = Jekyll.configuration(opts)
site = Jekyll::Site.new(opts)
source = options['source']
destination = options['destination']
source = opts['source']
destination = opts['destination']
if opts['watch']
self.watch(site, opts)
if options['watch']
self.watch(site, options)
else
self.build(site, opts)
self.build(site, options)
end
end

View File

@ -5,7 +5,7 @@ module Jekyll
require 'webrick'
include WEBrick
destination = options.destination
destination = options['destination']
FileUtils.mkdir_p(destination)
@ -13,12 +13,12 @@ module Jekyll
mime_types.store 'js', 'application/javascript'
s = HTTPServer.new(
:Port => options.port,
:BindAddress => options.host,
:Port => options['port'],
:BindAddress => options['host'],
:MimeTypes => mime_types
)
s.mount(options.baseurl, HTTPServlet::FileHandler, destination)
s.mount(options['baseurl'], HTTPServlet::FileHandler, destination)
t = Thread.new { s.start }
trap("INT") { s.shutdown }
t.join()