class Fluoride::Collector::Storage::FS

Public Instance Methods

directory() click to toggle source
# File lib/fluoride-collector/storage/fs.rb, line 7
def directory
  @config.directory
end
storage_file() { |file| ... } click to toggle source
# File lib/fluoride-collector/storage/fs.rb, line 36
def storage_file
  FileUtils.mkdir_p(File::dirname(storage_path))
  return if storage_used > storage_limit
  File::open(storage_path, "a") do |file|
    yield file
  end
end
storage_limit() click to toggle source
# File lib/fluoride-collector/storage/fs.rb, line 11
def storage_limit
  @config.storage_limit
end
storage_path() click to toggle source
# File lib/fluoride-collector/storage/fs.rb, line 32
def storage_path
  thread_locals[collection_type] ||= File::join(directory, "#{collection_type}-#{Process.pid}-#{Thread.current.object_id}.yml")
end
storage_used() click to toggle source
# File lib/fluoride-collector/storage/fs.rb, line 21
def storage_used
  dir = Dir.new(directory)
  dir.inject(0) do |sum, file|
    if file =~ %r{\A\.}
      sum
    else
      sum + File.size(File::join(directory, file))
    end
  end
end
write() click to toggle source
# File lib/fluoride-collector/storage/fs.rb, line 15
def write
  storage_file do |file|
    file.write(record_yaml)
  end
end