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

#executeObject



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

def execute
  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

#launch_editorObject



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

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