imdone-core
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -0,1 +1,2 @@ | ||
// TODO:10 Create list groups to show and hide for projects/repos | ||
var _ = require('lodash'); | ||
@@ -2,0 +3,0 @@ |
@@ -56,8 +56,14 @@ var _ = require('lodash'), | ||
Project.prototype.toJSON = function() { | ||
return _.omit(this, ["modifiedQ", "modifiedInterval", "_events", "_maxListeners", "domain"]); | ||
return _.omit(this, | ||
["modifiedQ", | ||
"modifiedInterval", | ||
"_events", | ||
"_maxListeners", | ||
"domain"]); | ||
}; | ||
// TODO:10 Need a way to run only one operation at a time on a project or repo. Use [kue](https://www.npmjs.org/package/kue) | ||
// TODO:20 Decide which listeners we should expose at the project level | ||
// emits project.modified, project.initialized, file.update, file.delete | ||
// TODO:40 Need a way to run only one operation at a time on a project or repo. Use [kue](https://www.npmjs.org/package/kue) | ||
// TODO:50 Decide which listeners we should expose at the project level | ||
// TODO:60 We should have a destroy method | ||
// emits project.modified, project.initialized, file.update, file.delete, file.processed | ||
/** | ||
@@ -84,13 +90,17 @@ * Description | ||
self.storeLists(self.getProjectLists(), function() { | ||
self.initialized = true; | ||
cb(null); | ||
self.emit('project.initialized', {project:self.getName()}); | ||
}); | ||
self.emit('project.initialized', {project:self.getName()}); | ||
// Start the modified interval | ||
self.modifiedInterval = setInterval(function() { | ||
if (self.modifiedQ.length > 0) { | ||
self.emit('project.modified', {project:self.name, mods:self.modifiedQ}); | ||
var data = {project:self.name, mods:self.modifiedQ}; | ||
log('emitting modified', data); | ||
self.emit('project.modified', data); | ||
self.modifiedQ = []; | ||
} | ||
}, 500); | ||
self.initialized = true; | ||
}); | ||
@@ -106,2 +116,3 @@ }; | ||
Project.prototype.queueModified = function(data) { | ||
log('queueing modified', data); | ||
this.modifiedQ.push(data); | ||
@@ -152,3 +163,3 @@ }; | ||
// DOING:10 Add file.update and file.delete listener for repos and emit project.modified | ||
// DONE:10 Add file.update and file.delete listener for repos and emit project.modified | ||
/** | ||
@@ -161,3 +172,3 @@ * Description | ||
this.fileUpdateListener = function(file) { | ||
// DOING:0 fix emit modified by saving these up and emitting only if a backlog exists | ||
// DONE:40 fix emit modified by saving these up and emitting only if a backlog exists | ||
self.emit('file.update', {project:self.getName(), file:file}); | ||
@@ -178,2 +189,19 @@ self.queueModified({mod:'file.update', file:file.getPath()}); | ||
/** | ||
* Description | ||
* @method fileProcessedListener | ||
* @param {} data | ||
* @return | ||
*/ | ||
this.fileProcessedListener = function(data) { | ||
var now = (new Date()).getTime(); | ||
if (!self.lastFileProcessed) self.lastFileProcessed = now; | ||
_.extend(data, {project:self.getName(), time:now}); | ||
self.emit('file.processed', data); | ||
if (now-self.lastFileProcessed > 10) { | ||
self.emit('files.processed', _.omit(data, ["ok", "file"])); | ||
self.lastFileProcessed = now; | ||
} | ||
}; | ||
}; | ||
@@ -218,3 +246,4 @@ | ||
// DONE:20 Use async file operations | ||
// DONE:80 Use async file operations | ||
// DONE:20 Only save config if there is more than one repo | ||
/** | ||
@@ -228,2 +257,4 @@ * Description | ||
var self = this; | ||
if (cb === undefined) cb = _.noop; | ||
if (this.getRepos().length === 1) return cb(); | ||
var dir = this.getConfigDir(); | ||
@@ -233,3 +264,2 @@ var file = this.getConfigFile(); | ||
fs.exists(dir, function(exists) { | ||
if (cb === undefined) cb = _.noop; | ||
if (!exists) wrench.mkdirSyncRecursive(dir); | ||
@@ -317,3 +347,3 @@ fs.writeFile(file, JSON.stringify(self.getConfig(), null, 2), cb); | ||
// DOING:0 Implement addRepo and removeRepo | ||
// DONE:50 Implement addRepo and removeRepo | ||
/** | ||
@@ -368,2 +398,6 @@ * Description | ||
repo.on('file.delete', this.fileDeleteListener); | ||
repo.removeListener('file.processed', this.fileProcessedListener); | ||
repo.on('file.processed', this.fileProcessedListener); | ||
repo.init(cb); | ||
@@ -412,3 +446,3 @@ }; | ||
if (allLists.length > 0) { | ||
var combinedLists = _.sortBy(_.uniq(_.flatten(allLists), 'name'), "name"); | ||
var combinedLists = _.uniq(_.flatten(allLists), 'name'); | ||
@@ -504,3 +538,3 @@ var listsLength = combinedLists.length; | ||
} | ||
// TODO:0 Fix all empty cb to return error | ||
// TODO:20 Fix all empty cb to return error | ||
}; | ||
@@ -596,3 +630,3 @@ | ||
// DONE:10 Test moveTasks | ||
// DONE:70 Test moveTasks | ||
/** | ||
@@ -734,3 +768,3 @@ * Description | ||
// TODO:0 User should be able to add a list to a project | ||
// TODO:30 User should be able to add a list to a project | ||
/** | ||
@@ -792,3 +826,3 @@ * Description | ||
// DOING:0 getFilesTree should return a nested list of files | ||
// DONE:30 getFilesTree should return a nested list of files | ||
/** | ||
@@ -795,0 +829,0 @@ * Description |
@@ -20,3 +20,3 @@ var _ = require('lodash'), | ||
DEFAULT_FILE_PATTERN = "^(readme\\.md|home\\.md)$", | ||
DEFAULT_EXCLUDE_PATTERN = "^(node_modules|bower_components|\\.imdone|target|build)\\/?|\\.(git|svn)|\\~$|\\.(jpg|png|gif|swp|ttf|otf)$", | ||
DEFAULT_EXCLUDE_PATTERN = "^(node_modules|bower_components|\\.imdone|target|build)[\\/\\\\]?|\\.(git|svn)|\\~$|\\.(jpg|png|gif|swp|ttf|otf)$", | ||
CONFIG_DIR = ".imdone", | ||
@@ -37,3 +37,3 @@ CONFIG_FILE = path.join(CONFIG_DIR,"config.json"), | ||
// Emits task.found, list.found, file.update and file.delete | ||
// Emits task.found, list.found, file.update and file.delete, file.processed | ||
/** | ||
@@ -252,2 +252,3 @@ * A Repository is a file system directory in which to look for tasks in files. The Repository manages all the files | ||
// DONE:0 Make sure lists are not saved on load in alphabetical order | ||
/** | ||
@@ -491,4 +492,8 @@ * Save the config file | ||
var files = []; | ||
_.each(allPaths, function(path) { | ||
_.each(allPaths, function(path, processed) { | ||
if (files.length > 10000) throw new Error('Too many files in path'); | ||
var stat = self.fileOK(path, includeDirs); | ||
self.emit("file.processed", {file:path, ok:(stat !== false), total:allPaths.length, | ||
processed:processed+1, repoId:self.getId()}); | ||
if (stat) { | ||
@@ -623,3 +628,5 @@ var file = new File(self.getId(), path); | ||
var funcs = _.map(files, function(file) { | ||
return function(cb) { self.readFile(file, cb); }; | ||
return function(cb) { | ||
self.readFile(file, cb); | ||
}; | ||
}); | ||
@@ -698,3 +705,3 @@ | ||
// DONE:0 Test renameList | ||
// DONE:60 Test renameList | ||
/** | ||
@@ -750,3 +757,3 @@ * Description | ||
// DOING: modifyTask must be async. Get file content before proceeding. | ||
// DOING:30 modifyTask must be async. Get file content before proceeding. | ||
/** | ||
@@ -753,0 +760,0 @@ * Description |
{ | ||
"name": "imdone-core", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "imdone-core", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,3 +10,3 @@ imdone-core | ||
---- | ||
1. [Use [visionmedia/dox](https://github.com/visionmedia/dox), [smartcomments/smartcomments](https://github.com/smartcomments/smartcomments) and [JSDoc](http://usejsdoc.org) for documenting the following...](#DOING:0) | ||
1. [Use [visionmedia/dox](https://github.com/visionmedia/dox), [smartcomments/smartcomments](https://github.com/smartcomments/smartcomments) and [JSDoc](http://usejsdoc.org) for documenting the following...](#DOING:10) | ||
- Project | ||
@@ -13,0 +13,0 @@ - Repository |
81101
2814