class T::Editor

Public Class Methods

edit(path) click to toggle source
# File lib/t/editor.rb, line 20
def edit(path)
  system(Shellwords.join([editor, path]))
end
editor() click to toggle source
# File lib/t/editor.rb, line 24
def editor
  ENV['VISUAL'] || ENV['EDITOR'] || system_editor
end
gets() click to toggle source
# File lib/t/editor.rb, line 7
def gets
  file = tempfile
  edit(file.path)
  File.read(file).strip
ensure
  file.close
  file.unlink
end
system_editor() click to toggle source
# File lib/t/editor.rb, line 28
def system_editor
  RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'notepad' : 'vi'
end
tempfile() click to toggle source
# File lib/t/editor.rb, line 16
def tempfile
  Tempfile.new('TWEET_EDITMSG')
end