Skip to content
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
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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/*
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node index.js
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*jshint node: true, -W106 */
'use strict';

function buildHtml() {
return '<!DOCTYPE html><html><header><title>Hello World</title></header>'+
'<body><p>Hello World</p></body></html>';
}

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;
};
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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/*"
}
}
27 changes: 27 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -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');
});
});