{"action":"created","issue":{"url":"https://api.github.com/repos/grosser/parallel/issues/176","repository_url":"https://api.github.com/repos/grosser/parallel","labels_url":"https://api.github.com/repos/grosser/parallel/issues/176/labels{/name}","comments_url":"https://api.github.com/repos/grosser/parallel/issues/176/comments","events_url":"https://api.github.com/repos/grosser/parallel/issues/176/events","html_url":"https://github.com/grosser/parallel/issues/176","id":157379372,"number":176,"title":"Access progress bar in finish lambda","user":{"login":"jimoleary","id":22506,"avatar_url":"https://avatars.githubusercontent.com/u/22506?v=3","gravatar_id":"","url":"https://api.github.com/users/jimoleary","html_url":"https://github.com/jimoleary","followers_url":"https://api.github.com/users/jimoleary/followers","following_url":"https://api.github.com/users/jimoleary/following{/other_user}","gists_url":"https://api.github.com/users/jimoleary/gists{/gist_id}","starred_url":"https://api.github.com/users/jimoleary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimoleary/subscriptions","organizations_url":"https://api.github.com/users/jimoleary/orgs","repos_url":"https://api.github.com/users/jimoleary/repos","events_url":"https://api.github.com/users/jimoleary/events{/privacy}","received_events_url":"https://api.github.com/users/jimoleary/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-29T10:19:24Z","updated_at":"2016-05-30T01:29:21Z","closed_at":null,"body":"I'd like to be able to change the title in the finish callback.\r\n\r\nThis allows more feedback to the user, for exampkle:\r\n\r\n\r\n```ruby\r\n      i =0\r\n      finish = lambda { |_, _, result, pbar|\r\n        i+=1\r\n        pbar.title=\"#{i.to_s.rjust(4,' ')} : #{result}\"\r\n      }\r\n```\r\n\r\nThe following patch would allow access (while maintaining backward compatibility):\r\n\r\n```\r\ndiff --git a/lib/parallel.rb b/lib/parallel.rb\r\nindex 020df18..130d77a 100644\r\n--- a/lib/parallel.rb\r\n+++ b/lib/parallel.rb\r\n@@ -267,7 +267,13 @@ module Parallel\r\n         progress = ProgressBar.create(progress_options)\r\n         old_finish = options[:finish]\r\n         options[:finish] = lambda do |item, i, result|\r\n-          old_finish.call(item, i, result) if old_finish\r\n+          if old_finish\r\n+            if old_finish.arity == 4\r\n+              old_finish.call(item, i, result, progress)\r\n+            else\r\n+              old_finish.call(item, i, result)\r\n+            end\r\n+          end\r\n           progress.increment\r\n         end\r\n       end\r\n```\r\n\r\nLet me know if you would consider this change and I can send a pull request. \r\n"},"comment":{"url":"https://api.github.com/repos/grosser/parallel/issues/comments/222395550","html_url":"https://github.com/grosser/parallel/issues/176#issuecomment-222395550","issue_url":"https://api.github.com/repos/grosser/parallel/issues/176","id":222395550,"user":{"login":"grosser","id":11367,"avatar_url":"https://avatars.githubusercontent.com/u/11367?v=3","gravatar_id":"","url":"https://api.github.com/users/grosser","html_url":"https://github.com/grosser","followers_url":"https://api.github.com/users/grosser/followers","following_url":"https://api.github.com/users/grosser/following{/other_user}","gists_url":"https://api.github.com/users/grosser/gists{/gist_id}","starred_url":"https://api.github.com/users/grosser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grosser/subscriptions","organizations_url":"https://api.github.com/users/grosser/orgs","repos_url":"https://api.github.com/users/grosser/repos","events_url":"https://api.github.com/users/grosser/events{/privacy}","received_events_url":"https://api.github.com/users/grosser/received_events","type":"User","site_admin":false},"created_at":"2016-05-30T01:29:21Z","updated_at":"2016-05-30T01:29:21Z","body":"all :progress option does is trigger the creation of a finish lambda, you\ncan create a custom progress bar and set it as finish lambda to do whatever\nyou please\n\nOn Sun, May 29, 2016 at 3:55 PM, jimoleary <notifications@github.com> wrote:\n\n> Looking at the code, the progress bar is created inside the gem and after\n> the finish lambda is created.\n>\n> So I can't pass it in and don't see how I can get a reference to it. The\n> only thing I can pass are the options which contain the initial title and\n> format etc.\n>\n> As I mentioned it's a small suggestion, and not a deal breaker when I\n> take the 4x improvement in performance into account ;)\n>\n> I'm not suggesting to use a different one, but to use the same but with\n> your own configuration, since that might be cleaner then patching the gem\n> On May 29, 2016 3:40 PM, \"jimoleary\" <notifications@github.com> wrote:\n>\n> > I'm not looking to use a different progress bar, I just want to be able\n> > to change the title on the current one to give more feedback.\n> >\n> > It's not a huge deal as I have monkey patched your version but that makes\n> > my code more brittle. However, I can always pin the gem version to avoid\n> > issues.\n> >\n> > Feel free to close the issue.\n> >\n> > Thanks.\n> > On 29 May 2016 11:29 pm, \"Michael Grosser\" <notifications@github.com>\n> > wrote:\n> >\n> > > seems like a strange edge case and an additional complixity/runtime\n> cost\n> > > for everyone else, so I'd prefer not to have that ... you should be\n> able\n> > to\n> > > implement your own progress bar in a finish callback ... that might\n> work\n> > > well ...\n> > >\n> > > —\n> > > You are receiving this because you authored the thread.\n> > > Reply to this email directly, view it on GitHub\n> > > <https://github.com/grosser/parallel/issues/176#issuecomment-222386568\n> >,\n> > > or mute the thread\n> > > <\n> >\n>\n> https://github.com/notifications/unsubscribe/AABX6td2ow6nu2PHpBqQv03TwJ0S7DA2ks5qGhNKgaJpZM4IpQk1\n> > >\n> > > .\n> > >\n> >\n> > —\n> > You are receiving this because you commented.\n> > Reply to this email directly, view it on GitHub\n> > <https://github.com/grosser/parallel/issues/176#issuecomment-222387131>,\n> > or mute the thread\n> > <\n>\n> https://github.com/notifications/unsubscribe/AAAsZ15Jougz6l6socktoCmt9c9Ccnubks5qGhXkgaJpZM4IpQk1\n> >\n> > .\n> >\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/grosser/parallel/issues/176#issuecomment-222387186>,\n> or mute\n> the thread\n> <\n> https://github.com/notifications/unsubscribe/AABX6verZ1xicp38ldOkJdvBRBaWR5uNks5qGhZOgaJpZM4IpQk1\n> >\n>\n> .\n>\n> —\n> You are receiving this because you commented.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/grosser/parallel/issues/176#issuecomment-222387757>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe/AAAsZyTFSFa2khlU3WUTzqJHhIY6Bin3ks5qGhlagaJpZM4IpQk1>\n> .\n>\n"}}
{"actor":{"display_login":"grosser"}}