Sha256: ff627b8cbbd7555548d0828f0685e0bf11558b08c16986efedab72968ffb7644
Contents?: true
Size: 1.19 KB
Versions: 6
Compression:
Stored size: 1.19 KB
Contents
module Picky module Backend 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 string and a symbol token. # def retrieve id = nil token = nil ::File.open(cache_path, 'r:utf-8') do |file| file.each_line do |line| id, token = line.split ?,, 2 yield id, (token.chomp! || token).to_sym end end end # # def open &block ::File.open cache_path, 'w:utf-8', &block end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems