Sha256: a7f5e3a0ef685e241b5e8fef4375efab53b33bc2730342217a25da67571aafdc

Contents?: true

Size: 927 Bytes

Versions: 2

Compression:

Stored size: 927 Bytes

Contents

require 'colorize'

module AmicoDb
  class Download
    attr_accessor :user
    attr_accessor :host
    attr_accessor :remote_path
    attr_accessor :local_path
    attr_accessor :cmd

    def initialize(user: AmicoDb.configuration.ssh_user,
                   host: AmicoDb.configuration.host,
                   remote_path: AmicoDb.configuration.remote_path,
                   local_path: AmicoDb.configuration.local_path)
      self.user = user
      self.host = host
      self.remote_path = remote_path
      self.local_path = local_path
      self.cmd = generate_cmd
    end

    def call
      AmicoDb::DownloadTools::CreateDirIfNotExist.new(local_path).call
      log_cmd
      system(cmd)
    end

    private

    def log_cmd
      puts 'Start download with scp:'.colorize(:red)
      puts cmd.colorize(:red)
    end

    def generate_cmd
      "scp #{user}@#{host}:#{remote_path} #{local_path}"
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amico-db-0.1.8 lib/amico-db/download.rb
amico-db-0.1.7 lib/amico-db/download.rb