Sha256: ea7e6e4b5ee9d6e3aa271653d87f2d502a8ac3ff75d966fe8fccfe581423a4d5
Contents?: true
Size: 522 Bytes
Versions: 7
Compression:
Stored size: 522 Bytes
Contents
module CouchDocs class DocumentDirectory attr_accessor :couch_doc_dir def initialize(path) Dir.new(path) @couch_doc_dir = path end def each_document Dir["#{couch_doc_dir}/*.json"].each do |filename| yield [ File.basename(filename, '.json'), JSON.parse(File.new(filename).read) ] end end def store_document(doc) file = File.new("#{couch_doc_dir}/#{doc['_id']}.json", "w+") file.write(doc.to_json) file.close end end end
Version data entries
7 entries across 7 versions & 2 rubygems