Class: DataKeeper::LocalStorage
- Inherits:
-
Object
- Object
- DataKeeper::LocalStorage
- Includes:
- SSHKit::DSL
- Defined in:
- lib/data_keeper/local_storage.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ LocalStorage
constructor
A new instance of LocalStorage.
- #retrieve(dump_name) ⇒ Object
- #save(file, filename, dump_name) ⇒ Object
Constructor Details
#initialize(data) ⇒ LocalStorage
Returns a new instance of LocalStorage.
9 10 11 12 |
# File 'lib/data_keeper/local_storage.rb', line 9 def initialize(data) @local_store_dir = data[:local_store_dir] @remote_access = data[:remote_access] end |
Instance Method Details
#retrieve(dump_name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/data_keeper/local_storage.rb', line 21 def retrieve(dump_name) tempfile = Tempfile.new local_store_dir = @local_store_dir last_dump_filename = nil on complete_host do last_dump_filename = capture :ls, "-1t #{File.join(local_store_dir, dump_name.to_s)} | head -n 1" download! File.join(local_store_dir, dump_name.to_s, last_dump_filename), tempfile.path end yield(tempfile, last_dump_filename) ensure tempfile.delete end |
#save(file, filename, dump_name) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/data_keeper/local_storage.rb', line 14 def save(file, filename, dump_name) path = dump_path(dump_name, filename) FileUtils.mkdir_p(File.dirname(path)) FileUtils.cp(file.path, path) end |