class LogStash::Inputs::S3::SinceDB::File

Public Class Methods

new(file) click to toggle source
# File lib/logstash/inputs/s3.rb, line 521
def initialize(file)
  @sincedb_path = file
end

Public Instance Methods

newer?(date) click to toggle source
# File lib/logstash/inputs/s3.rb, line 525
def newer?(date)
  date > read
end
read() click to toggle source
# File lib/logstash/inputs/s3.rb, line 529
def read
  if ::File.exists?(@sincedb_path)
    content = ::File.read(@sincedb_path).chomp.strip
    # If the file was created but we didn't have the time to write to it
    return content.empty? ? Time.new(0) : Time.parse(content)
  else
    return Time.new(0)
  end
end
write(since = nil) click to toggle source
# File lib/logstash/inputs/s3.rb, line 539
def write(since = nil)
  since = Time.now() if since.nil?
  ::File.open(@sincedb_path, 'w') { |file| file.write(since.to_s) }
end