implement basic toString() (#272)

* implement basic toString()

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* refactor

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* remove load-image from string

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* more refactor

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* doing es5 way

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* final refactor

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* refactor

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* remove if else from map

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fix function call

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* add sequencer.steps

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* add tests for toString and stepToString

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fix toString final

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fix build failing

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* refactored and fix tests

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* refactor tests

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
Varun Gupta
2018-06-01 22:15:22 +05:30
committed by Jeffrey Warren
parent be810fb9c4
commit ac183205f0
7 changed files with 90 additions and 33 deletions

View File

@@ -121,7 +121,7 @@ ImageSequencer = function ImageSequencer(options) {
progressObj = spinnerObj
delete arguments['0']
}
var this_ = (this.name == "ImageSequencer")?this:this.sequencer;
var args = (this.name == "ImageSequencer")?[]:[this.images];
for (var arg in arguments) args.push(copy(arguments[arg]));
@@ -198,6 +198,24 @@ ImageSequencer = function ImageSequencer(options) {
return modulesdata;
}
function toString(step) {
if(step) {
return stepToString(step);
} else {
return copy(this.images.image1.steps).map(stepToString).slice(1).join(',');
}
}
function stepToString(step) {
let inputs = copy(modulesInfo(step.options.name).inputs);
inputs = inputs || {};
for(let input in inputs) inputs[input] = step.options[input] || inputs[input].default;
var configurations = Object.keys(inputs).map(key=>key + ':' + inputs[key]).join(',');
return `${step.options.name}(${configurations})`;
}
return {
//literals and objects
name: "ImageSequencer",
@@ -218,12 +236,14 @@ ImageSequencer = function ImageSequencer(options) {
setUI: setUI,
exportBin: exportBin,
modulesInfo: modulesInfo,
toString: toString,
stepToString: stepToString,
//other functions
log: log,
objTypeOf: objTypeOf,
copy: copy,
setInputStep: require('./ui/SetInputStep')(sequencer)
}