Class: Sym::App::Commands::OpenEditor

Inherits:
BaseCommand show all
Includes:
Sym
Defined in:
lib/sym/app/commands/open_editor.rb

Constant Summary

Constants included from Sym

DESCRIPTION, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sym

config, default_key, default_key?, default_key_file

Constructor Details

This class inherits a constructor from Sym::App::Commands::BaseCommand

Instance Attribute Details

#tempfileObject

Returns the value of attribute tempfile.



19
20
21
# File 'lib/sym/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/sym/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/sym/app/commands/open_editor.rb', line 34

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