Class: Snapshooter::Storage::Local
- Defined in:
- lib/snapshooter/storage/local.rb
Instance Method Summary collapse
Methods included from Log
Instance Method Details
#get(filename) {|"snapshots/#{filename}"| ... } ⇒ Object
25 26 27 |
# File 'lib/snapshooter/storage/local.rb', line 25 def get(filename, &block) yield "snapshots/#{filename}" end |
#save(filename, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/snapshooter/storage/local.rb', line 6 def save(filename, &block) with_log("Save snapshots/#{filename} to local") do FileUtils.mkdir_p "snapshots" unless File.exists?("snapshots") file = Tempfile.new("snapshooter_local_storage") file.close begin yield file.path File.open "snapshots/#{filename}", "w" do |f| f.write File.read(file.path) end ensure file.unlink end end end |