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

require 'haml'

module Guard
  class Haml < Guard
    
    def initialize(watchers = [], options = {})
      super(watchers, {
        :notifications => true      
      }.merge(options))
      @watchers, @options = watchers, options
      @haml_options = options.delete(:haml_options) || {}
    end
    
    def compile_haml file
      content = File.new(file).read
      engine = ::Haml::Engine.new(content, @haml_options)
      engine.render
    end

    # Get the file path to output the html based on the file being
    # built.  The output path is relative to where guard is being run.
    #
    # @param file [String] path to file being built
    # @return [String] path to file where output should be written
    #
    def get_output(file)
      if @options[:output]
        output_folder = File.join(  @options[:output], '..', File.dirname(file) )
        FileUtils.mkdir_p(output_folder)
        file_name = File.basename(file).split('.').first
        File.join(output_folder, file_name + '.html')
      else
        file.split('.')[0..-2].join('.')
      end
    end
    
    def run_all
      run_on_change(Watcher.match_files(self, Dir.glob(File.join('**', '*.*'))))
      #patterns = @watchers.map { |w| w.pattern }
      #files = Dir.glob('**/*.*')
      #paths = files.map do |file|
      #  patterns.map  { |pattern| file if file.match(Regexp.new(pattern)) }
      #end
      #run_on_change(paths.flatten.compact)
    end
  <commit_msg>adding :input option to exclude the input dir from the output<commit_after>require 'guard'
require 'guard/guard'
require 'guard/watcher'

require 'haml'

module Guard
  class Haml < Guard
    
    def initialize(watchers = [], options = {})
      super(watchers, {
        :notifications => true      
      }.merge(options))
      @watchers, @options = watchers, options
      @haml_options = options.delete(:haml_options) || {}
      @input_dir = options.delete(:input)
      @input_dir += '/' if @input_dir && @input_dir[@input_dir.length-1] != '/'
    end
    
    def compile_haml file
      content = File.new(file).read
      engine = ::Haml::Engine.new(content, @haml_options)
      engine.render
    end

    # Get the file path to output the html based on the file being
    # built.  The output path is relative to where guard is being run.
    #
    # @param file [String] path to file being built
    # @return [String] path to file where output should be written
    #
    def get_output(file)
      if @options[:output]
        file_dir = File.dirname(file)
        file_dir = file_dir.sub!(@input_dir, '') if @input_dir
        output_folder = File.join(  @options[:output], file_dir )
        FileUtils.mkdir_p(output_folder)
        file_name = File.basename(file).split('.').first
        File.join(output_folder, file_name + '.html')
      else
        file.split('.')[0..-2].join('.')
      end
    end
    
    def run_all
      run_on_change(Watcher.match_files(self, Dir.glob(File.join('**', '*.*'))))
      #patterns = @watchers.map { |w| w.pattern }
      #files = Dir.glob('**/*.*')
      #paths = files.map do |file|
      #  patterns.map  { |pattern| file if file.match(Regexp.new(pattern)) }
      #end
      #run_on_change(paths.flatten.compact)
    end
  
{'fraction_non_alphanumeric': 0.13528171135884304, 'fraction_numerical': 0.0015064778547755348, 'mean_word_length': 2.5660580021482278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4072851', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1062, 'n_words': 262}