<commit_before>require 'guard'
require 'guard/guard'

require 'jekyll'

module Guard
  class Jekyll < Guard

    VERSION = '0.2.0'

    def initialize(watchers=[], options={})
      super
      @working_path = File.expand_path(File.dirname("."))
    end

    def start
      UI.info "Guard::Jekyll is watching for file changes..."
      run_all
      true
    end

    def run_all
      jekyll!
    end

    def run_on_changes(paths)
      jekyll!
    end

    def reload
      jekyll!
    end

    private

    def jekyll!
      UI.info "Guard::Jekyll running."

      create_site
      @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
      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<commit_msg>Allows passing in an alternate source directory<commit_after>require 'guard'
require 'guard/guard'

require 'jekyll'

module Guard
  class Jekyll < Guard

    VERSION = '0.2.0'

    def initialize(watchers=[], options={})
      super
      @working_path = File.expand_path(options[:source]  || 
                                       options['source'] || 
                                       File.dirname("."))
    end

    def start
      UI.info "Guard::Jekyll is watching for file changes..."
      run_all
      true
    end

    def run_all
      jekyll!
    end

    def run_on_changes(paths)
      jekyll!
    end

    def reload
      jekyll!
    end

    private

    def jekyll!
      UI.info "Guard::Jekyll running."

      create_site
      @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
      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
{'fraction_non_alphanumeric': 0.11205501618122977, 'fraction_numerical': 0.0024271844660194173, 'mean_word_length': 2.2200520833333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '765908', 'n_tokens_mistral': 798, 'n_tokens_neox': 757, 'n_words': 183}