lib/hx/cli.rb in hx-0.13.0 vs lib/hx/cli.rb in hx-0.14.0
- old
+ new
@@ -105,13 +105,11 @@
base_url = "http://localhost:#{real_port}/"
server.logger.info "Serving on #{base_url}"
# reload the site/config, folding in the new base URL
config_file = site.options[:config_file]
- raw_config = File.open(config_file, 'r') { |s| YAML.load(s) }
- (raw_config['options'] ||= {})['base_url'] = base_url
- site = Hx::Site.load_raw(raw_config, config_file)
+ site = Hx::Site.load_file(config_file, :base_url => base_url)
app = Hx::Rack::Application.new(site, site.options)
server.mount('/', ::Rack::Handler::WEBrick, app)
%w(INT TERM).each { |s| trap(s) { server.shutdown } }
server.start
@@ -125,20 +123,22 @@
do_gen(site, true)
end
def self.do_gen(site, update_only)
output_dir = Hx.get_pathname(site.options, :output_dir)
- site.each_entry(Path::ALL) do |path, entry|
- pathname = output_dir + path
- content = entry['content']
- if update_only
- update_time = entry['updated']
- else
- update_time = nil
+ Hx.cache_scope do
+ site.each_entry(Path::ALL) do |path, entry|
+ pathname = output_dir + path
+ content = entry['content']
+ if update_only
+ update_time = entry['updated']
+ else
+ update_time = nil
+ end
+ written = Hx.refresh_file(pathname, content, update_time,
+ entry['executable'])
+ puts "===> #{path}" if written
end
- written = Hx.refresh_file(pathname, content, update_time,
- entry['executable'])
- puts "===> #{path}" if written
end
end
def self.cmd_editup(site, entry_spec)
cmd_edit(site, entry_spec)