Class: Failbot::FileBackend
- Inherits:
- 
      Object
      
        - Object
- Failbot::FileBackend
 
- Defined in:
- lib/failbot/file_backend.rb
Instance Method Summary collapse
- 
  
    
      #initialize(path)  ⇒ FileBackend 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of FileBackend. 
- #ping ⇒ Object
- #report(data) ⇒ Object
- #reports ⇒ Object
Constructor Details
#initialize(path) ⇒ FileBackend
Returns a new instance of FileBackend.
| 5 6 7 8 9 10 11 | # 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 | 
Instance Method Details
#ping ⇒ Object
| 27 28 29 | # File 'lib/failbot/file_backend.rb', line 27 def ping raise StandardError, "cannot write to #{@path}" unless File.writable?(@path) end | 
#report(data) ⇒ Object
| 13 14 15 16 17 | # 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 ⇒ Object
| 19 20 21 22 23 24 25 | # File 'lib/failbot/file_backend.rb', line 19 def reports reports = [] File.foreach(@path) do |line| reports << JSON.parse(line) end reports end |