GitHub PullRequestReviewCommentEvent at 2014-09-28 22:40:36
Repository: grape
Actor: towanda
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/intridea/grape/pulls/comments/18133274","id":18133274,"diff_hunk":"@@ -120,51 +120,48 @@ def mount_in(route_set)\n       end\n     end\n \n-    def prepare_routes\n-      routes = []\n-      options[:method].each do |method|\n-        # pp \"Method #{method} #{object_id}\"\n-\n-        options[:path].each do |path|\n-          prepared_path = prepare_path(path)\n-\n-          anchor = options[:route_options][:anchor]\n-          anchor = anchor.nil? ? true : anchor\n+    def prepare_routes_requirements\n+      endpoint_requirements = options[:route_options][:requirements] || {}\n+      all_requirements = (namespace_stackable(:namespace).map(&:requirements) << endpoint_requirements)\n+      requirements = all_requirements.reduce({}) do |base_requirements, single_requirements|\n+        base_requirements.merge!(single_requirements)\n+      end\n+    end\n \n-          endpoint_requirements = options[:route_options][:requirements] || {}\n-          all_requirements = (namespace_stackable(:namespace).map(&:requirements) << endpoint_requirements)\n-          requirements = all_requirements.reduce({}) do |base_requirements, single_requirements|\n-            base_requirements.merge!(single_requirements)\n-          end\n+    def prepare_routes_path_params(path)\n+      regex = Rack::Mount::RegexpWithNamedGroups.new(path)\n+      path_params = {}\n+      # named parameters in the api path\n+      named_params = regex.named_captures.map { |nc| nc[0] } - %w(version format)\n+      named_params.each { |named_param| path_params[named_param] = \"\" }\n+      # route parameters declared via desc or appended to the api declaration\n+      route_params = (options[:route_options][:params] || {})\n+      path_params.merge!(route_params)\n+    end\n \n-          path = compile_path(prepared_path, anchor && !options[:app], requirements)\n-          regex = Rack::Mount::RegexpWithNamedGroups.new(path)\n-          path_params = {}\n-          # named parameters in the api path\n-          named_params = regex.named_captures.map { |nc| nc[0] } - %w(version format)\n-          named_params.each { |named_param| path_params[named_param] = \"\" }\n-          # route parameters declared via desc or appended to the api declaration\n-          route_params = (options[:route_options][:params] || {})\n-          path_params.merge!(route_params)\n+    def prepare_routes\n+      options[:method].map do |method|\n+        options[:path].map do |path|\n+          prepared_path = prepare_path(path)\n+          anchor = options[:route_options].fetch(:anchor) { |_| true }","path":"lib/grape/endpoint.rb","position":51,"original_position":51,"commit_id":"95157dbff3aff63f44528bf07c5289b1f739688b","original_commit_id":"95157dbff3aff63f44528bf07c5289b1f739688b","user":{"login":"towanda","id":17824,"avatar_url":"https://avatars.githubusercontent.com/u/17824?v=2","gravatar_id":"","url":"https://api.github.com/users/towanda","html_url":"https://github.com/towanda","followers_url":"https://api.github.com/users/towanda/followers","following_url":"https://api.github.com/users/towanda/following{/other_user}","gists_url":"https://api.github.com/users/towanda/gists{/gist_id}","starred_url":"https://api.github.com/users/towanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/towanda/subscriptions","organizations_url":"https://api.github.com/users/towanda/orgs","repos_url":"https://api.github.com/users/towanda/repos","events_url":"https://api.github.com/users/towanda/events{/privacy}","received_events_url":"https://api.github.com/users/towanda/received_events","type":"User","site_admin":false},"body":"You are right, I´ll fix it.","created_at":"2014-09-28T22:40:36Z","updated_at":"2014-09-28T22:40:36Z","html_url":"https://github.com/intridea/grape/pull/770#discussion_r18133274","pull_request_url":"https://api.github.com/repos/intridea/grape/pulls/770","_links":{"self":{"href":"https://api.github.com/repos/intridea/grape/pulls/comments/18133274"},"html":{"href":"https://github.com/intridea/grape/pull/770#discussion_r18133274"},"pull_request":{"href":"https://api.github.com/repos/intridea/grape/pulls/770"}}},"pull_request":{"url":"https://api.github.com/repos/intridea/grape/pulls/770","id":21903928,"html_url":"https://github.com/intridea/grape/pull/770","diff_url":"https://github.com/intridea/grape/pull/770.diff","patch_url":"https://github.com/intridea/grape/pull/770.patch","issue_url":"https://api.github.com/repos/intridea/grape/issues/770","number":770,"state":"open","locked":false,"title":"Refactor prepare routes method","user":{"login":"towanda","id":17824,"avatar_url":"https://avatars.githubusercontent.com/u/17824?v=2","gravatar_id":"","url":"https://api.github.com/users/towanda","html_url":"https://github.com/towanda","followers_url":"https://api.github.com/users/towanda/followers","following_url":"https://api.github.com/users/towanda/following{/other_user}","gists_url":"https://api.github.com/users/towanda/gists{/gist_id}","starred_url":"https://api.github.com/users/towanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/towanda/subscriptions","organizations_url":"https://api.github.com/users/towanda/orgs","repos_url":"https://api.github.com/users/towanda/repos","events_url":"https://api.github.com/users/towanda/events{/privacy}","received_events_url":"https://api.github.com/users/towanda/received_events","type":"User","site_admin":false},"body":"This PR refactors the prepare_routes method in Endpoint, extracting two methods to make it more readable.","created_at":"2014-09-28T17:12:10Z","updated_at":"2014-09-28T22:40:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83971bcfc3d36ea1479d5f79c0a787c7adc2a7c9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/intridea/grape/pulls/770/commits","review_comments_url":"https://api.github.com/repos/intridea/grape/pulls/770/comments","review_comment_url":"https://api.github.com/repos/intridea/grape/pulls/comments/{number}","comments_url":"https://api.github.com/repos/intridea/grape/issues/770/comments","statuses_url":"https://api.github.com/repos/intridea/grape/statuses/95157dbff3aff63f44528bf07c5289b1f739688b","head":{"label":"towanda:refactor-prepare-routes","ref":"refactor-prepare-routes","sha":"95157dbff3aff63f44528bf07c5289b1f739688b","user":{"login":"towanda","id":17824,"avatar_url":"https://avatars.githubusercontent.com/u/17824?v=2","gravatar_id":"","url":"https://api.github.com/users/towanda","html_url":"https://github.com/towanda","followers_url":"https://api.github.com/users/towanda/followers","following_url":"https://api.github.com/users/towanda/following{/other_user}","gists_url":"https://api.github.com/users/towanda/gists{/gist_id}","starred_url":"https://api.github.com/users/towanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/towanda/subscriptions","organizations_url":"https://api.github.com/users/towanda/orgs","repos_url":"https://api.github.com/users/towanda/repos","events_url":"https://api.github.com/users/towanda/events{/privacy}","received_events_url":"https://api.github.com/users/towanda/received_events","type":"User","site_admin":false},"repo":{"id":24287959,"name":"grape","full_name":"towanda/grape","owner":{"login":"towanda","id":17824,"avatar_url":"https://avatars.githubusercontent.com/u/17824?v=2","gravatar_id":"","url":"https://api.github.com/users/towanda","html_url":"https://github.com/towanda","followers_url":"https://api.github.com/users/towanda/followers","following_url":"https://api.github.com/users/towanda/following{/other_user}","gists_url":"https://api.github.com/users/towanda/gists{/gist_id}","starred_url":"https://api.github.com/users/towanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/towanda/subscriptions","organizations_url":"https://api.github.com/users/towanda/orgs","repos_url":"https://api.github.com/users/towanda/repos","events_url":"https://api.github.com/users/towanda/events{/privacy}","received_events_url":"https://api.github.com/users/towanda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/towanda/grape","description":"An opinionated micro-framework for creating REST-like APIs in Ruby.","fork":true,"url":"https://api.github.com/repos/towanda/grape","forks_url":"https://api.github.com/repos/towanda/grape/forks","keys_url":"https://api.github.com/repos/towanda/grape/keys{/key_id}","collaborators_url":"https://api.github.com/repos/towanda/grape/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/towanda/grape/teams","hooks_url":"https://api.github.com/repos/towanda/grape/hooks","issue_events_url":"https://api.github.com/repos/towanda/grape/issues/events{/number}","events_url":"https://api.github.com/repos/towanda/grape/events","assignees_url":"https://api.github.com/repos/towanda/grape/assignees{/user}","branches_url":"https://api.github.com/repos/towanda/grape/branches{/branch}","tags_url":"https://api.github.com/repos/towanda/grape/tags","blobs_url":"https://api.github.com/repos/towanda/grape/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/towanda/grape/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/towanda/grape/git/refs{/sha}","trees_url":"https://api.github.com/repos/towanda/grape/git/trees{/sha}","statuses_url":"https://api.github.com/repos/towanda/grape/statuses/{sha}","languages_url":"https://api.github.com/repos/towanda/grape/languages","stargazers_url":"https://api.github.com/repos/towanda/grape/stargazers","contributors_url":"https://api.github.com/repos/towanda/grape/contributors","subscribers_url":"https://api.github.com/repos/towanda/grape/subscribers","subscription_url":"https://api.github.com/repos/towanda/grape/subscription","commits_url":"https://api.github.com/repos/towanda/grape/commits{/sha}","git_commits_url":"https://api.github.com/repos/towanda/grape/git/commits{/sha}","comments_url":"https://api.github.com/repos/towanda/grape/comments{/number}","issue_comment_url":"https://api.github.com/repos/towanda/grape/issues/comments/{number}","contents_url":"https://api.github.com/repos/towanda/grape/contents/{+path}","compare_url":"https://api.github.com/repos/towanda/grape/compare/{base}...{head}","merges_url":"https://api.github.com/repos/towanda/grape/merges","archive_url":"https://api.github.com/repos/towanda/grape/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/towanda/grape/downloads","issues_url":"https://api.github.com/repos/towanda/grape/issues{/number}","pulls_url":"https://api.github.com/repos/towanda/grape/pulls{/number}","milestones_url":"https://api.github.com/repos/towanda/grape/milestones{/number}","notifications_url":"https://api.github.com/repos/towanda/grape/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/towanda/grape/labels{/name}","releases_url":"https://api.github.com/repos/towanda/grape/releases{/id}","created_at":"2014-09-21T10:12:46Z","updated_at":"2014-09-21T00:01:52Z","pushed_at":"2014-09-28T17:08:13Z","git_url":"git://github.com/towanda/grape.git","ssh_url":"git@github.com:towanda/grape.git","clone_url":"https://github.com/towanda/grape.git","svn_url":"https://github.com/towanda/grape","homepage":"http://intridea.github.io/grape","size":5296,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"intridea:master","ref":"master","sha":"899c3096c935b9a74d63297dcf2ca7eefb263eba","user":{"login":"intridea","id":3747,"avatar_url":"https://avatars.githubusercontent.com/u/3747?v=2","gravatar_id":"","url":"https://api.github.com/users/intridea","html_url":"https://github.com/intridea","followers_url":"https://api.github.com/users/intridea/followers","following_url":"https://api.github.com/users/intridea/following{/other_user}","gists_url":"https://api.github.com/users/intridea/gists{/gist_id}","starred_url":"https://api.github.com/users/intridea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intridea/subscriptions","organizations_url":"https://api.github.com/users/intridea/orgs","repos_url":"https://api.github.com/users/intridea/repos","events_url":"https://api.github.com/users/intridea/events{/privacy}","received_events_url":"https://api.github.com/users/intridea/received_events","type":"Organization","site_admin":false},"repo":{"id":812393,"name":"grape","full_name":"intridea/grape","owner":{"login":"intridea","id":3747,"avatar_url":"https://avatars.githubusercontent.com/u/3747?v=2","gravatar_id":"","url":"https://api.github.com/users/intridea","html_url":"https://github.com/intridea","followers_url":"https://api.github.com/users/intridea/followers","following_url":"https://api.github.com/users/intridea/following{/other_user}","gists_url":"https://api.github.com/users/intridea/gists{/gist_id}","starred_url":"https://api.github.com/users/intridea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intridea/subscriptions","organizations_url":"https://api.github.com/users/intridea/orgs","repos_url":"https://api.github.com/users/intridea/repos","events_url":"https://api.github.com/users/intridea/events{/privacy}","received_events_url":"https://api.github.com/users/intridea/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/intridea/grape","description":"An opinionated micro-framework for creating REST-like APIs in Ruby.","fork":false,"url":"https://api.github.com/repos/intridea/grape","forks_url":"https://api.github.com/repos/intridea/grape/forks","keys_url":"https://api.github.com/repos/intridea/grape/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intridea/grape/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intridea/grape/teams","hooks_url":"https://api.github.com/repos/intridea/grape/hooks","issue_events_url":"https://api.github.com/repos/intridea/grape/issues/events{/number}","events_url":"https://api.github.com/repos/intridea/grape/events","assignees_url":"https://api.github.com/repos/intridea/grape/assignees{/user}","branches_url":"https://api.github.com/repos/intridea/grape/branches{/branch}","tags_url":"https://api.github.com/repos/intridea/grape/tags","blobs_url":"https://api.github.com/repos/intridea/grape/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intridea/grape/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intridea/grape/git/refs{/sha}","trees_url":"https://api.github.com/repos/intridea/grape/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intridea/grape/statuses/{sha}","languages_url":"https://api.github.com/repos/intridea/grape/languages","stargazers_url":"https://api.github.com/repos/intridea/grape/stargazers","contributors_url":"https://api.github.com/repos/intridea/grape/contributors","subscribers_url":"https://api.github.com/repos/intridea/grape/subscribers","subscription_url":"https://api.github.com/repos/intridea/grape/subscription","commits_url":"https://api.github.com/repos/intridea/grape/commits{/sha}","git_commits_url":"https://api.github.com/repos/intridea/grape/git/commits{/sha}","comments_url":"https://api.github.com/repos/intridea/grape/comments{/number}","issue_comment_url":"https://api.github.com/repos/intridea/grape/issues/comments/{number}","contents_url":"https://api.github.com/repos/intridea/grape/contents/{+path}","compare_url":"https://api.github.com/repos/intridea/grape/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intridea/grape/merges","archive_url":"https://api.github.com/repos/intridea/grape/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intridea/grape/downloads","issues_url":"https://api.github.com/repos/intridea/grape/issues{/number}","pulls_url":"https://api.github.com/repos/intridea/grape/pulls{/number}","milestones_url":"https://api.github.com/repos/intridea/grape/milestones{/number}","notifications_url":"https://api.github.com/repos/intridea/grape/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intridea/grape/labels{/name}","releases_url":"https://api.github.com/repos/intridea/grape/releases{/id}","created_at":"2010-08-02T14:25:08Z","updated_at":"2014-09-28T20:28:37Z","pushed_at":"2014-09-27T12:47:19Z","git_url":"git://github.com/intridea/grape.git","ssh_url":"git@github.com:intridea/grape.git","clone_url":"https://github.com/intridea/grape.git","svn_url":"https://github.com/intridea/grape","homepage":"http://intridea.github.io/grape","size":12586,"stargazers_count":4958,"watchers_count":4958,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":537,"mirror_url":null,"open_issues_count":90,"forks":537,"open_issues":90,"watchers":4958,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/intridea/grape/pulls/770"},"html":{"href":"https://github.com/intridea/grape/pull/770"},"issue":{"href":"https://api.github.com/repos/intridea/grape/issues/770"},"comments":{"href":"https://api.github.com/repos/intridea/grape/issues/770/comments"},"review_comments":{"href":"https://api.github.com/repos/intridea/grape/pulls/770/comments"},"review_comment":{"href":"https://api.github.com/repos/intridea/grape/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/intridea/grape/pulls/770/commits"},"statuses":{"href":"https://api.github.com/repos/intridea/grape/statuses/95157dbff3aff63f44528bf07c5289b1f739688b"}}}}