lib/picky/backend/file/text.rb in picky-2.7.0 vs lib/picky/backend/file/text.rb in picky-3.0.0.pre1

- old
+ new

@@ -1,54 +1,58 @@ -module Backend +module Picky - module File + module Backend - # Index data dumped in the text format. - # - class Text < Basic + module File - # Uses the extension "txt". + # Index data dumped in the text format. # - 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 + class Text < Basic - # Retrieves prepared index data in the form - # * id,data\n - # * id,data\n - # * id,data\n - # - # Yields an id string and a symbol token. - # - def retrieve - id = nil - token = nil - ::File.open(cache_path, 'r:binary') do |file| - file.each_line do |line| - id, token = line.split ?,, 2 - yield id, (token.chomp! || token).to_sym + # 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 string and a symbol token. + # + def retrieve + id = nil + token = nil + ::File.open(cache_path, 'r:binary') do |file| + file.each_line do |line| + id, token = line.split ?,, 2 + yield id, (token.chomp! || token).to_sym + end end end - end - # - # - def open &block - ::File.open cache_path, 'w:binary', &block - end + # + # + def open &block + ::File.open cache_path, 'w:binary', &block + end + + end end end \ No newline at end of file