{"action":"created","issue":{"url":"https://api.github.com/repos/awesome-print/awesome_print/issues/343","repository_url":"https://api.github.com/repos/awesome-print/awesome_print","labels_url":"https://api.github.com/repos/awesome-print/awesome_print/issues/343/labels{/name}","comments_url":"https://api.github.com/repos/awesome-print/awesome_print/issues/343/comments","events_url":"https://api.github.com/repos/awesome-print/awesome_print/issues/343/events","html_url":"https://github.com/awesome-print/awesome_print/issues/343","id":340508436,"node_id":"MDU6SXNzdWUzNDA1MDg0MzY=","number":343,"title":"[Feature] 'depth' in options","user":{"login":"maciejpk","id":5055263,"node_id":"MDQ6VXNlcjUwNTUyNjM=","avatar_url":"https://avatars2.githubusercontent.com/u/5055263?v=4","gravatar_id":"","url":"https://api.github.com/users/maciejpk","html_url":"https://github.com/maciejpk","followers_url":"https://api.github.com/users/maciejpk/followers","following_url":"https://api.github.com/users/maciejpk/following{/other_user}","gists_url":"https://api.github.com/users/maciejpk/gists{/gist_id}","starred_url":"https://api.github.com/users/maciejpk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciejpk/subscriptions","organizations_url":"https://api.github.com/users/maciejpk/orgs","repos_url":"https://api.github.com/users/maciejpk/repos","events_url":"https://api.github.com/users/maciejpk/events{/privacy}","received_events_url":"https://api.github.com/users/maciejpk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-12T06:44:05Z","updated_at":"2018-09-06T04:39:46Z","closed_at":null,"author_association":"NONE","body":"This is actually a feature request that shouldn't be hard to implement.\r\nWhat I actually would like to have, is a depth of \"awesome printing\", so when for example I have an array like:\r\n```\r\narr = [\r\n  [1,2,3],\r\n  [4,5,6],\r\n  [7,8,9]\r\n]\r\n```\r\nthen for `depth == 2` it would print it the usual way, which would be `ap arr`, but if the `depth == 1` then it would be displayed like in the above manner.\r\n\r\nReason for this feature? Pluck command. Let's take an `ActiveRecord` and do something like this\r\n`ap User.where(...).pluck(:id, :created_at, :updated_at)`\r\nIt would be printed in an ugly way, which would be something alike\r\n```\r\n[\r\n    [ 0] [\r\n        [0] 6,\r\n        [1] Fri, 22 Jun 2018 10:31:53 UTC +00:00,\r\n        [2] Fri, 22 Jun 2018 10:31:53 UTC +00:00\r\n    ],\r\n    [ 1] [\r\n        [0] 7,\r\n        [1] Tue, 26 Jun 2018 09:00:50 UTC +00:00,\r\n        [2] Tue, 26 Jun 2018 09:00:50 UTC +00:00\r\n    ],\r\n    [ 2] [\r\n        [0] 8,\r\n        [1] Tue, 26 Jun 2018 09:01:09 UTC +00:00,\r\n        [2] Tue, 26 Jun 2018 09:01:09 UTC +00:00\r\n    ],\r\n    [ 3] [\r\n        [0] 10,\r\n        [1] Wed, 27 Jun 2018 07:28:20 UTC +00:00,\r\n        [2] Wed, 27 Jun 2018 07:28:20 UTC +00:00\r\n    ]\r\n]\r\n```\r\nwhen instead I would like it to show each record as a row, so that would look something like this\r\n\r\n```\r\n[\r\n    [ 0] [6, Fri, 22 Jun 2018 10:31:53 UTC +00:00, Fri, 22 Jun 2018 10:31:53 UTC +00:00],\r\n    [ 1] [7, Tue, 26 Jun 2018 09:00:50 UTC +00:00, Tue, 26 Jun 2018 09:00:50 UTC +00:00],\r\n    [ 2] [8, Tue, 26 Jun 2018 09:01:09 UTC +00:00, Tue, 26 Jun 2018 09:01:09 UTC +00:00],\r\n    [ 3] [10, Wed, 27 Jun 2018 07:28:20 UTC +00:00, Wed, 27 Jun 2018 07:28:20 UTC +00:00]\r\n]\r\n```"},"comment":{"url":"https://api.github.com/repos/awesome-print/awesome_print/issues/comments/418962291","html_url":"https://github.com/awesome-print/awesome_print/issues/343#issuecomment-418962291","issue_url":"https://api.github.com/repos/awesome-print/awesome_print/issues/343","id":418962291,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODk2MjI5MQ==","user":{"login":"bmon","id":2115272,"node_id":"MDQ6VXNlcjIxMTUyNzI=","avatar_url":"https://avatars2.githubusercontent.com/u/2115272?v=4","gravatar_id":"","url":"https://api.github.com/users/bmon","html_url":"https://github.com/bmon","followers_url":"https://api.github.com/users/bmon/followers","following_url":"https://api.github.com/users/bmon/following{/other_user}","gists_url":"https://api.github.com/users/bmon/gists{/gist_id}","starred_url":"https://api.github.com/users/bmon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmon/subscriptions","organizations_url":"https://api.github.com/users/bmon/orgs","repos_url":"https://api.github.com/users/bmon/repos","events_url":"https://api.github.com/users/bmon/events{/privacy}","received_events_url":"https://api.github.com/users/bmon/received_events","type":"User","site_admin":false},"created_at":"2018-09-06T04:39:46Z","updated_at":"2018-09-06T04:39:46Z","author_association":"NONE","body":"I've also found myself wanting this, the example above can be patched in (i.e in ~/.pryrc) like so:\r\n\r\n```ruby\r\nrequire \"awesome_print\"\r\nmodule AwesomePrint\r\n  module Formatters\r\n    class ArrayFormatter\r\n      alias old_gen generate_printable_array\r\n      def generate_printable_array\r\n        options[:multiline] = false\r\n        old_gen\r\n      end\r\n    end\r\n  end\r\nend\r\nAwesomePrint.pry!\r\n```\r\n\r\nDoesn't support depth, and if you want to start printing out complex objects it will wrap and look very ugly, but for a quick hack it does the trick pretty well."}}
{"actor":{"display_login":"bmon"}}