Class: Testjour::Rsync
- Inherits:
-
Object
- Object
- Testjour::Rsync
- Defined in:
- lib/testjour/rsync.rb
Class Method Summary collapse
Instance Method Summary collapse
- #command ⇒ Object
- #copy ⇒ Object
- #copy_with_retry ⇒ Object
- #destination_dir ⇒ Object
- #elapsed_time ⇒ Object
-
#initialize(source_uri) ⇒ Rsync
constructor
A new instance of Rsync.
- #successful? ⇒ Boolean
- #uri ⇒ Object
Constructor Details
#initialize(source_uri) ⇒ Rsync
Returns a new instance of Rsync.
14 15 16 |
# File 'lib/testjour/rsync.rb', line 14 def initialize(source_uri) @source_uri = source_uri end |
Class Method Details
.copy_to_current_directory_from(source_uri) ⇒ Object
10 11 12 |
# File 'lib/testjour/rsync.rb', line 10 def self.copy_to_current_directory_from(source_uri) new(source_uri).copy_with_retry end |
Instance Method Details
#command ⇒ Object
40 41 42 |
# File 'lib/testjour/rsync.rb', line 40 def command "rsync -az --delete --exclude=.git --exclude=*.log --exclude=*.pid #{uri.user}@#{uri.host}:#{uri.path}/ #{destination_dir}" end |
#copy ⇒ Object
27 28 29 30 |
# File 'lib/testjour/rsync.rb', line 27 def copy @start_time = Time.now @successful = system(command) end |
#copy_with_retry ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/testjour/rsync.rb', line 18 def copy_with_retry retryable :tries => 2, :on => RsyncFailed do Testjour.logger.info "Rsyncing: #{command}" copy Testjour.logger.debug("Rsync finished in %.2fs" % elapsed_time) raise RsyncFailed.new unless successful? end end |
#destination_dir ⇒ Object
44 45 46 |
# File 'lib/testjour/rsync.rb', line 44 def destination_dir File.(".") end |
#elapsed_time ⇒ Object
32 33 34 |
# File 'lib/testjour/rsync.rb', line 32 def elapsed_time Time.now - @start_time end |
#successful? ⇒ Boolean
36 37 38 |
# File 'lib/testjour/rsync.rb', line 36 def successful? @successful end |
#uri ⇒ Object
48 49 50 |
# File 'lib/testjour/rsync.rb', line 48 def uri URI.parse(@source_uri) end |