├── test ├── names.txt └── bionode-template.js ├── .gitignore ├── .npmignore ├── index.js ├── .travis.yml ├── docs ├── public │ ├── fonts │ │ ├── aller-bold.eot │ │ ├── aller-bold.ttf │ │ ├── aller-bold.woff │ │ ├── aller-light.eot │ │ ├── aller-light.ttf │ │ ├── aller-light.woff │ │ ├── novecento-bold.eot │ │ ├── novecento-bold.ttf │ │ └── novecento-bold.woff │ └── stylesheets │ │ └── normalize.css ├── bionode-template.html └── docco.css ├── cli.js ├── .jshintrc ├── LICENSE ├── package.json ├── lib └── bionode-template.js ├── CODE_OF_CONDUCT.md ├── README.md ├── CONTRIBUTING.md └── bionode-template.min.js /test/names.txt: -------------------------------------------------------------------------------- 1 | World 2 | Foo -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | coverage 4 | tmp 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | coverage 4 | tmp 5 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/bionode-template') 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "7" 4 | after_script: 5 | - npm run coveralls 6 | -------------------------------------------------------------------------------- /docs/public/fonts/aller-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionode/bionode-template/master/docs/public/fonts/aller-bold.eot -------------------------------------------------------------------------------- /docs/public/fonts/aller-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionode/bionode-template/master/docs/public/fonts/aller-bold.ttf -------------------------------------------------------------------------------- /docs/public/fonts/aller-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionode/bionode-template/master/docs/public/fonts/aller-bold.woff -------------------------------------------------------------------------------- /docs/public/fonts/aller-light.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionode/bionode-template/master/docs/public/fonts/aller-light.eot -------------------------------------------------------------------------------- /docs/public/fonts/aller-light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionode/bionode-template/master/docs/public/fonts/aller-light.ttf -------------------------------------------------------------------------------- /docs/public/fonts/aller-light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionode/bionode-template/master/docs/public/fonts/aller-light.woff -------------------------------------------------------------------------------- /docs/public/fonts/novecento-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionode/bionode-template/master/docs/public/fonts/novecento-bold.eot -------------------------------------------------------------------------------- /docs/public/fonts/novecento-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionode/bionode-template/master/docs/public/fonts/novecento-bold.ttf -------------------------------------------------------------------------------- /docs/public/fonts/novecento-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionode/bionode-template/master/docs/public/fonts/novecento-bold.woff -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var JSONStream = require('JSONStream') 3 | var template = require('./') 4 | 5 | var args = process.argv.slice(2) 6 | 7 | var command = args[0] 8 | var arg1 = args[1] 9 | 10 | var templateStream = template[command](arg1) 11 | 12 | templateStream 13 | .pipe(JSONStream.stringify(false)) 14 | .pipe(process.stdout) 15 | 16 | if (!process.stdin.isTTY) { 17 | process.stdin 18 | .pipe(templateStream) 19 | } 20 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "asi": true, // Tolerate Automatic Semicolon Insertion (no semicolons). 3 | "browser": true, // Standard browser globals e.g. `window`, `document`. 4 | "dojo": true, // Enable globals exposed by Dojo Toolkit. 5 | "jquery": true, // Enable globals exposed by jQuery JavaScript library. 6 | "node": true, // Enable globals available when code is running inside of the NodeJS runtime environment. 7 | "shadow": true, // This option suppresses warnings about variable shadowing i.e. declaring a variable that had been already declared somewhere in the outer scope. 8 | "laxcomma": true, // This option suppresses warnings about comma-first coding style. 9 | "laxbreak": true // This option suppresses most of the warnings about possibly unsafe line breakings in your code. 10 | } 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Bruno Vieira 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/bionode-template.js: -------------------------------------------------------------------------------- 1 | var split = require('split') 2 | var test = require('tape') 3 | 4 | var template = require('../') 5 | 6 | test('Should take a name argument and return object with greeting', function (t) { 7 | t.plan(1) 8 | template.greet('World').on('data', function (data) { 9 | t.deepEqual(data, {'greeting': 'Hello World'}) 10 | }) 11 | }) 12 | 13 | test('Should write to stream and return objects with greetings', function (t) { 14 | t.plan(1) 15 | var greet = createGreet(t) 16 | greet.write('World') 17 | greet.write('Foo') 18 | greet.end() 19 | }) 20 | 21 | test('Should pipe to stream and return objects with greetings', function (t) { 22 | t.plan(1) 23 | var greet = createGreet(t) 24 | var names = 'World\nFoo' 25 | var stream = split() 26 | stream.pipe(greet) 27 | stream.write(names) 28 | stream.end() 29 | }) 30 | 31 | function createGreet (t) { 32 | var greetings = [] 33 | var result = [ 34 | {greeting: 'Hello World'}, 35 | {greeting: 'Hello Foo'} 36 | ] 37 | var greet = template.greet() 38 | greet.on('data', function (data) { greetings.push(data) }) 39 | greet.on('end', function () { t.deepEqual(greetings, result) }) 40 | return greet 41 | } 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bionode-template", 3 | "description": "Template module to use as base for quickly creating bionode modules.", 4 | "version": "0.0.5", 5 | "homepage": "http://github.com/bionode/bionode-template", 6 | "repository": { 7 | "type": "git", 8 | "url": "git://github.com/bionode/bionode-template.git" 9 | }, 10 | "author": { 11 | "name": "Bruno Vieira", 12 | "email": "mail@bmpvieira.com" 13 | }, 14 | "dependencies": { 15 | "through2": "^2.0.3", 16 | "debug": "^2.6.8", 17 | "JSONStream": "^1.3.1" 18 | }, 19 | "devDependencies": { 20 | "browserify": "^14.4.0", 21 | "coveralls": "~2.13.1", 22 | "dependency-check": "^2.8.0", 23 | "docco": "~0.7.0", 24 | "istanbul": "~0.4.5", 25 | "split": "~1.0.0", 26 | "standard": "^10.0.2", 27 | "tap-spec": "^4.1.1", 28 | "tape": "^4.6.3", 29 | "testling": "^1.7.1", 30 | "uglify-js": "~3.0.15" 31 | }, 32 | "keywords": [ 33 | "bio", 34 | "biology", 35 | "bioinformatics", 36 | "bionode", 37 | "template", 38 | "api", 39 | "streams", 40 | "client", 41 | "server", 42 | "cli" 43 | ], 44 | "main": "index.js", 45 | "bin": { 46 | "bionode-template": "cli.js" 47 | }, 48 | "scripts": { 49 | "test": "standard && dependency-check . && node test/bionode-template.js | tap-spec", 50 | "test-browser": "browserify test/bionode-template.js | testling | tap-spec", 51 | "coverage": "istanbul cover test/bionode-template.js --report lcovonly -- | tap-spec && rm -rf ./coverage", 52 | "coveralls": "istanbul cover test/bionode-template.js --report lcovonly -- | tap-spec && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls && rm -rf ./coverage", 53 | "build-browser": "browserify index.js -r ./index.js:bionode-template | uglifyjs > bionode-template.min.js", 54 | "build-docs": "docco ./lib/bionode-template.js" 55 | }, 56 | "license": "MIT" 57 | } 58 | -------------------------------------------------------------------------------- /lib/bionode-template.js: -------------------------------------------------------------------------------- 1 | // # bionode-template 2 | // > Template module to use as a base for quickly creating bionode modules. 3 | // > 4 | // > doi: [?](?) 5 | // > author: [Bruno Vieira](http://bmpvieira.com) 6 | // > email: 7 | // > license: [MIT](https://raw.githubusercontent.com/bionode/bionode-template/master/LICENSE) 8 | // 9 | // --- 10 | // 11 | // ## Usage 12 | // This module can be used in Node.js/browsers, as described further below, or as a command line tool. 13 | // Examples: 14 | // 15 | // $ npm install -g bionode-template 16 | // 17 | // # bionode-template [command] [arguments] 18 | // $ bionode-template greet World 19 | // $ echo World | bionode-template greet 20 | // $ echo World | bionode-template greet |dat import --json 21 | 22 | var through = require('through2') 23 | var debug = require('debug')('bionode-template') 24 | 25 | var template = module.exports 26 | 27 | var CONSTANT = 'Hello' 28 | 29 | // ## Greet 30 | // Returns a stream that transforms name strings into greeting messages: 31 | // 32 | // template.greet('World').on('data', console.log) 33 | // => {"greeting":"Hello World"} 34 | // 35 | // The name can also be passed with write: 36 | // 37 | // var greet = template.greet() 38 | // greet.on('data', console.log) 39 | // greet.write('World') 40 | // greet.write('Foo') 41 | // => {"greeting":"Hello World"} 42 | // => {"greeting":"Hello Foo"} 43 | // 44 | // Or piped, for example, from a file: 45 | // 46 | // var split = require('split') 47 | // 48 | // fs.createReadStream('names.txt') 49 | // .pipe(split()) 50 | // .pipe(greet) 51 | // .on('data', console.log) 52 | 53 | template.greet = function (name) { 54 | var stream = through.obj(transform) 55 | if (name) { stream.write(name); stream.end() } 56 | return stream 57 | 58 | function transform (obj, enc, next) { 59 | var name = obj.toString().replace('\n', '') 60 | var message = [ 61 | CONSTANT, 62 | name 63 | ].join(' ') 64 | 65 | debug('greet message', message) 66 | 67 | this.push({greeting: message}) 68 | next() 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at mail@bionode.io. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | bionode logo 4 | 5 |
6 | bionode.io 7 |

