Class: Observed::BuiltinPlugins::File

Inherits:
Reporter
  • Object
show all
Includes:
Reporter::RegexpMatching, Reporter::ReportFormatting
Defined in:
lib/observed/builtin_plugins/file.rb

Constant Summary collapse

UNDEFINED =
Object.new

Instance Method Summary collapse

Methods included from Reporter::ReportFormatting

#format_report

Methods included from Configurable

#configure, #get_attribute_value, #has_attribute_value?, included, #initialize

Methods included from Reporter::RegexpMatching

#match

Methods inherited from Reporter

#match

Methods included from Pluggable

included

Instance Method Details

#report(tag, time, data) ⇒ Object

Parameters:

  • tag (String)
  • time (Time)
  • data (Hash)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/observed/builtin_plugins/file.rb', line 21

def report(tag, time, data)
  formatted_data = format_report(tag, time, data)
  mode = case self.mode
         when :append, 'a'
           'a'
         when :overwrite, 'w'
           'w'
         else
           fail "Unsupported value for the parameter `:mode`: Supported values are :append, :overwrite, " +
                    "'a', 'w'. The specified value is #{self.mode.inspect}"
         end
  ::File.open(path, mode) do |f|
    f.puts formatted_data
  end
end