Class: DRbQS::Transfer

Inherits:
Object
  • Object
show all
Defined in:
lib/drbqs/ssh/transfer.rb

Overview

Transfer files to directory on DRbQS server. In this class we use scp command. Note that after we transfer files we delete the files.

Direct Known Subclasses

TransferTest

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, host, directory) ⇒ Transfer

options

:mkdir    true or nil


11
12
13
14
15
16
# File 'lib/drbqs/ssh/transfer.rb', line 11

def initialize(user, host, directory)
  @user = user
  @host = host
  @directory = File.expand_path(directory)
  FileUtils.mkdir_p(@directory)
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



7
8
9
# File 'lib/drbqs/ssh/transfer.rb', line 7

def directory
  @directory
end

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/drbqs/ssh/transfer.rb', line 7

def host
  @host
end

#userObject (readonly)

Returns the value of attribute user.



7
8
9
# File 'lib/drbqs/ssh/transfer.rb', line 7

def user
  @user
end

Instance Method Details

#informationObject



35
36
37
# File 'lib/drbqs/ssh/transfer.rb', line 35

def information
  "#{@user}@#{@host} #{@directory}"
end

#scp(path) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/drbqs/ssh/transfer.rb', line 23

def scp(path)
  name = File.basename(path)
  unless File.exist?(path)
    raise ArgumentError, "File #{path} does not exist."
  end
  if transfer_file(path, name)
    FileUtils.rm_r(path)
    return true
  end
  return false
end