class LogTail::FileStateStore

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).

Attributes

path_to_file[W]

Public Instance Methods

path_to_file() click to toggle source

Provides the path to the file that is used to store the state ( unless a custom StateStore is used).

# File lib/apache_log_tail.rb, line 70
def path_to_file
  @path_to_file ||= "/tmp/.apache_log_tail-state.yml"
end
recall() click to toggle source

Retrieves the state from the store. @return [Hash]

# File lib/apache_log_tail.rb, line 80
def recall
  if not File.exists? path_to_file
    {}
  else
    YAML.load File.read( path_to_file)
  end
end
remember(state) click to toggle source

Stores the supplied state. @param [Hash] state

# File lib/apache_log_tail.rb, line 91
def remember state
  File.open  path_to_file, "w" do |file|
    file.write  state.to_yaml
  end
end