class Snapshotar::Storage::FileStorage
Attributes
base_path[RW]
Use this property to specify the local path where snapshots are stored.
- Default
-
tmp/
Public Instance Methods
create(filename,serialized_tree)
click to toggle source
creates a snapshot specified by the given filename
with data provided
- Params
filename
-
name of the snapshot to create
serialized_tree
-
json serialized data
# File lib/snapshotar/storage/file_storage.rb, line 49 def create(filename,serialized_tree) File.open(File.join(@base_path, filename),"w") do |f| f.write(serialized_tree) end end
delete(filename)
click to toggle source
deletes a snapshot specified by the given filename
.
- Params
filename
-
name of the snapshot to delete
# File lib/snapshotar/storage/file_storage.rb, line 61 def delete(filename) File.delete File.join(@base_path, filename) end
index()
click to toggle source
lists available snapshots in this storage.
- returns
-
array of filenames
# File lib/snapshotar/storage/file_storage.rb, line 26 def index Dir["#{@base_path}/*.json"].map{|p| File.basename(p)} end
show(filename)
click to toggle source
loads a snapshot specified by the given filename
.
- Params
filename
-
name of the snapshot to load
- returns
-
still seralized json
# File lib/snapshotar/storage/file_storage.rb, line 38 def show(filename) File.read File.join(@base_path, filename) end