Skip to content

Commit

Permalink
Added support for export pipeline extension objects. Fixes #963 (#964)
Browse files Browse the repository at this point in the history
* WIP #963 Added support for extension objects (not just fns)

* WIP #963 Updated the cli exporter to extension object format
  • Loading branch information
brollb authored Jan 28, 2017
1 parent c3f9ce7 commit dc2df29
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
22 changes: 20 additions & 2 deletions src/plugins/Export/Export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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];
Expand All @@ -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);
Expand Down
29 changes: 15 additions & 14 deletions src/plugins/Export/formats/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 CliExporter = {};

var deserializersFromString = function(sections) {
CliExporter.deserializersFromString = function(sections) {
var hasBool = false;

// Add serializers given cli string input
Expand All @@ -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
Expand Down Expand Up @@ -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;
});

0 comments on commit dc2df29

Please sign in to comment.