Added support for export pipeline extension objects. Fixes #963 (#964)

* WIP #963 Added support for extension objects (not just fns)

* WIP #963 Updated the cli exporter to extension object format
Esse commit está contido em:
Brian Broll
2017-01-28 12:49:05 -06:00
commit de GitHub
commit dc2df294a4
2 arquivos alterados com 35 adições e 16 exclusões
+20 -2
Ver Arquivo
@@ -123,6 +123,22 @@ define([
return config;
};
Export.prototype.getExporterFor = function (name) {
var Exporter = function() {},
format = FORMATS[name],
exporter;
Exporter.prototype = this;
exporter = new Exporter();
if (typeof format === 'function') {
exporter.main = format;
} else {
_.extend(exporter, format);
}
return exporter;
};
Export.prototype.generateOutputFiles = function (children) {
var name = this.core.getAttribute(this.activeNode, 'name');
@@ -131,10 +147,12 @@ define([
// Get the selected format
var config = this.getCurrentConfig(),
format = config.format || 'Basic CLI',
generate = FORMATS[format],
exporter,
staticInputs,
files;
exporter = this.getExporterFor(format);
staticInputs = config.staticInputs.map(id => {
var opId = id.split('/').splice(0, this.activeNodeDepth).join('/'),
port = this._portCache[id];
@@ -147,7 +165,7 @@ define([
};
});
files = generate.call(this, sections, staticInputs);
files = exporter.main(sections, staticInputs);
// If it returns a string, just put a single file
if (typeof files === 'string') {
return this.blobClient.putFile(`${name}.lua`, files);
+15 -14
Ver Arquivo
@@ -4,9 +4,18 @@ define([
], function(
) {
var TOBOOLEAN;
var TOBOOLEAN =
`local function toboolean(str)
if str == 'true' then
return true
elseif str == 'false' then
return false
end
end`;
var deserializersFromString = function(sections) {
var CliExporter = {};
CliExporter.deserializersFromString = function(sections) {
var hasBool = false;
// Add serializers given cli string input
@@ -33,13 +42,14 @@ define([
return sections;
};
var createExecFile = function (sections, staticInputs) {
CliExporter.main = function (sections, staticInputs) {
var code = [];
// Update deserializers for cli input
deserializersFromString.call(this, sections);
this.deserializersFromString(sections);
// Define all the operations, pipelines, etc
// 'getAllDefinitions' is provided as part of the public api
code.push(this.getAllDefinitions(sections));
// Command line specific stuff
@@ -90,14 +100,5 @@ define([
return staticInputs.length ? files : files['init.lua'];
};
TOBOOLEAN =
`local function toboolean(str)
if str == 'true' then
return true
elseif str == 'false' then
return false
end
end`;
return createExecFile;
return CliExporter;
});