Class: Moku::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/moku/upload.rb

Overview

An upload from a source path to a destination path

Instance Method Summary collapse

Constructor Details

#initialize(source, host, dest) ⇒ Upload

Returns a new instance of Upload.

Parameters:

  • source (Pathname, String)
  • host (Sites::Host)
  • dest (Pathname, String)

    If dest contains a colon, the left side will be treated as the hostname.


12
13
14
15
16
# File 'lib/moku/upload.rb', line 12

def initialize(source, host, dest)
  @source = source.to_s
  @host = host
  @dest = dest
end

Instance Method Details

#full_destObject


31
32
33
# File 'lib/moku/upload.rb', line 31

def full_dest
  "#{host.user}@#{host.hostname}:#{dest}"
end

#to_commandString

This upload as a shell command

Returns:

  • (String)

27
28
29
# File 'lib/moku/upload.rb', line 27

def to_command
  "rsync -vrlpz #{source}/. #{full_dest}/"
end

#with(runner) ⇒ Status

Perform this upload with the given runner.

Returns:

  • (Status)

    Return type is whatever the runner returns, likely a Status instance.


21
22
23
# File 'lib/moku/upload.rb', line 21

def with(runner)
  runner.run(to_command)
end