Class: Deploio::RcloneClient
- Inherits:
-
Object
- Object
- Deploio::RcloneClient
- Defined in:
- lib/deploio/rclone_client.rb
Constant Summary collapse
- REMOTE =
"DEPLOIO"
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
Instance Method Summary collapse
- #check_requirements ⇒ Object
- #download(bucket, object, destination) ⇒ Object
-
#initialize(endpoint:, access_key:, secret_key:, dry_run: false) ⇒ RcloneClient
constructor
A new instance of RcloneClient.
- #list(bucket) ⇒ Object
Constructor Details
#initialize(endpoint:, access_key:, secret_key:, dry_run: false) ⇒ RcloneClient
Returns a new instance of RcloneClient.
12 13 14 15 16 17 |
# File 'lib/deploio/rclone_client.rb', line 12 def initialize(endpoint:, access_key:, secret_key:, dry_run: false) @endpoint = endpoint @access_key = access_key @secret_key = secret_key @dry_run = dry_run end |
Instance Attribute Details
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
10 11 12 |
# File 'lib/deploio/rclone_client.rb', line 10 def dry_run @dry_run end |
Instance Method Details
#check_requirements ⇒ Object
19 20 21 |
# File 'lib/deploio/rclone_client.rb', line 19 def check_requirements check_rclone_installed end |
#download(bucket, object, destination) ⇒ Object
33 34 35 |
# File 'lib/deploio/rclone_client.rb', line 33 def download(bucket, object, destination) run("copyto", remote_path(bucket, object), destination, "--progress", "--stats-one-line") end |
#list(bucket) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/deploio/rclone_client.rb', line 23 def list(bucket) output = capture("lsjson", remote_path(bucket)) return [] if output.nil? || output.empty? data = JSON.parse(output) data.is_a?(Array) ? data : [] rescue JSON::ParserError [] end |