lib/approvals/utilities/dotfile.rb in approvals-0.0.9 vs lib/approvals/utilities/dotfile.rb in approvals-0.0.10

- old
+ new

@@ -2,37 +2,32 @@ class Dotfile class << self def reset - File.delete(path) if File.exists?(path) - touch + File.truncate(path, 0) if File.exists?(path) end - def path - File.join(Approvals.project_dir, '.approvals') - end - - def touch - FileUtils.touch(path) - end - def append(text) unless includes?(text) write text end end + private + + def path + File.join(Approvals.project_dir, '.approvals') + end + def includes?(text) system("cat #{path} | grep -q \"^#{text}$\"") end def write(text) File.open(path, 'a+') do |f| f.write "#{text}\n" end end - end end - end