Sha256: adf011604650d57a07e7e21c5b08fa907c3a146a2b2881dbca6dafabfc5dfc7a

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require "sequel"

require_relative "tobox/version"

require "mutex_m"

module Tobox
  class Error < StandardError; end

  EMPTY = [].freeze

  module Plugins
    @plugins = {}
    @plugins.extend(Mutex_m)

    # Loads a plugin based on a name. If the plugin hasn't been loaded, tries to load
    # it from the load path under "httpx/plugins/" directory.
    #
    def self.load_plugin(name)
      h = @plugins
      unless (plugin = h.synchronize { h[name] })
        require "tobox/plugins/#{name}"
        raise "Plugin #{name} hasn't been registered" unless (plugin = h.synchronize { h[name] })
      end
      plugin
    end

    # Registers a plugin (+mod+) in the central store indexed by +name+.
    #
    def self.register_plugin(name, mod)
      h = @plugins
      h.synchronize { h[name] = mod }
    end
  end
end

require_relative "tobox/fetcher"
require_relative "tobox/worker"
require_relative "tobox/pool"
require_relative "tobox/application"
require_relative "tobox/configuration"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tobox-0.5.2 lib/tobox.rb
tobox-0.5.1 lib/tobox.rb
tobox-0.5.0 lib/tobox.rb