Module: DocBookInMongo
Instance Method Summary collapse
Instance Method Details
#file_in_mongo(filename, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/doc_book_in_mongo.rb', line 9 def file_in_mongo(filename,={}) session = Moped::Session.new([ "#{[:host]}:#{[:port]}" ]) session.use [:database] xml2json = File.join(File.dirname(__FILE__),'..','bin','xml2json') cmd = %Q(#{xml2json} #{filename}) output = `#{cmd}` json = JSON.parse(output) doc = json['book'] doc['_id'] = doc['id'] session[[:collection]].insert(doc) end |