GitHub PullRequestReviewCommentEvent at 2014-11-25 19:43:29
Repository: spree
Actor: dkubb
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/comments/20889098","id":20889098,"diff_hunk":"@@ -1,71 +1,57 @@\n-require 'stringex'\n-\n module Spree\n   module Core\n-    module Permalinks\n-      extend ActiveSupport::Concern\n+    class Permalinks < Module\n \n-      included do\n-        class_attribute :permalink_options\n-      end\n+      RAND = Random.new\n+      BASE = 10\n \n-      module ClassMethods\n-        def make_permalink(options={})\n-          options[:field] ||= :permalink\n-          self.permalink_options = options\n+      def initialize(options = {})\n+        @options = options\n+      end\n \n-          before_validation(:on => :create) { save_permalink }\n+      def included(host)\n+        host.class_eval do\n+          define_singleton_method :find_by_param do |*args|\n+            find_by_number(*args)\n+          end\n+          define_singleton_method :find_by_param! do |*args|\n+            find_by_number!(*args)\n+          end\n         end\n \n-        def find_by_param(value, *args)\n-          self.send(\"find_by_#{permalink_field}\", value, *args)\n-        end\n+        generator = method(:generate_permalink)\n \n-        def find_by_param!(value, *args)\n-          self.send(\"find_by_#{permalink_field}!\", value, *args)\n+        host.before_validation do |instance|\n+          instance.number ||= generator.call(host)\n         end\n+      end\n \n-        def permalink_field\n-          permalink_options[:field]\n-        end\n+    private\n \n-        def permalink_prefix\n-          permalink_options[:prefix] || \"\"\n-        end\n+      def generate_permalink(host)\n+        length = length()","path":"core/lib/spree/core/permalinks.rb","position":55,"original_position":55,"commit_id":"37eae2715dabf4d076a83187b13639735a3e53f8","original_commit_id":"37eae2715dabf4d076a83187b13639735a3e53f8","user":{"login":"dkubb","id":133,"avatar_url":"https://avatars.githubusercontent.com/u/133?v=3","gravatar_id":"","url":"https://api.github.com/users/dkubb","html_url":"https://github.com/dkubb","followers_url":"https://api.github.com/users/dkubb/followers","following_url":"https://api.github.com/users/dkubb/following{/other_user}","gists_url":"https://api.github.com/users/dkubb/gists{/gist_id}","starred_url":"https://api.github.com/users/dkubb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkubb/subscriptions","organizations_url":"https://api.github.com/users/dkubb/orgs","repos_url":"https://api.github.com/users/dkubb/repos","events_url":"https://api.github.com/users/dkubb/events{/privacy}","received_events_url":"https://api.github.com/users/dkubb/received_events","type":"User","site_admin":false},"body":"If `length` is an attr_reader, as suggested earlier, then it's probably not necessary to assign it to a local variable.","created_at":"2014-11-25T19:43:29Z","updated_at":"2014-11-25T19:43:29Z","html_url":"https://github.com/MountainRoseHerbs/spree/pull/34#discussion_r20889098","pull_request_url":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/comments/20889098"},"html":{"href":"https://github.com/MountainRoseHerbs/spree/pull/34#discussion_r20889098"},"pull_request":{"href":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/34","id":24957762,"html_url":"https://github.com/MountainRoseHerbs/spree/pull/34","diff_url":"https://github.com/MountainRoseHerbs/spree/pull/34.diff","patch_url":"https://github.com/MountainRoseHerbs/spree/pull/34.patch","issue_url":"https://api.github.com/repos/MountainRoseHerbs/spree/issues/34","number":34,"state":"open","locked":false,"title":"Cleanup permalink generation","user":{"login":"mbj","id":117966,"avatar_url":"https://avatars.githubusercontent.com/u/117966?v=3","gravatar_id":"","url":"https://api.github.com/users/mbj","html_url":"https://github.com/mbj","followers_url":"https://api.github.com/users/mbj/followers","following_url":"https://api.github.com/users/mbj/following{/other_user}","gists_url":"https://api.github.com/users/mbj/gists{/gist_id}","starred_url":"https://api.github.com/users/mbj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbj/subscriptions","organizations_url":"https://api.github.com/users/mbj/orgs","repos_url":"https://api.github.com/users/mbj/repos","events_url":"https://api.github.com/users/mbj/events{/privacy}","received_events_url":"https://api.github.com/users/mbj/received_events","type":"User","site_admin":false},"body":"Fix permalink generation to not contain various smells. See verbose description in the last commit in this PR.","created_at":"2014-11-24T19:40:57Z","updated_at":"2014-11-25T19:43:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb413ca434465ef7e54e8f1ee56e3c899085afd4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/34/commits","review_comments_url":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/34/comments","review_comment_url":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/comments/{number}","comments_url":"https://api.github.com/repos/MountainRoseHerbs/spree/issues/34/comments","statuses_url":"https://api.github.com/repos/MountainRoseHerbs/spree/statuses/37eae2715dabf4d076a83187b13639735a3e53f8","head":{"label":"MountainRoseHerbs:2-3-stable-mrh-cleanup-permalink-generation","ref":"2-3-stable-mrh-cleanup-permalink-generation","sha":"37eae2715dabf4d076a83187b13639735a3e53f8","user":{"login":"MountainRoseHerbs","id":2074141,"avatar_url":"https://avatars.githubusercontent.com/u/2074141?v=3","gravatar_id":"","url":"https://api.github.com/users/MountainRoseHerbs","html_url":"https://github.com/MountainRoseHerbs","followers_url":"https://api.github.com/users/MountainRoseHerbs/followers","following_url":"https://api.github.com/users/MountainRoseHerbs/following{/other_user}","gists_url":"https://api.github.com/users/MountainRoseHerbs/gists{/gist_id}","starred_url":"https://api.github.com/users/MountainRoseHerbs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MountainRoseHerbs/subscriptions","organizations_url":"https://api.github.com/users/MountainRoseHerbs/orgs","repos_url":"https://api.github.com/users/MountainRoseHerbs/repos","events_url":"https://api.github.com/users/MountainRoseHerbs/events{/privacy}","received_events_url":"https://api.github.com/users/MountainRoseHerbs/received_events","type":"Organization","site_admin":false},"repo":{"id":12473049,"name":"spree","full_name":"MountainRoseHerbs/spree","owner":{"login":"MountainRoseHerbs","id":2074141,"avatar_url":"https://avatars.githubusercontent.com/u/2074141?v=3","gravatar_id":"","url":"https://api.github.com/users/MountainRoseHerbs","html_url":"https://github.com/MountainRoseHerbs","followers_url":"https://api.github.com/users/MountainRoseHerbs/followers","following_url":"https://api.github.com/users/MountainRoseHerbs/following{/other_user}","gists_url":"https://api.github.com/users/MountainRoseHerbs/gists{/gist_id}","starred_url":"https://api.github.com/users/MountainRoseHerbs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MountainRoseHerbs/subscriptions","organizations_url":"https://api.github.com/users/MountainRoseHerbs/orgs","repos_url":"https://api.github.com/users/MountainRoseHerbs/repos","events_url":"https://api.github.com/users/MountainRoseHerbs/events{/privacy}","received_events_url":"https://api.github.com/users/MountainRoseHerbs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MountainRoseHerbs/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":true,"url":"https://api.github.com/repos/MountainRoseHerbs/spree","forks_url":"https://api.github.com/repos/MountainRoseHerbs/spree/forks","keys_url":"https://api.github.com/repos/MountainRoseHerbs/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MountainRoseHerbs/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MountainRoseHerbs/spree/teams","hooks_url":"https://api.github.com/repos/MountainRoseHerbs/spree/hooks","issue_events_url":"https://api.github.com/repos/MountainRoseHerbs/spree/issues/events{/number}","events_url":"https://api.github.com/repos/MountainRoseHerbs/spree/events","assignees_url":"https://api.github.com/repos/MountainRoseHerbs/spree/assignees{/user}","branches_url":"https://api.github.com/repos/MountainRoseHerbs/spree/branches{/branch}","tags_url":"https://api.github.com/repos/MountainRoseHerbs/spree/tags","blobs_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MountainRoseHerbs/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/MountainRoseHerbs/spree/languages","stargazers_url":"https://api.github.com/repos/MountainRoseHerbs/spree/stargazers","contributors_url":"https://api.github.com/repos/MountainRoseHerbs/spree/contributors","subscribers_url":"https://api.github.com/repos/MountainRoseHerbs/spree/subscribers","subscription_url":"https://api.github.com/repos/MountainRoseHerbs/spree/subscription","commits_url":"https://api.github.com/repos/MountainRoseHerbs/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/MountainRoseHerbs/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/MountainRoseHerbs/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/MountainRoseHerbs/spree/contents/{+path}","compare_url":"https://api.github.com/repos/MountainRoseHerbs/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MountainRoseHerbs/spree/merges","archive_url":"https://api.github.com/repos/MountainRoseHerbs/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MountainRoseHerbs/spree/downloads","issues_url":"https://api.github.com/repos/MountainRoseHerbs/spree/issues{/number}","pulls_url":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/MountainRoseHerbs/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/MountainRoseHerbs/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MountainRoseHerbs/spree/labels{/name}","releases_url":"https://api.github.com/repos/MountainRoseHerbs/spree/releases{/id}","created_at":"2013-08-29T22:58:09Z","updated_at":"2014-11-24T20:15:20Z","pushed_at":"2014-11-25T15:10:31Z","git_url":"git://github.com/MountainRoseHerbs/spree.git","ssh_url":"git@github.com:MountainRoseHerbs/spree.git","clone_url":"https://github.com/MountainRoseHerbs/spree.git","svn_url":"https://github.com/MountainRoseHerbs/spree","homepage":"http://spreecommerce.com","size":42781,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"2-3-stable-mrh"}},"base":{"label":"MountainRoseHerbs:2-3-stable-mrh","ref":"2-3-stable-mrh","sha":"23a2e2dd1cb1d5931c89f2ad81e060d9e55144fe","user":{"login":"MountainRoseHerbs","id":2074141,"avatar_url":"https://avatars.githubusercontent.com/u/2074141?v=3","gravatar_id":"","url":"https://api.github.com/users/MountainRoseHerbs","html_url":"https://github.com/MountainRoseHerbs","followers_url":"https://api.github.com/users/MountainRoseHerbs/followers","following_url":"https://api.github.com/users/MountainRoseHerbs/following{/other_user}","gists_url":"https://api.github.com/users/MountainRoseHerbs/gists{/gist_id}","starred_url":"https://api.github.com/users/MountainRoseHerbs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MountainRoseHerbs/subscriptions","organizations_url":"https://api.github.com/users/MountainRoseHerbs/orgs","repos_url":"https://api.github.com/users/MountainRoseHerbs/repos","events_url":"https://api.github.com/users/MountainRoseHerbs/events{/privacy}","received_events_url":"https://api.github.com/users/MountainRoseHerbs/received_events","type":"Organization","site_admin":false},"repo":{"id":12473049,"name":"spree","full_name":"MountainRoseHerbs/spree","owner":{"login":"MountainRoseHerbs","id":2074141,"avatar_url":"https://avatars.githubusercontent.com/u/2074141?v=3","gravatar_id":"","url":"https://api.github.com/users/MountainRoseHerbs","html_url":"https://github.com/MountainRoseHerbs","followers_url":"https://api.github.com/users/MountainRoseHerbs/followers","following_url":"https://api.github.com/users/MountainRoseHerbs/following{/other_user}","gists_url":"https://api.github.com/users/MountainRoseHerbs/gists{/gist_id}","starred_url":"https://api.github.com/users/MountainRoseHerbs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MountainRoseHerbs/subscriptions","organizations_url":"https://api.github.com/users/MountainRoseHerbs/orgs","repos_url":"https://api.github.com/users/MountainRoseHerbs/repos","events_url":"https://api.github.com/users/MountainRoseHerbs/events{/privacy}","received_events_url":"https://api.github.com/users/MountainRoseHerbs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MountainRoseHerbs/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":true,"url":"https://api.github.com/repos/MountainRoseHerbs/spree","forks_url":"https://api.github.com/repos/MountainRoseHerbs/spree/forks","keys_url":"https://api.github.com/repos/MountainRoseHerbs/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MountainRoseHerbs/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MountainRoseHerbs/spree/teams","hooks_url":"https://api.github.com/repos/MountainRoseHerbs/spree/hooks","issue_events_url":"https://api.github.com/repos/MountainRoseHerbs/spree/issues/events{/number}","events_url":"https://api.github.com/repos/MountainRoseHerbs/spree/events","assignees_url":"https://api.github.com/repos/MountainRoseHerbs/spree/assignees{/user}","branches_url":"https://api.github.com/repos/MountainRoseHerbs/spree/branches{/branch}","tags_url":"https://api.github.com/repos/MountainRoseHerbs/spree/tags","blobs_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MountainRoseHerbs/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/MountainRoseHerbs/spree/languages","stargazers_url":"https://api.github.com/repos/MountainRoseHerbs/spree/stargazers","contributors_url":"https://api.github.com/repos/MountainRoseHerbs/spree/contributors","subscribers_url":"https://api.github.com/repos/MountainRoseHerbs/spree/subscribers","subscription_url":"https://api.github.com/repos/MountainRoseHerbs/spree/subscription","commits_url":"https://api.github.com/repos/MountainRoseHerbs/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/MountainRoseHerbs/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/MountainRoseHerbs/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/MountainRoseHerbs/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/MountainRoseHerbs/spree/contents/{+path}","compare_url":"https://api.github.com/repos/MountainRoseHerbs/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MountainRoseHerbs/spree/merges","archive_url":"https://api.github.com/repos/MountainRoseHerbs/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MountainRoseHerbs/spree/downloads","issues_url":"https://api.github.com/repos/MountainRoseHerbs/spree/issues{/number}","pulls_url":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/MountainRoseHerbs/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/MountainRoseHerbs/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MountainRoseHerbs/spree/labels{/name}","releases_url":"https://api.github.com/repos/MountainRoseHerbs/spree/releases{/id}","created_at":"2013-08-29T22:58:09Z","updated_at":"2014-11-24T20:15:20Z","pushed_at":"2014-11-25T15:10:31Z","git_url":"git://github.com/MountainRoseHerbs/spree.git","ssh_url":"git@github.com:MountainRoseHerbs/spree.git","clone_url":"https://github.com/MountainRoseHerbs/spree.git","svn_url":"https://github.com/MountainRoseHerbs/spree","homepage":"http://spreecommerce.com","size":42781,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"2-3-stable-mrh"}},"_links":{"self":{"href":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/34"},"html":{"href":"https://github.com/MountainRoseHerbs/spree/pull/34"},"issue":{"href":"https://api.github.com/repos/MountainRoseHerbs/spree/issues/34"},"comments":{"href":"https://api.github.com/repos/MountainRoseHerbs/spree/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/MountainRoseHerbs/spree/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/MountainRoseHerbs/spree/statuses/37eae2715dabf4d076a83187b13639735a3e53f8"}}}}