{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/comments/36759985","id":36759985,"diff_hunk":"@@ -0,0 +1,36 @@\n+require \"gds_api/publishing_api\"\n+\n+module GdsApi\n+  class PublishingApi < GdsApi::Base\n+    class SpecialRoutePublisher\n+      def initialize(options = {})\n+        @logger = options[:logger] || GdsApi::Base.logger\n+        @publishing_api = options[:publishing_api] || GdsApi::PublishingApi.new(Plek.find(\"publishing-api\"))\n+      end\n+\n+      def publish(options)\n+        logger.info(\"Publishing #{options.fetch(:type)} route #{options.fetch(:base_path)}, routing to #{options.fetch(:rendering_app)}\")\n+\n+        publishing_api.put_content_item(options.fetch(:base_path), {\n+          content_id: options.fetch(:content_id),\n+          format: \"special_route\",\n+          title: options.fetch(:title),\n+          description: options[:description] || \"\",\n+          routes: [\n+            {\n+              path: options.fetch(:base_path),\n+              type: options.fetch(:type),\n+            }\n+          ],\n+          publishing_app: options.fetch(:publishing_app),\n+          rendering_app: options.fetch(:rendering_app),\n+          update_type: \"major\",\n+          public_updated_at: (Time.respond_to?(:zone) ? Time.zone.try(:now) : Time.now).iso8601,","path":"lib/gds_api/publishing_api/special_route_publisher.rb","position":28,"original_position":28,"commit_id":"f966ca1e1c299fc7254d82938ba28804aed0dcdf","original_commit_id":"f966ca1e1c299fc7254d82938ba28804aed0dcdf","user":{"login":"alext","id":5560,"avatar_url":"https://avatars.githubusercontent.com/u/5560?v=3","gravatar_id":"","url":"https://api.github.com/users/alext","html_url":"https://github.com/alext","followers_url":"https://api.github.com/users/alext/followers","following_url":"https://api.github.com/users/alext/following{/other_user}","gists_url":"https://api.github.com/users/alext/gists{/gist_id}","starred_url":"https://api.github.com/users/alext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alext/subscriptions","organizations_url":"https://api.github.com/users/alext/orgs","repos_url":"https://api.github.com/users/alext/repos","events_url":"https://api.github.com/users/alext/events{/privacy}","received_events_url":"https://api.github.com/users/alext/received_events","type":"User","site_admin":false},"body":"Why the `Time.zone.try(:now)` here.  That could in theory return nil, which would be invalid.","created_at":"2015-08-11T15:39:12Z","updated_at":"2015-08-11T15:39:12Z","html_url":"https://github.com/alphagov/gds-api-adapters/pull/340#discussion_r36759985","pull_request_url":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/340","_links":{"self":{"href":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/comments/36759985"},"html":{"href":"https://github.com/alphagov/gds-api-adapters/pull/340#discussion_r36759985"},"pull_request":{"href":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/340"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/340","id":42131397,"html_url":"https://github.com/alphagov/gds-api-adapters/pull/340","diff_url":"https://github.com/alphagov/gds-api-adapters/pull/340.diff","patch_url":"https://github.com/alphagov/gds-api-adapters/pull/340.patch","issue_url":"https://api.github.com/repos/alphagov/gds-api-adapters/issues/340","number":340,"state":"closed","locked":false,"title":"Add special route publisher under PublishingApi.","user":{"login":"elliotcm","id":109225,"avatar_url":"https://avatars.githubusercontent.com/u/109225?v=3","gravatar_id":"","url":"https://api.github.com/users/elliotcm","html_url":"https://github.com/elliotcm","followers_url":"https://api.github.com/users/elliotcm/followers","following_url":"https://api.github.com/users/elliotcm/following{/other_user}","gists_url":"https://api.github.com/users/elliotcm/gists{/gist_id}","starred_url":"https://api.github.com/users/elliotcm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elliotcm/subscriptions","organizations_url":"https://api.github.com/users/elliotcm/orgs","repos_url":"https://api.github.com/users/elliotcm/repos","events_url":"https://api.github.com/users/elliotcm/events{/privacy}","received_events_url":"https://api.github.com/users/elliotcm/received_events","type":"User","site_admin":false},"body":"This will be used in several apps for registering\r\n\"special\" routes like `/government` or `/robots.txt`\r\n\r\nSee https://trello.com/c/blLdEZN5/292-make-apps-register-special-routes-on-deploy","created_at":"2015-08-11T13:56:46Z","updated_at":"2015-08-11T15:39:12Z","closed_at":"2015-08-11T14:21:12Z","merged_at":"2015-08-11T14:21:12Z","merge_commit_sha":"83daa4c6f301eb07d7d7822a8f6611e5f736a751","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/340/commits","review_comments_url":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/340/comments","review_comment_url":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/gds-api-adapters/issues/340/comments","statuses_url":"https://api.github.com/repos/alphagov/gds-api-adapters/statuses/f966ca1e1c299fc7254d82938ba28804aed0dcdf","head":{"label":"alphagov:add-special-route-helper","ref":"add-special-route-helper","sha":"f966ca1e1c299fc7254d82938ba28804aed0dcdf","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":2898846,"name":"gds-api-adapters","full_name":"alphagov/gds-api-adapters","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/gds-api-adapters","description":"A set of API adapters to work with the GDS APIs","fork":false,"url":"https://api.github.com/repos/alphagov/gds-api-adapters","forks_url":"https://api.github.com/repos/alphagov/gds-api-adapters/forks","keys_url":"https://api.github.com/repos/alphagov/gds-api-adapters/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/gds-api-adapters/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/gds-api-adapters/teams","hooks_url":"https://api.github.com/repos/alphagov/gds-api-adapters/hooks","issue_events_url":"https://api.github.com/repos/alphagov/gds-api-adapters/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/gds-api-adapters/events","assignees_url":"https://api.github.com/repos/alphagov/gds-api-adapters/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/gds-api-adapters/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/gds-api-adapters/tags","blobs_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/gds-api-adapters/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/gds-api-adapters/languages","stargazers_url":"https://api.github.com/repos/alphagov/gds-api-adapters/stargazers","contributors_url":"https://api.github.com/repos/alphagov/gds-api-adapters/contributors","subscribers_url":"https://api.github.com/repos/alphagov/gds-api-adapters/subscribers","subscription_url":"https://api.github.com/repos/alphagov/gds-api-adapters/subscription","commits_url":"https://api.github.com/repos/alphagov/gds-api-adapters/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/gds-api-adapters/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/gds-api-adapters/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/gds-api-adapters/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/gds-api-adapters/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/gds-api-adapters/merges","archive_url":"https://api.github.com/repos/alphagov/gds-api-adapters/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/gds-api-adapters/downloads","issues_url":"https://api.github.com/repos/alphagov/gds-api-adapters/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/gds-api-adapters/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/gds-api-adapters/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/gds-api-adapters/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/gds-api-adapters/releases{/id}","created_at":"2011-12-02T14:13:57Z","updated_at":"2015-04-24T08:53:39Z","pushed_at":"2015-08-11T14:35:22Z","git_url":"git://github.com/alphagov/gds-api-adapters.git","ssh_url":"git@github.com:alphagov/gds-api-adapters.git","clone_url":"https://github.com/alphagov/gds-api-adapters.git","svn_url":"https://github.com/alphagov/gds-api-adapters","homepage":"","size":4570,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":5,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"ed44fbb777071337fc77d39c4f2e79ac1d6f04ed","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":2898846,"name":"gds-api-adapters","full_name":"alphagov/gds-api-adapters","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/gds-api-adapters","description":"A set of API adapters to work with the GDS APIs","fork":false,"url":"https://api.github.com/repos/alphagov/gds-api-adapters","forks_url":"https://api.github.com/repos/alphagov/gds-api-adapters/forks","keys_url":"https://api.github.com/repos/alphagov/gds-api-adapters/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/gds-api-adapters/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/gds-api-adapters/teams","hooks_url":"https://api.github.com/repos/alphagov/gds-api-adapters/hooks","issue_events_url":"https://api.github.com/repos/alphagov/gds-api-adapters/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/gds-api-adapters/events","assignees_url":"https://api.github.com/repos/alphagov/gds-api-adapters/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/gds-api-adapters/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/gds-api-adapters/tags","blobs_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/gds-api-adapters/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/gds-api-adapters/languages","stargazers_url":"https://api.github.com/repos/alphagov/gds-api-adapters/stargazers","contributors_url":"https://api.github.com/repos/alphagov/gds-api-adapters/contributors","subscribers_url":"https://api.github.com/repos/alphagov/gds-api-adapters/subscribers","subscription_url":"https://api.github.com/repos/alphagov/gds-api-adapters/subscription","commits_url":"https://api.github.com/repos/alphagov/gds-api-adapters/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/gds-api-adapters/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/gds-api-adapters/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/gds-api-adapters/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/gds-api-adapters/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/gds-api-adapters/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/gds-api-adapters/merges","archive_url":"https://api.github.com/repos/alphagov/gds-api-adapters/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/gds-api-adapters/downloads","issues_url":"https://api.github.com/repos/alphagov/gds-api-adapters/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/gds-api-adapters/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/gds-api-adapters/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/gds-api-adapters/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/gds-api-adapters/releases{/id}","created_at":"2011-12-02T14:13:57Z","updated_at":"2015-04-24T08:53:39Z","pushed_at":"2015-08-11T14:35:22Z","git_url":"git://github.com/alphagov/gds-api-adapters.git","ssh_url":"git@github.com:alphagov/gds-api-adapters.git","clone_url":"https://github.com/alphagov/gds-api-adapters.git","svn_url":"https://github.com/alphagov/gds-api-adapters","homepage":"","size":4570,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/340"},"html":{"href":"https://github.com/alphagov/gds-api-adapters/pull/340"},"issue":{"href":"https://api.github.com/repos/alphagov/gds-api-adapters/issues/340"},"comments":{"href":"https://api.github.com/repos/alphagov/gds-api-adapters/issues/340/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/340/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/gds-api-adapters/pulls/340/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/gds-api-adapters/statuses/f966ca1e1c299fc7254d82938ba28804aed0dcdf"}}}}