Class: Notification::FileNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/gaddygaddy-client/notification/file_notification.rb

Class Method Summary collapse

Class Method Details

.file_dirObject



24
25
26
# File 'lib/gaddygaddy-client/notification/file_notification.rb', line 24

def self.file_dir
  @file_dir
end

.file_dir=(file_dir) ⇒ Object



20
21
22
# File 'lib/gaddygaddy-client/notification/file_notification.rb', line 20

def self.file_dir= file_dir
  @file_dir = file_dir
end

.notify(event, message_text) ⇒ Object



28
29
30
31
32
33
# File 'lib/gaddygaddy-client/notification/file_notification.rb', line 28

def self.notify(event, message_text)
  f=File.open(File.join(file_dir,'gaddy_notification.log'), 'a')
  f.write "#{event['event_time'].strftime('%Y-%m-%d %H:%M')} #{event['type']} #{message_text}\n"
  f.fsync
  f.close
end

.text_in_log_file(message) ⇒ Object

This will check if the text is already in the log file



36
37
38
39
# File 'lib/gaddygaddy-client/notification/file_notification.rb', line 36

def self.text_in_log_file message
  log_file=File.join(file_dir,'gaddy_notification.log')
  `/bin/grep '#{message}' #{log_file} `.strip.length > 0
end