{"action":"created","comment":{"url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/comments/200853182","pull_request_review_id":135244888,"id":200853182,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDg1MzE4Mg==","diff_hunk":"@@ -0,0 +1,111 @@\n+require File.expand_path(File.dirname(__FILE__) + '/neo')\n+\n+class AboutSandwichCode < Neo::Koan\n+\n+  def count_lines(file_name)\n+    file = open(file_name)\n+    count = 0\n+    while file.gets\n+      count += 1\n+    end\n+    count\n+  ensure\n+    file.close if file\n+  end\n+\n+  def test_counting_lines\n+    assert_equal 4, count_lines(\"example_file.txt\")\n+  end\n+\n+  # ------------------------------------------------------------------\n+\n+  def find_line(file_name)\n+    file = open(file_name)\n+    while line = file.gets\n+      return line if line.match(/e/)\n+    end\n+  ensure\n+    file.close if file\n+  end\n+\n+  def test_finding_lines\n+    assert_equal \"test\\n\", find_line(\"example_file.txt\")\n+  end\n+\n+  # ------------------------------------------------------------------\n+  # THINK ABOUT IT:\n+  #\n+  # The count_lines and find_line are similar, and yet different.\n+  # They both follow the pattern of \"sandwich code\".\n+  #\n+  # Sandwich code is code that comes in three parts: (1) the top slice\n+  # of bread, (2) the meat, and (3) the bottom slice of bread.  The\n+  # bread part of the sandwich almost always goes together, but\n+  # the meat part changes all the time.\n+  #\n+  # Because the changing part of the sandwich code is in the middle,\n+  # abstracting the top and bottom bread slices to a library can be\n+  # difficult in many languages.\n+  #\n+  # (Aside for C++ programmers: The idiom of capturing allocated\n+  # pointers in a smart pointer constructor is an attempt to deal with\n+  # the problem of sandwich code for resource allocation.)\n+  #\n+  # Consider the following code:\n+  #\n+\n+  def file_sandwich(file_name)\n+    file = open(file_name)\n+    yield(file)\n+  ensure\n+    file.close if file\n+  end\n+\n+  # Now we write:\n+\n+  def count_lines2(file_name)\n+    file_sandwich(file_name) do |file|\n+      count = 0\n+      while file.gets\n+        count += 1\n+      end\n+      count\n+    end\n+  end\n+\n+  def test_counting_lines2\n+    assert_equal 4, count_lines2(\"example_file.txt\")\n+  end\n+\n+  # ------------------------------------------------------------------\n+\n+  def find_line2(file_name)\n+    # Rewrite find_line using the file_sandwich library function.\n+    file_sandwich(file_name) do |file|\n+      while line = file.gets\n+        return line if line.match(/e/)\n+      end\n+    end\t\n+  end\n+\n+  def test_finding_lines2\n+    assert_equal \"test\\n\", find_line2(\"example_file.txt\")\n+  end\n+\n+  # ------------------------------------------------------------------\n+\n+  def count_lines3(file_name)\n+    open(file_name) do |file|\n+      count = 0\n+      while file.gets\n+        count += 1\n+      end\n+      count\n+    end\n+  end\n+\n+  def test_open_handles_the_file_sandwich_when_given_a_block\n+    assert_equal 4, count_lines3(\"example_file.txt\")","path":"2253/1/about_sandwich_code.rb","position":108,"original_position":108,"commit_id":"c8454c50e307c81beacdb6b5ec36a6f5422d7dad","original_commit_id":"c8454c50e307c81beacdb6b5ec36a6f5422d7dad","user":{"login":"houndci-bot","id":6697940,"node_id":"MDQ6VXNlcjY2OTc5NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","created_at":"2018-07-08T20:43:15Z","updated_at":"2018-07-08T20:43:18Z","html_url":"https://github.com/rubizza-survival-camp/summer-2018/pull/96#discussion_r200853182","pull_request_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/96","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/comments/200853182"},"html":{"href":"https://github.com/rubizza-survival-camp/summer-2018/pull/96#discussion_r200853182"},"pull_request":{"href":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/96"}}},"pull_request":{"url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/96","id":199958374,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk5OTU4Mzc0","html_url":"https://github.com/rubizza-survival-camp/summer-2018/pull/96","diff_url":"https://github.com/rubizza-survival-camp/summer-2018/pull/96.diff","patch_url":"https://github.com/rubizza-survival-camp/summer-2018/pull/96.patch","issue_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/issues/96","number":96,"state":"open","locked":false,"title":"2253-1","user":{"login":"Ctalk3r","id":40827175,"node_id":"MDQ6VXNlcjQwODI3MTc1","avatar_url":"https://avatars0.githubusercontent.com/u/40827175?v=4","gravatar_id":"","url":"https://api.github.com/users/Ctalk3r","html_url":"https://github.com/Ctalk3r","followers_url":"https://api.github.com/users/Ctalk3r/followers","following_url":"https://api.github.com/users/Ctalk3r/following{/other_user}","gists_url":"https://api.github.com/users/Ctalk3r/gists{/gist_id}","starred_url":"https://api.github.com/users/Ctalk3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ctalk3r/subscriptions","organizations_url":"https://api.github.com/users/Ctalk3r/orgs","repos_url":"https://api.github.com/users/Ctalk3r/repos","events_url":"https://api.github.com/users/Ctalk3r/events{/privacy}","received_events_url":"https://api.github.com/users/Ctalk3r/received_events","type":"User","site_admin":false},"body":"## Номер\r\n2253\r\n\r\n## Номер задания\r\n1\r\n\r\n## Ссылка на видео с демо\r\nhttps://youtu.be/FsAk0R4Ow7E\r\n\r\n## Комментарии\r\nПочти готово\r\n","created_at":"2018-07-08T20:14:01Z","updated_at":"2018-07-08T20:43:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"47ac2e609d94f7d05ee97a21989a12692930f5e4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/96/commits","review_comments_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/96/comments","review_comment_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/issues/96/comments","statuses_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/statuses/c8454c50e307c81beacdb6b5ec36a6f5422d7dad","head":{"label":"Ctalk3r:master","ref":"master","sha":"c8454c50e307c81beacdb6b5ec36a6f5422d7dad","user":{"login":"Ctalk3r","id":40827175,"node_id":"MDQ6VXNlcjQwODI3MTc1","avatar_url":"https://avatars0.githubusercontent.com/u/40827175?v=4","gravatar_id":"","url":"https://api.github.com/users/Ctalk3r","html_url":"https://github.com/Ctalk3r","followers_url":"https://api.github.com/users/Ctalk3r/followers","following_url":"https://api.github.com/users/Ctalk3r/following{/other_user}","gists_url":"https://api.github.com/users/Ctalk3r/gists{/gist_id}","starred_url":"https://api.github.com/users/Ctalk3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ctalk3r/subscriptions","organizations_url":"https://api.github.com/users/Ctalk3r/orgs","repos_url":"https://api.github.com/users/Ctalk3r/repos","events_url":"https://api.github.com/users/Ctalk3r/events{/privacy}","received_events_url":"https://api.github.com/users/Ctalk3r/received_events","type":"User","site_admin":false},"repo":{"id":139972492,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk5NzI0OTI=","name":"summer-2018","full_name":"Ctalk3r/summer-2018","owner":{"login":"Ctalk3r","id":40827175,"node_id":"MDQ6VXNlcjQwODI3MTc1","avatar_url":"https://avatars0.githubusercontent.com/u/40827175?v=4","gravatar_id":"","url":"https://api.github.com/users/Ctalk3r","html_url":"https://github.com/Ctalk3r","followers_url":"https://api.github.com/users/Ctalk3r/followers","following_url":"https://api.github.com/users/Ctalk3r/following{/other_user}","gists_url":"https://api.github.com/users/Ctalk3r/gists{/gist_id}","starred_url":"https://api.github.com/users/Ctalk3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ctalk3r/subscriptions","organizations_url":"https://api.github.com/users/Ctalk3r/orgs","repos_url":"https://api.github.com/users/Ctalk3r/repos","events_url":"https://api.github.com/users/Ctalk3r/events{/privacy}","received_events_url":"https://api.github.com/users/Ctalk3r/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Ctalk3r/summer-2018","description":null,"fork":true,"url":"https://api.github.com/repos/Ctalk3r/summer-2018","forks_url":"https://api.github.com/repos/Ctalk3r/summer-2018/forks","keys_url":"https://api.github.com/repos/Ctalk3r/summer-2018/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ctalk3r/summer-2018/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ctalk3r/summer-2018/teams","hooks_url":"https://api.github.com/repos/Ctalk3r/summer-2018/hooks","issue_events_url":"https://api.github.com/repos/Ctalk3r/summer-2018/issues/events{/number}","events_url":"https://api.github.com/repos/Ctalk3r/summer-2018/events","assignees_url":"https://api.github.com/repos/Ctalk3r/summer-2018/assignees{/user}","branches_url":"https://api.github.com/repos/Ctalk3r/summer-2018/branches{/branch}","tags_url":"https://api.github.com/repos/Ctalk3r/summer-2018/tags","blobs_url":"https://api.github.com/repos/Ctalk3r/summer-2018/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ctalk3r/summer-2018/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ctalk3r/summer-2018/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ctalk3r/summer-2018/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ctalk3r/summer-2018/statuses/{sha}","languages_url":"https://api.github.com/repos/Ctalk3r/summer-2018/languages","stargazers_url":"https://api.github.com/repos/Ctalk3r/summer-2018/stargazers","contributors_url":"https://api.github.com/repos/Ctalk3r/summer-2018/contributors","subscribers_url":"https://api.github.com/repos/Ctalk3r/summer-2018/subscribers","subscription_url":"https://api.github.com/repos/Ctalk3r/summer-2018/subscription","commits_url":"https://api.github.com/repos/Ctalk3r/summer-2018/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ctalk3r/summer-2018/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ctalk3r/summer-2018/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ctalk3r/summer-2018/issues/comments{/number}","contents_url":"https://api.github.com/repos/Ctalk3r/summer-2018/contents/{+path}","compare_url":"https://api.github.com/repos/Ctalk3r/summer-2018/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ctalk3r/summer-2018/merges","archive_url":"https://api.github.com/repos/Ctalk3r/summer-2018/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ctalk3r/summer-2018/downloads","issues_url":"https://api.github.com/repos/Ctalk3r/summer-2018/issues{/number}","pulls_url":"https://api.github.com/repos/Ctalk3r/summer-2018/pulls{/number}","milestones_url":"https://api.github.com/repos/Ctalk3r/summer-2018/milestones{/number}","notifications_url":"https://api.github.com/repos/Ctalk3r/summer-2018/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ctalk3r/summer-2018/labels{/name}","releases_url":"https://api.github.com/repos/Ctalk3r/summer-2018/releases{/id}","deployments_url":"https://api.github.com/repos/Ctalk3r/summer-2018/deployments","created_at":"2018-07-06T10:48:49Z","updated_at":"2018-07-08T20:42:55Z","pushed_at":"2018-07-08T20:42:53Z","git_url":"git://github.com/Ctalk3r/summer-2018.git","ssh_url":"git@github.com:Ctalk3r/summer-2018.git","clone_url":"https://github.com/Ctalk3r/summer-2018.git","svn_url":"https://github.com/Ctalk3r/summer-2018","homepage":null,"size":14219,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rubizza-survival-camp:master","ref":"master","sha":"c99fdfda9ff36e7b140393ab9a51b021dec0c9d8","user":{"login":"rubizza-survival-camp","id":40864986,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwODY0OTg2","avatar_url":"https://avatars1.githubusercontent.com/u/40864986?v=4","gravatar_id":"","url":"https://api.github.com/users/rubizza-survival-camp","html_url":"https://github.com/rubizza-survival-camp","followers_url":"https://api.github.com/users/rubizza-survival-camp/followers","following_url":"https://api.github.com/users/rubizza-survival-camp/following{/other_user}","gists_url":"https://api.github.com/users/rubizza-survival-camp/gists{/gist_id}","starred_url":"https://api.github.com/users/rubizza-survival-camp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubizza-survival-camp/subscriptions","organizations_url":"https://api.github.com/users/rubizza-survival-camp/orgs","repos_url":"https://api.github.com/users/rubizza-survival-camp/repos","events_url":"https://api.github.com/users/rubizza-survival-camp/events{/privacy}","received_events_url":"https://api.github.com/users/rubizza-survival-camp/received_events","type":"Organization","site_admin":false},"repo":{"id":139868408,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk4Njg0MDg=","name":"summer-2018","full_name":"rubizza-survival-camp/summer-2018","owner":{"login":"rubizza-survival-camp","id":40864986,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwODY0OTg2","avatar_url":"https://avatars1.githubusercontent.com/u/40864986?v=4","gravatar_id":"","url":"https://api.github.com/users/rubizza-survival-camp","html_url":"https://github.com/rubizza-survival-camp","followers_url":"https://api.github.com/users/rubizza-survival-camp/followers","following_url":"https://api.github.com/users/rubizza-survival-camp/following{/other_user}","gists_url":"https://api.github.com/users/rubizza-survival-camp/gists{/gist_id}","starred_url":"https://api.github.com/users/rubizza-survival-camp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubizza-survival-camp/subscriptions","organizations_url":"https://api.github.com/users/rubizza-survival-camp/orgs","repos_url":"https://api.github.com/users/rubizza-survival-camp/repos","events_url":"https://api.github.com/users/rubizza-survival-camp/events{/privacy}","received_events_url":"https://api.github.com/users/rubizza-survival-camp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rubizza-survival-camp/summer-2018","description":null,"fork":false,"url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018","forks_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/forks","keys_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/teams","hooks_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/hooks","issue_events_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/issues/events{/number}","events_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/events","assignees_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/assignees{/user}","branches_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/branches{/branch}","tags_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/tags","blobs_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/git/refs{/sha}","trees_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/statuses/{sha}","languages_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/languages","stargazers_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/stargazers","contributors_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/contributors","subscribers_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/subscribers","subscription_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/subscription","commits_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/commits{/sha}","git_commits_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/git/commits{/sha}","comments_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/comments{/number}","issue_comment_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/issues/comments{/number}","contents_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/contents/{+path}","compare_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/merges","archive_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/downloads","issues_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/issues{/number}","pulls_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls{/number}","milestones_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/milestones{/number}","notifications_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/labels{/name}","releases_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/releases{/id}","deployments_url":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/deployments","created_at":"2018-07-05T15:28:12Z","updated_at":"2018-07-07T20:17:21Z","pushed_at":"2018-07-08T20:42:54Z","git_url":"git://github.com/rubizza-survival-camp/summer-2018.git","ssh_url":"git@github.com:rubizza-survival-camp/summer-2018.git","clone_url":"https://github.com/rubizza-survival-camp/summer-2018.git","svn_url":"https://github.com/rubizza-survival-camp/summer-2018","homepage":null,"size":86207,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"archived":false,"open_issues_count":12,"license":null,"forks":54,"open_issues":12,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/96"},"html":{"href":"https://github.com/rubizza-survival-camp/summer-2018/pull/96"},"issue":{"href":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/issues/96"},"comments":{"href":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/issues/96/comments"},"review_comments":{"href":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/96/comments"},"review_comment":{"href":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/pulls/96/commits"},"statuses":{"href":"https://api.github.com/repos/rubizza-survival-camp/summer-2018/statuses/c8454c50e307c81beacdb6b5ec36a6f5422d7dad"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"houndci-bot"}}