class Failbot::FileBackend

Public Class Methods

new(path) click to toggle source
# File lib/failbot/file_backend.rb, line 5
def initialize(path)
  @path = path

  if path.to_s.empty?
    raise ArgumentError, "FAILBOT_BACKEND_FILE_PATH setting required."
  end
end

Public Instance Methods

ping() click to toggle source
# File lib/failbot/file_backend.rb, line 27
def ping
  raise StandardError, "cannot write to #{@path}" unless File.writable?(@path)
end
report(data) click to toggle source
# File lib/failbot/file_backend.rb, line 13
def report(data)
  File.open(@path, 'a') do |file|
    file.puts(data.to_json)
  end
end
reports() click to toggle source
# File lib/failbot/file_backend.rb, line 19
def reports
  reports = []
  File.foreach(@path) do |line|
    reports << JSON.parse(line)
  end
  reports
end