Class: Toolshed::ServerAdministration::SCP
- Inherits:
-
Object
- Object
- Toolshed::ServerAdministration::SCP
- Includes:
- Password
- Defined in:
- lib/toolshed/server_administration/scp.rb
Overview
Handles SCP file from one place to another
Instance Attribute Summary collapse
-
#local_path ⇒ Object
readonly
rubocop:disable LineLength.
-
#password ⇒ Object
readonly
rubocop:disable LineLength.
-
#remote_host ⇒ Object
readonly
rubocop:disable LineLength.
-
#remote_path ⇒ Object
readonly
rubocop:disable LineLength.
-
#ssh_options ⇒ Object
readonly
rubocop:disable LineLength.
-
#username ⇒ Object
readonly
rubocop:disable LineLength.
-
#verbose_output ⇒ Object
readonly
rubocop:disable LineLength.
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(options = nil) ⇒ SCP
constructor
A new instance of SCP.
- #upload ⇒ Object
Methods included from Password
Constructor Details
#initialize(options = nil) ⇒ SCP
Returns a new instance of SCP.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/toolshed/server_administration/scp.rb', line 15 def initialize( = nil) ||= {} @password = [:password] @remote_host = [:remote_host] @remote_path = [:remote_path] @local_path = [:local_path] @username = [:username] @verbose_output = [:verbose_output] = [:ssh_options] ||= {} .merge!(password: password_from_config(password)) end |
Instance Attribute Details
#local_path ⇒ Object (readonly)
rubocop:disable LineLength
13 14 15 |
# File 'lib/toolshed/server_administration/scp.rb', line 13 def local_path @local_path end |
#password ⇒ Object (readonly)
rubocop:disable LineLength
13 14 15 |
# File 'lib/toolshed/server_administration/scp.rb', line 13 def password @password end |
#remote_host ⇒ Object (readonly)
rubocop:disable LineLength
13 14 15 |
# File 'lib/toolshed/server_administration/scp.rb', line 13 def remote_host @remote_host end |
#remote_path ⇒ Object (readonly)
rubocop:disable LineLength
13 14 15 |
# File 'lib/toolshed/server_administration/scp.rb', line 13 def remote_path @remote_path end |
#ssh_options ⇒ Object (readonly)
rubocop:disable LineLength
13 14 15 |
# File 'lib/toolshed/server_administration/scp.rb', line 13 def end |
#username ⇒ Object (readonly)
rubocop:disable LineLength
13 14 15 |
# File 'lib/toolshed/server_administration/scp.rb', line 13 def username @username end |
#verbose_output ⇒ Object (readonly)
rubocop:disable LineLength
13 14 15 |
# File 'lib/toolshed/server_administration/scp.rb', line 13 def verbose_output @verbose_output end |
Instance Method Details
#download ⇒ Object
28 29 30 31 32 |
# File 'lib/toolshed/server_administration/scp.rb', line 28 def download Toolshed.logger.info "Attempting to SCP from #{username}@#{remote_host}:#{remote_path} to #{local_path}." # rubocop:disable LineLength Net::SCP.download!(remote_host, username, remote_path, local_path, ssh: , recursive: true) # rubocop:disable LineLength on_complete end |
#upload ⇒ Object
34 35 36 37 38 |
# File 'lib/toolshed/server_administration/scp.rb', line 34 def upload Toolshed.logger.info "Attempting to SCP from #{local_path} to #{username}@#{remote_host}:#{remote_path}." # rubocop:disable LineLength Net::SCP.upload!(remote_host, username, local_path, remote_path, ssh: , recursive: true) # rubocop:disable LineLength on_complete end |