GitHub PullRequestReviewCommentEvent at 2014-10-30 12:18:37
Repository: enb-bem-tmpl-specs
Actor: j0tunn
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/comments/19600916","id":19600916,"diff_hunk":"@@ -2,24 +2,61 @@ var inherits = require('util').inherits,\n     MochaBase = require('mocha/lib/reporters/base'),\n     path = require('path'),\n     fs = require('fs'),\n-    REPORTS_DIR = 'tmpl-specs-reports';\n+    REPORTS_DIR = 'tmpl-specs-reports',\n+    REPORTS_PATH = path.join(process.cwd(), REPORTS_DIR),\n+    cbs = [];\n \n inherits(Base, MochaBase);\n module.exports = Base;\n \n+Base.prototype.endProcess = endProcess;\n+\n+Base.saveFile = saveFile;\n+Base.sum = sum;\n+\n+process.on('exit', function (code) {\n+    cbs.forEach(function (cb) {\n+        cb();\n+    });\n+    process.exit(code);\n+});\n+\n function Base(runner) {\n     MochaBase.call(this, runner);\n }\n \n-Base.prototype._reportsPath = path.join(process.cwd(), REPORTS_DIR);\n+function endProcess(cb) {\n+    cbs.push(cb);\n+}\n \n-Base.prototype._prepare = function () {\n-    if (!fs.existsSync(this._reportsPath)) {\n-        fs.mkdirSync(this._reportsPath);\n+function saveFile(fileName, content) {\n+    if (!fs.existsSync(REPORTS_PATH)) {\n+        fs.mkdirSync(REPORTS_PATH);\n     }\n-};\n+    fs.writeFileSync(path.join(REPORTS_PATH, fileName), content);\n+}\n+\n+/**\n+ * Adds objects field\n+ *\n+ * @param {Object} obj1 Source1\n+ * @param {Object} obj2 Source2\n+ * @returns {Number} Accumulator created by Source 2\n+ */\n+function sum(obj1, obj2) {\n+    return Object\n+        .keys(obj2)\n+        .reduce(function (acc, key) {\n+            acc[key] = __parseNumber(acc[key]);\n+            obj1[key] && (acc[key] += __parseNumber(obj1[key]));\n+            return acc;\n+        }, Object.create(obj2));\n \n-Base.prototype.saveFile = function (fileName, content) {\n-    this._prepare();\n-    fs.writeFileSync(path.join(this._reportsPath, fileName), content);\n-};\n+    function __parseNumber(num) {\n+        if (typeof num !== 'number') {\n+            num = parseFloat(num);\n+            Number.isNaN(num) && (num = 0);\n+        }\n+        return num;\n+    }\n+}","path":"lib/reporters/base.js","position":71,"original_position":71,"commit_id":"f675dda6c1a72f5edf101cbc3d38446a76484b1b","original_commit_id":"f675dda6c1a72f5edf101cbc3d38446a76484b1b","user":{"login":"j0tunn","id":7701229,"avatar_url":"https://avatars.githubusercontent.com/u/7701229?v=2","gravatar_id":"","url":"https://api.github.com/users/j0tunn","html_url":"https://github.com/j0tunn","followers_url":"https://api.github.com/users/j0tunn/followers","following_url":"https://api.github.com/users/j0tunn/following{/other_user}","gists_url":"https://api.github.com/users/j0tunn/gists{/gist_id}","starred_url":"https://api.github.com/users/j0tunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j0tunn/subscriptions","organizations_url":"https://api.github.com/users/j0tunn/orgs","repos_url":"https://api.github.com/users/j0tunn/repos","events_url":"https://api.github.com/users/j0tunn/events{/privacy}","received_events_url":"https://api.github.com/users/j0tunn/received_events","type":"User","site_admin":false},"body":"А ниче, что если есть какой-то ключ в obj1, которого нет obj2 - то он просто пропустится, а вот если наоборот - то в итоговом объекте он будет","created_at":"2014-10-30T12:18:37Z","updated_at":"2014-10-30T12:18:37Z","html_url":"https://github.com/enb-bem/enb-bem-tmpl-specs/pull/31#discussion_r19600916","pull_request_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/31","_links":{"self":{"href":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/comments/19600916"},"html":{"href":"https://github.com/enb-bem/enb-bem-tmpl-specs/pull/31#discussion_r19600916"},"pull_request":{"href":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/31"}}},"pull_request":{"url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/31","id":23239502,"html_url":"https://github.com/enb-bem/enb-bem-tmpl-specs/pull/31","diff_url":"https://github.com/enb-bem/enb-bem-tmpl-specs/pull/31.diff","patch_url":"https://github.com/enb-bem/enb-bem-tmpl-specs/pull/31.patch","issue_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/issues/31","number":31,"state":"open","locked":false,"title":"Dump files and generate HTML report when happen process exit","user":{"login":"unlok","id":3048454,"avatar_url":"https://avatars.githubusercontent.com/u/3048454?v=2","gravatar_id":"","url":"https://api.github.com/users/unlok","html_url":"https://github.com/unlok","followers_url":"https://api.github.com/users/unlok/followers","following_url":"https://api.github.com/users/unlok/following{/other_user}","gists_url":"https://api.github.com/users/unlok/gists{/gist_id}","starred_url":"https://api.github.com/users/unlok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unlok/subscriptions","organizations_url":"https://api.github.com/users/unlok/orgs","repos_url":"https://api.github.com/users/unlok/repos","events_url":"https://api.github.com/users/unlok/events{/privacy}","received_events_url":"https://api.github.com/users/unlok/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-10-23T16:10:53Z","updated_at":"2014-10-30T12:18:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"716590e6ae9a988318ad39afebcdf017921222a3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/31/commits","review_comments_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/31/comments","review_comment_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/issues/31/comments","statuses_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/statuses/f675dda6c1a72f5edf101cbc3d38446a76484b1b","head":{"label":"unlok:fix/html-reporter","ref":"fix/html-reporter","sha":"f675dda6c1a72f5edf101cbc3d38446a76484b1b","user":{"login":"unlok","id":3048454,"avatar_url":"https://avatars.githubusercontent.com/u/3048454?v=2","gravatar_id":"","url":"https://api.github.com/users/unlok","html_url":"https://github.com/unlok","followers_url":"https://api.github.com/users/unlok/followers","following_url":"https://api.github.com/users/unlok/following{/other_user}","gists_url":"https://api.github.com/users/unlok/gists{/gist_id}","starred_url":"https://api.github.com/users/unlok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unlok/subscriptions","organizations_url":"https://api.github.com/users/unlok/orgs","repos_url":"https://api.github.com/users/unlok/repos","events_url":"https://api.github.com/users/unlok/events{/privacy}","received_events_url":"https://api.github.com/users/unlok/received_events","type":"User","site_admin":false},"repo":{"id":25031023,"name":"enb-bem-tmpl-specs","full_name":"unlok/enb-bem-tmpl-specs","owner":{"login":"unlok","id":3048454,"avatar_url":"https://avatars.githubusercontent.com/u/3048454?v=2","gravatar_id":"","url":"https://api.github.com/users/unlok","html_url":"https://github.com/unlok","followers_url":"https://api.github.com/users/unlok/followers","following_url":"https://api.github.com/users/unlok/following{/other_user}","gists_url":"https://api.github.com/users/unlok/gists{/gist_id}","starred_url":"https://api.github.com/users/unlok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unlok/subscriptions","organizations_url":"https://api.github.com/users/unlok/orgs","repos_url":"https://api.github.com/users/unlok/repos","events_url":"https://api.github.com/users/unlok/events{/privacy}","received_events_url":"https://api.github.com/users/unlok/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/unlok/enb-bem-tmpl-specs","description":"BEM template specs for ENB","fork":true,"url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs","forks_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/forks","keys_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/teams","hooks_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/hooks","issue_events_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/issues/events{/number}","events_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/events","assignees_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/assignees{/user}","branches_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/branches{/branch}","tags_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/tags","blobs_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/git/refs{/sha}","trees_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/statuses/{sha}","languages_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/languages","stargazers_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/stargazers","contributors_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/contributors","subscribers_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/subscribers","subscription_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/subscription","commits_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/commits{/sha}","git_commits_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/git/commits{/sha}","comments_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/comments{/number}","issue_comment_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/issues/comments/{number}","contents_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/contents/{+path}","compare_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/merges","archive_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/downloads","issues_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/issues{/number}","pulls_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/pulls{/number}","milestones_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/milestones{/number}","notifications_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/labels{/name}","releases_url":"https://api.github.com/repos/unlok/enb-bem-tmpl-specs/releases{/id}","created_at":"2014-10-10T10:29:57Z","updated_at":"2014-10-10T10:36:24Z","pushed_at":"2014-10-30T09:58:31Z","git_url":"git://github.com/unlok/enb-bem-tmpl-specs.git","ssh_url":"git@github.com:unlok/enb-bem-tmpl-specs.git","clone_url":"https://github.com/unlok/enb-bem-tmpl-specs.git","svn_url":"https://github.com/unlok/enb-bem-tmpl-specs","homepage":"","size":297,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"enb-bem:master","ref":"master","sha":"79ef87c969f1198c5016f54aa0a8b5bc8c712183","user":{"login":"enb-bem","id":8117111,"avatar_url":"https://avatars.githubusercontent.com/u/8117111?v=2","gravatar_id":"","url":"https://api.github.com/users/enb-bem","html_url":"https://github.com/enb-bem","followers_url":"https://api.github.com/users/enb-bem/followers","following_url":"https://api.github.com/users/enb-bem/following{/other_user}","gists_url":"https://api.github.com/users/enb-bem/gists{/gist_id}","starred_url":"https://api.github.com/users/enb-bem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enb-bem/subscriptions","organizations_url":"https://api.github.com/users/enb-bem/orgs","repos_url":"https://api.github.com/users/enb-bem/repos","events_url":"https://api.github.com/users/enb-bem/events{/privacy}","received_events_url":"https://api.github.com/users/enb-bem/received_events","type":"Organization","site_admin":false},"repo":{"id":22675688,"name":"enb-bem-tmpl-specs","full_name":"enb-bem/enb-bem-tmpl-specs","owner":{"login":"enb-bem","id":8117111,"avatar_url":"https://avatars.githubusercontent.com/u/8117111?v=2","gravatar_id":"","url":"https://api.github.com/users/enb-bem","html_url":"https://github.com/enb-bem","followers_url":"https://api.github.com/users/enb-bem/followers","following_url":"https://api.github.com/users/enb-bem/following{/other_user}","gists_url":"https://api.github.com/users/enb-bem/gists{/gist_id}","starred_url":"https://api.github.com/users/enb-bem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enb-bem/subscriptions","organizations_url":"https://api.github.com/users/enb-bem/orgs","repos_url":"https://api.github.com/users/enb-bem/repos","events_url":"https://api.github.com/users/enb-bem/events{/privacy}","received_events_url":"https://api.github.com/users/enb-bem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/enb-bem/enb-bem-tmpl-specs","description":"BEM template specs for ENB","fork":false,"url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs","forks_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/forks","keys_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/teams","hooks_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/hooks","issue_events_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/issues/events{/number}","events_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/events","assignees_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/assignees{/user}","branches_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/branches{/branch}","tags_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/tags","blobs_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/git/refs{/sha}","trees_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/statuses/{sha}","languages_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/languages","stargazers_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/stargazers","contributors_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/contributors","subscribers_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/subscribers","subscription_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/subscription","commits_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/commits{/sha}","git_commits_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/git/commits{/sha}","comments_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/comments{/number}","issue_comment_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/issues/comments/{number}","contents_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/contents/{+path}","compare_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/merges","archive_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/downloads","issues_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/issues{/number}","pulls_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls{/number}","milestones_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/milestones{/number}","notifications_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/labels{/name}","releases_url":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/releases{/id}","created_at":"2014-08-06T08:39:30Z","updated_at":"2014-10-29T16:23:48Z","pushed_at":"2014-10-28T19:23:22Z","git_url":"git://github.com/enb-bem/enb-bem-tmpl-specs.git","ssh_url":"git@github.com:enb-bem/enb-bem-tmpl-specs.git","clone_url":"https://github.com/enb-bem/enb-bem-tmpl-specs.git","svn_url":"https://github.com/enb-bem/enb-bem-tmpl-specs","homepage":"","size":917,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":7,"forks":4,"open_issues":7,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/31"},"html":{"href":"https://github.com/enb-bem/enb-bem-tmpl-specs/pull/31"},"issue":{"href":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/issues/31"},"comments":{"href":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/issues/31/comments"},"review_comments":{"href":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/31/comments"},"review_comment":{"href":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/pulls/31/commits"},"statuses":{"href":"https://api.github.com/repos/enb-bem/enb-bem-tmpl-specs/statuses/f675dda6c1a72f5edf101cbc3d38446a76484b1b"}}}}