<commit_before>class Fabrication::Support

  class << self

    def fabricatable?(name)
      Fabrication::Fabricator.schematics.include?(name) || class_for(name)
    end

    def class_for(class_or_to_s)
      if class_or_to_s.respond_to?(:to_sym)
        class_name = variable_name_to_class_name(class_or_to_s)
        class_name.split('::').inject(Object) do |object, string|
          object.const_get(string)
        end
      else
        class_or_to_s
      end
    rescue NameError
    end

    def variable_name_to_class_name(name)
      name.to_s.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase}
    end

    def find_definitions
      base_path = defined?(Rails) ? Rails.root : "."
      ['test', 'spec'].map do |folder|
        path = File.expand_path(File.join(base_path, folder, 'fabricators'))

        load("#{path}.rb") if File.exists?("#{path}.rb")<commit_msg>Unnecessary use of map<commit_after>class Fabrication::Support

  class << self

    def fabricatable?(name)
      Fabrication::Fabricator.schematics.include?(name) || class_for(name)
    end

    def class_for(class_or_to_s)
      if class_or_to_s.respond_to?(:to_sym)
        class_name = variable_name_to_class_name(class_or_to_s)
        class_name.split('::').inject(Object) do |object, string|
          object.const_get(string)
        end
      else
        class_or_to_s
      end
    rescue NameError
    end

    def variable_name_to_class_name(name)
      name.to_s.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase}
    end

    def find_definitions
      base_path = defined?(Rails) ? Rails.root : "."
      ['test', 'spec'].each do |folder|
        path = File.expand_path(File.join(base_path, folder, 'fabricators'))

        load("#{path}.rb") if File.exists?("#{path}.rb")
{'fraction_non_alphanumeric': 0.15496098104793757, 'fraction_numerical': 0.002229654403567447, 'mean_word_length': 3.024663677130045, 'pattern_counts': {'":': 2, '<': 7, '<?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': '2236164', 'n_tokens_mistral': 651, 'n_tokens_neox': 632, 'n_words': 96}