diff --git a/components/CallMethod.coffee b/components/CallMethod.coffee index bf60e93..725a2b8 100644 --- a/components/CallMethod.coffee +++ b/components/CallMethod.coffee @@ -9,13 +9,22 @@ class CallMethod extends noflo.Component @method = null @args = [] - @inPorts = - in: new noflo.Port 'object' - method: new noflo.Port 'string' - arguments: new noflo.Port 'all' - @outPorts = - out: new noflo.Port 'all' - error: new noflo.Port 'string' + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object on which a method will be called' + method: + datatype: 'string' + description: 'Name of the method to call' + arguments: + datatype: 'all' + description: 'Arguments given to the method (one argument per IP)' + @outPorts = new noflo.OutPorts + out: + datatype: 'all' + description: 'Value returned by the method call' + error: + datatype: 'object' @inPorts.in.on 'begingroup', (group) => @outPorts.out.beginGroup group @@ -42,7 +51,7 @@ class CallMethod extends noflo.Component @inPorts.arguments.on 'connect', => @args = [] - + @inPorts.arguments.on 'data', (data) => @args.push data diff --git a/components/CreateDate.coffee b/components/CreateDate.coffee index 5ca55fd..c09a5d4 100644 --- a/components/CreateDate.coffee +++ b/components/CreateDate.coffee @@ -4,10 +4,14 @@ class CreateDate extends noflo.Component description: 'Create a new Date object from string' icon: 'clock-o' constructor: -> - @inPorts = - in: new noflo.Port 'string' - @outPorts = - out: new noflo.Port 'object' + @inPorts = new noflo.InPorts + in: + datatype: 'string' + description: 'A string representation of a date in RFC2822/IETF/ISO8601 format' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'A new Date object' @inPorts.in.on 'begingroup', (group) => @outPorts.out.beginGroup group diff --git a/components/CreateObject.coffee b/components/CreateObject.coffee index 0782a09..0a92f49 100644 --- a/components/CreateObject.coffee +++ b/components/CreateObject.coffee @@ -2,10 +2,14 @@ noflo = require 'noflo' class CreateObject extends noflo.Component constructor: -> - @inPorts = - start: new noflo.Port 'bang' - @outPorts = - out: new noflo.Port 'object' + @inPorts = new noflo.InPorts + start: + datatype: 'bang' + description: 'Signal to create a new object' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'A new empty object' @inPorts.start.on 'begingroup', (group) => @outPorts.out.beginGroup group diff --git a/components/DuplicateProperty.coffee b/components/DuplicateProperty.coffee index 9d750fc..5a7b967 100644 --- a/components/DuplicateProperty.coffee +++ b/components/DuplicateProperty.coffee @@ -5,12 +5,16 @@ class DuplicateProperty extends noflo.Component @properties = {} @separator = '/' - @inPorts = - property: new noflo.ArrayPort() - separator: new noflo.Port() - in: new noflo.Port() - @outPorts = - out: new noflo.Port() + @inPorts = new noflo.InPorts + property: + datatype: 'all' + separator: + datatype: 'string' + in: + datatype: 'object' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' @inPorts.property.on 'data', (data) => @setProperty data @@ -35,7 +39,7 @@ class DuplicateProperty extends noflo.Component if propParts.length > 2 @properties[propParts.pop()] = propParts return - + @properties[propParts[1]] = propParts[0] addProperties: (object) -> diff --git a/components/Extend.coffee b/components/Extend.coffee index 2037997..9667150 100644 --- a/components/Extend.coffee +++ b/components/Extend.coffee @@ -12,13 +12,23 @@ class Extend extends noflo.Component @key = null @reverse = false - @inPorts = - in: new noflo.Port - base: new noflo.Port - key: new noflo.Port - reverse: new noflo.Port - @outPorts = - out: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to extend' + base: + datatype: 'object' + description: 'Objects to extend with (one object per IP)' + key: + datatype: 'string' + description: 'Property name to extend with' + reverse: + datatype: 'string' + description: 'A string equal "true" if you want to reverse the order of extension algorithm' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'The object received on port "in" extended' @inPorts.base.on "connect", => @bases = [] diff --git a/components/ExtractProperty.coffee b/components/ExtractProperty.coffee index 924ad30..18a1c2a 100644 --- a/components/ExtractProperty.coffee +++ b/components/ExtractProperty.coffee @@ -7,11 +7,17 @@ class ExtractProperty extends noflo.Component in the incoming object" constructor: -> - @inPorts = - in: new noflo.Port - key: new noflo.Port - @outPorts = - out: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'An object to extract property from' + key: + datatype: 'string' + description: 'Property names to extract (one property per IP)' + @outPorts = new noflo.OutPorts + out: + datatype: 'all' + description: 'Values of the property extracted (each value sent as a separate IP)' @inPorts.key.on "connect", => @keys = [] diff --git a/components/FilterProperty.coffee b/components/FilterProperty.coffee index 0c79ad4..e1a6dc8 100644 --- a/components/FilterProperty.coffee +++ b/components/FilterProperty.coffee @@ -21,16 +21,27 @@ class FilterProperty extends noflo.Component @accepts = [] @regexps = [] - @inPorts = - in: new noflo.Port - key: new noflo.Port - recurse: new noflo.Port - keep: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to filter properties from' + key: + datatype: 'string' + description: 'Keys to filter (one key per IP)' + recurse: + datatype: 'string' + description: '"true" to recurse on the object\'s values' + keep: + datatype: 'string' + description: '"true" if matching properties must be kept, otherwise removed' # Legacy mode - accept: new noflo.ArrayPort - regexp: new noflo.ArrayPort - @outPorts = - out: new noflo.Port + accept: + datatype: 'all' + regexp: + datatype: 'all' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' @inPorts.keep.on "data", (keep) => @keep = true if keep is "true" diff --git a/components/FilterPropertyValue.coffee b/components/FilterPropertyValue.coffee index d13d80d..3c0f2ad 100644 --- a/components/FilterPropertyValue.coffee +++ b/components/FilterPropertyValue.coffee @@ -6,13 +6,23 @@ class FilterPropertyValue extends noflo.Component @accepts = {} @regexps = {} - @inPorts = - accept: new noflo.ArrayPort 'all' - regexp: new noflo.ArrayPort 'string' - in: new noflo.Port 'object' - @outPorts = - out: new noflo.Port 'object' - missed: new noflo.Port 'object' + @inPorts = new noflo.InPorts + accept: + datatype: 'all' + description: '' + regexp: + datatype: 'string' + description: '' + in: + datatype: 'object' + description: 'Object to filter properties from' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'Object including the filtered properties' + missed: + datatype: 'object' + description: 'Object received as input if no key have been matched' @inPorts.accept.on 'data', (data) => @prepareAccept data diff --git a/components/FlattenObject.coffee b/components/FlattenObject.coffee index 90bc4ce..b6ced67 100644 --- a/components/FlattenObject.coffee +++ b/components/FlattenObject.coffee @@ -3,11 +3,15 @@ noflo = require 'noflo' class FlattenObject extends noflo.Component constructor: -> @map = {} - @inPorts = - map: new noflo.ArrayPort() - in: new noflo.Port() - @outPorts = - out: new noflo.Port() + @inPorts = new noflo.InPorts + map: + datatype: 'all' + in: + datatype: 'object' + description: 'Object to flatten' + @outPorts = new noflo.OutPorts + out: + datatype: 'array' @inPorts.map.on 'data', (data) => @prepareMap data diff --git a/components/GetObjectKey.coffee b/components/GetObjectKey.coffee index 04121a6..62679cf 100644 --- a/components/GetObjectKey.coffee +++ b/components/GetObjectKey.coffee @@ -7,14 +7,26 @@ class GetObjectKey extends noflo.Component @data = [] @key = [] - @inPorts = - in: new noflo.Port 'object' - key: new noflo.ArrayPort 'string' - sendgroup: new noflo.Port 'boolean' - @outPorts = - out: new noflo.Port 'all' - object: new noflo.Port 'object' - missed: new noflo.Port 'object' + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to get keys from' + key: + datatype: 'string' + description: 'Keys to extract from the object (one key per IP)' + sendgroup: + datatype: 'boolean' + description: 'true to send keys as groups around value IPs, false otherwise' + @outPorts = new noflo.OutPorts + out: + datatype: 'all' + description: 'Values extracts from the input object given the input keys (one value per IP, potentially grouped using the key names)' + object: + datatype: 'object' + description: 'Object forwarded from input if at least one property matches the input keys' + missed: + datatype: 'object' + description: 'Object forwarded from input if no property matches the input keys' @inPorts.in.on 'connect', => @data = [] @@ -30,7 +42,7 @@ class GetObjectKey extends noflo.Component # Data already sent @outPorts.out.disconnect() return - + # No key, data will be sent when we get it return unless @key.length diff --git a/components/InsertProperty.coffee b/components/InsertProperty.coffee index edd47fb..f1a4694 100644 --- a/components/InsertProperty.coffee +++ b/components/InsertProperty.coffee @@ -8,11 +8,17 @@ class InsertProperty extends noflo.Component constructor: -> @properties = {} - @inPorts = - in: new noflo.Port - property: new noflo.Port - @outPorts = - out: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to insert property into' + property: + datatype: 'all' + description: 'Property to insert (property sent as group, value sent as IP)' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'Object received as input with added properties' @inPorts.property.on "connect", => @properties = {} diff --git a/components/Join.coffee b/components/Join.coffee index d02d00e..2a63938 100644 --- a/components/Join.coffee +++ b/components/Join.coffee @@ -9,11 +9,17 @@ class Join extends noflo.Component constructor: -> @delimiter = "," - @inPorts = - in: new noflo.Port - delimiter: new noflo.Port - @outPorts = - out: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to join values from' + delimiter: + datatype: 'string' + description: 'Delimiter to join values' + @outPorts = new noflo.OutPorts + out: + datatype: 'string' + description: 'String conversion of all values joined with delimiter into one string' @inPorts.delimiter.on "data", (@delimiter) => diff --git a/components/Keys.coffee b/components/Keys.coffee index 0e7ae01..3449e72 100644 --- a/components/Keys.coffee +++ b/components/Keys.coffee @@ -6,10 +6,14 @@ class Keys extends noflo.Component description: "gets only the keys of an object and forward them as an array" constructor: -> - @inPorts = - in: new noflo.Port 'object' - @outPorts = - out: new noflo.Port 'all' + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to get keys from' + @outPorts = new noflo.OutPorts + out: + datatype: 'string' + description: 'Keys from the incoming object (one per IP)' @inPorts.in.on "begingroup", (group) => @outPorts.out.beginGroup(group) diff --git a/components/MapProperty.coffee b/components/MapProperty.coffee index 5642a83..8af828e 100644 --- a/components/MapProperty.coffee +++ b/components/MapProperty.coffee @@ -5,12 +5,16 @@ class MapProperty extends noflo.Component @map = {} @regexps = {} - @inPorts = - map: new noflo.ArrayPort() - regexp: new noflo.ArrayPort() - in: new noflo.Port() - @outPorts = - out: new noflo.Port() + @inPorts = new noflo.InPorts + map: + datatype: 'all' + regexp: + datatype: 'string' + in: + datatype: 'object' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' @inPorts.map.on 'data', (data) => @prepareMap data diff --git a/components/MapPropertyValue.coffee b/components/MapPropertyValue.coffee index c45a713..0e0e1db 100644 --- a/components/MapPropertyValue.coffee +++ b/components/MapPropertyValue.coffee @@ -7,12 +7,16 @@ class MapPropertyValue extends noflo.Component @regexpAny = {} @regexp = {} - @inPorts = - map: new noflo.ArrayPort() - regexp: new noflo.ArrayPort() - in: new noflo.Port() - @outPorts = - out: new noflo.Port() + @inPorts = new noflo.InPorts + map: + datatype: 'all' + regexp: + datatype: 'string' + in: + datatype: 'object' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' @inPorts.map.on 'data', (data) => @prepareMap data diff --git a/components/MergeObjects.coffee b/components/MergeObjects.coffee index 09c4c83..3debde8 100644 --- a/components/MergeObjects.coffee +++ b/components/MergeObjects.coffee @@ -8,10 +8,14 @@ class MergeObjects extends noflo.Component constructor: -> @merge = _.bind @merge, this - @inPorts = - in: new noflo.Port - @outPorts = - out: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Objects to merge (one per IP)' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'A new object containing the merge of input objects' @inPorts.in.on "connect", () => @groups = [] diff --git a/components/RemoveProperty.coffee b/components/RemoveProperty.coffee index 050ce48..ce49b7d 100644 --- a/components/RemoveProperty.coffee +++ b/components/RemoveProperty.coffee @@ -5,11 +5,17 @@ class RemoveProperty extends noflo.Component icon: 'ban' constructor: -> @properties = [] - @inPorts = - in: new noflo.Port() - property: new noflo.ArrayPort() - @outPorts = - out: new noflo.Port() + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to remove properties from' + property: + datatype: 'string' + description: 'Properties to remove (one per IP)' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'Object forwarded from input' @inPorts.property.on 'data', (data) => @properties.push data diff --git a/components/ReplaceKey.coffee b/components/ReplaceKey.coffee index beb6887..60a7e51 100644 --- a/components/ReplaceKey.coffee +++ b/components/ReplaceKey.coffee @@ -8,11 +8,16 @@ class ReplaceKey extends noflo.Component constructor: -> @patterns = {} - @inPorts = - in: new noflo.Port - pattern: new noflo.Port - @outPorts = - out: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to replace a key from' + pattern: + datatype: 'all' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'Object forwared from input' @inPorts.pattern.on "data", (@patterns) => diff --git a/components/SetProperty.coffee b/components/SetProperty.coffee index 7d111c1..a70546d 100644 --- a/components/SetProperty.coffee +++ b/components/SetProperty.coffee @@ -4,11 +4,16 @@ class SetProperty extends noflo.Component constructor: -> @properties = {} - @inPorts = - property: new noflo.ArrayPort() - in: new noflo.Port() - @outPorts = - out: new noflo.Port() + @inPorts = new noflo.InPorts + property: + datatype: 'all' + in: + datatype: 'object' + description: 'Object to set property on' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'Object forwared from input' @inPorts.property.on 'data', (data) => @setProperty data diff --git a/components/SetPropertyValue.coffee b/components/SetPropertyValue.coffee index 13233ca..7532db4 100644 --- a/components/SetPropertyValue.coffee +++ b/components/SetPropertyValue.coffee @@ -8,14 +8,24 @@ class SetPropertyValue extends noflo.Component @groups = [] @keep = false - @inPorts = - property: new noflo.Port 'string' - value: new noflo.Port 'all' - in: new noflo.Port 'object' + @inPorts = new noflo.InPorts + property: + datatype: 'string' + description: 'Property name to set value on' + value: + datatype: 'all' + description: 'Property value to set' + in: + datatype: 'object' + description: 'Object to set property value on' # Persist value - keep: new noflo.Port 'boolean' - @outPorts = - out: new noflo.Port 'object' + keep: + datatype: 'boolean' + description: 'true if input value must be kept around, false to drop it after the value is set' + @outPorts = new noflo.OutPorts + out: + datatype: 'object' + description: 'Object forwarded from the input' @inPorts.keep.on 'data', (keep) => @keep = String(keep) is 'true' diff --git a/components/SimplifyObject.coffee b/components/SimplifyObject.coffee index caaa258..0b15d95 100644 --- a/components/SimplifyObject.coffee +++ b/components/SimplifyObject.coffee @@ -3,10 +3,14 @@ noflo = require 'noflo' class SimplifyObject extends noflo.Component constructor: -> - @inPorts = - in: new noflo.Port - @outPorts = - out: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'all' + description: 'Object to simplify' + @outPorts = new noflo.OutPorts + out: + datatype: 'all' + description: 'Simplified object' @inPorts.in.on 'beginGroup', (group) => @outPorts.out.beginGroup group diff --git a/components/Size.coffee b/components/Size.coffee index 4123348..438ebda 100644 --- a/components/Size.coffee +++ b/components/Size.coffee @@ -6,10 +6,14 @@ class Size extends noflo.Component description: "gets the size of an object and sends that out as a number" constructor: -> - @inPorts = - in: new noflo.Port 'object' - @outPorts = - out: new noflo.Port 'int' + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to measure the size of' + @outPorts = new noflo.OutPorts + out: + datatype: 'int' + description: 'Size of the input object' @inPorts.in.on "begingroup", (group) => @outPorts.out.beginGroup(group) diff --git a/components/SliceArray.coffee b/components/SliceArray.coffee index 8cf8b9d..b762576 100644 --- a/components/SliceArray.coffee +++ b/components/SliceArray.coffee @@ -5,13 +5,22 @@ class SliceArray extends noflo.Component @begin = 0 @end = null - @inPorts = - in: new noflo.Port() - begin: new noflo.Port() - end: new noflo.Port() + @inPorts = new noflo.InPorts + in: + datatype: 'array' + description: 'Array to slice' + begin: + datatype: 'number' + description: 'Beginning of the slicing' + end: + datatype: 'number' + description: 'End of the slicing' @outPorts = - out: new noflo.Port() - error: new noflo.Port() + out: + datatype: 'array' + description: 'Result of the slice operation' + error: + datatype: 'string' @inPorts.begin.on 'data', (data) => @begin = data diff --git a/components/SplitArray.coffee b/components/SplitArray.coffee index 28b9368..d6ef5b8 100644 --- a/components/SplitArray.coffee +++ b/components/SplitArray.coffee @@ -2,10 +2,12 @@ noflo = require 'noflo' class SplitArray extends noflo.Component constructor: -> - @inPorts = - in: new noflo.Port() - @outPorts = - out: new noflo.ArrayPort() + @inPorts = new noflo.InPorts + in: + datatype: 'all' + @outPorts = new noflo.OutPorts + out: + datatype: 'all' @inPorts.in.on 'begingroup', (group) => @outPorts.out.beginGroup group diff --git a/components/SplitObject.coffee b/components/SplitObject.coffee index 17e0609..e0a1c9c 100644 --- a/components/SplitObject.coffee +++ b/components/SplitObject.coffee @@ -6,10 +6,14 @@ class SplitObject extends noflo.Component wrapped with the key as the group" constructor: -> - @inPorts = - in: new noflo.Port - @outPorts = - out: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'object' + description: 'Object to split key/values from' + @outPorts = new noflo.OutPorts + out: + datatype: 'all' + description: 'Values from the input object (one value per IP and its key sent as group)' @inPorts.in.on "begingroup", (group) => @outPorts.out.beginGroup(group) diff --git a/components/UniqueArray.coffee b/components/UniqueArray.coffee index 900b297..8722c72 100644 --- a/components/UniqueArray.coffee +++ b/components/UniqueArray.coffee @@ -2,10 +2,14 @@ noflo = require 'noflo' class UniqueArray extends noflo.Component constructor: -> - @inPorts = - in: new noflo.Port() - @outPorts = - out: new noflo.Port() + @inPorts = new noflo.InPorts + in: + datatype: 'array' + description: 'Array to get unique values from' + @outPorts = new noflo.OutPorts + out: + datatype: 'array' + description: 'Array containing only unique values from the input array' @inPorts.in.on 'data', (data) => @outPorts.out.send @unique data diff --git a/components/Values.coffee b/components/Values.coffee index f98d066..225de5e 100644 --- a/components/Values.coffee +++ b/components/Values.coffee @@ -6,10 +6,14 @@ class Values extends noflo.Component description: "gets only the values of an object and forward them as an array" constructor: -> - @inPorts = - in: new noflo.Port - @outPorts = - out: new noflo.Port + @inPorts = new noflo.InPorts + in: + datatype: 'all' + description: 'Object to extract values from' + @outPorts = new noflo.OutPorts + out: + datatype: 'all' + description: 'Values extracted from the input object (one value per IP)' @inPorts.in.on "begingroup", (group) => @outPorts.out.beginGroup(group) diff --git a/spec/FilterPropertyValue.coffee b/spec/FilterPropertyValue.coffee index 706ce9e..29055e5 100644 --- a/spec/FilterPropertyValue.coffee +++ b/spec/FilterPropertyValue.coffee @@ -13,10 +13,10 @@ describe 'FilterPropertyValue component', -> beforeEach -> c = FilterPropertyValue.getComponent() - c.inPorts.in.attach noflo.internalSocket.createSocket() - c.outPorts.out.attach noflo.internalSocket.createSocket() - ins = c.inPorts.in - out = c.outPorts.out + ins = noflo.internalSocket.createSocket() + out = noflo.internalSocket.createSocket() + c.inPorts.in.attach ins + c.outPorts.out.attach out describe 'when instantiated', -> it 'should have input ports', -> diff --git a/spec/FlattenObject.coffee b/spec/FlattenObject.coffee index 9edbb11..c3ceba9 100644 --- a/spec/FlattenObject.coffee +++ b/spec/FlattenObject.coffee @@ -14,12 +14,12 @@ describe 'FlattenObject component', -> beforeEach -> c = FlattenObject.getComponent() - c.inPorts.in.attach noflo.internalSocket.createSocket() - c.inPorts.map.attach noflo.internalSocket.createSocket() - c.outPorts.out.attach noflo.internalSocket.createSocket() - ins = c.inPorts.in - map = c.inPorts.map - out = c.outPorts.out + ins = noflo.internalSocket.createSocket() + map = noflo.internalSocket.createSocket() + out = noflo.internalSocket.createSocket() + c.inPorts.in.attach ins + c.inPorts.map.attach map + c.outPorts.out.attach out describe 'when instantiated', -> it 'should have input ports', -> diff --git a/spec/MapProperty.coffee b/spec/MapProperty.coffee index f16532c..d6557f7 100644 --- a/spec/MapProperty.coffee +++ b/spec/MapProperty.coffee @@ -14,12 +14,12 @@ describe 'MapProperty component', -> beforeEach -> c = MapProperty.getComponent() - c.inPorts.in.attach noflo.internalSocket.createSocket() - c.inPorts.map.attach noflo.internalSocket.createSocket() - c.outPorts.out.attach noflo.internalSocket.createSocket() - ins = c.inPorts.in - map = c.inPorts.map - out = c.outPorts.out + ins = noflo.internalSocket.createSocket() + map = noflo.internalSocket.createSocket() + out = noflo.internalSocket.createSocket() + c.inPorts.in.attach ins + c.inPorts.map.attach map + c.outPorts.out.attach out describe 'when instantiated', -> it 'should have input ports', ->