lib/vos/box/marks.rb in vos-0.1.3 vs lib/vos/box/marks.rb in vos-0.1.4

- old
+ new

@@ -1,31 +1,29 @@ module Vos class Box module Marks - def mark key - ensure_mark_requrements! - file("#{marks_dir}/#{key}").create! + def mark! key + marks_dir.file(key).create + @marks_cache = nil end def has_mark? key - ensure_mark_requrements! - entry["#{marks_dir}/#{key}"].exist? + marks_cache.include? key.to_s end + alias_method :marked?, :has_mark? - def clear_marks - bash "rm -r #{marks_dir}" + def clear_marks! + marks_dir.destroy + @marks_cache = nil end - + + def marks_dir + dir "/marks" + end + protected - def marks_dir - home "/.marks" - end - - def ensure_mark_requrements! - unless @ensure_mark_requrements - self.dir(marks_dir).create - @ensure_mark_requrements = true - end + def marks_cache + @marks_cache ||= marks_dir.files(bang: false).collect{|file| file.name} end end end end \ No newline at end of file