Class: CloudSync::Archiver

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud_sync/archiver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, destination) ⇒ Archiver

Returns a new instance of Archiver.



6
7
8
9
# File 'lib/cloud_sync/archiver.rb', line 6

def initialize source, destination
  @source       = Resource.new source
  @destination  = Resource.new destination
end

Instance Attribute Details

#destinationObject

Returns the value of attribute destination.



4
5
6
# File 'lib/cloud_sync/archiver.rb', line 4

def destination
  @destination
end

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'lib/cloud_sync/archiver.rb', line 4

def source
  @source
end

Instance Method Details

#archiveObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cloud_sync/archiver.rb', line 11

def archive

  unless source
    return Log.error "Invalid syntax for resource #{source}"
  end

  unless destination
    return Log.error "Invalid syntax for resource #{destination}"
  end

  tar = Resource.new("filesystem:#{archive_path}")
  system "tar czvf #{archive_path} #{source.path}"
  destination.istream("/home/dan/moo.tgz") << tar.ostream
  system "rm #{archive_path}"

end