Class: Secrets::App::Commands::OpenEditor

Inherits:
Command
  • Object
show all
Includes:
Secrets
Defined in:
lib/secrets/app/commands/open_editor.rb

Constant Summary

Constants included from Secrets

VERSION

Instance Attribute Summary collapse

Attributes inherited from Command

#cli

Instance Method Summary collapse

Methods included from Secrets

included

Methods inherited from Command

inherited, #initialize, #key, #opts

Constructor Details

This class inherits a constructor from Secrets::App::Commands::Command

Instance Attribute Details

#tempfileObject

Returns the value of attribute tempfile.



13
14
15
# File 'lib/secrets/app/commands/open_editor.rb', line 13

def tempfile
  @tempfile
end

Instance Method Details

#launch_editorObject



27
28
29
# File 'lib/secrets/app/commands/open_editor.rb', line 27

def launch_editor
  system("#{cli.editor} #{tempfile.path}")
end

#runObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/secrets/app/commands/open_editor.rb', line 15

def run
  begin
    self.tempfile = ::Tempfile.new(::Base64.urlsafe_encode64(opts[:file]))
    decrypt_content(self.tempfile)
    result = process launch_editor
  ensure
    self.tempfile.close if tempfile
    self.tempfile.unlink rescue nil
  end
  result
end