class Terjira::Editor
Public Class Methods
editor_text(content = '')
click to toggle source
# File lib/terjira/option_support/editor.rb, line 3 def self.editor_text(content = '') editor = ENV['EDITOR'] if editor.nil? || editor.empty? raise 'EDITOR environment variable not found. Please set a default editor.' end tmp_file = Tempfile.new('content') tmp_file.write(content) tmp_file.close success = system "#{editor} #{tmp_file.path}" content = File.read(tmp_file.path) if success tmp_file.unlink raise 'Editor returned a non-zero exit code. Something must have gone wrong' unless success content end