Class: LogTail::FileStateStore
- Inherits:
-
Object
- Object
- LogTail::FileStateStore
- Defined in:
- lib/apache_log_tail.rb
Overview
This is the default implementation of StateStore, which stores the state in a file ( by default in /tmp with a static name although this is configurable).
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#path_to_file ⇒ Object
65 66 67 |
# File 'lib/apache_log_tail.rb', line 65 def path_to_file @path_to_file ||= "/tmp/.apache_log_tail-state.yml" end |
Instance Method Details
#recall ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/apache_log_tail.rb', line 72 def recall if not File.exists? path_to_file {} else YAML.load File.read( path_to_file) end end |
#remember(state) ⇒ Object
80 81 82 83 84 |
# File 'lib/apache_log_tail.rb', line 80 def remember state File.open path_to_file, "w" do |file| file.write state.to_yaml end end |