<commit_before>module Imagine
  class Config
    attr_accessor :orm, :plugins, :default_plugin, :engines

    def initialize(options={}, &block)
      self.orm  = options.delete(:orm)
      self.plugins  = options.delete(:plugins)
      self.default_plugin = options.delete(:default_plugin)
      self.engines = []
      instance_eval &block if block_given?
    end

    def orm(orm=nil)
      @orm = orm if orm
      @orm ||= :active_record
    end

    def plugins(plugins=nil)
      @plugins = plugins if plugins
      @plugins ||= load_all_plugins
    end

    def default_plugin(default_plugin=nil)
      @default_plugin = default_plugin if default_plugin
      @default_plugin ||= load_default_plugin
    end

    private

      def load_all_plugins
        plugin_path = File.expand_path('../../../plugins/', __FILE__)
        Dir.entries(plugin_path).sort.each.inject([]) do |plugins, dir|<commit_msg>[Orm] defaults to mongoid when ActiveRecord::Base is not around<commit_after>module Imagine
  class Config
    attr_accessor :orm, :plugins, :default_plugin, :engines

    def initialize(options={}, &block)
      self.orm  = options.delete(:orm)
      self.plugins  = options.delete(:plugins)
      self.default_plugin = options.delete(:default_plugin)
      self.engines = []
      instance_eval &block if block_given?
    end

    def orm(orm=nil)
      @orm = orm if orm
      @orm ||= (defined?(Mongoid) && ! defined?(ActiveRecord::Base)) ? :mongoid : :active_record
    end

    def plugins(plugins=nil)
      @plugins = plugins if plugins
      @plugins ||= load_all_plugins
    end

    def default_plugin(default_plugin=nil)
      @default_plugin = default_plugin if default_plugin
      @default_plugin ||= load_default_plugin
    end

    private

      def load_all_plugins
        plugin_path = File.expand_path('../../../plugins/', __FILE__)
        Dir.entries(plugin_path).sort.each.inject([]) do |plugins, dir|
{'fraction_non_alphanumeric': 0.11266149870801033, 'fraction_numerical': 0.0, 'mean_word_length': 3.033333333333333, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5071529', 'n_tokens_mistral': 593, 'n_tokens_neox': 578, 'n_words': 132}