Class: Notification::FileNotification
- Inherits:
-
Object
- Object
- Notification::FileNotification
- Defined in:
- lib/gaddygaddy-client/notification/file_notification.rb
Class Method Summary collapse
- .file_dir ⇒ Object
- .file_dir=(file_dir) ⇒ Object
- .notify(event, message_text) ⇒ Object
-
.text_in_log_file(message) ⇒ Object
This will check if the text is already in the log file.
Class Method Details
.file_dir ⇒ Object
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, ) f=File.open(File.join(file_dir,'gaddy_notification.log'), 'a') f.write "#{event['event_time'].strftime('%Y-%m-%d %H:%M')} #{event['type']} #{}\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 log_file=File.join(file_dir,'gaddy_notification.log') `/bin/grep '#{}' #{log_file} `.strip.length > 0 end |