{"action":"created","comment":{"url":"https://api.github.com/repos/lumoslabs/txgh/pulls/comments/54654914","id":54654914,"diff_hunk":"@@ -0,0 +1,101 @@\n+require 'json'\n+\n+module Txgh\n+  module Handlers\n+    module Github\n+      class RequestHandler\n+        class << self\n+\n+          include ResponseHelpers\n+\n+          def handle_request(request, logger)\n+            case request.env['HTTP_X_GITHUB_EVENT']\n+              when 'push'\n+                handle_push(request, logger)\n+              else\n+                handle_unexpected\n+            end\n+          end\n+\n+          private\n+\n+          def handle_push(request, logger)\n+            klass = Txgh::Handlers::Github::PushHandler\n+            new(request, logger).handle(klass)\n+          end\n+\n+          def handle_unexpected\n+            respond_with_error(400, 'Unexpected event type')\n+          end\n+\n+        end\n+\n+        include ResponseHelpers\n+\n+        attr_reader :request, :logger\n+\n+        def initialize(request, logger)\n+          @request = request\n+          @logger = logger\n+        end\n+\n+        def handle(klass)\n+          handle_safely do\n+            handler = klass.new(\n+              project: config.transifex_project,\n+              repo: config.github_repo,\n+              payload: payload,\n+              logger: logger\n+            )\n+\n+            handler.execute","path":"lib/txgh/handlers/github/request_handler.rb","position":51,"original_position":51,"commit_id":"cee0c5d2061a41aed05c52f6f207fd0daca093da","original_commit_id":"cee0c5d2061a41aed05c52f6f207fd0daca093da","user":{"login":"zvkemp","id":2286046,"avatar_url":"https://avatars.githubusercontent.com/u/2286046?v=3","gravatar_id":"","url":"https://api.github.com/users/zvkemp","html_url":"https://github.com/zvkemp","followers_url":"https://api.github.com/users/zvkemp/followers","following_url":"https://api.github.com/users/zvkemp/following{/other_user}","gists_url":"https://api.github.com/users/zvkemp/gists{/gist_id}","starred_url":"https://api.github.com/users/zvkemp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zvkemp/subscriptions","organizations_url":"https://api.github.com/users/zvkemp/orgs","repos_url":"https://api.github.com/users/zvkemp/repos","events_url":"https://api.github.com/users/zvkemp/events{/privacy}","received_events_url":"https://api.github.com/users/zvkemp/received_events","type":"User","site_admin":false},"body":"temp variable `handler` not doing much here","created_at":"2016-03-01T23:31:54Z","updated_at":"2016-03-01T23:31:54Z","html_url":"https://github.com/lumoslabs/txgh/pull/8#discussion_r54654914","pull_request_url":"https://api.github.com/repos/lumoslabs/txgh/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/lumoslabs/txgh/pulls/comments/54654914"},"html":{"href":"https://github.com/lumoslabs/txgh/pull/8#discussion_r54654914"},"pull_request":{"href":"https://api.github.com/repos/lumoslabs/txgh/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/lumoslabs/txgh/pulls/8","id":61173584,"html_url":"https://github.com/lumoslabs/txgh/pull/8","diff_url":"https://github.com/lumoslabs/txgh/pull/8.diff","patch_url":"https://github.com/lumoslabs/txgh/pull/8.patch","issue_url":"https://api.github.com/repos/lumoslabs/txgh/issues/8","number":8,"state":"open","locked":false,"title":"Refactor request handlers","user":{"login":"camertron","id":575280,"avatar_url":"https://avatars.githubusercontent.com/u/575280?v=3","gravatar_id":"","url":"https://api.github.com/users/camertron","html_url":"https://github.com/camertron","followers_url":"https://api.github.com/users/camertron/followers","following_url":"https://api.github.com/users/camertron/following{/other_user}","gists_url":"https://api.github.com/users/camertron/gists{/gist_id}","starred_url":"https://api.github.com/users/camertron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camertron/subscriptions","organizations_url":"https://api.github.com/users/camertron/orgs","repos_url":"https://api.github.com/users/camertron/repos","events_url":"https://api.github.com/users/camertron/events{/privacy}","received_events_url":"https://api.github.com/users/camertron/received_events","type":"User","site_admin":false},"body":"In preparation for automatically deleting resources when branches are deleted, this PR refactors the request handlers. Currently the only Github webhook txgh is capable of receiving is the \"push\" webhook, i.e. when someone commits and pushes changes. A single endpoint, `/hooks/github`, handles these requests. Now that we'd like to handle more than just the \"push\" event, it makes sense to move the push-only logic into it's own file. Please note the following changes:\r\n\r\n1. `lib/txgh/handlers/github_hook_handler.rb` has been moved to `lib/txgh/handlers/github/push_handler.rb` along with corresponding specs.\r\n2. `lib/txgh/handlers/transifex_hook_handler.rb` has been moved to `lib/txgh/handlers/transifex/hook_handler.rb` along with corresponding specs.\r\n3. Two new classes, `Txgh::Handlers::Github::RequestHandler` and `Txgh::Handlers::Transifex::RequestHandler`, act as mini routers and hand requests off to the appropriate sub-handler.\r\n\r\n@lumoslabs/platform","created_at":"2016-03-01T00:48:07Z","updated_at":"2016-03-01T23:31:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4dd8ab24966f7540f7cfec83bce019ce3a331c6f","assignee":{"login":"zvkemp","id":2286046,"avatar_url":"https://avatars.githubusercontent.com/u/2286046?v=3","gravatar_id":"","url":"https://api.github.com/users/zvkemp","html_url":"https://github.com/zvkemp","followers_url":"https://api.github.com/users/zvkemp/followers","following_url":"https://api.github.com/users/zvkemp/following{/other_user}","gists_url":"https://api.github.com/users/zvkemp/gists{/gist_id}","starred_url":"https://api.github.com/users/zvkemp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zvkemp/subscriptions","organizations_url":"https://api.github.com/users/zvkemp/orgs","repos_url":"https://api.github.com/users/zvkemp/repos","events_url":"https://api.github.com/users/zvkemp/events{/privacy}","received_events_url":"https://api.github.com/users/zvkemp/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/lumoslabs/txgh/pulls/8/commits","review_comments_url":"https://api.github.com/repos/lumoslabs/txgh/pulls/8/comments","review_comment_url":"https://api.github.com/repos/lumoslabs/txgh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lumoslabs/txgh/issues/8/comments","statuses_url":"https://api.github.com/repos/lumoslabs/txgh/statuses/cee0c5d2061a41aed05c52f6f207fd0daca093da","head":{"label":"lumoslabs:refactor_handlers","ref":"refactor_handlers","sha":"cee0c5d2061a41aed05c52f6f207fd0daca093da","user":{"login":"lumoslabs","id":723646,"avatar_url":"https://avatars.githubusercontent.com/u/723646?v=3","gravatar_id":"","url":"https://api.github.com/users/lumoslabs","html_url":"https://github.com/lumoslabs","followers_url":"https://api.github.com/users/lumoslabs/followers","following_url":"https://api.github.com/users/lumoslabs/following{/other_user}","gists_url":"https://api.github.com/users/lumoslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/lumoslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lumoslabs/subscriptions","organizations_url":"https://api.github.com/users/lumoslabs/orgs","repos_url":"https://api.github.com/users/lumoslabs/repos","events_url":"https://api.github.com/users/lumoslabs/events{/privacy}","received_events_url":"https://api.github.com/users/lumoslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":49293078,"name":"txgh","full_name":"lumoslabs/txgh","owner":{"login":"lumoslabs","id":723646,"avatar_url":"https://avatars.githubusercontent.com/u/723646?v=3","gravatar_id":"","url":"https://api.github.com/users/lumoslabs","html_url":"https://github.com/lumoslabs","followers_url":"https://api.github.com/users/lumoslabs/followers","following_url":"https://api.github.com/users/lumoslabs/following{/other_user}","gists_url":"https://api.github.com/users/lumoslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/lumoslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lumoslabs/subscriptions","organizations_url":"https://api.github.com/users/lumoslabs/orgs","repos_url":"https://api.github.com/users/lumoslabs/repos","events_url":"https://api.github.com/users/lumoslabs/events{/privacy}","received_events_url":"https://api.github.com/users/lumoslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lumoslabs/txgh","description":"A server that integrates Transifex with GitHub","fork":true,"url":"https://api.github.com/repos/lumoslabs/txgh","forks_url":"https://api.github.com/repos/lumoslabs/txgh/forks","keys_url":"https://api.github.com/repos/lumoslabs/txgh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lumoslabs/txgh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lumoslabs/txgh/teams","hooks_url":"https://api.github.com/repos/lumoslabs/txgh/hooks","issue_events_url":"https://api.github.com/repos/lumoslabs/txgh/issues/events{/number}","events_url":"https://api.github.com/repos/lumoslabs/txgh/events","assignees_url":"https://api.github.com/repos/lumoslabs/txgh/assignees{/user}","branches_url":"https://api.github.com/repos/lumoslabs/txgh/branches{/branch}","tags_url":"https://api.github.com/repos/lumoslabs/txgh/tags","blobs_url":"https://api.github.com/repos/lumoslabs/txgh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lumoslabs/txgh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lumoslabs/txgh/git/refs{/sha}","trees_url":"https://api.github.com/repos/lumoslabs/txgh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lumoslabs/txgh/statuses/{sha}","languages_url":"https://api.github.com/repos/lumoslabs/txgh/languages","stargazers_url":"https://api.github.com/repos/lumoslabs/txgh/stargazers","contributors_url":"https://api.github.com/repos/lumoslabs/txgh/contributors","subscribers_url":"https://api.github.com/repos/lumoslabs/txgh/subscribers","subscription_url":"https://api.github.com/repos/lumoslabs/txgh/subscription","commits_url":"https://api.github.com/repos/lumoslabs/txgh/commits{/sha}","git_commits_url":"https://api.github.com/repos/lumoslabs/txgh/git/commits{/sha}","comments_url":"https://api.github.com/repos/lumoslabs/txgh/comments{/number}","issue_comment_url":"https://api.github.com/repos/lumoslabs/txgh/issues/comments{/number}","contents_url":"https://api.github.com/repos/lumoslabs/txgh/contents/{+path}","compare_url":"https://api.github.com/repos/lumoslabs/txgh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lumoslabs/txgh/merges","archive_url":"https://api.github.com/repos/lumoslabs/txgh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lumoslabs/txgh/downloads","issues_url":"https://api.github.com/repos/lumoslabs/txgh/issues{/number}","pulls_url":"https://api.github.com/repos/lumoslabs/txgh/pulls{/number}","milestones_url":"https://api.github.com/repos/lumoslabs/txgh/milestones{/number}","notifications_url":"https://api.github.com/repos/lumoslabs/txgh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lumoslabs/txgh/labels{/name}","releases_url":"https://api.github.com/repos/lumoslabs/txgh/releases{/id}","deployments_url":"https://api.github.com/repos/lumoslabs/txgh/deployments","created_at":"2016-01-08T19:54:08Z","updated_at":"2016-01-12T21:33:15Z","pushed_at":"2016-03-01T22:37:31Z","git_url":"git://github.com/lumoslabs/txgh.git","ssh_url":"git@github.com:lumoslabs/txgh.git","clone_url":"https://github.com/lumoslabs/txgh.git","svn_url":"https://github.com/lumoslabs/txgh","homepage":null,"size":252,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"lumoslabs:master","ref":"master","sha":"fb26658e5e8f401b4e99c05d4fef225ef553cbba","user":{"login":"lumoslabs","id":723646,"avatar_url":"https://avatars.githubusercontent.com/u/723646?v=3","gravatar_id":"","url":"https://api.github.com/users/lumoslabs","html_url":"https://github.com/lumoslabs","followers_url":"https://api.github.com/users/lumoslabs/followers","following_url":"https://api.github.com/users/lumoslabs/following{/other_user}","gists_url":"https://api.github.com/users/lumoslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/lumoslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lumoslabs/subscriptions","organizations_url":"https://api.github.com/users/lumoslabs/orgs","repos_url":"https://api.github.com/users/lumoslabs/repos","events_url":"https://api.github.com/users/lumoslabs/events{/privacy}","received_events_url":"https://api.github.com/users/lumoslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":49293078,"name":"txgh","full_name":"lumoslabs/txgh","owner":{"login":"lumoslabs","id":723646,"avatar_url":"https://avatars.githubusercontent.com/u/723646?v=3","gravatar_id":"","url":"https://api.github.com/users/lumoslabs","html_url":"https://github.com/lumoslabs","followers_url":"https://api.github.com/users/lumoslabs/followers","following_url":"https://api.github.com/users/lumoslabs/following{/other_user}","gists_url":"https://api.github.com/users/lumoslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/lumoslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lumoslabs/subscriptions","organizations_url":"https://api.github.com/users/lumoslabs/orgs","repos_url":"https://api.github.com/users/lumoslabs/repos","events_url":"https://api.github.com/users/lumoslabs/events{/privacy}","received_events_url":"https://api.github.com/users/lumoslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lumoslabs/txgh","description":"A server that integrates Transifex with GitHub","fork":true,"url":"https://api.github.com/repos/lumoslabs/txgh","forks_url":"https://api.github.com/repos/lumoslabs/txgh/forks","keys_url":"https://api.github.com/repos/lumoslabs/txgh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lumoslabs/txgh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lumoslabs/txgh/teams","hooks_url":"https://api.github.com/repos/lumoslabs/txgh/hooks","issue_events_url":"https://api.github.com/repos/lumoslabs/txgh/issues/events{/number}","events_url":"https://api.github.com/repos/lumoslabs/txgh/events","assignees_url":"https://api.github.com/repos/lumoslabs/txgh/assignees{/user}","branches_url":"https://api.github.com/repos/lumoslabs/txgh/branches{/branch}","tags_url":"https://api.github.com/repos/lumoslabs/txgh/tags","blobs_url":"https://api.github.com/repos/lumoslabs/txgh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lumoslabs/txgh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lumoslabs/txgh/git/refs{/sha}","trees_url":"https://api.github.com/repos/lumoslabs/txgh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lumoslabs/txgh/statuses/{sha}","languages_url":"https://api.github.com/repos/lumoslabs/txgh/languages","stargazers_url":"https://api.github.com/repos/lumoslabs/txgh/stargazers","contributors_url":"https://api.github.com/repos/lumoslabs/txgh/contributors","subscribers_url":"https://api.github.com/repos/lumoslabs/txgh/subscribers","subscription_url":"https://api.github.com/repos/lumoslabs/txgh/subscription","commits_url":"https://api.github.com/repos/lumoslabs/txgh/commits{/sha}","git_commits_url":"https://api.github.com/repos/lumoslabs/txgh/git/commits{/sha}","comments_url":"https://api.github.com/repos/lumoslabs/txgh/comments{/number}","issue_comment_url":"https://api.github.com/repos/lumoslabs/txgh/issues/comments{/number}","contents_url":"https://api.github.com/repos/lumoslabs/txgh/contents/{+path}","compare_url":"https://api.github.com/repos/lumoslabs/txgh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lumoslabs/txgh/merges","archive_url":"https://api.github.com/repos/lumoslabs/txgh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lumoslabs/txgh/downloads","issues_url":"https://api.github.com/repos/lumoslabs/txgh/issues{/number}","pulls_url":"https://api.github.com/repos/lumoslabs/txgh/pulls{/number}","milestones_url":"https://api.github.com/repos/lumoslabs/txgh/milestones{/number}","notifications_url":"https://api.github.com/repos/lumoslabs/txgh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lumoslabs/txgh/labels{/name}","releases_url":"https://api.github.com/repos/lumoslabs/txgh/releases{/id}","deployments_url":"https://api.github.com/repos/lumoslabs/txgh/deployments","created_at":"2016-01-08T19:54:08Z","updated_at":"2016-01-12T21:33:15Z","pushed_at":"2016-03-01T22:37:31Z","git_url":"git://github.com/lumoslabs/txgh.git","ssh_url":"git@github.com:lumoslabs/txgh.git","clone_url":"https://github.com/lumoslabs/txgh.git","svn_url":"https://github.com/lumoslabs/txgh","homepage":null,"size":252,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lumoslabs/txgh/pulls/8"},"html":{"href":"https://github.com/lumoslabs/txgh/pull/8"},"issue":{"href":"https://api.github.com/repos/lumoslabs/txgh/issues/8"},"comments":{"href":"https://api.github.com/repos/lumoslabs/txgh/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/lumoslabs/txgh/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/lumoslabs/txgh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lumoslabs/txgh/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/lumoslabs/txgh/statuses/cee0c5d2061a41aed05c52f6f207fd0daca093da"}}}}