Class: Command::Cacheable::GzipPathname

Inherits:
Pathname
  • Object
show all
Defined in:
lib/command/cacheable/gzpathname.rb

Overview

A pathname (file) that reads and writes a list of lines, as gzipped

Instance Method Summary collapse

Instance Method Details

#read_fileObject



21
22
23
24
25
26
# File 'lib/command/cacheable/gzpathname.rb', line 21

def read_file
  content = nil
  Zlib::GzipReader.open(to_s) do |gz|
    content = gz.readlines
  end
end

#save_file(content) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/command/cacheable/gzpathname.rb', line 13

def save_file content
  parent.mkpath unless parent.exist?
  unlink if exist?
  Zlib::GzipWriter.open(to_s) do |gz|
    gz.puts content
  end
end