Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnonEilat committed Jun 27, 2014
1 parent 6ad0ced commit 7bb6f6a
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 47 deletions.
7 changes: 3 additions & 4 deletions update/Repository.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/***
/**
* @constructor
* @param {Object} data
* @returns {Repository}
*/
function Repository(data) {
var self = this;
/**
* @type {string}
*/
Expand All @@ -30,8 +29,8 @@ function Repository(data) {
* @returns {string} Folder name
*/
Repository.prototype.getFolderName = function() {
var lastSlash = self.url.lastIndexOf("/");
return this.url.substring(lastSlash + 1, self.url.length);
var lastSlash = this.url.lastIndexOf("/");
return this.url.substring(lastSlash + 1, this.url.length);
};

Repository.prototype.getDotGitFolder = function() {
Expand Down
3 changes: 1 addition & 2 deletions update/commitsToJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var colors = require('colors');
* ]
* @returns {void}
*/
function commitsArray(repo, callBack) {
module.exports.commitsArray = function(repo, callBack) {

var result = '';
var separator = ' qqqqqqqq ';
Expand Down Expand Up @@ -83,4 +83,3 @@ function commitsArray(repo, callBack) {
}


module.exports.commitsArray = commitsArray;
5 changes: 0 additions & 5 deletions update/d3.v3.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion update/getCommitsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var colors = require('colors');



/***
/**
* @description write File
* @param {type} commits
* @param {Repository} repo
Expand Down
18 changes: 5 additions & 13 deletions update/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var functionToRun;
* @param {Function} func To run after all of the getLogForFile instances were done
* @returns {void}
*/
var setFunction = function(func) {
module.exports.setFunction = function(func) {
functionToRun = func;
};

Expand All @@ -45,7 +45,7 @@ var dotGitPath = '';
* @param {string} path
* @returns {void}
*/
var setDotGitPath = function(path) {
module.exports.setDotGitPath = function(path) {
dotGitPath = path;
};

Expand Down Expand Up @@ -74,7 +74,7 @@ parentPath = findParentPath(parentPath);
* @param {string} str Repository URL.
* @returns {string} Folder name
*/
var getFolderName = function(str) {
module.exports.getFolderName = function(str) {
var lastSlash = str.lastIndexOf("/");
var end = str.length;
if (str.indexOf('.git') === -1)
Expand All @@ -91,7 +91,7 @@ var getFolderName = function(str) {
* @param {boolean} verbose Do you want a lot of output?
* @returns {void}
*/
var cloneOrPull = function(repoURL, callBack, verbose) {
module.exports.cloneOrPull = function(repoURL, callBack, verbose) {
containingFolder = getFolderName(repoURL);
var clone = false;
var gitFolder = '--git-dir=' + parentPath + '/repositories/' + containingFolder + '/.git';
Expand Down Expand Up @@ -155,7 +155,7 @@ function getRelativePath(fullPath) {
* @param {string} fullPath of file to get its log.
* @returns {void}
*/
var getLogForFile = function(fullPath, callBack) {
module.exports.getLogForFile = function(fullPath, callBack) {
if (dotGitPath === '')
throw new Error('\ngit-dir must be set.\nUse setGitDir to set it.'.red);

Expand Down Expand Up @@ -229,11 +229,3 @@ var getLogForFile = function(fullPath, callBack) {
console.log(buff.toString('utf8').red);
});
};


module.exports.setFunction = setFunction;
module.exports.setDotGitPath = setDotGitPath;
module.exports.cloneOrPull = cloneOrPull;
module.exports.getLogForFile = getLogForFile;
module.exports.getFolderName = getFolderName;

8 changes: 3 additions & 5 deletions update/jsonSanitizer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

/***
/**
*@description Sanitize JSON string before saving, so it can be read again. (Escapes newlines etc)
* @param {string} unsanitized string
* @returns {string} Sanitized string
* @see https://gist.github.com/jamischarles/1046671
*/
function sanitize(unsanitized) {
module.exports.sanitize = function(unsanitized) {
return unsanitized
.trim()
.replace(/\\/g, "\\\\")
Expand All @@ -15,7 +15,5 @@ function sanitize(unsanitized) {
.replace(/\f/g, "\\f")
.replace(/"/g, "\\\"") //.replace(/'/g,"\\\'")
.trim();
}
};


module.exports.sanitize = sanitize;
12 changes: 6 additions & 6 deletions update/lineCounter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


/***
/**
* @description Count size(in bytes), and lines in files and folders.
* @constructor
*/
Expand All @@ -15,7 +15,7 @@ function LineCounter() {
*/
var allFiles = new Array();

/***
/**
* @description Fill allFiles array with all file names under currentPath - ignor folders
* @param {string} currentPath
* @returns {void}
Expand All @@ -37,7 +37,7 @@ function LineCounter() {
}
};

/***
/**
* @description Return true if fileName is or within the .git folder.
* @param {string} fileName To check if its a git file.
* @returns {boolean}
Expand All @@ -55,7 +55,7 @@ function LineCounter() {
}


/***
/**
* @description Return file size in bytes - for hard links return 0.
* @param {string} path to get is size.
* @returns {number} File size in bytes
Expand All @@ -68,7 +68,7 @@ function LineCounter() {
}
};

/***
/**
* @param {string} directory to get is size.
* @returns {number} Directory size in bytes
*/
Expand Down Expand Up @@ -151,7 +151,7 @@ function LineCounter() {



exports.createLineCounter = function() {
module.exports.createLineCounter = function() {
return new LineCounter();
};

Expand Down
11 changes: 4 additions & 7 deletions update/numStat.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

/***
/**
* @module
* @description Module to parse the result of git log --numstat
* @see man git log --numstat
*/


/***
*
/**
* Column1 = inserted
* Column2 = removed
* columns are separeted by tab (\t)
Expand Down Expand Up @@ -39,7 +39,7 @@ var parseLineStat = function(lineStat) {
* @param {string} numstat
* @returns {Object<total:<number>,files:<Array>}
*/
var parseNumStat = function(numstat) {
module.exports.parseNumStat = function(numstat) {
var lines = numstat.split('\n');
var statArr = new Array();
for (var i = 0; i < lines.length; i++) {
Expand All @@ -57,6 +57,3 @@ var parseNumStat = function(numstat) {
// ,'files': statArr
};
};


module.exports.parseNumStat = parseNumStat;
2 changes: 1 addition & 1 deletion update/repositories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var eKnights = require('../eKnightsData').eKnightsData;
var eKnights = require('../src/eKnightsData').eKnightsData;
var Repository = require('./Repository').Repository;


Expand Down
6 changes: 3 additions & 3 deletions update/rootChecker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var spawn = require('child_process').spawn;
var colors = require('colors');

module.exports.isRootUser = isRootUser;



/**
Expand All @@ -13,7 +13,7 @@ module.exports.isRootUser = isRootUser;
* @returns {void}
* TODO: maybe it's better to use id
*/
function isRootUser(callback, testing) {
module.exports.isRootUser = function(callback, testing) {
if (testing) {
callback();
return;
Expand All @@ -30,4 +30,4 @@ function isRootUser(callback, testing) {

callback();
});
}
};

0 comments on commit 7bb6f6a

Please sign in to comment.