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

Process API #59

Merged
merged 7 commits into from Nov 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,3 @@
{
"extends": "airbnb-base"
}
4 changes: 1 addition & 3 deletions .travis.yml
@@ -1,8 +1,6 @@
language: node_js
node_js:
- '4.6'
before_script:
- npm install -g grunt-cli
- '6'
deploy:
provider: npm
email: henri.bergius@iki.fi
Expand Down
30 changes: 0 additions & 30 deletions Gruntfile.coffee

This file was deleted.

1 change: 1 addition & 0 deletions LICENSE-MIT
@@ -1,3 +1,4 @@
Copyright (c) 2014-2017 Flowhub UG
Copyright (c) 2013 Henri Bergius

Permission is hereby granted, free of charge, to any person
Expand Down
30 changes: 0 additions & 30 deletions components/GetAvatar.coffee

This file was deleted.

41 changes: 41 additions & 0 deletions components/GetAvatar.js
@@ -0,0 +1,41 @@
const noflo = require('noflo');
const gravatar = require('gravatar');

// @runtime noflo-nodejs

exports.getComponent = () => {
const c = new noflo.Component();
c.description = 'Get avatar URL for a given email';
c.inPorts.add('email', {
datatype: 'string',
});
c.inPorts.add('size', {
datatype: 'int',
control: true,
default: 200,
});
c.outPorts.add('avatar', {
datatype: 'string',
});
c.forwardBrackets = {
email: ['avatar'],
};
c.process((input, output) => {
if (!input.hasData('email')) return;
if (input.attached('size').length && !input.hasData('size')) {
return;
}
let size = 200;
if (input.hasData('size')) {
size = input.getData('size');
}
const email = input.getData('email');
const avatar = gravatar.url(email, {
s: size,
}, true);
output.sendDone({
avatar,
});
});
return c;
};
22 changes: 9 additions & 13 deletions package.json
Expand Up @@ -13,28 +13,24 @@
},
"license": "MIT",
"dependencies": {
"noflo": "0.x >= 0.5",
"noflo": "0.x >= 0.8",
"gravatar": "^1.6.0"
},
"devDependencies": {
"chai": "^4.0.0",
"coffee-script": "^1.12.2",
"grunt": "^1.0.1",
"grunt-coffeelint": "^0.0.16",
"grunt-contrib-watch": "^1.0.0",
"grunt-mocha-test": "^0.13.2",
"mocha": "^4.0.0"
"eslint": "^4.10.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"fbp-spec": "^0.2.3",
"noflo-nodejs": "^0.8.1"
},
"noflo": {
"icon": "user",
"components": {
"GetAvatar": "./components/GetAvatar.coffee"
}
"icon": "user"
},
"keywords": [
"noflo"
],
"scripts": {
"test": "grunt test"
"pretest": "eslint components/*.js",
"test": "fbp-spec --secret test --address ws://localhost:3333 --command 'noflo-nodejs --port 3333 --register=false --secret test' spec/"
}
}
23 changes: 0 additions & 23 deletions spec/GetAvatar.coffee

This file was deleted.

10 changes: 10 additions & 0 deletions spec/GetAvatar.yaml
@@ -0,0 +1,10 @@
topic: 'gravatar/GetAvatar'
cases:
-
name: 'receiving an email'
assertion: 'should send an avatar URL'
inputs:
email: 'henri.bergius@iki.fi'
expect:
avatar:
equals: 'https://s.gravatar.com/avatar/995f27ce7205a79c55d4e44223cd6de0?s=200'