Class: GitSafe::SshTempfile
- Inherits:
-
Object
- Object
- GitSafe::SshTempfile
- Defined in:
- lib/git-safe/ssh_tempfile.rb
Instance Attribute Summary collapse
-
#private_key_string ⇒ Object
readonly
Returns the value of attribute private_key_string.
-
#private_key_temp_file ⇒ Object
readonly
Returns the value of attribute private_key_temp_file.
Instance Method Summary collapse
- #create_private_key_tmp_file ⇒ Object
-
#initialize(private_key_string) ⇒ SshTempfile
constructor
A new instance of SshTempfile.
- #safe_unlink_private_key_tmp_file ⇒ Object
Constructor Details
#initialize(private_key_string) ⇒ SshTempfile
Returns a new instance of SshTempfile.
5 6 7 8 |
# File 'lib/git-safe/ssh_tempfile.rb', line 5 def initialize(private_key_string) @private_key_string = private_key_string @private_key_temp_file = create_private_key_tmp_file end |
Instance Attribute Details
#private_key_string ⇒ Object (readonly)
Returns the value of attribute private_key_string.
3 4 5 |
# File 'lib/git-safe/ssh_tempfile.rb', line 3 def private_key_string @private_key_string end |
#private_key_temp_file ⇒ Object (readonly)
Returns the value of attribute private_key_temp_file.
3 4 5 |
# File 'lib/git-safe/ssh_tempfile.rb', line 3 def private_key_temp_file @private_key_temp_file end |
Instance Method Details
#create_private_key_tmp_file ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/git-safe/ssh_tempfile.rb', line 14 def create_private_key_tmp_file tf = Tempfile.new('git-ssh-wrapper') tf << private_key_string tf.puts('') # required for openssh keys tf.chmod(0600) tf.flush tf.close tf end |
#safe_unlink_private_key_tmp_file ⇒ Object
10 11 12 |
# File 'lib/git-safe/ssh_tempfile.rb', line 10 def safe_unlink_private_key_tmp_file private_key_temp_file&.unlink end |