{"action":"created","comment":{"url":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/comments/62474685","id":62474685,"diff_hunk":"@@ -0,0 +1,58 @@\n+class SlugSetup\n+    \n+    attr_reader :name \n+\n+    def self.setup(name)\n+        new(name).send(:candidates)\n+    end\n+\n+    def initialize(name)\n+        @name = name\n+    end\n+    \n+    def candidates\n+        [   @name.method(:short_name), \n+            @name.method(:prolonged_name), \n+            @name.method(:orged), \n+            :name\n+        ]\n+    end\n+    \n+end\n+\n+class String\n+    \n+    NOT_WANTED = %w(the of for and in to)\n+\n+    def short_name\n+        if self.match(/parochial church/i)\n+            parochial_churches\n+        else\n+            slug_words.first(3).join('-')\n+        end\n+    end\n+\n+    def prolonged_name\n+        \"#{short_name}-#{slug_words[-2]}-#{slug_words[-1]}\"\n+    end\n+\n+    def orged\n+        \"#{slug_words.join('-')}-org\"\n+    end\n+\n+    def slug_words\n+        words = \"#{self}\".delete('\\'','-').downcase_words\n+        words.reject {|w| NOT_WANTED.include?(w) }\n+    end\n+    \n+    def parochial_churches\n+        parish = self.slice(/(?<=parish of )(.+)\\z/i).downcase_words","path":"app/services/slug_setup.rb","position":49,"original_position":49,"commit_id":"bf7b03ed1d65dedf261c812acd715258d6344307","original_commit_id":"bf7b03ed1d65dedf261c812acd715258d6344307","user":{"login":"tansaku","id":30216,"avatar_url":"https://avatars.githubusercontent.com/u/30216?v=3","gravatar_id":"","url":"https://api.github.com/users/tansaku","html_url":"https://github.com/tansaku","followers_url":"https://api.github.com/users/tansaku/followers","following_url":"https://api.github.com/users/tansaku/following{/other_user}","gists_url":"https://api.github.com/users/tansaku/gists{/gist_id}","starred_url":"https://api.github.com/users/tansaku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tansaku/subscriptions","organizations_url":"https://api.github.com/users/tansaku/orgs","repos_url":"https://api.github.com/users/tansaku/repos","events_url":"https://api.github.com/users/tansaku/events{/privacy}","received_events_url":"https://api.github.com/users/tansaku/received_events","type":"User","site_admin":false},"body":"I wonder if we need the `self` keyword here and below? perhaps their presence is helpful ...?","created_at":"2016-05-09T09:55:07Z","updated_at":"2016-05-09T09:55:07Z","html_url":"https://github.com/AgileVentures/LocalSupport/pull/292#discussion_r62474685","pull_request_url":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/292","_links":{"self":{"href":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/comments/62474685"},"html":{"href":"https://github.com/AgileVentures/LocalSupport/pull/292#discussion_r62474685"},"pull_request":{"href":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/292"}}},"pull_request":{"url":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/292","id":67769201,"html_url":"https://github.com/AgileVentures/LocalSupport/pull/292","diff_url":"https://github.com/AgileVentures/LocalSupport/pull/292.diff","patch_url":"https://github.com/AgileVentures/LocalSupport/pull/292.patch","issue_url":"https://api.github.com/repos/AgileVentures/LocalSupport/issues/292","number":292,"state":"open","locked":false,"title":"118172295 friendly id should have custom parser","user":{"login":"bryszard","id":12682792,"avatar_url":"https://avatars.githubusercontent.com/u/12682792?v=3","gravatar_id":"","url":"https://api.github.com/users/bryszard","html_url":"https://github.com/bryszard","followers_url":"https://api.github.com/users/bryszard/followers","following_url":"https://api.github.com/users/bryszard/following{/other_user}","gists_url":"https://api.github.com/users/bryszard/gists{/gist_id}","starred_url":"https://api.github.com/users/bryszard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryszard/subscriptions","organizations_url":"https://api.github.com/users/bryszard/orgs","repos_url":"https://api.github.com/users/bryszard/repos","events_url":"https://api.github.com/users/bryszard/events{/privacy}","received_events_url":"https://api.github.com/users/bryszard/received_events","type":"User","site_admin":false},"body":"Adds feature - https://www.pivotaltracker.com/story/show/118172295.\r\n\r\nOK, now friendly_id has a custom parser. It makes slugs in a following order (gets to next if it's not unique):\r\n1. short_name - 3 first words of the name (separated by \"-\"); it deletes apostrophies from words\r\n2. prolonged_name - short_name with two last words of the name (separated by \"-\"); it deletes apostrophies from words\r\n3. name - every word of the name, separated by \"-\" (friendly_id default); it doesn't delete apostrophies from words\r\n\r\nNevertheless, the problem are now names like \"The Stanmore And Canons Park Synagogue Eruv Committee\" - slug here would be \"the-stanmore-and\". \r\n\r\nSolution to that would be more complicated custom parser (e.g. throwing out \"the\", \"and\" or other similar words) or totally custom slugs - setup by users through a form.\r\n\r\nI found explanation to add the \"slug_candidates\" method here: http://norman.github.io/friendly_id/file.Guide.html","created_at":"2016-04-25T18:50:51Z","updated_at":"2016-05-09T09:55:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f07899cec9b51a1734f948132938696c2c8500bb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/292/commits","review_comments_url":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/292/comments","review_comment_url":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AgileVentures/LocalSupport/issues/292/comments","statuses_url":"https://api.github.com/repos/AgileVentures/LocalSupport/statuses/bf7b03ed1d65dedf261c812acd715258d6344307","head":{"label":"bryszard:118172295_friendly_id_should_have_custom_parser","ref":"118172295_friendly_id_should_have_custom_parser","sha":"bf7b03ed1d65dedf261c812acd715258d6344307","user":{"login":"bryszard","id":12682792,"avatar_url":"https://avatars.githubusercontent.com/u/12682792?v=3","gravatar_id":"","url":"https://api.github.com/users/bryszard","html_url":"https://github.com/bryszard","followers_url":"https://api.github.com/users/bryszard/followers","following_url":"https://api.github.com/users/bryszard/following{/other_user}","gists_url":"https://api.github.com/users/bryszard/gists{/gist_id}","starred_url":"https://api.github.com/users/bryszard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryszard/subscriptions","organizations_url":"https://api.github.com/users/bryszard/orgs","repos_url":"https://api.github.com/users/bryszard/repos","events_url":"https://api.github.com/users/bryszard/events{/privacy}","received_events_url":"https://api.github.com/users/bryszard/received_events","type":"User","site_admin":false},"repo":{"id":54380248,"name":"LocalSupport","full_name":"bryszard/LocalSupport","owner":{"login":"bryszard","id":12682792,"avatar_url":"https://avatars.githubusercontent.com/u/12682792?v=3","gravatar_id":"","url":"https://api.github.com/users/bryszard","html_url":"https://github.com/bryszard","followers_url":"https://api.github.com/users/bryszard/followers","following_url":"https://api.github.com/users/bryszard/following{/other_user}","gists_url":"https://api.github.com/users/bryszard/gists{/gist_id}","starred_url":"https://api.github.com/users/bryszard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryszard/subscriptions","organizations_url":"https://api.github.com/users/bryszard/orgs","repos_url":"https://api.github.com/users/bryszard/repos","events_url":"https://api.github.com/users/bryszard/events{/privacy}","received_events_url":"https://api.github.com/users/bryszard/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bryszard/LocalSupport","description":"A directory of local support services","fork":true,"url":"https://api.github.com/repos/bryszard/LocalSupport","forks_url":"https://api.github.com/repos/bryszard/LocalSupport/forks","keys_url":"https://api.github.com/repos/bryszard/LocalSupport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bryszard/LocalSupport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bryszard/LocalSupport/teams","hooks_url":"https://api.github.com/repos/bryszard/LocalSupport/hooks","issue_events_url":"https://api.github.com/repos/bryszard/LocalSupport/issues/events{/number}","events_url":"https://api.github.com/repos/bryszard/LocalSupport/events","assignees_url":"https://api.github.com/repos/bryszard/LocalSupport/assignees{/user}","branches_url":"https://api.github.com/repos/bryszard/LocalSupport/branches{/branch}","tags_url":"https://api.github.com/repos/bryszard/LocalSupport/tags","blobs_url":"https://api.github.com/repos/bryszard/LocalSupport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bryszard/LocalSupport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bryszard/LocalSupport/git/refs{/sha}","trees_url":"https://api.github.com/repos/bryszard/LocalSupport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bryszard/LocalSupport/statuses/{sha}","languages_url":"https://api.github.com/repos/bryszard/LocalSupport/languages","stargazers_url":"https://api.github.com/repos/bryszard/LocalSupport/stargazers","contributors_url":"https://api.github.com/repos/bryszard/LocalSupport/contributors","subscribers_url":"https://api.github.com/repos/bryszard/LocalSupport/subscribers","subscription_url":"https://api.github.com/repos/bryszard/LocalSupport/subscription","commits_url":"https://api.github.com/repos/bryszard/LocalSupport/commits{/sha}","git_commits_url":"https://api.github.com/repos/bryszard/LocalSupport/git/commits{/sha}","comments_url":"https://api.github.com/repos/bryszard/LocalSupport/comments{/number}","issue_comment_url":"https://api.github.com/repos/bryszard/LocalSupport/issues/comments{/number}","contents_url":"https://api.github.com/repos/bryszard/LocalSupport/contents/{+path}","compare_url":"https://api.github.com/repos/bryszard/LocalSupport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bryszard/LocalSupport/merges","archive_url":"https://api.github.com/repos/bryszard/LocalSupport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bryszard/LocalSupport/downloads","issues_url":"https://api.github.com/repos/bryszard/LocalSupport/issues{/number}","pulls_url":"https://api.github.com/repos/bryszard/LocalSupport/pulls{/number}","milestones_url":"https://api.github.com/repos/bryszard/LocalSupport/milestones{/number}","notifications_url":"https://api.github.com/repos/bryszard/LocalSupport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bryszard/LocalSupport/labels{/name}","releases_url":"https://api.github.com/repos/bryszard/LocalSupport/releases{/id}","deployments_url":"https://api.github.com/repos/bryszard/LocalSupport/deployments","created_at":"2016-03-21T10:34:44Z","updated_at":"2016-03-21T10:34:46Z","pushed_at":"2016-05-06T10:22:27Z","git_url":"git://github.com/bryszard/LocalSupport.git","ssh_url":"git@github.com:bryszard/LocalSupport.git","clone_url":"https://github.com/bryszard/LocalSupport.git","svn_url":"https://github.com/bryszard/LocalSupport","homepage":null,"size":13547,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"AgileVentures:develop","ref":"develop","sha":"affb602c3658ef700b52f34dd3711ca93370024d","user":{"login":"AgileVentures","id":5116968,"avatar_url":"https://avatars.githubusercontent.com/u/5116968?v=3","gravatar_id":"","url":"https://api.github.com/users/AgileVentures","html_url":"https://github.com/AgileVentures","followers_url":"https://api.github.com/users/AgileVentures/followers","following_url":"https://api.github.com/users/AgileVentures/following{/other_user}","gists_url":"https://api.github.com/users/AgileVentures/gists{/gist_id}","starred_url":"https://api.github.com/users/AgileVentures/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgileVentures/subscriptions","organizations_url":"https://api.github.com/users/AgileVentures/orgs","repos_url":"https://api.github.com/users/AgileVentures/repos","events_url":"https://api.github.com/users/AgileVentures/events{/privacy}","received_events_url":"https://api.github.com/users/AgileVentures/received_events","type":"Organization","site_admin":false},"repo":{"id":14499588,"name":"LocalSupport","full_name":"AgileVentures/LocalSupport","owner":{"login":"AgileVentures","id":5116968,"avatar_url":"https://avatars.githubusercontent.com/u/5116968?v=3","gravatar_id":"","url":"https://api.github.com/users/AgileVentures","html_url":"https://github.com/AgileVentures","followers_url":"https://api.github.com/users/AgileVentures/followers","following_url":"https://api.github.com/users/AgileVentures/following{/other_user}","gists_url":"https://api.github.com/users/AgileVentures/gists{/gist_id}","starred_url":"https://api.github.com/users/AgileVentures/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgileVentures/subscriptions","organizations_url":"https://api.github.com/users/AgileVentures/orgs","repos_url":"https://api.github.com/users/AgileVentures/repos","events_url":"https://api.github.com/users/AgileVentures/events{/privacy}","received_events_url":"https://api.github.com/users/AgileVentures/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AgileVentures/LocalSupport","description":"A directory of local support services and volunteer opportunities","fork":true,"url":"https://api.github.com/repos/AgileVentures/LocalSupport","forks_url":"https://api.github.com/repos/AgileVentures/LocalSupport/forks","keys_url":"https://api.github.com/repos/AgileVentures/LocalSupport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AgileVentures/LocalSupport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AgileVentures/LocalSupport/teams","hooks_url":"https://api.github.com/repos/AgileVentures/LocalSupport/hooks","issue_events_url":"https://api.github.com/repos/AgileVentures/LocalSupport/issues/events{/number}","events_url":"https://api.github.com/repos/AgileVentures/LocalSupport/events","assignees_url":"https://api.github.com/repos/AgileVentures/LocalSupport/assignees{/user}","branches_url":"https://api.github.com/repos/AgileVentures/LocalSupport/branches{/branch}","tags_url":"https://api.github.com/repos/AgileVentures/LocalSupport/tags","blobs_url":"https://api.github.com/repos/AgileVentures/LocalSupport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AgileVentures/LocalSupport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AgileVentures/LocalSupport/git/refs{/sha}","trees_url":"https://api.github.com/repos/AgileVentures/LocalSupport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AgileVentures/LocalSupport/statuses/{sha}","languages_url":"https://api.github.com/repos/AgileVentures/LocalSupport/languages","stargazers_url":"https://api.github.com/repos/AgileVentures/LocalSupport/stargazers","contributors_url":"https://api.github.com/repos/AgileVentures/LocalSupport/contributors","subscribers_url":"https://api.github.com/repos/AgileVentures/LocalSupport/subscribers","subscription_url":"https://api.github.com/repos/AgileVentures/LocalSupport/subscription","commits_url":"https://api.github.com/repos/AgileVentures/LocalSupport/commits{/sha}","git_commits_url":"https://api.github.com/repos/AgileVentures/LocalSupport/git/commits{/sha}","comments_url":"https://api.github.com/repos/AgileVentures/LocalSupport/comments{/number}","issue_comment_url":"https://api.github.com/repos/AgileVentures/LocalSupport/issues/comments{/number}","contents_url":"https://api.github.com/repos/AgileVentures/LocalSupport/contents/{+path}","compare_url":"https://api.github.com/repos/AgileVentures/LocalSupport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AgileVentures/LocalSupport/merges","archive_url":"https://api.github.com/repos/AgileVentures/LocalSupport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AgileVentures/LocalSupport/downloads","issues_url":"https://api.github.com/repos/AgileVentures/LocalSupport/issues{/number}","pulls_url":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls{/number}","milestones_url":"https://api.github.com/repos/AgileVentures/LocalSupport/milestones{/number}","notifications_url":"https://api.github.com/repos/AgileVentures/LocalSupport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AgileVentures/LocalSupport/labels{/name}","releases_url":"https://api.github.com/repos/AgileVentures/LocalSupport/releases{/id}","deployments_url":"https://api.github.com/repos/AgileVentures/LocalSupport/deployments","created_at":"2013-11-18T17:24:59Z","updated_at":"2016-05-03T06:12:58Z","pushed_at":"2016-05-06T13:27:12Z","git_url":"git://github.com/AgileVentures/LocalSupport.git","ssh_url":"git@github.com:AgileVentures/LocalSupport.git","clone_url":"https://github.com/AgileVentures/LocalSupport.git","svn_url":"https://github.com/AgileVentures/LocalSupport","homepage":"http://www.harrowcn.org.uk","size":55963,"stargazers_count":21,"watchers_count":21,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":81,"mirror_url":null,"open_issues_count":17,"forks":81,"open_issues":17,"watchers":21,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/292"},"html":{"href":"https://github.com/AgileVentures/LocalSupport/pull/292"},"issue":{"href":"https://api.github.com/repos/AgileVentures/LocalSupport/issues/292"},"comments":{"href":"https://api.github.com/repos/AgileVentures/LocalSupport/issues/292/comments"},"review_comments":{"href":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/292/comments"},"review_comment":{"href":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AgileVentures/LocalSupport/pulls/292/commits"},"statuses":{"href":"https://api.github.com/repos/AgileVentures/LocalSupport/statuses/bf7b03ed1d65dedf261c812acd715258d6344307"}}}}