Class: Backup::FileItem::Local

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/file_item/local.rb

Instance Method Summary collapse

Methods inherited from Base

#file_hash, #semantic_path, #stat

Instance Method Details

#create_directory_once(*directories) ⇒ Object



6
7
8
9
10
# File 'lib/backup/file_item/local.rb', line 6

def create_directory_once(*directories)
  directories.each do |path|
    FileUtils.mkdir_p(path) unless Dir.exists?(path)
  end
end

#create_file_once(file, data) ⇒ Object



12
13
14
15
# File 'lib/backup/file_item/local.rb', line 12

def create_file_once(file, data)
  date = date.read if date.is_a? File
  File.open(file, "w").puts(data) unless File.exists?(file)
end

#dir(path, mask = "*") ⇒ Object



21
22
23
# File 'lib/backup/file_item/local.rb', line 21

def dir(path, mask = "*")
  Dir["#{path}/#{mask}"]
end

#read_file(file) ⇒ Object



17
18
19
# File 'lib/backup/file_item/local.rb', line 17

def read_file(file)
  open(file).read if File.exists? file
end