Class: Vana::Element::Copy
Overview
Instance Method Summary
collapse
Methods inherited from BaseElement
#execute, #initialize, #name=
Instance Method Details
#action(host, *_args) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/vana/element/copy.rb', line 38
def action(host, *_args)
if host == 'localhost'
begin
FileUtils.cp_r(@opts[:src], @opts[:dest], preserve: @opts[:preserve_time])
success = true
rescue Errno::ENOENT
success = false
end
{
src: @opts[:src],
dest: @opts[:dest],
success: success
}
elsif @opts[:remote_src]
else
begin
Net::SCP.start(host, nil) do |scp|
scp.upload!(@opts[:src], @opts[:dest], recursive: true, preserve: @opts[:preserve_time])
end
success = true
rescue Net::SCP::Error
success = false
end
{
src: @opts[:src],
dest: @opts[:dest],
success: success
}
end
end
|
#dest=(dest) ⇒ Object
26
27
28
|
# File 'lib/vana/element/copy.rb', line 26
def dest=(dest)
@opts[:dest] = dest
end
|
#preserve_time=(preserve_time) ⇒ Object
34
35
36
|
# File 'lib/vana/element/copy.rb', line 34
def preserve_time=(preserve_time)
@opts[:preserve_time] = preserve_time
end
|
#remote_src=(remote_src) ⇒ Object
30
31
32
|
# File 'lib/vana/element/copy.rb', line 30
def remote_src=(remote_src)
@opts[:remote_src] = remote_src
end
|
#setup(*args) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/vana/element/copy.rb', line 15
def setup(*args)
@opts[:src] ||= args[0]
@opts[:dest] ||= args[1]
@element_opts[:name] ||= "copy #{@opts[:src]} to #{@opts[:dest]}"
end
|
#src=(src) ⇒ Object
22
23
24
|
# File 'lib/vana/element/copy.rb', line 22
def src=(src)
@opts[:src] = src
end
|