<commit_before>require 'yaml'
require 'pp'
# Defaults datasource for Tiller.

class ::Hash
  def deep_merge!(second)
    merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
    self.merge!(second, &merger)
  end
end


class DefaultsDataSource < Tiller::DataSource
  # Open and parse the environment file
  def setup
    defaults_file = File.join(@config[:tiller_base], 'defaults.yaml')
    defaults_dir  = File.join(@config[:tiller_base], 'defaults.d')
    @defaults_hash = Hash.new

    # Read defaults in from defaults file
    if File.file? defaults_file
      @defaults_hash.deep_merge!(YAML.load(open(defaults_file)))
    end

    # If we have YAML files in defaults.d, also merge them<commit_msg>Quick tidyup<commit_after>require 'yaml'
# Defaults datasource for Tiller.

# Thanks, StackOverflow ;)
class ::Hash
  def deep_merge!(second)
    merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
    self.merge!(second, &merger)
  end
end


class DefaultsDataSource < Tiller::DataSource
  def setup
    defaults_file = File.join(@config[:tiller_base], 'defaults.yaml')
    defaults_dir  = File.join(@config[:tiller_base], 'defaults.d')
    @defaults_hash = Hash.new

    # Read defaults in from defaults file
    if File.file? defaults_file
      @defaults_hash.deep_merge!(YAML.load(open(defaults_file)))
    end

    # If we have YAML files in defaults.d, also merge them
{'fraction_non_alphanumeric': 0.1320754716981132, 'fraction_numerical': 0.011711125569290826, 'mean_word_length': 3.945337620578778, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3367187', 'n_tokens_mistral': 526, 'n_tokens_neox': 513, 'n_words': 138}