lib/picky/index/file/text.rb in picky-0.11.2 vs lib/picky/index/file/text.rb in picky-0.12.0

- old
+ new

@@ -1,21 +1,36 @@ module Index module File + # Index data dumped in the text format. + # class Text < Basic + # Uses the extension "txt". + # def extension :txt end + # Text files are used exclusively for + # prepared data files. + # def load raise "Can't load from text file. Use JSON or Marshal." end + # Text files are used exclusively for + # prepared data files. + # def dump hash raise "Can't dump to text file. Use JSON or Marshal." end + # Retrieves prepared index data in the form + # * id,data\n + # * id,data\n + # * id,data\n + # # Yields an id and a symbol token. # def retrieve id, token = ::File.open(cache_path, 'r:binary') do |file| @@ -23,9 +38,16 @@ id, token = line.split ?,, 2 yield id.to_i, (token.chomp! || token).to_sym end end end + + # + # + def open_for_indexing &block + ::File.open cache_path, 'w:binary', &block + end + end end \ No newline at end of file