Sha256: 42230f97f96ab51c98e005f7b0d14471a875dbb9dc2222db951536fddbd86c42
Contents?: true
Size: 600 Bytes
Versions: 2
Compression:
Stored size: 600 Bytes
Contents
require "tempfile" require "shellwords" module T class Editor class << self def gets file = tempfile edit(file.path) File.read(file).strip ensure file.close file.unlink end def tempfile Tempfile.new("TWEET_EDITMSG") end def edit(path) system(Shellwords.join([editor, path])) end def editor ENV["VISUAL"] || ENV["EDITOR"] || system_editor end def system_editor /mswin|mingw/.match?(RbConfig::CONFIG["host_os"]) ? "notepad" : "vi" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
t-4.1.1 | lib/t/editor.rb |
t-4.1.0 | lib/t/editor.rb |