diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..df6d0ab --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "0.12" + - "0.11" + - "0.10" +script: "npm run-script test-travis" +after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..afe4fd1 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +PROJECT= "norris-nrti: " +MAKE= make --no-print-directory +JSHINT= ./node_modules/.bin/jshint +JSHINT_OPTS= --config .jshintrc + +JS_FILES= $(shell find . -maxdepth 1 -name '*.js') $(shell find lib -name '*.js') $(shell find test -name '*.js') + + +default: test + +test: + @echo "$(PROJECT)Executing JSHint..." + @$(JSHINT) $(JSHINT_OPTS) $(JS_FILES) + ./node_modules/mocha/bin/mocha ./test/* \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..a9c522f --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: node index.js \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..82e5a06 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +[![Build Status](https://travis-ci.org/DeltaGraphs/APSupervisor.svg?branch=development)](https://travis-ci.org/DeltaGraphs/APSupervisor) + +[![Coverage Status](https://coveralls.io/repos/DeltaGraphs/APSupervisor/badge.svg?branch=development)](https://coveralls.io/r/DeltaGraphs/APSupervisor?branch=development) + +# APSupervisor +Dashboard to supervise APS busses in Padua diff --git a/index.js b/index.js new file mode 100644 index 0000000..1bbefaa --- /dev/null +++ b/index.js @@ -0,0 +1,41 @@ +/*jshint node: true, -W106 */ +'use strict'; + +function buildHtml() { + return '
Hello World
'+ + '

Hello World

'; +} + +console.log('Hello World'); + +var http = require('http'); +var port = process.env.PORT || 3000; + +http.createServer(function (req, res) { + var html = buildHtml(); + + res.writeHead(200, { + 'Content-Type': 'text/html', + 'Content-Length': html.length, + 'Expires': new Date().toUTCString() + }); + res.end(html); +}).listen(port); + +module.exports = function(n) { + if (typeof n !== 'number') { + return null; + } + + if (n % 3 === 0 && n % 5 === 0) { + return 'fizzbuzz'; + } + if (n % 3 === 0) { + return 'fizz'; + } + if (n % 5 === 0) { + return 'buzz'; + } + + return '' + n; +}; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..218a205 --- /dev/null +++ b/package.json @@ -0,0 +1,45 @@ +{ + "name": "APSupervisor", + "version": "0.0.1", + "description": "Dashboard to supervise APS busses in Padua", + "main": "index.js", + "repository": { + "type": "git", + "url": "https://github.com/DeltaGraphs/APSupervisor" + }, + "keywords": [ + "APS", + "APSupervisor", + "Padova", + "Padua", + "norris", + "RTBI", + "graphs", + "bar", + "line", + "maps", + "table", + "charts" + ], + "author": "Matteo Furlan", + "license": "MIT", + "bugs": { + "url": "https://github.com/DeltaGraphs/APSupervisor/issues" + }, + "homepage": "https://github.com/DeltaGraphs/APSupervisor", + "dependencies": { + "ejs": "^2.3.1", + "express": "^4.12.3" + }, + "devDependencies": { + "jshint": "^2.7.0", + "mocha": "^2.2.4", + "istanbul": "^0.3.13", + "coveralls": "^2.11.2", + "mocha-lcov-reporter": "0.0.2" + }, + "scripts": { + "test": "make", + "test-travis": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec ./test/*" + } +} diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..9227334 --- /dev/null +++ b/test/test.js @@ -0,0 +1,27 @@ +/*jshint node: true, -W106 */ +'use strict'; + +var assert = require('assert'); +var fizzbuzz = require('../'); + +describe('fizzbuzz', function() { + it('returns null when passed a non-number', function() { + assert.equal(fizzbuzz('abc'), null); + }); + + it('returns fizzbuzz when divisible by 15', function() { + assert.equal(fizzbuzz(45), 'fizzbuzz'); + }); + + it('returns fizz when divisible by 3 but not 5', function() { + assert.equal(fizzbuzz(6), 'fizz'); + }); + + it('returns buzz when divisble by 5 but not 3', function() { + assert.equal(fizzbuzz(10), 'buzz'); + }); + + it('returns input otherwise', function() { + assert.equal(fizzbuzz(7), '7'); + }); +}); \ No newline at end of file