Class: SSHKit::Backend::Abstract
- Inherits:
-
Object
- Object
- SSHKit::Backend::Abstract
- Defined in:
- lib/sshkit/backends/abstract.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #as(user, &block) ⇒ Object
- #background(command, args = []) ⇒ Object
- #capture(command, args = []) ⇒ Object
- #execute(command, args = []) ⇒ Object
-
#initialize(host, &block) ⇒ Abstract
constructor
A new instance of Abstract.
- #make(commands = []) ⇒ Object
- #rake(commands = []) ⇒ Object
- #run ⇒ Object
- #test(command, args = []) ⇒ Object
- #with(environment, &block) ⇒ Object
- #within(directory, &block) ⇒ Object
Constructor Details
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/sshkit/backends/abstract.rb', line 8 def host @host end |
Instance Method Details
#as(user, &block) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/sshkit/backends/abstract.rb', line 66 def as(user, &block) @user = user execute <<-EOTEST if ! sudo su #{user} -c whoami > /dev/null then echo "You cannot switch to user '#{user}' using sudo, please check the sudoers file" 1>&2 false fi EOTEST yield ensure remove_instance_variable(:@user) end |
#background(command, args = []) ⇒ Object
28 29 30 |
# File 'lib/sshkit/backends/abstract.rb', line 28 def background(command, args=[]) raise MethodUnavailableError end |
#capture(command, args = []) ⇒ Object
40 41 42 |
# File 'lib/sshkit/backends/abstract.rb', line 40 def capture(command, args=[]) raise MethodUnavailableError end |
#execute(command, args = []) ⇒ Object
36 37 38 |
# File 'lib/sshkit/backends/abstract.rb', line 36 def execute(command, args=[]) raise MethodUnavailableError end |
#make(commands = []) ⇒ Object
20 21 22 |
# File 'lib/sshkit/backends/abstract.rb', line 20 def make(commands=[]) raise MethodUnavailableError end |
#rake(commands = []) ⇒ Object
24 25 26 |
# File 'lib/sshkit/backends/abstract.rb', line 24 def rake(commands=[]) raise MethodUnavailableError end |
#run ⇒ Object
10 11 12 |
# File 'lib/sshkit/backends/abstract.rb', line 10 def run # Nothing to do end |
#test(command, args = []) ⇒ Object
32 33 34 |
# File 'lib/sshkit/backends/abstract.rb', line 32 def test(command, args=[]) raise MethodUnavailableError end |
#with(environment, &block) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/sshkit/backends/abstract.rb', line 57 def with(environment, &block) @_env = (@env ||= {}) @env = @_env.merge environment yield ensure @env = @_env remove_instance_variable(:@_env) end |
#within(directory, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sshkit/backends/abstract.rb', line 44 def within(directory, &block) (@pwd ||= []).push directory.to_s execute <<-EOTEST if test ! -d #{File.join(@pwd)} then echo "Directory does not exist '#{File.join(@pwd)}'" 1>&2 false fi EOTEST yield ensure @pwd.pop end |