Class: Machines::Upload

Inherits:
Command show all
Defined in:
lib/machines/upload.rb

Instance Attribute Summary collapse

Attributes inherited from Command

#check, #command

Instance Method Summary collapse

Methods inherited from Command

scp, scp=, ssh, ssh=, #use_sudo

Constructor Details

#initialize(local, remote, check) ⇒ Upload

Returns a new instance of Upload.



5
6
7
8
# File 'lib/machines/upload.rb', line 5

def initialize(local, remote, check)
  super(nil, check)
  @local, @remote = local, remote
end

Instance Attribute Details

#localObject

Returns the value of attribute local.



3
4
5
# File 'lib/machines/upload.rb', line 3

def local
  @local
end

#remoteObject

Returns the value of attribute remote.



3
4
5
# File 'lib/machines/upload.rb', line 3

def remote
  @remote
end

Instance Method Details

#infoObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/machines/upload.rb', line 16

def info
  name = local
  if local.is_a?(NamedBuffer)
    if local.name
      name = "buffer from #{local.name}"
    else
      name = "unnamed buffer"
    end
  end
  "UPLOAD #{name} to #{remote}"
end

#runObject



10
11
12
13
14
# File 'lib/machines/upload.rb', line 10

def run
  process do
    @@scp.upload!(local, remote, {:recursive => local.is_a?(String) && File.directory?(local)})
  end
end