YUKI Hiroshi
null+****@clear*****
Mon Dec 17 18:28:28 JST 2012
YUKI Hiroshi 2012-12-17 18:28:28 +0900 (Mon, 17 Dec 2012) New Revision: 6699e1cb5e0ab91a3fe83ae4fd5aac43e2e5b4f6 https://github.com/groonga/gcs/commit/6699e1cb5e0ab91a3fe83ae4fd5aac43e2e5b4f6 Log: Support "body" for scenarios Modified files: tools/scenario-runner.js Modified: tools/scenario-runner.js (+12 -1) =================================================================== --- tools/scenario-runner.js 2012-12-17 18:21:39 +0900 (4abc2e4) +++ tools/scenario-runner.js 2012-12-17 18:28:28 +0900 (31515e1) @@ -1,5 +1,8 @@ var Client = require(__dirname + '/../lib/client').Client; var EventEmitter = require('events').EventEmitter; +var xml = require(__dirname + '/../lib/batch/xml'); +var fs = require('fs'); +var path = require('path'); var xml2js = require('xml2js'); var xml2jsConfig = JSON.parse(JSON.stringify(xml2js.defaults['0.1'])); xml2jsConfig.explicitRoot = true; @@ -284,7 +287,15 @@ ScenarioRunner.prototype._process = function(scenario, callback) { switch (scenario.type) { case 'doc': - return this.client.DocumentsBatch(request.params, requestCallback); + var batches = request.body; + if (typeof batches == 'string') { + batches = fs.readFileSync(request.body, 'UTF-8'); + if (format == 'xml') + batches = xml.toJSON(batches); + else + batches = JSON.parse(batches); + } + return this.client.DocumentsBatch({ Docs: batches }, requestCallback); case 'search': return this.client.Search(request.params, requestCallback); -------------- next part -------------- HTML����������������������������... Download