{"action":"created","comment":{"url":"https://api.github.com/repos/sourcejs/Source/pulls/comments/24393391","id":24393391,"diff_hunk":"@@ -176,17 +58,179 @@ var writeDataFile = function (callback) {\n             }\n         }\n \n-        fs.writeFile(outputFile, JSON.stringify(fileTree(config.specsRoot), null, 4), function (err) {\n-            if (err) {\n-                console.log('Error writing file tree: ', err);\n-            } else {\n-                console.log(\"Pages tree JSON saved to \" + outputFile);\n-                flagNotExec = true;\n+        collectSpecsData(config.specsRoot, function(specsData) {\n+            fs.writeFile(outputFile, JSON.stringify(specsData, null, 4), function (err) {\n+                if (err) {\n+                    console.log('Error writing file tree: ', err);\n+                } else {\n+                    console.log(\"Pages tree JSON saved to \" + outputFile);\n+                    flagNotExec = true;\n+                }\n+\n+                if (typeof callback === 'function') callback(err);\n+            });\n+        });\n+    }\n+};\n+\n+var TasksQueue = function(options) {\n+    this.threadsNumber = options && options.threads ? options.threads : 1;\n+    this.threadQueues = [];\n+    this.ptr = 0;\n+    for (var i = 0; i < this.threadsNumber; i++) {\n+        this.threadQueues.push([]);\n+    }\n+};\n+\n+TasksQueue.prototype.push = function(task) {\n+    this.threadQueues[this.getQueueNumber()].push(task);\n+};\n+\n+TasksQueue.prototype.getQueueNumber = function() {\n+    this.ptr++;\n+    if (this.ptr >= this.threadsNumber) {\n+        this.ptr = 0;\n+    }\n+    return this.ptr;\n+};\n+\n+TasksQueue.processTasksSync = function(tasks, callback) {\n+    if (!tasks || !tasks.length) {\n+        callback && callback();\n+        return;\n+    }\n+    tasks.shift()(function() {\n+        TasksQueue.processTasksSync(tasks, callback);\n+    });\n+};\n+\n+TasksQueue.prototype.execute = function(callback) {\n+    var self = this;\n+    var remaining = this.threadQueues.length;\n+    this.threadQueues.forEach(function(queue) {\n+        TasksQueue.processTasksSync(queue, function() {\n+            if (!--remaining) {\n+                callback && callback();\n             }\n+        });\n+    });\n+};\n \n-            if (typeof callback === 'function') callback(err);\n+var tasks = new TasksQueue({\n+    'threads': 16\n+});\n+\n+/**\n+ * @function fillInSpecDataObject - method to fill in spec data.\n+ * It create basic fields and initializes async action to fill last\n+ * modification date from git log or nodeJS fs.stat data.\n+ *\n+ * @param {Object} accumulator - empty spec data object to fill\n+ * @param {Object} meta - additional information, whitch is needed to create spec data\n+ * @param {String} meta.basename - spec file name\n+ * @param {String} meta.dirname - spec directory name\n+ * @param {String} meta.root - normalized specs root path\n+ * @param {String} meta.app - normalized app root path\n+ * @param {Object} meta.fileStat - nodeJS fs.stat method result \n+ */\n+var fillInSpecDataObject = function(accumulator, meta) {\n+    var command = 'git -C ' + global.opts.core.common.pathToUser + ' log -1 --format=\"%ad\" -- ' + dirname;  \n+    var specDataObject = accumulator['specFile'] = accumulator['specFile'] || {};\n+    var dirname = meta.dirname;\n+    var info = {};\n+\n+    try {\n+        info = JSON.parse(fs.readFileSync(dirname + '/' + config.infoFile));\n+    } catch(e) {\n+        info = {\n+            'error': \"Cannot parse the file\",\n+            'path': dirname + '/' + config.infoFile\n+        };\n+    };\n+\n+    Object.keys(info).forEach(function(key) {\n+        specDataObject[key] = info[key];\n+    });\n+\n+    specDataObject['id'] = dirname.replace(meta.root, '').replace(meta.app, '');\n+    specDataObject['url'] = '/' + specDataObject['id'];\n+    specDataObject['fileName'] = meta.basename;\n+\n+    var thumbPath = path.join(dirname, 'thumbnail.png');","path":"core/file-tree/index.js","position":269,"original_position":269,"commit_id":"04b1f3e2937d8f3f1d9aae7f2e8be352cd360868","original_commit_id":"04b1f3e2937d8f3f1d9aae7f2e8be352cd360868","user":{"login":"cheshirsky","id":3994577,"avatar_url":"https://avatars.githubusercontent.com/u/3994577?v=3","gravatar_id":"","url":"https://api.github.com/users/cheshirsky","html_url":"https://github.com/cheshirsky","followers_url":"https://api.github.com/users/cheshirsky/followers","following_url":"https://api.github.com/users/cheshirsky/following{/other_user}","gists_url":"https://api.github.com/users/cheshirsky/gists{/gist_id}","starred_url":"https://api.github.com/users/cheshirsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheshirsky/subscriptions","organizations_url":"https://api.github.com/users/cheshirsky/orgs","repos_url":"https://api.github.com/users/cheshirsky/repos","events_url":"https://api.github.com/users/cheshirsky/events{/privacy}","received_events_url":"https://api.github.com/users/cheshirsky/received_events","type":"User","site_admin":false},"body":"Ok, 4 sure.","created_at":"2015-02-10T07:24:27Z","updated_at":"2015-02-10T07:24:27Z","html_url":"https://github.com/sourcejs/Source/pull/92#discussion_r24393391","pull_request_url":"https://api.github.com/repos/sourcejs/Source/pulls/92","_links":{"self":{"href":"https://api.github.com/repos/sourcejs/Source/pulls/comments/24393391"},"html":{"href":"https://github.com/sourcejs/Source/pull/92#discussion_r24393391"},"pull_request":{"href":"https://api.github.com/repos/sourcejs/Source/pulls/92"}}},"pull_request":{"url":"https://api.github.com/repos/sourcejs/Source/pulls/92","id":28815977,"html_url":"https://github.com/sourcejs/Source/pull/92","diff_url":"https://github.com/sourcejs/Source/pull/92.diff","patch_url":"https://github.com/sourcejs/Source/pull/92.patch","issue_url":"https://api.github.com/repos/sourcejs/Source/issues/92","number":92,"state":"open","locked":false,"title":"Specs parser improvements","user":{"login":"cheshirsky","id":3994577,"avatar_url":"https://avatars.githubusercontent.com/u/3994577?v=3","gravatar_id":"","url":"https://api.github.com/users/cheshirsky","html_url":"https://github.com/cheshirsky","followers_url":"https://api.github.com/users/cheshirsky/followers","following_url":"https://api.github.com/users/cheshirsky/following{/other_user}","gists_url":"https://api.github.com/users/cheshirsky/gists{/gist_id}","starred_url":"https://api.github.com/users/cheshirsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheshirsky/subscriptions","organizations_url":"https://api.github.com/users/cheshirsky/orgs","repos_url":"https://api.github.com/users/cheshirsky/repos","events_url":"https://api.github.com/users/cheshirsky/events{/privacy}","received_events_url":"https://api.github.com/users/cheshirsky/received_events","type":"User","site_admin":false},"body":"- modified async mode of specs data collecting\r\n- ability to get last modification data from git","created_at":"2015-02-06T15:21:49Z","updated_at":"2015-02-10T07:24:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bbfa0f3fef152ebfc49428764615c2656c273653","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sourcejs/Source/pulls/92/commits","review_comments_url":"https://api.github.com/repos/sourcejs/Source/pulls/92/comments","review_comment_url":"https://api.github.com/repos/sourcejs/Source/pulls/comments/{number}","comments_url":"https://api.github.com/repos/sourcejs/Source/issues/92/comments","statuses_url":"https://api.github.com/repos/sourcejs/Source/statuses/04b1f3e2937d8f3f1d9aae7f2e8be352cd360868","head":{"label":"sourcejs:mikhailov/specs-parser","ref":"mikhailov/specs-parser","sha":"04b1f3e2937d8f3f1d9aae7f2e8be352cd360868","user":{"login":"sourcejs","id":3853046,"avatar_url":"https://avatars.githubusercontent.com/u/3853046?v=3","gravatar_id":"","url":"https://api.github.com/users/sourcejs","html_url":"https://github.com/sourcejs","followers_url":"https://api.github.com/users/sourcejs/followers","following_url":"https://api.github.com/users/sourcejs/following{/other_user}","gists_url":"https://api.github.com/users/sourcejs/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcejs/subscriptions","organizations_url":"https://api.github.com/users/sourcejs/orgs","repos_url":"https://api.github.com/users/sourcejs/repos","events_url":"https://api.github.com/users/sourcejs/events{/privacy}","received_events_url":"https://api.github.com/users/sourcejs/received_events","type":"Organization","site_admin":false},"repo":{"id":9578262,"name":"Source","full_name":"sourcejs/Source","owner":{"login":"sourcejs","id":3853046,"avatar_url":"https://avatars.githubusercontent.com/u/3853046?v=3","gravatar_id":"","url":"https://api.github.com/users/sourcejs","html_url":"https://github.com/sourcejs","followers_url":"https://api.github.com/users/sourcejs/followers","following_url":"https://api.github.com/users/sourcejs/following{/other_user}","gists_url":"https://api.github.com/users/sourcejs/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcejs/subscriptions","organizations_url":"https://api.github.com/users/sourcejs/orgs","repos_url":"https://api.github.com/users/sourcejs/repos","events_url":"https://api.github.com/users/sourcejs/events{/privacy}","received_events_url":"https://api.github.com/users/sourcejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sourcejs/Source","description":"Living Style Guides Engine and Maintenance Environment for Front-end Components. Core repository.","fork":false,"url":"https://api.github.com/repos/sourcejs/Source","forks_url":"https://api.github.com/repos/sourcejs/Source/forks","keys_url":"https://api.github.com/repos/sourcejs/Source/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcejs/Source/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcejs/Source/teams","hooks_url":"https://api.github.com/repos/sourcejs/Source/hooks","issue_events_url":"https://api.github.com/repos/sourcejs/Source/issues/events{/number}","events_url":"https://api.github.com/repos/sourcejs/Source/events","assignees_url":"https://api.github.com/repos/sourcejs/Source/assignees{/user}","branches_url":"https://api.github.com/repos/sourcejs/Source/branches{/branch}","tags_url":"https://api.github.com/repos/sourcejs/Source/tags","blobs_url":"https://api.github.com/repos/sourcejs/Source/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcejs/Source/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcejs/Source/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcejs/Source/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcejs/Source/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcejs/Source/languages","stargazers_url":"https://api.github.com/repos/sourcejs/Source/stargazers","contributors_url":"https://api.github.com/repos/sourcejs/Source/contributors","subscribers_url":"https://api.github.com/repos/sourcejs/Source/subscribers","subscription_url":"https://api.github.com/repos/sourcejs/Source/subscription","commits_url":"https://api.github.com/repos/sourcejs/Source/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcejs/Source/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcejs/Source/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcejs/Source/issues/comments/{number}","contents_url":"https://api.github.com/repos/sourcejs/Source/contents/{+path}","compare_url":"https://api.github.com/repos/sourcejs/Source/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcejs/Source/merges","archive_url":"https://api.github.com/repos/sourcejs/Source/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcejs/Source/downloads","issues_url":"https://api.github.com/repos/sourcejs/Source/issues{/number}","pulls_url":"https://api.github.com/repos/sourcejs/Source/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcejs/Source/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcejs/Source/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcejs/Source/labels{/name}","releases_url":"https://api.github.com/repos/sourcejs/Source/releases{/id}","created_at":"2013-04-21T11:05:02Z","updated_at":"2015-02-09T12:28:54Z","pushed_at":"2015-02-09T10:01:58Z","git_url":"git://github.com/sourcejs/Source.git","ssh_url":"git@github.com:sourcejs/Source.git","clone_url":"https://github.com/sourcejs/Source.git","svn_url":"https://github.com/sourcejs/Source","homepage":"http://sourcejs.com","size":14822,"stargazers_count":281,"watchers_count":281,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":28,"forks":25,"open_issues":28,"watchers":281,"default_branch":"master"}},"base":{"label":"sourcejs:0.4.1","ref":"0.4.1","sha":"3bc1966d0ccf80c37b9df3dc996d82a00c4c9730","user":{"login":"sourcejs","id":3853046,"avatar_url":"https://avatars.githubusercontent.com/u/3853046?v=3","gravatar_id":"","url":"https://api.github.com/users/sourcejs","html_url":"https://github.com/sourcejs","followers_url":"https://api.github.com/users/sourcejs/followers","following_url":"https://api.github.com/users/sourcejs/following{/other_user}","gists_url":"https://api.github.com/users/sourcejs/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcejs/subscriptions","organizations_url":"https://api.github.com/users/sourcejs/orgs","repos_url":"https://api.github.com/users/sourcejs/repos","events_url":"https://api.github.com/users/sourcejs/events{/privacy}","received_events_url":"https://api.github.com/users/sourcejs/received_events","type":"Organization","site_admin":false},"repo":{"id":9578262,"name":"Source","full_name":"sourcejs/Source","owner":{"login":"sourcejs","id":3853046,"avatar_url":"https://avatars.githubusercontent.com/u/3853046?v=3","gravatar_id":"","url":"https://api.github.com/users/sourcejs","html_url":"https://github.com/sourcejs","followers_url":"https://api.github.com/users/sourcejs/followers","following_url":"https://api.github.com/users/sourcejs/following{/other_user}","gists_url":"https://api.github.com/users/sourcejs/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcejs/subscriptions","organizations_url":"https://api.github.com/users/sourcejs/orgs","repos_url":"https://api.github.com/users/sourcejs/repos","events_url":"https://api.github.com/users/sourcejs/events{/privacy}","received_events_url":"https://api.github.com/users/sourcejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sourcejs/Source","description":"Living Style Guides Engine and Maintenance Environment for Front-end Components. Core repository.","fork":false,"url":"https://api.github.com/repos/sourcejs/Source","forks_url":"https://api.github.com/repos/sourcejs/Source/forks","keys_url":"https://api.github.com/repos/sourcejs/Source/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcejs/Source/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcejs/Source/teams","hooks_url":"https://api.github.com/repos/sourcejs/Source/hooks","issue_events_url":"https://api.github.com/repos/sourcejs/Source/issues/events{/number}","events_url":"https://api.github.com/repos/sourcejs/Source/events","assignees_url":"https://api.github.com/repos/sourcejs/Source/assignees{/user}","branches_url":"https://api.github.com/repos/sourcejs/Source/branches{/branch}","tags_url":"https://api.github.com/repos/sourcejs/Source/tags","blobs_url":"https://api.github.com/repos/sourcejs/Source/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcejs/Source/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcejs/Source/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcejs/Source/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcejs/Source/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcejs/Source/languages","stargazers_url":"https://api.github.com/repos/sourcejs/Source/stargazers","contributors_url":"https://api.github.com/repos/sourcejs/Source/contributors","subscribers_url":"https://api.github.com/repos/sourcejs/Source/subscribers","subscription_url":"https://api.github.com/repos/sourcejs/Source/subscription","commits_url":"https://api.github.com/repos/sourcejs/Source/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcejs/Source/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcejs/Source/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcejs/Source/issues/comments/{number}","contents_url":"https://api.github.com/repos/sourcejs/Source/contents/{+path}","compare_url":"https://api.github.com/repos/sourcejs/Source/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcejs/Source/merges","archive_url":"https://api.github.com/repos/sourcejs/Source/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcejs/Source/downloads","issues_url":"https://api.github.com/repos/sourcejs/Source/issues{/number}","pulls_url":"https://api.github.com/repos/sourcejs/Source/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcejs/Source/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcejs/Source/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcejs/Source/labels{/name}","releases_url":"https://api.github.com/repos/sourcejs/Source/releases{/id}","created_at":"2013-04-21T11:05:02Z","updated_at":"2015-02-09T12:28:54Z","pushed_at":"2015-02-09T10:01:58Z","git_url":"git://github.com/sourcejs/Source.git","ssh_url":"git@github.com:sourcejs/Source.git","clone_url":"https://github.com/sourcejs/Source.git","svn_url":"https://github.com/sourcejs/Source","homepage":"http://sourcejs.com","size":14822,"stargazers_count":281,"watchers_count":281,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":28,"forks":25,"open_issues":28,"watchers":281,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sourcejs/Source/pulls/92"},"html":{"href":"https://github.com/sourcejs/Source/pull/92"},"issue":{"href":"https://api.github.com/repos/sourcejs/Source/issues/92"},"comments":{"href":"https://api.github.com/repos/sourcejs/Source/issues/92/comments"},"review_comments":{"href":"https://api.github.com/repos/sourcejs/Source/pulls/92/comments"},"review_comment":{"href":"https://api.github.com/repos/sourcejs/Source/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/sourcejs/Source/pulls/92/commits"},"statuses":{"href":"https://api.github.com/repos/sourcejs/Source/statuses/04b1f3e2937d8f3f1d9aae7f2e8be352cd360868"}}}}