Sha256: fde4406c41e2d1a606ea3b6cc2e54f453c51fe3be4140b8a74e99cb079d82227

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

require 'guard'
require 'guard/guard'

require 'jekyll'

module Guard
  class Jekyll < Guard
    def initialize(watchers = [], options = {})
      defaults = {
        :source => './',
        :destination => './_site',
        :config => ['_config.yml'],
      }

      super(watchers, defaults.merge(options))
    end

    def start
      UI.info 'Guard::Jekyll is watching for file changes'
      rebuild
    end

    def run_all
      rebuild
    end

    def run_on_changes(paths)
      rebuild
    end

    private

    # rebuilds the entire jekyll site
    #
    def rebuild
      UI.info 'Guard::Jekyll regenerating'

      site = ::Jekyll::Site.new(::Jekyll.configuration(options))
      site.process

      UI.info 'Guard::Jekyll done.'
    rescue Exception => e
      UI.error "Guard::Jekyll failed: #{e}"
      throw :task_has_failed
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
guard-jekyll-1.3.0 lib/guard/jekyll.rb