Class: Backup::Storages::Local
- Defined in:
- lib/backup-agent/storages/local.rb
Defined Under Namespace
Classes: Object
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
Instance Method Summary collapse
- #delete(relative_path) ⇒ Object
- #each ⇒ Object
-
#initialize(directory:) ⇒ Local
constructor
A new instance of Local.
- #store(relative_path, file_to_write) ⇒ Object
Constructor Details
#initialize(directory:) ⇒ Local
Returns a new instance of Local.
11 12 13 |
# File 'lib/backup-agent/storages/local.rb', line 11 def initialize(directory:) @directory = directory.gsub(/\/*\z/, "") # Ensure trailing slash end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
9 10 11 |
# File 'lib/backup-agent/storages/local.rb', line 9 def directory @directory end |
Instance Method Details
#delete(relative_path) ⇒ Object
21 22 23 |
# File 'lib/backup-agent/storages/local.rb', line 21 def delete(relative_path) FileUtils.rm_f(File.join(directory, relative_path)) end |
#each ⇒ Object
25 26 27 28 29 |
# File 'lib/backup-agent/storages/local.rb', line 25 def each Dir.glob File.join(directory, "**", "*") do |path| yield Backup::Storages::Local::Object.new(self, path[directory.size+1..-1]) end end |
#store(relative_path, file_to_write) ⇒ Object
15 16 17 18 19 |
# File 'lib/backup-agent/storages/local.rb', line 15 def store(relative_path, file_to_write) FileUtils.mkdir_p(directory) FileUtils.cp_r(file_to_write, File.join(directory, relative_path)) Backup::Storages::Local::Object.new(self, relative_path) end |