{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/comments/55184903","id":55184903,"diff_hunk":"@@ -0,0 +1,115 @@\n+'use strict';\n+\n+const http = require('http');\n+const fs = require('fs');\n+const request = require('request');\n+const Promise = require('bluebird');\n+const co = require('co');\n+const mystem = require('./index');\n+\n+function main(callback) {\n+    return co(function* (){\n+        let oauthToken = yield readFile('key.txt');\n+        oauthToken = oauthToken.split('\\n').shift();\n+\n+        let repos = yield sendRequest('users/urfu-2015/repos', oauthToken, '+json');\n+        repos = JSON.parse(repos.pop())\n+            .map(item => item.name)\n+            .filter(item => /^(verstka|javascript)-tasks-\\d+/i.test(item));\n+        let readmeText = yield Promise.all(repos.map(item => {\n+            return sendRequest('repos/urfu-2015/' + item + '/readme', oauthToken, '.VERSION.raw');\n+        }));\n+        readmeText = separateToSingleWords(readmeText);\n+\n+        const data = yield Promise.all([\n+            readFile('prepositions.txt'),\n+            mystem.analyze(readmeText)\n+        ]);\n+\n+        return getAllWordsFreq(data);\n+    })\n+    .then(callback);\n+}\n+\n+module.exports.top = function (num) {\n+    return main(function (words) {\n+        var keys = Object.keys(words)\n+            .sort((a, b) => words[b] - words[a]);\n+\n+        var result = {};\n+        for (var i = 0; i < num; i++) {\n+            result[keys[i]] = words[keys[i]];\n+        }\n+\n+        return result;\n+    });\n+};\n+\n+module.exports.count = function (word) {\n+    return main(function (words) {\n+        return mystem.analyze(word)\n+        .then(item => {\n+            if (item && item.length > 0 && words[item[0]]) {\n+                return words[item[0]];\n+            }\n+            throw('Sorry, your analyzed word -> ' + item + ' doesn\\'t exist');\n+        });\n+    });\n+};\n+\n+function getAllWordsFreq(data) {\n+    const prepos = data[0].replace(/\\n(?!$)/gi, '|').replace(/\\|null/, '');\n+    const preposRegExp = new RegExp('(^|\\\\s)(' + prepos + ')(?=\\\\s|$)', 'gi');\n+    let allWords = data[1].join(' ')\n+        .replace(preposRegExp, '')\n+        .split(' ')\n+        .sort((a, b) => a > b ? 1 : -1);\n+\n+    var wordsFreq = {};\n+    allWords.forEach(item => {\n+        if (!wordsFreq.hasOwnProperty(item)) {\n+            wordsFreq[item] = 1;\n+        } else {\n+            wordsFreq[item] += 1;\n+        }\n+    });\n+    return wordsFreq;\n+}\n+\n+function separateToSingleWords(text) {\n+    return text.join(' ')\n+        .replace(/[^а-яё\\s-]+/gi, '')\n+        .replace(/(^|[^а-яё])[а-яё](?![а-яё])/gi, '')\n+        .replace(/\\s+/g, ' ');\n+}\n+\n+function getOptions(query, oauthToken, accept) {\n+    return {\n+        url: 'https://api.github.com/' + query + '?access_token=' + oauthToken,","path":"counter.js","position":88,"original_position":88,"commit_id":"5dc976fad39ad85a5a1d8f4c2be58d71d645f2ec","original_commit_id":"5dc976fad39ad85a5a1d8f4c2be58d71d645f2ec","user":{"login":"DudaGod","id":5900697,"avatar_url":"https://avatars.githubusercontent.com/u/5900697?v=3","gravatar_id":"","url":"https://api.github.com/users/DudaGod","html_url":"https://github.com/DudaGod","followers_url":"https://api.github.com/users/DudaGod/followers","following_url":"https://api.github.com/users/DudaGod/following{/other_user}","gists_url":"https://api.github.com/users/DudaGod/gists{/gist_id}","starred_url":"https://api.github.com/users/DudaGod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DudaGod/subscriptions","organizations_url":"https://api.github.com/users/DudaGod/orgs","repos_url":"https://api.github.com/users/DudaGod/repos","events_url":"https://api.github.com/users/DudaGod/events{/privacy}","received_events_url":"https://api.github.com/users/DudaGod/received_events","type":"User","site_admin":false},"body":"Посмотрел, но не понял какой профит от нее в данном случае. Она на вход принимает распарсенный URL object и возвращает URL строку. А URL строка у меня уже есть...","created_at":"2016-03-07T10:25:47Z","updated_at":"2016-03-07T10:25:47Z","html_url":"https://github.com/urfu-2015/webdev-tasks-1/pull/26#discussion_r55184903","pull_request_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/comments/55184903"},"html":{"href":"https://github.com/urfu-2015/webdev-tasks-1/pull/26#discussion_r55184903"},"pull_request":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/26","id":61172793,"html_url":"https://github.com/urfu-2015/webdev-tasks-1/pull/26","diff_url":"https://github.com/urfu-2015/webdev-tasks-1/pull/26.diff","patch_url":"https://github.com/urfu-2015/webdev-tasks-1/pull/26.patch","issue_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/issues/26","number":26,"state":"open","locked":false,"title":"Дудкевич Дмитрий","user":{"login":"DudaGod","id":5900697,"avatar_url":"https://avatars.githubusercontent.com/u/5900697?v=3","gravatar_id":"","url":"https://api.github.com/users/DudaGod","html_url":"https://github.com/DudaGod","followers_url":"https://api.github.com/users/DudaGod/followers","following_url":"https://api.github.com/users/DudaGod/following{/other_user}","gists_url":"https://api.github.com/users/DudaGod/gists{/gist_id}","starred_url":"https://api.github.com/users/DudaGod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DudaGod/subscriptions","organizations_url":"https://api.github.com/users/DudaGod/orgs","repos_url":"https://api.github.com/users/DudaGod/repos","events_url":"https://api.github.com/users/DudaGod/events{/privacy}","received_events_url":"https://api.github.com/users/DudaGod/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-01T00:39:47Z","updated_at":"2016-03-07T10:25:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7fea3b886e8e861228fff7d7588b0491b299f3c6","assignee":{"login":"Zhigalov","id":1654243,"avatar_url":"https://avatars.githubusercontent.com/u/1654243?v=3","gravatar_id":"","url":"https://api.github.com/users/Zhigalov","html_url":"https://github.com/Zhigalov","followers_url":"https://api.github.com/users/Zhigalov/followers","following_url":"https://api.github.com/users/Zhigalov/following{/other_user}","gists_url":"https://api.github.com/users/Zhigalov/gists{/gist_id}","starred_url":"https://api.github.com/users/Zhigalov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zhigalov/subscriptions","organizations_url":"https://api.github.com/users/Zhigalov/orgs","repos_url":"https://api.github.com/users/Zhigalov/repos","events_url":"https://api.github.com/users/Zhigalov/events{/privacy}","received_events_url":"https://api.github.com/users/Zhigalov/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/26/commits","review_comments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/26/comments","review_comment_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/issues/26/comments","statuses_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/statuses/5dc976fad39ad85a5a1d8f4c2be58d71d645f2ec","head":{"label":"DudaGod:master","ref":"master","sha":"5dc976fad39ad85a5a1d8f4c2be58d71d645f2ec","user":{"login":"DudaGod","id":5900697,"avatar_url":"https://avatars.githubusercontent.com/u/5900697?v=3","gravatar_id":"","url":"https://api.github.com/users/DudaGod","html_url":"https://github.com/DudaGod","followers_url":"https://api.github.com/users/DudaGod/followers","following_url":"https://api.github.com/users/DudaGod/following{/other_user}","gists_url":"https://api.github.com/users/DudaGod/gists{/gist_id}","starred_url":"https://api.github.com/users/DudaGod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DudaGod/subscriptions","organizations_url":"https://api.github.com/users/DudaGod/orgs","repos_url":"https://api.github.com/users/DudaGod/repos","events_url":"https://api.github.com/users/DudaGod/events{/privacy}","received_events_url":"https://api.github.com/users/DudaGod/received_events","type":"User","site_admin":false},"repo":{"id":52428565,"name":"webdev-tasks-1","full_name":"DudaGod/webdev-tasks-1","owner":{"login":"DudaGod","id":5900697,"avatar_url":"https://avatars.githubusercontent.com/u/5900697?v=3","gravatar_id":"","url":"https://api.github.com/users/DudaGod","html_url":"https://github.com/DudaGod","followers_url":"https://api.github.com/users/DudaGod/followers","following_url":"https://api.github.com/users/DudaGod/following{/other_user}","gists_url":"https://api.github.com/users/DudaGod/gists{/gist_id}","starred_url":"https://api.github.com/users/DudaGod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DudaGod/subscriptions","organizations_url":"https://api.github.com/users/DudaGod/orgs","repos_url":"https://api.github.com/users/DudaGod/repos","events_url":"https://api.github.com/users/DudaGod/events{/privacy}","received_events_url":"https://api.github.com/users/DudaGod/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DudaGod/webdev-tasks-1","description":"","fork":true,"url":"https://api.github.com/repos/DudaGod/webdev-tasks-1","forks_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/forks","keys_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/teams","hooks_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/hooks","issue_events_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/issues/events{/number}","events_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/events","assignees_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/assignees{/user}","branches_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/branches{/branch}","tags_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/tags","blobs_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/statuses/{sha}","languages_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/languages","stargazers_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/stargazers","contributors_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/contributors","subscribers_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/subscribers","subscription_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/subscription","commits_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/contents/{+path}","compare_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/merges","archive_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/downloads","issues_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/issues{/number}","pulls_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/pulls{/number}","milestones_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/milestones{/number}","notifications_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/labels{/name}","releases_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/releases{/id}","deployments_url":"https://api.github.com/repos/DudaGod/webdev-tasks-1/deployments","created_at":"2016-02-24T09:03:00Z","updated_at":"2016-03-01T00:38:48Z","pushed_at":"2016-03-04T13:29:50Z","git_url":"git://github.com/DudaGod/webdev-tasks-1.git","ssh_url":"git@github.com:DudaGod/webdev-tasks-1.git","clone_url":"https://github.com/DudaGod/webdev-tasks-1.git","svn_url":"https://github.com/DudaGod/webdev-tasks-1","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"urfu-2015:master","ref":"master","sha":"6ff732253132f88e1eec631e611136f3676768b7","user":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"repo":{"id":52003967,"name":"webdev-tasks-1","full_name":"urfu-2015/webdev-tasks-1","owner":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urfu-2015/webdev-tasks-1","description":"","fork":false,"url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1","forks_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/forks","keys_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/teams","hooks_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/hooks","issue_events_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/events","assignees_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/tags","blobs_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/languages","stargazers_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/stargazers","contributors_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/contributors","subscribers_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/subscribers","subscription_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/subscription","commits_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/merges","archive_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/downloads","issues_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/releases{/id}","deployments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/deployments","created_at":"2016-02-18T11:54:14Z","updated_at":"2016-02-18T11:54:14Z","pushed_at":"2016-03-06T21:22:52Z","git_url":"git://github.com/urfu-2015/webdev-tasks-1.git","ssh_url":"git@github.com:urfu-2015/webdev-tasks-1.git","clone_url":"https://github.com/urfu-2015/webdev-tasks-1.git","svn_url":"https://github.com/urfu-2015/webdev-tasks-1","homepage":null,"size":5,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":13,"forks":34,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/26"},"html":{"href":"https://github.com/urfu-2015/webdev-tasks-1/pull/26"},"issue":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/issues/26"},"comments":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-1/statuses/5dc976fad39ad85a5a1d8f4c2be58d71d645f2ec"}}}}