Class: Shhh::App::Commands::OpenEditor

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

Constant Summary

Constants included from Shhh

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Instance Attribute Details

#tempfileObject

Returns the value of attribute tempfile


19
20
21
# File 'lib/shhh/app/commands/open_editor.rb', line 19

def tempfile
  @tempfile
end

Instance Method Details

#launch_editorObject


33
34
35
# File 'lib/shhh/app/commands/open_editor.rb', line 33

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

#runObject


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/shhh/app/commands/open_editor.rb', line 21

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