{"action":"created","comment":{"url":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/comments/85312944","pull_request_review_id":6034984,"id":85312944,"diff_hunk":"@@ -3,87 +3,225 @@\n const express = require('express');\n const app = express();\n const fs = require('fs');\n+const main_path = require('path');\n \n const PORT = process.env.PORT || 4000;\n \n const Transform = require('stream').Transform;\n \n-var rus_abc = [\n-'А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П'\n-,'Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ы','Ь','Э','Ю','Я',\n-'a','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п',\n-'р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ы','ь','э','ю','я'\n-];\n \n-var eng_abc = [\n-'A', 'B', 'V', 'G', 'D', 'E', 'Jo', 'Zh','Z', 'I', 'J', 'K', 'L', 'M', 'N', 'O','P', 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'Ch', 'Sh', 'Shh','##', 'Y', '\\'\\'', \n-'Je', 'Ju', 'Ja', 'a','b','v','g','d','e','jo','zh','z','i','j','k','l','m','n','o','p','r','s','t',\n-'u','f','h','c','ch','sh','shh','#','y','\\'','je','ju','ja'\n-];\n \n-\n-class T_to_eng extends Transform {\n+class Translator extends Transform {\n \tconstructor(options) {\n \t\tsuper(options);\n+\t\tthis.aim_lang = null;\n+\t\tthis.jsonprep = false;\n+\t\tthis.jsonrdy = false\n+\n \t}\n-\t_transform(chunk, encoding, callback) {\n-//========================\n-\t\tvar str = chunk.toString('utf-8');\n-\t\tvar new_str = '';\n-\t\tfor (let i = 0; i < str.length; ++i) {\n-\t\t\tlet letter = str[i];\n-\t\t\tind = eng_abc.indexOf(letter);\n-\t\t\tif(ind != -1) {\n-\t\t\t\tnew_str += eng_abc[ind];\n-\t\t\t}\n-\t\t\telse {\n-\t\t\t\tnew_str += str[i];\n-\t\t\t}\n+\n+\t_prepareJSON() {\n+\t\tif(!this.jsonprep) {\n+\t\t\tthis.push('{\"content\": \"');\n+\t\t\tthis.jsonprep = true;\n \t\t}\n-//========================\n-\t\tcallback();\n \t}\n-}\n \n-class T_to_rus extends Transform {\n-\tconstructor(options) {\n-\t\tsuper(options);\n+\t_finishJSON() {\n+\t\tif(!this.jsonrdy) {\n+\t\t\tthis.push('\"}');\n+\t\t\tthis.jsonrdy = true;\n+\t\t}\n+\t\t\t\n+\t}\n+\n+\t_flush(callback) {\n+\t\tthis._finishJSON();\n+\t\tcallback();\n \t}\n-\t_transform(chunk, encoding, callback) {\n-\t\tvar str = chunk.toString('utf8');\n-\n-\t\t//3 letters\n-  \t\tstr = text.replace('Shh', 'Щ');\n-\t\tstr = test.replase('ShH', 'Щ');\n-\t\tstr = text.replace('shh', 'щ');\n-\n-\t\t//2 letters\n-\t\tstr = text.replace('Zh', 'Ж');\n-  \t\tstr = text.replace('Sh', 'Ш');\n-  \t\tstr = text.replace('Je', 'Э');\n-  \t\tstr = text.replace('Ju', 'Ю');\n-  \t\tstr = text.replace('Ja', 'Я');\n-  \t\tstr = text.replace('zh', 'ж');  \t\t\n-  \t\tstr = text.replace('sh', 'ш');\n-\t\tstr = text.replace('##', 'Ъ');\n-\t\tstr = text.replace('\\'\\'', 'Ь');\n-  \t\tstr = text.replace('je', 'э');\n-  \t\tstr = text.replace('ju', 'ю');\n-  \t\tstr = text.replace('ja', 'я');\n \n+\t\n+\t_transform(chunk, encoding, callback) {\n+//========================\n \t\tvar str = chunk.toString('utf-8');\n-\t\tvar new_str = '';\n-\t\tfor (let i = 0; i < str.length; ++i) {\n-\t\t\tlet letter = str[i];\n-\t\t\tind = rus_abc.indexOf(letter);\n-\t\t\tif(ind != -1) {\n-\t\t\t\tnew_str += rus_abc[ind];\n+\t\tvar new_str = '';\t\t\n+\t\tlet rusInd = str.match(/[а-яА-Я]/);\t\t\n+\t\tlet engInd = str.match(/[a-zA-Z]/);\n+\t\tif (this.aim_lang == null) {\t\t\t\n+\t\t\tif(rusInd != null && engInd != null) {\n+\t\t\t\tif(rusInd < engInd) {\n+\t\t\t\t\tthis.aim_lang = 'eng';\n+\t\t\t\t}\n+\t\t\t\telse {\n+\t\t\t\t\tthis.aim_lang = 'rus';\n+\t\t\t\t}\n \t\t\t}\n \t\t\telse {\n-\t\t\t\tnew_str += str[i];\n+\t\t\t\tif(rusInd != null && engInd == null) {\n+\t\t\t\t\tthis.aim_lang = 'eng';\n+\t\t\t\t}\n+\t\t\t\telse {\n+\t\t\t\t\tif(rusInd == null && engInd != null) {\n+\t\t\t\t\t\tthis.aim_lang = 'rus'\n+\t\t\t\t\t\t\n+\t\t\t\t\t}\n+\t\t\t\t}\n \t\t\t}\n \t\t}\n \n+\t\tthis._prepareJSON();","path":"index.js","position":null,"original_position":130,"commit_id":"03cfd52252858557ad73883f0dcf1d0b72e51386","original_commit_id":"03cfd52252858557ad73883f0dcf1d0b72e51386","user":{"login":"govorov","id":6274882,"avatar_url":"https://avatars.githubusercontent.com/u/6274882?v=3","gravatar_id":"","url":"https://api.github.com/users/govorov","html_url":"https://github.com/govorov","followers_url":"https://api.github.com/users/govorov/followers","following_url":"https://api.github.com/users/govorov/following{/other_user}","gists_url":"https://api.github.com/users/govorov/gists{/gist_id}","starred_url":"https://api.github.com/users/govorov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/govorov/subscriptions","organizations_url":"https://api.github.com/users/govorov/orgs","repos_url":"https://api.github.com/users/govorov/repos","events_url":"https://api.github.com/users/govorov/events{/privacy}","received_events_url":"https://api.github.com/users/govorov/received_events","type":"User","site_admin":false},"body":"Лучше все замены положить в массив и пройти по нему, а не писать одну строчку 9000 раз)","created_at":"2016-10-27T10:55:01Z","updated_at":"2016-10-27T10:55:01Z","html_url":"https://github.com/hse2016/part-1-task-3/pull/12#discussion_r85312944","pull_request_url":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/comments/85312944"},"html":{"href":"https://github.com/hse2016/part-1-task-3/pull/12#discussion_r85312944"},"pull_request":{"href":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/12","id":89544998,"html_url":"https://github.com/hse2016/part-1-task-3/pull/12","diff_url":"https://github.com/hse2016/part-1-task-3/pull/12.diff","patch_url":"https://github.com/hse2016/part-1-task-3/pull/12.patch","issue_url":"https://api.github.com/repos/hse2016/part-1-task-3/issues/12","number":12,"state":"open","locked":false,"title":"Update index.js","user":{"login":"Kozyyy","id":12642521,"avatar_url":"https://avatars.githubusercontent.com/u/12642521?v=3","gravatar_id":"","url":"https://api.github.com/users/Kozyyy","html_url":"https://github.com/Kozyyy","followers_url":"https://api.github.com/users/Kozyyy/followers","following_url":"https://api.github.com/users/Kozyyy/following{/other_user}","gists_url":"https://api.github.com/users/Kozyyy/gists{/gist_id}","starred_url":"https://api.github.com/users/Kozyyy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kozyyy/subscriptions","organizations_url":"https://api.github.com/users/Kozyyy/orgs","repos_url":"https://api.github.com/users/Kozyyy/repos","events_url":"https://api.github.com/users/Kozyyy/events{/privacy}","received_events_url":"https://api.github.com/users/Kozyyy/received_events","type":"User","site_admin":false},"body":"Осталось немного, но не успеваю(","created_at":"2016-10-16T23:35:24Z","updated_at":"2016-10-27T10:55:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"556d9fdda2a276cd11e418208e845f1341e4f92c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/12/commits","review_comments_url":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/12/comments","review_comment_url":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hse2016/part-1-task-3/issues/12/comments","statuses_url":"https://api.github.com/repos/hse2016/part-1-task-3/statuses/03cfd52252858557ad73883f0dcf1d0b72e51386","head":{"label":"Kozyyy:master","ref":"master","sha":"03cfd52252858557ad73883f0dcf1d0b72e51386","user":{"login":"Kozyyy","id":12642521,"avatar_url":"https://avatars.githubusercontent.com/u/12642521?v=3","gravatar_id":"","url":"https://api.github.com/users/Kozyyy","html_url":"https://github.com/Kozyyy","followers_url":"https://api.github.com/users/Kozyyy/followers","following_url":"https://api.github.com/users/Kozyyy/following{/other_user}","gists_url":"https://api.github.com/users/Kozyyy/gists{/gist_id}","starred_url":"https://api.github.com/users/Kozyyy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kozyyy/subscriptions","organizations_url":"https://api.github.com/users/Kozyyy/orgs","repos_url":"https://api.github.com/users/Kozyyy/repos","events_url":"https://api.github.com/users/Kozyyy/events{/privacy}","received_events_url":"https://api.github.com/users/Kozyyy/received_events","type":"User","site_admin":false},"repo":{"id":71009648,"name":"part-1-task-3","full_name":"Kozyyy/part-1-task-3","owner":{"login":"Kozyyy","id":12642521,"avatar_url":"https://avatars.githubusercontent.com/u/12642521?v=3","gravatar_id":"","url":"https://api.github.com/users/Kozyyy","html_url":"https://github.com/Kozyyy","followers_url":"https://api.github.com/users/Kozyyy/followers","following_url":"https://api.github.com/users/Kozyyy/following{/other_user}","gists_url":"https://api.github.com/users/Kozyyy/gists{/gist_id}","starred_url":"https://api.github.com/users/Kozyyy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kozyyy/subscriptions","organizations_url":"https://api.github.com/users/Kozyyy/orgs","repos_url":"https://api.github.com/users/Kozyyy/repos","events_url":"https://api.github.com/users/Kozyyy/events{/privacy}","received_events_url":"https://api.github.com/users/Kozyyy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Kozyyy/part-1-task-3","description":null,"fork":true,"url":"https://api.github.com/repos/Kozyyy/part-1-task-3","forks_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/forks","keys_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/teams","hooks_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/hooks","issue_events_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/events","assignees_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/tags","blobs_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/languages","stargazers_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/stargazers","contributors_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/contributors","subscribers_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/subscribers","subscription_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/subscription","commits_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/merges","archive_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/downloads","issues_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/labels{/name}","releases_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/Kozyyy/part-1-task-3/deployments","created_at":"2016-10-15T19:46:01Z","updated_at":"2016-10-15T19:46:03Z","pushed_at":"2016-10-27T04:37:03Z","git_url":"git://github.com/Kozyyy/part-1-task-3.git","ssh_url":"git@github.com:Kozyyy/part-1-task-3.git","clone_url":"https://github.com/Kozyyy/part-1-task-3.git","svn_url":"https://github.com/Kozyyy/part-1-task-3","homepage":null,"size":12,"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":"hse2016:master","ref":"master","sha":"8b68a5559db84ce8553745ebcb59592300436e23","user":{"login":"hse2016","id":21147595,"avatar_url":"https://avatars.githubusercontent.com/u/21147595?v=3","gravatar_id":"","url":"https://api.github.com/users/hse2016","html_url":"https://github.com/hse2016","followers_url":"https://api.github.com/users/hse2016/followers","following_url":"https://api.github.com/users/hse2016/following{/other_user}","gists_url":"https://api.github.com/users/hse2016/gists{/gist_id}","starred_url":"https://api.github.com/users/hse2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hse2016/subscriptions","organizations_url":"https://api.github.com/users/hse2016/orgs","repos_url":"https://api.github.com/users/hse2016/repos","events_url":"https://api.github.com/users/hse2016/events{/privacy}","received_events_url":"https://api.github.com/users/hse2016/received_events","type":"Organization","site_admin":false},"repo":{"id":70604524,"name":"part-1-task-3","full_name":"hse2016/part-1-task-3","owner":{"login":"hse2016","id":21147595,"avatar_url":"https://avatars.githubusercontent.com/u/21147595?v=3","gravatar_id":"","url":"https://api.github.com/users/hse2016","html_url":"https://github.com/hse2016","followers_url":"https://api.github.com/users/hse2016/followers","following_url":"https://api.github.com/users/hse2016/following{/other_user}","gists_url":"https://api.github.com/users/hse2016/gists{/gist_id}","starred_url":"https://api.github.com/users/hse2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hse2016/subscriptions","organizations_url":"https://api.github.com/users/hse2016/orgs","repos_url":"https://api.github.com/users/hse2016/repos","events_url":"https://api.github.com/users/hse2016/events{/privacy}","received_events_url":"https://api.github.com/users/hse2016/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hse2016/part-1-task-3","description":null,"fork":false,"url":"https://api.github.com/repos/hse2016/part-1-task-3","forks_url":"https://api.github.com/repos/hse2016/part-1-task-3/forks","keys_url":"https://api.github.com/repos/hse2016/part-1-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hse2016/part-1-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hse2016/part-1-task-3/teams","hooks_url":"https://api.github.com/repos/hse2016/part-1-task-3/hooks","issue_events_url":"https://api.github.com/repos/hse2016/part-1-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/hse2016/part-1-task-3/events","assignees_url":"https://api.github.com/repos/hse2016/part-1-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/hse2016/part-1-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/hse2016/part-1-task-3/tags","blobs_url":"https://api.github.com/repos/hse2016/part-1-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hse2016/part-1-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hse2016/part-1-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/hse2016/part-1-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hse2016/part-1-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/hse2016/part-1-task-3/languages","stargazers_url":"https://api.github.com/repos/hse2016/part-1-task-3/stargazers","contributors_url":"https://api.github.com/repos/hse2016/part-1-task-3/contributors","subscribers_url":"https://api.github.com/repos/hse2016/part-1-task-3/subscribers","subscription_url":"https://api.github.com/repos/hse2016/part-1-task-3/subscription","commits_url":"https://api.github.com/repos/hse2016/part-1-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/hse2016/part-1-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/hse2016/part-1-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/hse2016/part-1-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/hse2016/part-1-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/hse2016/part-1-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hse2016/part-1-task-3/merges","archive_url":"https://api.github.com/repos/hse2016/part-1-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hse2016/part-1-task-3/downloads","issues_url":"https://api.github.com/repos/hse2016/part-1-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/hse2016/part-1-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/hse2016/part-1-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/hse2016/part-1-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hse2016/part-1-task-3/labels{/name}","releases_url":"https://api.github.com/repos/hse2016/part-1-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/hse2016/part-1-task-3/deployments","created_at":"2016-10-11T14:56:11Z","updated_at":"2016-10-11T14:56:39Z","pushed_at":"2016-10-27T04:37:04Z","git_url":"git://github.com/hse2016/part-1-task-3.git","ssh_url":"git@github.com:hse2016/part-1-task-3.git","clone_url":"https://github.com/hse2016/part-1-task-3.git","svn_url":"https://github.com/hse2016/part-1-task-3","homepage":null,"size":110,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":13,"forks":13,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/12"},"html":{"href":"https://github.com/hse2016/part-1-task-3/pull/12"},"issue":{"href":"https://api.github.com/repos/hse2016/part-1-task-3/issues/12"},"comments":{"href":"https://api.github.com/repos/hse2016/part-1-task-3/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hse2016/part-1-task-3/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/hse2016/part-1-task-3/statuses/03cfd52252858557ad73883f0dcf1d0b72e51386"}}}}
{"actor":{"display_login":"govorov"}}