Class: Backupsss::Tar

Inherits:
Object
  • Object
show all
Defined in:
lib/backupsss/tar.rb

Overview

The Tar class is used for creating a tar archive.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, dest) ⇒ Tar

Returns a new instance of Tar.



8
9
10
11
# File 'lib/backupsss/tar.rb', line 8

def initialize(src, dest)
  @src = src
  @dest = dest
end

Instance Attribute Details

#destObject (readonly)

Returns the value of attribute dest.



6
7
8
# File 'lib/backupsss/tar.rb', line 6

def dest
  @dest
end

#srcObject (readonly)

Returns the value of attribute src.



6
7
8
# File 'lib/backupsss/tar.rb', line 6

def src
  @src
end

Instance Method Details

#filenameObject



28
29
30
# File 'lib/backupsss/tar.rb', line 28

def filename
  dest.split('/').last
end

#makeObject



13
14
15
16
17
18
# File 'lib/backupsss/tar.rb', line 13

def make
  if valid_dest? && valid_src?
    Open3.capture3("tar -cvf #{dest} #{src}")
    File.open(dest)
  end
end

#valid_dest?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/backupsss/tar.rb', line 20

def valid_dest?
  dir_exists?(dest_dir) && dest_writable?
end

#valid_src?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/backupsss/tar.rb', line 24

def valid_src?
  dir_exists?(src) && src_readable?
end