<commit_before># encoding: utf-8

module TTY
  # A class responsible for managing plugins installation
  class Plugins
    PLUGIN_PREFIX = 'tty'

    attr_accessor :plugins
    private :plugins

    # Initialize the Plugins
    #
    # @api public
    def initialize
      @plugins = []
    end

    # Load all plugins that are not enabled
    #
    # @api public
    def load
      plugins.each do |plugin|
        plugin.load! unless plugin.enabled?
      end
    end

    # Register plugin with name in internal array
    #
    # @param [String] name
    #
    # @param [TTY::Plugin] plugin
    #
    # @api public
    def register(name, plugin = false)
      if plugin && !loaded?(name)
        plugins << plugin
      end
    end

    # Find all installed TTY plugins and store them
    #
    # @api private
    def find
      Gem.refresh
      Gem::Specification.each do |gem|
        next unless gem.name =~ /^#{PLUGIN_PREFIX}/
        plugin_name = gem.name[/^#{PLUGIN_PREFIX}-(.*)/, 1]
        register(plugin_name, Plugin.new(plugin_name, gem))
      end
      plugins
    end

    # Return a list of all plugin names as strings
    #
    # @api public
    def names
      plugins.each_with_object(Hash.new) do |hash, plugin|
        hash[plugin.name] = plugin
        hash
      end
    end

    private

    # Check if plugin is already loaded
    #
    # @api private
    def loaded?(name)
      plugins.any? { |plugin| plugin.gem_name == name }
    end
  end # PluginManager
end # TTY<commit_msg>Fix regression.<commit_after># encoding: utf-8

module TTY
  # A class responsible for managing plugins installation
  class Plugins
    PLUGIN_PREFIX = 'tty'

    attr_accessor :plugins
    private :plugins

    # Initialize the Plugins
    #
    # @api public
    def initialize
      @plugins = []
    end

    # Load all plugins that are not enabled
    #
    # @api public
    def load
      plugins.each do |plugin|
        plugin.load! unless plugin.enabled?
      end
    end

    # Register plugin with name in internal array
    #
    # @param [String] name
    #
    # @param [TTY::Plugin] plugin
    #
    # @api public
    def register(name, plugin = false)
      if plugin && !loaded?(name)
        plugins << plugin
      end
    end

    # Find all installed TTY plugins and store them
    #
    # @api private
    def find
      Gem.refresh
      Gem::Specification.each do |gem|
        next unless gem.name =~ /^#{PLUGIN_PREFIX}/
        plugin_name = gem.name[/^#{PLUGIN_PREFIX}-(.*)/, 1]
        register(plugin_name, Plugin.new(plugin_name, gem))
      end
      plugins
    end

    # Return a list of all plugin names as strings
    #
    # @api public
    def names
      plugins.reduce({}) do |hash, plugin|
        hash[plugin.name] = plugin
        hash
      end
    end

    private

    # Check if plugin is already loaded
    #
    # @api private
    def loaded?(name)
      plugins.any? { |plugin| plugin.gem_name == name }
    end
  end # PluginManager
end # TTY
{'fraction_non_alphanumeric': 0.08982035928143713, 'fraction_numerical': 0.0013306719893546241, 'mean_word_length': 2.0251509054325956, 'pattern_counts': {'":': 0, '<': 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': '6467037', 'n_tokens_mistral': 918, 'n_tokens_neox': 904, 'n_words': 290}