From cb3dc49f9a71652197d503de796dcd8ede9b6144 Mon Sep 17 00:00:00 2001 From: loss Date: Tue, 2 Jul 2013 14:06:43 +0300 Subject: [PATCH 1/3] fix config --- etc/project | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/etc/project b/etc/project index 3b35ba4..f593378 100644 --- a/etc/project +++ b/etc/project @@ -8,7 +8,7 @@ "initiator": { "callback": { - + "flows": { "test-basic": { "tasks": [{ @@ -22,12 +22,6 @@ "{$uppercase}" ], "$set": "result" -// }, { -// "$function":"console.print", -// "$args":[ -// "Running equal...", -// "STRING against {$uppercase}" -// ] }] }, "test-every-000": { From 41a303807345ba73a61b291a1d89b4f54cc34876 Mon Sep 17 00:00:00 2001 From: loss Date: Tue, 2 Jul 2013 14:07:08 +0300 Subject: [PATCH 2/3] several params support for flow --- script/flow.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/script/flow.js b/script/flow.js index ad36775..249d4aa 100644 --- a/script/flow.js +++ b/script/flow.js @@ -4,7 +4,8 @@ module.exports = { launchContext: function () { return { token: process.argv[3], - param: process.argv[4] + param: process.argv[4], + params: process.argv.slice(4) }; }, launch: function (conf) { @@ -21,7 +22,7 @@ module.exports = { */ var callbackIConf = conf.initiator['callback']; - + var callbackIClass = dataflows.initiator('callback'); if ('function' == typeof callbackIClass) { @@ -32,7 +33,10 @@ module.exports = { var flow = processor.process (this.launchContext().token, { templates: {}, - request: {param: this.launchContext().param}, + request: { + param: this.launchContext().param, + params: this.launchContext().params + }, autoRun: false }); From fb7b184b2deb8cb5e99be0c098d46e384da79113 Mon Sep 17 00:00:00 2001 From: loss Date: Mon, 30 Sep 2013 10:20:00 +0300 Subject: [PATCH 3/3] tasks for string operations and external process launching --- task/exec.js | 27 +++++++++++++++++++++++++++ task/vars.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 task/exec.js create mode 100644 task/vars.js diff --git a/task/exec.js b/task/exec.js new file mode 100644 index 0000000..5cee6ef --- /dev/null +++ b/task/exec.js @@ -0,0 +1,27 @@ +var task = require ('dataflo.ws/task/base'), + util = require ('util'), + exec = require ('child_process').exec; + +var execTask = module.exports = function (config) { + this.init (config); +}; + +util.inherits (execTask, task); +util.extend (execTask.prototype, { + run: function () { + var self = this; + var args = self.args || self.$args || []; + var options = self.options || []; + + var cmd = self.command + ' ' + args.join(' '); + + exec(cmd, options, function(error, stdout, stderr) { + if (error) { + self.failed(stderr); + } else { + self.completed(stdout || self.returnAnything); + } + }); + } +}); + diff --git a/task/vars.js b/task/vars.js new file mode 100644 index 0000000..f75e479 --- /dev/null +++ b/task/vars.js @@ -0,0 +1,49 @@ +var task = require ('dataflo.ws/task/base'), + util = require ('util'); + +var varsTask = module.exports = function (config) { + this.init (config); +}; + +util.inherits (varsTask, task); +util.extend (varsTask.prototype, { + run: function () { + var self = this; + var args = self.args || self.$args; + + var item = args.shift(); + var funcName = args.shift(); + var func = item[funcName]; + + if (typeof func == "function") { + self.completed( func.apply(item, args) ); + } else { + self.failed(funcName + " is not a function"); + } + + }, + + concat: function() { + var self = this; + var args = self.args || self.$args; + + self.completed(args.join('')); + }, + + join: function() { + var self = this; + var args = self.args || self.$args; + var clue = self.clue || self.delimiter; + + self.completed(args.join(clue)); + }, + + set: function() { + var self = this; + var args = self.args || self.$args; + var value = self.value || self.args[0]; + + self.completed(value); + } +}); +