Sha256: 31f4fdf566047278c69b24a5289d374e954fd88992ef3fc680a8be606586a538
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require 'toothpick/git' require 'toothpick/search' require 'toothpick/errors' require 'date' module Toothpick module Commands TOOTHPICK_HOME = ENV['HOME'] + "/.toothpick" def self.init(picks_repo) Git.clone_repo(picks_repo, TOOTHPICK_HOME) end 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 def self.search(string) abort_if_setup_not_done! Search.new(TOOTHPICK_HOME, string) end private 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 def self.pick_file_path File.join(TOOTHPICK_HOME, pick_filename) end def self.pick_filename Time.now.utc.to_date.strftime + ".md" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
toothpick-0.0.2 | lib/toothpick/commands.rb |