<commit_before>require 'yaml'

class Jobim::Settings

  attr_reader :options

  def initialize(run_load=true)
    load if run_load
  end

  def options
    @options ||= {
      :Daemonize => false,
      :Dir => Dir.pwd,
      :Host => '0.0.0.0',
      :Port => 3000,
      :Prefix => '/',
      :Quiet => false
    }
  end

  def load_file(file)
    opts = YAML.load_file(file)
    opts.keys.each do |key|
      opts[(key.to_s.capitalize.to_sym rescue key) || key] = opts.delete(key)
    end

    if opts[:Dir]
      unless Pathname.new(opts[:Dir]).absolute?
        opts[:Dir] = File.expand_path("../#{opts[:Dir]}", file)
      end
    end

    options.merge!(opts)
  end

  def load
    dir = Pathname('.').realpath
    files = []

    loop do
      file = File.expand_path('.jobim.yml', dir)
      if File.exists? file
        files.unshift(file)
      else
        file = File.expand_path('.jobim.yaml', dir)
        files.unshift(file) if File.exists? file
      end

      break if dir.root?

      dir = dir.parent
    end

    files.each {|file| self.load_file(file)}

    options
  end

end
<commit_msg>Changing Pathanme call due to FakeFS useage<commit_after>require 'yaml'

class Jobim::Settings

  attr_reader :options

  def initialize(run_load=true)
    load if run_load
  end

  def options
    @options ||= {
      :Daemonize => false,
      :Dir => Dir.pwd,
      :Host => '0.0.0.0',
      :Port => 3000,
      :Prefix => '/',
      :Quiet => false
    }
  end

  def load_file(file)
    opts = YAML.load_file(file)
    opts.keys.each do |key|
      opts[(key.to_s.capitalize.to_sym rescue key) || key] = opts.delete(key)
    end

    if opts[:Dir]
      unless Pathname.new(opts[:Dir]).absolute?
        opts[:Dir] = File.expand_path("../#{opts[:Dir]}", file)
      end
    end

    options.merge!(opts)
  end

  def load
    dir = Pathname(Dir.pwd)
    files = []

    loop do
      file = File.expand_path('.jobim.yml', dir)
      if File.exists? file
        files.unshift(file)
      else
        file = File.expand_path('.jobim.yaml', dir)
        files.unshift(file) if File.exists? file
      end

      break if dir.root?

      dir = dir.parent
    end

    files.each {|file| self.load_file(file)}

    options
  end

end

{'fraction_non_alphanumeric': 0.13727232341181697, 'fraction_numerical': 0.007107952021323856, 'mean_word_length': 2.1452513966480447, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1962876', 'n_tokens_mistral': 820, 'n_tokens_neox': 783, 'n_words': 178}