Sha256: 377aeea0b412dcf802b8fc32697957eb6c7c31994be02b502c5eb9796cbc80de

Contents?: true

Size: 1.21 KB

Versions: 15

Compression:

Stored size: 1.21 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 -r #{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 -r #{remote_host}:#{remote_file} #{local_dir.chomp('/')}/"
            "#{local_dir.chomp('/')}/#{File.basename(remote_file)}"
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fulmar-1.8.1 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.8.0 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.7.5 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.7.4 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.7.3 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.7.2 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.7.1 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.7.0 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.6.4 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.6.3 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.6.2 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.6.1 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.6.0 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.5.2 lib/fulmar/infrastructure/service/copy_service.rb
fulmar-1.5.1 lib/fulmar/infrastructure/service/copy_service.rb