Sha256: 2ca94151e6524effa17961fd87d23a7cdb085f296f24555194a8e03b51888bba

Contents?: true

Size: 720 Bytes

Versions: 1

Compression:

Stored size: 720 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.0.16 lib/zabbix-ruby-client/plugins.rb