Sha256: 71a778acf2f00631fbb0406487e79c99af3a30090cca62ebf2ee9d2a8902cb08
Contents?: true
Size: 681 Bytes
Versions: 1
Compression:
Stored size: 681 Bytes
Contents
module GitQuickBooks ## # Setup Marshalling cache class Cache # attr_accesor :base_path def load(name) Marshal.load(IO.read("tmp/#{name}")) end def present?(name) File.file?("tmp/#{name}") end def write(name, data) File.open("tmp/#{name}", 'w+') do |f| f.write(Marshal.dump(data)) end end def delete(name) File.delete("tmp/#{name}") end def fetch(name, &block) if !present?(name) @data = block.call write(name, @data) @data else puts "#{name} extracted from cache".red @data = GitQuickBooks::Cache.new.load(name) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gitquickbooks-0.0.1 | lib/gitquickbooks/cache.rb |