Sha256: 6e76b71fba06371421a82b4a5d1581c3b24c52bedd8a7350a7832910a077cd76
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
# encoding: utf-8 require 'guard' require 'guard/guard' require 'jekyll' module Guard class Jekyll < Guard def initialize(watchers = [], options = {}) super @source = options[:source] || File.dirname('.') end def start UI.info 'Guard::Jekyll is watching for file changes' create_site(@source) end def run_all jekyll! end def run_on_changes(paths) jekyll! end def run_on_additions(paths) jekyll! end def run_on_modifications(paths) jekyll! end def run_on_removals(paths) jekyll! end private def jekyll! UI.info 'Guard::Jekyll running' @jekyll_site.process UI.info 'Guard::Jekyll complete' rescue Exception => e UI.error "Guard::Jekyll failed: #{e}" throw :task_has_failed end def create_site(source) working_path = File.expand_path(source) options = {'source' => working_path} unless File.exists? File.join(working_path, '_config.yml') options['destination'] = File.join(working_path, '_site') options['plugins'] = File.join(working_path, '_plugins') end config = ::Jekyll.configuration(options) @jekyll_site = ::Jekyll::Site.new(config) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
guard-jekyll-1.1.0 | lib/guard/jekyll.rb |