Class: Testjour::Rsync

Inherits:
Object
  • Object
show all
Defined in:
lib/testjour/rsync.rb

Class Method Summary collapse

Class Method Details

.copy_to_current_directory_from(source_uri) ⇒ Object



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

def self.copy_to_current_directory_from(source_uri)
  destination_dir = File.expand_path(".")
  uri = URI.parse(source_uri)
  
  command = "rsync -az --delete --exclude=.git --exclude=*.log --exclude=*.pid #{uri.user}@#{uri.host}:#{uri.path}/ #{destination_dir}"
  
  Testjour.logger.info "Rsyncing: #{command}"
  start_time = Time.now
  successful = system command
  
  if successful
    time = Time.now - start_time
    Testjour.logger.debug("Rsync finished in %.2fs" % time)
  else
    raise RsyncFailed.new
  end
end