return execStr;
}
+/**
+ * toExecArray
+ *
+ * @param {fileId}
+ * @returns {string}
+ */
+function toExecArray(command, options, workspaceId) {
+ return new Promise(function(resolve, reject) {
+ var ocf = ocfReference[command]; // Array
+ var finalOptions = {};
+ var ocfObj = {};
+ ocf.forEach(function(o) {
+ ocfObj[o.option] = o;
+ });
+
+ // set default parameters
+ ocf.forEach(function(o) {
+ o.arg.forEach(function(arg) {
+ if(!(arg.initialValue === "") && arg.initialValue) {
+ if(!(finalOptions[o.option])) {
+ finalOptions[o.option] = [];
+ finalOptions[o.option].push(arg.initialValue);
+ } else {
+ finalOptions[o.option].push(arg.initialValue);
+ }
+ }
+ });
+ });
+
+ getUUIDs(workspaceId)
+ .then(function(uuids) {
+ // set user setting parameters
+ options.forEach(function(o) {
+ var s = [];
+ var outRegExp = /out|append/;
+ o.arguments.forEach(function(arg, i) {
+ if(ocfObj[o.name].arg[i].formType === 'select') {
+ s.push(uuids[arg]);
+ } else {
+ s.push(arg);
+ }
+ });
+ finalOptions[o.name] = s;
+ });
+ var array = Object.keys(finalOptions).reduce(function(a,b) {
+ a.push(b);
+ finalOptions[b].forEach(function(v) {
+ a.push(v);
+ });
+ return a;
+ },[]);
+ resolve(array);
+ });
+ });
+}
/**
* execute
toExecString: toExecString,
execute: execute,
getFiles: getFiles,
- getUUIDs: getUUIDs
+ getUUIDs: getUUIDs,
+ toExecArray: toExecArray
}
module.exports = { instance: eos };
});
+ var test2 = `
+ /**
+ * 実行時文字列への変換
+ *
+ * @param command
+ * @param options
+ * @returns {string}
+ * function toExecString(command, params) {
+ */
+ `;
+
describe(test2, function() {
it('should return true when all options is proper.', function() {
var result = eos.toExecString('dcdFilePrint', [{name: '-r', arguments: [1,2,3]}, { name: '-i', arguments: ['file1.txt']}, { name: '-o', arguments: ['file3.txt']} ], "1f83f620-c1ed-11e5-9657-7942989daa00");
});
});
- var test2 = `
+ var toExecArray = `
/**
- * 実行時文字列への変換
+ * 実行時配列への変換
*
* @param command
- * @param options
* @returns {string}
* function toExecString(command, params) {
*/
`;
+ describe(toExecArray, function() {
+ before(function() {
+ process.env.NODE_ENV = '';
+ return db.init()
+ .then(function() {
+ return Promise.all([db.test1(), db.test2(), db.testRest()])
+ });
+ });
+
+ it('should be resolved with length 4', function() {
+ var command = testCommand.command;
+ var options = testCommand.options;
+ var workspace = testCommand.workspace;
+ return eos.toExecArray(command, options, '1f83f620-c1ed-11e5-9657-7942989daa00').should.be.eventually.length(16);
+ });
+
+ });
describe('execute', function() {
before(function() {