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

Feature: 'Comment' operation #123

Merged
merged 2 commits into from
May 2, 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
14 changes: 14 additions & 0 deletions src/core/FlowControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions src/core/config/Categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ const Categories = [
"Jump",
"Conditional Jump",
"Return",
"Comment"
]
},
];
Expand Down
14 changes: 14 additions & 0 deletions src/core/config/OperationConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br><br>This operation decodes data from an ASCII Base64 string back into its raw format.<br><br>e.g. <code>aGVsbG8=</code> becomes <code>hello</code>",
run: Base64.runFrom,
Expand Down
30 changes: 30 additions & 0 deletions test/tests/operations/FlowControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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+/="]
}
]
},
]);