8 | 9 | 10 | # bionode-template 11 | 12 | > Template module to use as a base for quickly creating bionode modules. 13 | 14 | [![npm](https://img.shields.io/npm/v/bionode-template.svg?style=flat-square)](http://npmjs.org/package/bionode-template) 15 | [![Travis](https://img.shields.io/travis/bionode/bionode-template.svg?style=flat-square)](https://travis-ci.org/bionode/bionode-template) 16 | [![Coveralls](https://img.shields.io/coveralls/bionode/bionode-template.svg?style=flat-square)](http://coveralls.io/r/bionode/bionode-template) 17 | [![Dependencies](http://img.shields.io/david/bionode/bionode-template.svg?style=flat-square)](http://david-dm.org/bionode/bionode-template) 18 | [![npm](https://img.shields.io/npm/dt/bionode-template.svg?style=flat-square)](https://www.npmjs.com/package/bionode-template) 19 | [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg?style=flat-square)](https://gitter.im/bionode/bionode) 20 | 21 | 22 | ## Principles 23 | 24 | This provides a quick template to build a bionode module. A bionode module should follow the [Unix philosophy](http://en.wikipedia.org/wiki/Unix_philosophy) and play nice with [Node.js](http://nodejs.org). 25 | 26 | That is: 27 | 28 | * Be small, simple and do one thing well; 29 | * Use [Node's CommonJS module pattern](http://nodejs.org/docs/latest/api/modules.html) and be available on [NPM](http://npmjs.org); 30 | * Provide Node.js [Streams](http://nodejs.org/api/stream.html); 31 | * Provide a [Command Line Interface](http://en.wikipedia.org/wiki/Command-line_interface) compatible with [Unix pipes](http://en.wikipedia.org/wiki/Pipeline_%28Unix%29); 32 | * If possible, work client-side (browser) using [browserify](https://github.com/substack/node-browserify); 33 | * Provide testing (preferably with [tape](http://github.com/substack/tape) and [testling](https://ci.testling.com)); 34 | * Provide code coverage (preferably with [istanbul](https://github.com/gotwarlost/istanbul)); 35 | * Provide code with comments and documentation (preferably with [docco](https://github.com/jashkenas/docco)); 36 | * [KISS](http://en.wikipedia.org/wiki/KISS_principle) and don't [abuse objects](http://timruffles.github.io/you-probably-dont-want-an-object); 37 | * Be [MIT](http://choosealicense.com/licenses/mit/) licensed. 38 | 39 | To try to maximize the compatibility of the new module and anticipate possible use cases, the authors of the new bionode module should be aware of the existing bionode modules and other useful projects like [Dat](http://github.com/maxogden/dat). 40 | 41 | The following sections should be adapted and included in the README.md file. 42 | 43 | 44 | ## Install 45 | 46 | Install ```bionode-template``` with [npm](//npmjs.org): 47 | 48 | ```sh 49 | $ npm install bionode-template 50 | ``` 51 | To use it as a command line tool, you can install it globally by adding ```-g``` . 52 | 53 | Alternatively, just include `bionode-template.min.js` via a `