class Posto::File

Public Class Methods

new(filename) click to toggle source
# File lib/posto/file.rb, line 5
def initialize(filename)
  @filename = filename
end

Public Instance Methods

commit(msg) click to toggle source
# File lib/posto/file.rb, line 13
def commit(msg)
  `git add #@filename`
  `git commit -m "#{msg}"`
end
commit_alone(msg) click to toggle source
# File lib/posto/file.rb, line 18
def commit_alone(msg)
  `git commit -m "#{msg}" #@filename`
end
oops() click to toggle source
# File lib/posto/file.rb, line 22
def oops
  `git reset --soft HEAD^`
end
template(todos) click to toggle source
# File lib/posto/file.rb, line 38
def template(todos)
  "todo\n----\n\n#{todos.join("\n")}\n"
end
todos() click to toggle source
# File lib/posto/file.rb, line 30
def todos
  if ::File.exists? @filename
    List.choose_todo_lines(IO.read(@filename).split("\n"))
  else
    []
  end
end
touch() click to toggle source
# File lib/posto/file.rb, line 26
def touch
  `touch #@filename`
end
write(todos) click to toggle source
# File lib/posto/file.rb, line 9
def write(todos)
  IO.write(@filename, template(todos))
end