Class: Fulmar::Infrastructure::Service::CopyService

Inherits:
Object
  • Object
show all
Defined in:
lib/fulmar/infrastructure/service/copy_service.rb

Overview

Provides access to composer

Class Method Summary collapse

Class Method Details

.download(shell, remote_host, remote_file, local_dir = '.') ⇒ Object

Downloads a file from a remote server

Parameters:

  • shell (Fulmar::Shell)
  • remote_host (String)

    SSH hostname

  • remote_file (String)

    remote directory

  • local_dir (String) (defaults to: '.')

    local filename, should be absolute



22
23
24
25
26
# File 'lib/fulmar/infrastructure/service/copy_service.rb', line 22

def self.download(shell, remote_host, remote_file, local_dir = '.')
  if shell.run "scp -Cr #{remote_host}:#{remote_file} #{local_dir.chomp('/')}/"
    "#{local_dir.chomp('/')}/#{File.basename(remote_file)}"
  end
end

.upload(shell, local_file, remote_host, remote_dir) ⇒ Object

Copies a file to a remote server

Parameters:

  • shell (Fulmar::Shell)
  • local_file (String)

    local filename, should be absolute

  • remote_host (String)

    SSH hostname

  • remote_dir (String)

    remote directory



11
12
13
14
15
# File 'lib/fulmar/infrastructure/service/copy_service.rb', line 11

def self.upload(shell, local_file, remote_host, remote_dir)
  if shell.run "scp -Cr #{local_file} #{remote_host}:#{remote_dir.chomp('/')}/"
    "#{remote_dir.chomp('/')}/#{File.basename(local_file)}"
  end
end