class Fiesta::Editor

Public Instance Methods

compose() click to toggle source
# File lib/fiesta/editor.rb, line 9
def compose
  create_temp_file
  open
  read
end

Private Instance Methods

create_temp_file() click to toggle source
# File lib/fiesta/editor.rb, line 17
def create_temp_file
  file << content
  file << "# #{comment}\n\n" if comment
  file.close
end
editor_command() click to toggle source
# File lib/fiesta/editor.rb, line 27
def editor_command
  ENV["EDITOR"] || "vi"
end
file() click to toggle source
# File lib/fiesta/editor.rb, line 39
def file
  @_file ||= Tempfile.new(["fiesta", ".md"])
end
open() click to toggle source
# File lib/fiesta/editor.rb, line 23
def open
  system(*editor_command.split, file.path)
end
read() click to toggle source
# File lib/fiesta/editor.rb, line 31
def read
  file.open
  file.unlink
  file.read.each_line.map do |line|
    line unless line.start_with?("\n") || line.start_with?("#")
  end.compact.join
end