Class: SSHKit::Backend::Netssh
Defined Under Namespace
Classes: Configuration
Instance Attribute Summary
Attributes inherited from Abstract
#host
Class Method Summary
collapse
Instance Method Summary
collapse
#make, #rake
Methods inherited from Abstract
#as, #debug, #error, #fatal, #info, #initialize, #log, #make, #rake, #warn, #with, #within
Class Method Details
.config ⇒ Object
68
69
70
|
# File 'lib/sshkit/backends/netssh.rb', line 68
def config
@config ||= Configuration.new
end
|
64
65
66
|
# File 'lib/sshkit/backends/netssh.rb', line 64
def configure
yield config
end
|
Instance Method Details
#background(*args) ⇒ Object
31
32
33
34
|
# File 'lib/sshkit/backends/netssh.rb', line 31
def background(*args)
options = args..merge(run_in_background: true)
_execute(*[*args, options]).success?
end
|
#capture(*args) ⇒ Object
36
37
38
39
|
# File 'lib/sshkit/backends/netssh.rb', line 36
def capture(*args)
options = args..merge(verbosity: Logger::DEBUG)
_execute(*[*args, options]).full_stdout.strip
end
|
#download!(remote, local = nil, options = {}) ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/sshkit/backends/netssh.rb', line 52
def download!(remote, local=nil, options = {})
ssh.scp.download!(remote, local, options) do |ch, name, received, total|
percentage = (received.to_f * 100 / total.to_f).to_i
if percentage > 0 && percentage % 10 == 0
info "Downloading #{name} #{percentage}%"
else
debug "Downloading #{name} #{percentage}%"
end
end
end
|
#execute(*args) ⇒ Object
27
28
29
|
# File 'lib/sshkit/backends/netssh.rb', line 27
def execute(*args)
_execute(*args).success?
end
|
#run ⇒ Object
15
16
17
|
# File 'lib/sshkit/backends/netssh.rb', line 15
def run
instance_exec(host, &@block)
end
|
#test(*args) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/sshkit/backends/netssh.rb', line 19
def test(*args)
options = args..merge(
raise_on_non_zero_exit: false,
verbosity: Logger::DEBUG
)
_execute(*[*args, options]).success?
end
|
#upload!(local, remote, options = {}) ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/sshkit/backends/netssh.rb', line 41
def upload!(local, remote, options = {})
ssh.scp.upload!(local, remote, options) do |ch, name, sent, total|
percentage = (sent.to_f * 100 / total.to_f).to_i
if percentage > 0 && percentage % 10 == 0
info "Uploading #{name} #{percentage}%"
else
debug "Uploading #{name} #{percentage}%"
end
end
end
|