Sha256: 3b79aeca090e0bb9dc15cb9a1110e9db5fcfe37fbdbb99d5884bd3a89781c699

Contents?: true

Size: 750 Bytes

Versions: 11

Compression:

Stored size: 750 Bytes

Contents

require "zabbix-ruby-client"

module ZabbixRubyClient
  module Plugins
    extend self

    def scan_dirs(dirs)
      @available = {}
      @loaded = {}
      dirs.each do |d|
        Dir.glob(File.join(d,"*.rb")).reduce(@available) { |a,x|
          name = File.basename(x,".rb")
          a[name] = x
          a
        }
      end
    end

    def loaded
      @loaded ||= {}
    end

    def register(plugin, klass)
      @loaded[plugin] = klass
    end

    def load(plugin)
      if @loaded[plugin]
        true
      else
        if @available[plugin]
          ZabbixRubyClient.send :load, @available[plugin]
        else
          nil
        end
      end
    end

    def reset
      @loaded = {}
      @available = {}
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.1.3 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.1.2 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.1.1 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.1.0 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.0.23 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.0.22 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.0.21 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.0.20 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.0.19 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.0.18 lib/zabbix-ruby-client/plugins.rb
zabbix-ruby-client-0.0.17 lib/zabbix-ruby-client/plugins.rb