Class: Hookit::Resource::Scp
- Inherits:
-
Base
- Object
- Base
- Hookit::Resource::Scp
show all
- Defined in:
- lib/hookit/resource/scp.rb
Instance Attribute Summary
Attributes inherited from Base
#dict
Instance Method Summary
collapse
Methods inherited from Base
#action, actions, #can_run?, default_action, #default_action, field, #not_if, #only_if
Constructor Details
#initialize(name) ⇒ Scp
Returns a new instance of Scp.
19
20
21
22
23
24
|
# File 'lib/hookit/resource/scp.rb', line 19
def initialize(name)
source(name) unless source
preserve(true) unless preserve
recursive(true) unless recursive
super
end
|
Instance Method Details
#cipher! ⇒ Object
37
38
39
40
|
# File 'lib/hookit/resource/scp.rb', line 37
def cipher!
(return "-c #{cipher}") if cipher
""
end
|
#compression! ⇒ Object
42
43
44
45
|
# File 'lib/hookit/resource/scp.rb', line 42
def compression!
(return "C") if compression
""
end
|
#config! ⇒ Object
47
48
49
50
|
# File 'lib/hookit/resource/scp.rb', line 47
def config!
(return "-F #{config}") if config
""
end
|
#copy! ⇒ Object
33
34
35
|
# File 'lib/hookit/resource/scp.rb', line 33
def copy!
run_command!("scp -q#{preserve!}#{recursive!}B#{compression!} #{config!} #{port!} #{cipher!} #{identity!} #{ssh_options!} #{source} #{destination}")
end
|
#identity! ⇒ Object
52
53
54
55
|
# File 'lib/hookit/resource/scp.rb', line 52
def identity!
(return "-i #{identity}") if identity
""
end
|
#port! ⇒ Object
57
58
59
60
|
# File 'lib/hookit/resource/scp.rb', line 57
def port!
(return "-P #{port}") if port
""
end
|
#preserve! ⇒ Object
62
63
64
65
|
# File 'lib/hookit/resource/scp.rb', line 62
def preserve!
(return "p") if preserve
""
end
|
#recursive! ⇒ Object
67
68
69
70
|
# File 'lib/hookit/resource/scp.rb', line 67
def recursive!
(return "r") if recursive
""
end
|
#run(action) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/hookit/resource/scp.rb', line 26
def run(action)
case action
when :copy
copy!
end
end
|
#run_command!(cmd, expect_code = 0) ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/hookit/resource/scp.rb', line 77
def run_command!(cmd, expect_code=0)
`#{cmd}`
code = $?.exitstatus
if code != expect_code
raise Hookit::Error::UnexpectedExit, "#{cmd} failed with exit code '#{code}'"
end
end
|
#ssh_options! ⇒ Object
72
73
74
75
|
# File 'lib/hookit/resource/scp.rb', line 72
def ssh_options!
(return "-o #{ssh_options}") if ssh_options
""
end
|