Class: Secrets::App::Commands::OpenEditor
- Includes:
- Secrets
- Defined in:
- lib/secrets/app/commands/open_editor.rb
Constant Summary
Constants included from Secrets
Instance Attribute Summary collapse
-
#tempfile ⇒ Object
Returns the value of attribute tempfile.
Attributes inherited from Command
Instance Method Summary collapse
Methods included from Secrets
Methods inherited from Command
inherited, #initialize, #key, #opts
Constructor Details
This class inherits a constructor from Secrets::App::Commands::Command
Instance Attribute Details
#tempfile ⇒ Object
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_editor ⇒ Object
27 28 29 |
# File 'lib/secrets/app/commands/open_editor.rb', line 27 def launch_editor system("#{cli.editor} #{tempfile.path}") end |
#run ⇒ Object
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 |