Sha256: addb33d2d7fc2dd0d61763b05ad2332c1c270b9a8ac4595a15d8aa820c21288a

Contents?: true

Size: 980 Bytes

Versions: 1

Compression:

Stored size: 980 Bytes

Contents

# encoding: UTF-8

require 'pathname'

require 'jekyll'

require 'guard/compat/plugin'

require 'guard/jekyll_plus/server'
require 'guard/jekyll_plus/config'
require 'guard/jekyll_plus/builder'

module Guard
  class JekyllPlus < Plugin
    def initialize(options = {})
      super

      @config = Config.new(options)
      @server = Server.new(@config)
      @builder = Builder.new(@config)
    end

    def start
      @builder.build
      @server.start if @config.serve?
      @config.info 'watching'
    end

    def reload
      stop
      @config.info 'Reloading Jekyll configuration!'
      @config.reload
      @builder.reload
      start
    end

    def stop
      @server.stop
    end

    def run_on_modifications(paths)
      reload if paths.any? { |f| @config.config_file?(f) }
      @builder.modified(paths)
    end

    def run_on_additions(paths)
      @builder.added(paths)
    end

    def run_on_removals(paths)
      @builder.removed(paths)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
guard-jekyll-plus-2.0.1 lib/guard/jekyll_plus.rb