Skip to content
Browse files

Coding style tweaks

  • Loading branch information...
1 parent 1a0a85b commit 4cf38158d0ab7e21022ad49de5ee98b300dd767f @vesln committed
View
8 lib/app.js
@@ -6,10 +6,9 @@
*/
/**
- * Module dependencies.
+ * Dependencies.
*/
var flatiron = require('flatiron');
-var path = require('path');
/**
* The application object.
@@ -35,6 +34,7 @@ app.use(flatiron.plugins.cli, {
' todo version - Lib version.',
' todo write - Write items to file.',
'',
- 'Author: Veselin Todorov <hi@vesln.com>'
+ 'Author: Veselin Todorov <hi@vesln.com>',
+ ''
]
-});
+});
View
2 lib/cli.js
@@ -41,4 +41,4 @@ app.cmd(/rm (.+)/, commands.destroy);
app.cmd(/write (.+)/, commands.write);
// Adds new todo item.
-app.cmd(/(.+)/, commands.add);
+app.cmd(/(.+)/, commands.add);
View
2 lib/commands.js
@@ -147,4 +147,4 @@ commands.write = function(filename) {
if (err) return commands.print(err);
});
});
-};
+};
View
10 lib/formatter.js
@@ -1,6 +1,6 @@
/*!
* todo - Todos in the CLI like what.
- *
+ *
* Veselin Todorov <hi@vesln.com>
* MIT License.
*/
@@ -12,14 +12,14 @@ var colors = require('colors');
/**
* Formatter namespace.
- *
+ *
* @type {Object}
*/
var formatter = module.exports;
/**
* Formats an item.
- *
+ *
* @param {Object} Todo item.
* @param {Number} Item number.
* @returns {String}
@@ -27,9 +27,9 @@ var formatter = module.exports;
*/
formatter.format = function(item, num) {
var state = (item.done) ? ''.green : ''.red;
-
+
return ' '
+ '#' + (num + 1) + ' '
+ state + ' '
+ item.text;
-};
+};
View
8 lib/storage.js
@@ -1,6 +1,6 @@
/*!
* todo - Todos in the CLI like what.
- *
+ *
* Veselin Todorov <hi@vesln.com>
* MIT License.
*/
@@ -13,14 +13,14 @@ var path = require('path');
/**
* Database path.
- *
+ *
* @type {String}
*/
var db = path.join(__dirname, '..', 'data', 'db.json');
/**
* Storage object.
- *
+ *
* @type {Object}
*/
-var storage = module.exports = new Storr(db);
+var storage = module.exports = new Storr(db);
View
7 lib/todos.js
@@ -1,3 +1,10 @@
+/*!
+ * todo - Todos in the CLI like what.
+ *
+ * Veselin Todorov <hi@vesln.com>
+ * MIT License.
+ */
+
var Todos = module.exports = function(storage) {
this.storage = storage;
};
View
8 test/app.test.js
@@ -1,6 +1,6 @@
/*!
* todo - Todos in the CLI like what.
- *
+ *
* Veselin Todorov <hi@vesln.com>
* MIT License.
*/
@@ -12,13 +12,13 @@ var flatiron = require('flatiron');
/**
* The tests object.
- *
+ *
* @type {Object}
*/
var app = require('../lib/app');
describe('app', function() {
- it('should be flatiron app', function() {
+ it('is flatiron app', function() {
app.should.eql(flatiron.app);
});
-});
+});
View
6 test/cli.test.js
@@ -25,11 +25,11 @@ var storage = require('../lib/storage');
var commands = require('../lib/commands');
describe('cli', function() {
- it('should expose flatiron app', function() {
+ it('exposes flatiron app', function() {
cli.should.eql(flatiron.app);
});
- it('should register routes', function() {
+ it('registers routes', function() {
cli.router.routes.version.on.should.eql(commands.version);
cli.router.routes.ls.on.should.eql(commands.list);
cli.router.routes.clear.on.should.eql(commands.clear);
@@ -38,4 +38,4 @@ describe('cli', function() {
cli.router.routes.undo['(.+)'].on.should.eql(commands.undo);
cli.router.routes['(.+)'].on.should.eql(commands.add);
});
-});
+});
View
2 test/commands.test.js
@@ -87,4 +87,4 @@ describe('commands', function() {
storage.items.should.eql([]);
});
});
-});
+});
View
4 test/formatter.test.js
@@ -14,11 +14,11 @@ var formatter = require('../lib/formatter');
describe('formatter', function() {
describe('.format()', function() {
- it('should format done items properly', function() {
+ it('formats finished items', function() {
formatter.format({ text: 'Foo', done: true }, 0).should.eql(' #1 \u001b[32m√\u001b[39m Foo');
});
- it('should format unfinished items properly', function() {
+ it('formats not finished items', function() {
formatter.format({ text: 'Foo', done: false }, 0).should.eql(' #1 \u001b[31m✖\u001b[39m Foo');
});
});
View
2 test/storage.test.js
@@ -18,7 +18,7 @@ var Storr = require('storr');
var storage = require('../lib/storage');
describe('storage', function() {
- it('should be Storr object', function() {
+ it('is Storr object', function() {
storage.constructor.should.eql(Storr);
});
});
View
9 test/support/fake_storage.js
@@ -1,3 +1,10 @@
+/*!
+ * todo - Todos in the CLI like what.
+ *
+ * Veselin Todorov <hi@vesln.com>
+ * MIT License.
+ */
+
var Storage = module.exports = function() {};
Storage.prototype.get = function(type, callback) {
@@ -22,4 +29,4 @@ Storage.prototype.save = function(callback) {
this.items = this._items;
delete this._items;
callback(null);
-};
+};
View
9 test/todos.test.js
@@ -1,3 +1,10 @@
+/*!
+ * todo - Todos in the CLI like what.
+ *
+ * Veselin Todorov <hi@vesln.com>
+ * MIT License.
+ */
+
var Todos = require('../lib/todos'),
Storage = require('./support/fake_storage');
@@ -90,4 +97,4 @@ describe("todos", function() {
items('undone').should.eql([undone, undone]);
});
});
-});
+});

0 comments on commit 4cf3815

Please sign in to comment.
Something went wrong with that request. Please try again.