<commit_before>require "thor"
require "open3"
require "fileutils"
require "yaml"

class Hash
  def find_and_replace!(find, replace)
    self.each do |key, value|
      if value.instance_of? Hash
        value.find_and_replace! find, replace
      else
        if value.instance_of? String
          value.gsub!(/#{find}/, replace)
        elsif value.instance_of? Array
          value.map! do |child_val|
            if value.instance_of? String
              value.gsub!(/#{find}/, replace)
            elsif value.instance_of? Hash
              value.find_and_replace! find, replace
            end
          end
        end
      end
    end
  end
end

module WordpressDeploy
  ##
  # WordpressDeploy's internal paths<commit_msg>Added recursive replace<commit_after>require "thor"
require "open3"
require "fileutils"
require "yaml"

class Hash

  def find_and_replace!(find, replace)
    RecursiveReplace.find_and_replace!(find, replace, self) 
  end

end

class RecursiveReplace

  def self.find_and_replace!(find, replace, obj)
    m = "find_and_replace_#{obj.class}!"
    send(m, find, replace, obj) if respond_to? m, true
  end

  private

  def self.find_and_replace_Hash!(find, replace, hash)
    hash.each { |k,v| find_and_replace!(find, replace, v) }
  end

  def self.find_and_replace_Array!(find, replace, arr)
    arr.each { |x| find_and_replace!(find, replace, x) }
  end

  def self.find_and_replace_String!(find, replace, str)
    str.gsub!(/#{find}/, replace)
  end

end

module WordpressDeploy
  ##
  # WordpressDeploy's internal paths
{'fraction_non_alphanumeric': 0.10154241645244216, 'fraction_numerical': 0.0012853470437017994, 'mean_word_length': 3.0232558139534884, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3183894', 'n_tokens_mistral': 520, 'n_tokens_neox': 508, 'n_words': 128}