Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
});