Sha256: 1edb33da116f99babec5fa192f94540bd3af115f548d6789a5997fac926f0520

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

module Fulmar
  module Infrastructure
    module Service
      # Provides access to composer
      class CopyService
        # Copies a file to a remote server
        # @param [Fulmar::Infrastructue::Service::ShellService] shell
        # @param [String] local_file local filename, should be absolute
        # @param [String] remote_host SSH hostname
        # @param [String] remote_dir remote directory
        def self.upload(shell, local_file, remote_host, remote_dir)
          if shell.run "scp #{local_file} #{remote_host}:#{remote_dir.chomp('/')}/"
            "#{remote_dir.chomp('/')}/#{File.basename(local_file)}"
          end
        end

        # Downloads a file from a remote server
        # @param [Fulmar::Infrastructue::Service::ShellService] shell
        # @param [String] remote_host SSH hostname
        # @param [String] remote_file remote directory
        # @param [String] local_dir local filename, should be absolute
        def self.download(shell, remote_host, remote_file, local_dir = '.')
          if shell.run "scp #{remote_host}:#{remote_file} #{local_dir.chomp('/')}/"
            "#{local_dir.chomp('/')}/#{File.basename(remote_file)}"
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fulmar-1.5.0 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.4.2 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.4.1 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.4.0 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.3.0 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.2.1 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.2.0 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.1.0 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.0.0 lib/fulmar/infrastructure/service/copy_service.rb