Class: Vx::SCM::Git::GitSSH
- Inherits:
-
Object
- Object
- Vx::SCM::Git::GitSSH
- Includes:
- Common::Helper::Shell
- Defined in:
- lib/vx/scm/git/git_ssh.rb
Instance Attribute Summary collapse
-
#deploy_key ⇒ Object
readonly
Returns the value of attribute deploy_key.
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#initialize(deploy_key) ⇒ GitSSH
constructor
A new instance of GitSSH.
- #key_location ⇒ Object
- #location ⇒ Object
- #open ⇒ Object
Constructor Details
#initialize(deploy_key) ⇒ GitSSH
Returns a new instance of GitSSH.
12 13 14 |
# File 'lib/vx/scm/git/git_ssh.rb', line 12 def initialize(deploy_key) @deploy_key = deploy_key end |
Instance Attribute Details
#deploy_key ⇒ Object (readonly)
Returns the value of attribute deploy_key.
10 11 12 |
# File 'lib/vx/scm/git/git_ssh.rb', line 10 def deploy_key @deploy_key end |
Class Method Details
.template(key_location) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/vx/scm/git/git_ssh.rb', line 47 def template(key_location) key = key_location ? "-i #{key_location}" : "" out = ['#!/bin/sh'] out << "exec /usr/bin/ssh -A -o LogLevel=quiet -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{key} $@" out.join "\n" end |
Instance Method Details
#create ⇒ Object
24 25 26 27 |
# File 'lib/vx/scm/git/git_ssh.rb', line 24 def create key_location location end |
#destroy ⇒ Object
29 30 31 32 33 34 |
# File 'lib/vx/scm/git/git_ssh.rb', line 29 def destroy key_location.unlink if key_location location.unlink @location = nil @key_location = nil end |
#key_location ⇒ Object
40 41 42 43 44 |
# File 'lib/vx/scm/git/git_ssh.rb', line 40 def key_location if deploy_key @key_location ||= write_tmp_file 'key', deploy_key, 0600 end end |
#location ⇒ Object
36 37 38 |
# File 'lib/vx/scm/git/git_ssh.rb', line 36 def location @location ||= write_tmp_file 'git', self.class.template(key_location && key_location.path), 0700 end |
#open ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/vx/scm/git/git_ssh.rb', line 16 def open begin yield create ensure destroy end end |