From addd45ae8efb1aa9bfd6ff3599fc1df6c93e942e Mon Sep 17 00:00:00 2001 From: n1474335 Date: Thu, 27 Apr 2017 13:05:29 +0000 Subject: [PATCH 1/2] Added 'Comment' operation for annotating the recipe --- src/core/FlowControl.js | 14 +++++++++++++ src/core/config/Categories.js | 1 + src/core/config/OperationConfig.js | 14 +++++++++++++ test/tests/operations/FlowControl.js | 30 ++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/src/core/FlowControl.js b/src/core/FlowControl.js index 54541f74..324bb93c 100755 --- a/src/core/FlowControl.js +++ b/src/core/FlowControl.js @@ -193,6 +193,20 @@ const FlowControl = { return state; }, + + /** + * Comment operation. + * + * @param {Object} state - The current state of the recipe. + * @param {number} state.progress - The current position in the recipe. + * @param {Dish} state.dish - The Dish being operated on. + * @param {Operation[]} state.opList - The list of operations in the recipe. + * @returns {Object} The updated state of the recipe. + */ + runComment: function(state) { + return state; + }, + }; export default FlowControl; diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js index da0c9f0a..63aef35a 100755 --- a/src/core/config/Categories.js +++ b/src/core/config/Categories.js @@ -292,6 +292,7 @@ const Categories = [ "Jump", "Conditional Jump", "Return", + "Comment" ] }, ]; diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index ca6bdbbd..ee0f8ce7 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -162,6 +162,20 @@ const OperationConfig = { flowControl: true, args: [] }, + "Comment": { + description: "Provides a place to write comments within the flow of the recipe. This operation has no computational effect.", + run: FlowControl.runComment, + inputType: "string", + outputType: "string", + flowControl: true, + args: [ + { + name: "", + type: "text", + value: "" + } + ] + }, "From Base64": { description: "Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.

This operation decodes data from an ASCII Base64 string back into its raw format.

e.g. aGVsbG8= becomes hello", run: Base64.runFrom, diff --git a/test/tests/operations/FlowControl.js b/test/tests/operations/FlowControl.js index 96ae2e80..50e87923 100644 --- a/test/tests/operations/FlowControl.js +++ b/test/tests/operations/FlowControl.js @@ -111,4 +111,34 @@ TestRegister.addTests([ }, ], }, + { + name: "Comment: nothing", + input: "", + expectedOutput: "", + recipeConfig: [ + { + "op": "Comment", + "args": [""] + } + ] + }, + { + name: "Fork, Comment, Base64", + input: "cat\nsat\nmat", + expectedOutput: "Y2F0\nc2F0\nbWF0\n", + recipeConfig: [ + { + "op": "Fork", + "args": ["\\n","\\n",false] + }, + { + "op": "Comment", + "args": ["Testing 123"] + }, + { + "op": "To Base64", + "args": ["A-Za-z0-9+/="] + } + ] + }, ]); From 8096fd20a72f9c31e2dd5c043e86824f996c11e0 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Thu, 27 Apr 2017 13:12:45 +0000 Subject: [PATCH 2/2] Fixed lint errors --- src/core/FlowControl.js | 2 +- test/tests/operations/FlowControl.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/FlowControl.js b/src/core/FlowControl.js index 324bb93c..4977eaaf 100755 --- a/src/core/FlowControl.js +++ b/src/core/FlowControl.js @@ -196,7 +196,7 @@ const FlowControl = { /** * Comment operation. - * + * * @param {Object} state - The current state of the recipe. * @param {number} state.progress - The current position in the recipe. * @param {Dish} state.dish - The Dish being operated on. diff --git a/test/tests/operations/FlowControl.js b/test/tests/operations/FlowControl.js index 50e87923..a48b8bf3 100644 --- a/test/tests/operations/FlowControl.js +++ b/test/tests/operations/FlowControl.js @@ -129,7 +129,7 @@ TestRegister.addTests([ recipeConfig: [ { "op": "Fork", - "args": ["\\n","\\n",false] + "args": ["\\n", "\\n", false] }, { "op": "Comment",