Sha256: 40e21fb0ef69f8bc11f89d46f8467ca05ab2a768f633d8ccd3c2753aab8e067c

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require "http"

require "whatweb/version"
require "whatweb/errors"

require "whatweb/helper"
using WhatWeb::Helper

require "whatweb/target"
require "whatweb/matcher"
require "whatweb/plugin"
require "whatweb/cli"

require "thread/pool"

module WhatWeb
  def self.execute_plugins(url, options = {})
    user_agent = options[:user_agent] || "WhatWeb/#{VERSION}"
    is_aggressive = options[:is_aggressive] || false
    max_threads = options[:max_threads] || 10

    plugins = PluginManager.instance.load_plugins
    target = Target.new(url, user_agent: user_agent)

    pool = Thread.pool(max_threads)
    results = {}
    plugins.each do |name, plugin|
      pool.process do
        result = plugin.execute(target, is_aggressive)
        results[name] = result unless result.empty?
      end
    end
    pool.shutdown
    results
  end

  def self.plugin_names
    plugins = PluginManager.instance.load_plugins
    plugins.map do |name, plugin|
      {
        name: name,
        author: plugin.author.encode("UTF-8"),
        description: plugin.description.encode("UTF-8"),
        website: plugin.website,
        version: plugin.version
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_whatweb-0.4.1 lib/whatweb.rb
simple_whatweb-0.4.0 lib/whatweb.rb