module Toothpick::Commands

Constants

TOOTHPICK_HOME

Public Class Methods

init(picks_repo) click to toggle source
# File lib/toothpick/commands.rb, line 11
def self.init(picks_repo)
  Git.clone_repo(picks_repo, TOOTHPICK_HOME)
end
new_pick() click to toggle source
# File lib/toothpick/commands.rb, line 15
def self.new_pick
  abort_if_setup_not_done!
  git = Git.new(TOOTHPICK_HOME)
  git.update
  pid = Kernel.spawn("$EDITOR #{pick_file_path}")
  Process.waitpid(pid)
  if $?.success? and File.exists?(pick_file_path)
    git.commit
    git.push
  end
end

Private Class Methods

abort_if_setup_not_done!() click to toggle source
# File lib/toothpick/commands.rb, line 34
def self.abort_if_setup_not_done!
  unless Git.on_git?(TOOTHPICK_HOME)
    raise Errors::ToothpickNotInitialized,
      "You need to run 'toothpick init' first"
  end
end
pick_file_path() click to toggle source
# File lib/toothpick/commands.rb, line 41
def self.pick_file_path
  File.join(TOOTHPICK_HOME, pick_filename)
end
pick_filename() click to toggle source
# File lib/toothpick/commands.rb, line 45
def self.pick_filename
  Time.now.utc.to_date.strftime + ".md"
end