<commit_before>=begin
                  Arachni
  Copyright (c) 2010-2012 Tasos "Zapotek" Laskos <<EMAIL>>

  This is free software; you can copy and distribute and modify
  this program under the term of the GPL v2.0 License
  (See LICENSE file for details)

=end

module Arachni

#
# The namespace under which all plugins exist
#
module Plugins
end

module Plugin

#
# Holds and manages the plugins.
#
# @author: Tasos "Zapotek" Laskos
#                                      <<EMAIL>>
#                                      <<EMAIL>>
# @version: 0.1.1
#
class Manager < Arachni::ComponentManager

    include Arachni::Module::Utilities

    DEFAULT = [
        'defaults/*'
    ]

    #
    # @param    [Arachni::Framework]    framework   framework instance
    #
    def initialize( framework )
        super( framework.opts.dir['plugins'], Arachni::Plugins )
        @framework = framework

        @jobs = []
    end

    def load_defaults!
        load( DEFAULT )
    end

    #
    # Runs each plug-in in its own thread.
    #
    def run
        i = 0
        each {
            |name, plugin|

            if( ret = sane_env?( plugin ) ) != true
                if !ret[:gem_errors].empty?
                    print_error( "[#{name}] The following plug-in dependencies aren't satisfied:" )
                    ret[:gem_errors].each {
                       |gem|
                        print_info( "\t* #{gem}" )
                    }

                    print_info( "Try installing them by running:" )
                    print_info( "\tgem install #{ret[:gem_errors].join( ' ' )}" )
                end

                raise
            end

            @jobs << Thread.new {

                exception_jail( false ) {
                    Thread.current[:name] = name

                    plugin_new = create( name )
                    plugin_new.prepare
                    plugin_new.run
                    plugin_new.clean_up
                }

            }

            i += 1
        }

        if i > 0
            print_status( 'Waiting for plugins to settle...' )
            ::IO::select( nil, nil, nil, 1 )
        end
    end

    def sane_env?( plugin )
        gem_errors = []

        plugin.gems.each {
            |gem|
            begin
                require gem
            rescue Exception => e
                gem_errors << gem
            end
        }

        return {<commit_msg>added current plugin instance to  Thread.current[:instance]<commit_after>=begin
                  Arachni
  Copyright (c) 2010-2012 Tasos "Zapotek" Laskos <<EMAIL>>

  This is free software; you can copy and distribute and modify
  this program under the term of the GPL v2.0 License
  (See LICENSE file for details)

=end

module Arachni

#
# The namespace under which all plugins exist
#
module Plugins
end

module Plugin

#
# Holds and manages the plugins.
#
# @author: Tasos "Zapotek" Laskos
#                                      <<EMAIL>>
#                                      <<EMAIL>>
# @version: 0.1.1
#
class Manager < Arachni::ComponentManager

    include Arachni::Module::Utilities

    DEFAULT = [
        'defaults/*'
    ]

    #
    # @param    [Arachni::Framework]    framework   framework instance
    #
    def initialize( framework )
        super( framework.opts.dir['plugins'], Arachni::Plugins )
        @framework = framework

        @jobs = []
    end

    def load_defaults!
        load( DEFAULT )
    end

    #
    # Runs each plug-in in its own thread.
    #
    def run
        i = 0
        each {
            |name, plugin|

            if( ret = sane_env?( plugin ) ) != true
                if !ret[:gem_errors].empty?
                    print_error( "[#{name}] The following plug-in dependencies aren't satisfied:" )
                    ret[:gem_errors].each {
                       |gem|
                        print_info( "\t* #{gem}" )
                    }

                    print_info( "Try installing them by running:" )
                    print_info( "\tgem install #{ret[:gem_errors].join( ' ' )}" )
                end

                raise
            end

            @jobs << Thread.new {

                exception_jail( false ) {
                    Thread.current[:name] = name

                    Thread.current[:instance] = plugin_new = create( name )
                    plugin_new.prepare
                    plugin_new.run
                    plugin_new.clean_up
                }

            }

            i += 1
        }

        if i > 0
            print_status( 'Waiting for plugins to settle...' )
            ::IO::select( nil, nil, nil, 1 )
        end
    end

    def sane_env?( plugin )
        gem_errors = []

        plugin.gems.each {
            |gem|
            begin
                require gem
            rescue Exception => e
                gem_errors << gem
            end
        }

        return {
{'fraction_non_alphanumeric': 0.09211061407076047, 'fraction_numerical': 0.0069133794225294835, 'mean_word_length': 1.2595314653192466, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7194714', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1283, 'n_words': 372}