Sha256: fb6dc515516ae10ffdb8814e9d71c1fa37b9e5415b612f42213a08d1b6ff7264
Contents?: true
Size: 1.76 KB
Versions: 6
Compression:
Stored size: 1.76 KB
Contents
module SSHKit module Backend MethodUnavailableError = Class.new(RuntimeError) class Abstract attr_reader :host def run # Nothing to do end def initialize(host, &block) raise "Must pass a Host object" unless host.is_a? Host @host = host @block = block end def make(commands=[]) raise MethodUnavailableError end def rake(commands=[]) raise MethodUnavailableError end def execute(command, args=[]) raise MethodUnavailableError end def capture(command, args=[]) raise MethodUnavailableError end 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 def with(environment, &block) @_env = (@env ||= {}) @env = @_env.merge environment yield ensure @env = @_env remove_instance_variable(:@_env) end 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 private def command(*args) SSHKit::Command.new(*args, in: @pwd.nil? ? nil : File.join(@pwd), env: @env, host: @host, user: @user) end def connection raise "No Connection Pool Implementation" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems