Class: Onering::Reporter::PluginDelegate

Inherits:
Object
  • Object
show all
Defined in:
lib/onering/plugins/reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(reporter, options = {}) ⇒ PluginDelegate

Returns a new instance of PluginDelegate.



30
31
32
33
34
35
36
# File 'lib/onering/plugins/reporter.rb', line 30

def initialize(reporter, options={})
  @_name = options.get(:plugin)
  @_path = options.get(:path)

  Onering::Logger.debug3("Creating plugin delegate for plugin #{@_name}", "Onering::Reporter::PluginDelegate")
  @_reporter = reporter
end

Instance Method Details

#get_bindingObject



38
39
40
# File 'lib/onering/plugins/reporter.rb', line 38

def get_binding()
  return binding()
end

#property(name, value = nil) ⇒ Object



55
56
57
# File 'lib/onering/plugins/reporter.rb', line 55

def property(name, value=nil)
  @_reporter.property(name, value)
end

#report(&block) ⇒ Object

DSL methods




44
45
46
47
48
49
50
51
52
53
# File 'lib/onering/plugins/reporter.rb', line 44

def report(&block)
  if block_given?
    start = Time.now.to_f
    yield

    finish = (Time.now.to_f - start.to_f)
    finish = (finish.round(4) rescue finish)
    Onering::Logger.debug3("Finished evaluating report for plugin #{@_name}, took #{finish} seconds", "Onering::Reporter::PluginDelegate")
  end
end

#stat(name, value = nil) ⇒ Object



59
60
61
62
63
# File 'lib/onering/plugins/reporter.rb', line 59

def stat(name, value=nil)
  unless value.nil?
    @_reporter.property((['metrics']+name.to_s.split('.')).join('.'), value)
  end
end