Method: Lowline#run_editor
- Defined in:
- lib/lowline.rb
#run_editor {|f| ... } ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/lowline.rb', line 57 def run_editor f = Tempfile.new "ditz" yield f f.close editor = ENV["EDITOR"] || "/usr/bin/vi" cmd = "#{editor} #{f.path.inspect}" mtime = File.mtime f.path system cmd or raise Error, "cannot execute command: #{cmd.inspect}" File.mtime(f.path) == mtime ? nil : f.path end |