Class: DRbQS::Transfer
- Inherits:
-
Object
- Object
- DRbQS::Transfer
- 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
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #information ⇒ Object
-
#initialize(user, host, directory) ⇒ Transfer
constructor
options :mkdir true or nil.
- #scp(path) ⇒ Object
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.(directory) FileUtils.mkdir_p(@directory) end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
7 8 9 |
# File 'lib/drbqs/ssh/transfer.rb', line 7 def directory @directory end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/drbqs/ssh/transfer.rb', line 7 def host @host end |
#user ⇒ Object (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
#information ⇒ Object
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 |