Module: MetricsInflux::Module

Defined in:
lib/metrics_influx/module.rb

Defined Under Namespace

Classes: Base, GraphiteCLI, ProcLoadavg, ProcMeminfo, ProcStatCpu, ProcStatProcs, ProcVmstat, SysNetStat

Class Method Summary collapse

Class Method Details

.<<(klass) ⇒ Object



9
10
11
12
# File 'lib/metrics_influx/module.rb', line 9

def self.<<(klass)
  key = klass.name.split('::')[-1].downcase
  @modules[key] = klass
end

.[](key) ⇒ Object

Raises:

  • (IndexError)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/metrics_influx/module.rb', line 14

def self.[](key)
  key = key.downcase

  unless @modules.has_key? key
    path = "metrics_influx/module/#{key}"

    spec = Gem::Specification.find_by_path(path)
    unless spec.nil?
      activated = spec.activate
      MetricsInflux.logger.info "Activated gem `#{spec.full_name}`" if activated
    end

    begin
      require path
    rescue LoadError
    end
  end

  raise IndexError, "Unknown module #{key}" unless @modules.has_key? key
  @modules[key]
end