{"id":13428043,"url":"https://github.com/awesome-print/awesome_print","last_synced_at":"2026-04-09T18:57:14.293Z","repository":{"id":858570,"uuid":"592743","full_name":"awesome-print/awesome_print","owner":"awesome-print","description":"Pretty print your Ruby objects with style -- in full color and with proper indentation","archived":false,"fork":false,"pushed_at":"2024-08-15T20:03:46.000Z","size":831,"stargazers_count":4086,"open_issues_count":107,"forks_count":453,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-04-30T07:47:10.029Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://github.com/michaeldv/awesome_print","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awesome-print.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-04-03T04:45:43.000Z","updated_at":"2025-04-28T03:26:34.000Z","dependencies_parsed_at":"2024-11-05T18:36:59.841Z","dependency_job_id":"de7ec6e0-a2e4-43d2-a19b-02811fb0843d","html_url":"https://github.com/awesome-print/awesome_print","commit_stats":{"total_commits":409,"total_committers":71,"mean_commits":5.76056338028169,"dds":0.6039119804400979,"last_synced_commit":"8a7ff0aabacbebf694c3e27242809219a96d5a3b"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awesome-print%2Fawesome_print","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awesome-print%2Fawesome_print/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awesome-print%2Fawesome_print/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awesome-print%2Fawesome_print/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awesome-print","download_url":"https://codeload.github.com/awesome-print/awesome_print/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251843662,"owners_count":21652855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T01:00:44.834Z","updated_at":"2026-04-09T18:57:14.239Z","avatar_url":"https://github.com/awesome-print.png","language":"Ruby","funding_links":[],"categories":["Debug","Acknowledgements","Ruby","Amazing Printer","Gems","WebSocket","CLI Utilities","Uncategorized"],"sub_categories":["Omniauth","Misc","Uncategorized"],"readme":"## Awesome Print ##\n\n[![RubyGems][gem_version_badge]][ruby_gems]\n[![Travis CI][travis_ci_badge]][travis_ci]\n[![Code Climate][code_climate_badge]][code_climate]\n[![Code Climate Coverage][code_climate_coverage_badge]][code_climate]\n[![RubyGems][gem_downloads_badge]][ruby_gems]\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/awesome-print/awesome_print?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n\nAwesome Print is a Ruby library that pretty prints Ruby objects in full color\nexposing their internal structure with proper indentation. Rails ActiveRecord\nobjects and usage within Rails templates are supported via included mixins.\n\n__NOTE__: awesome_print v1.9.0 may not work on Ruby versions 2.4 or older or Rails versions 4.2 or older.\nThe upcoming awesome_print v2.0 will *require* Ruby v1.9.3 or later and Rails v3.0 or later.\n\n### Installation ###\n    # Installing as Ruby gem\n    $ gem install awesome_print\n\n    # Cloning the repository\n    $ git clone git://github.com/awesome-print/awesome_print.git\n\n### Usage ###\n\n```ruby\nrequire \"awesome_print\"\nap object, options = {}\n```\n\nDefault options:\n\n```ruby\nindent:        4,      # Number of spaces for indenting.\nindex:         true,   # Display array indices.\nhtml:          false,  # Use ANSI color codes rather than HTML.\nmultiline:     true,   # Display in multiple lines.\nplain:         false,  # Use colors.\nraw:           false,  # Do not recursively format instance variables.\nsort_keys:     false,  # Do not sort hash keys.\nsort_vars:     true,   # Sort instance variables.\nlimit:         false,  # Limit arrays \u0026 hashes. Accepts bool or int.\nruby19_syntax: false,  # Use Ruby 1.9 hash syntax in output.\nclass_name:    :class, # Method called to report the instance class name. (e.g. :to_s)\nobject_id:     true,   # Show object id.\ncolor: {\n  args:       :pale,\n  array:      :white,\n  bigdecimal: :blue,\n  class:      :yellow,\n  date:       :greenish,\n  falseclass: :red,\n  integer:    :blue,\n  float:      :blue,\n  hash:       :pale,\n  keyword:    :cyan,\n  method:     :purpleish,\n  nilclass:   :red,\n  rational:   :blue,\n  string:     :yellowish,\n  struct:     :pale,\n  symbol:     :cyanish,\n  time:       :greenish,\n  trueclass:  :green,\n  variable:   :cyanish\n}\n```\n\nSupported color names:\n\n```ruby\n:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white\n:black, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :pale\n```\n\nUse `Object#ai` to return an ASCII encoded string:\n\n```ruby\nirb\u003e \"awesome print\".ai\n=\u003e \"\\e[0;33m\\\"awesome print\\\"\\e[0m\"\n```\n\n### Examples ###\n\n#### Array\n\n```ruby\n$ cat \u003e 1.rb\nrequire \"awesome_print\"\ndata = [ false, 42, %w(forty two), { :now =\u003e Time.now, :class =\u003e Time.now.class, :distance =\u003e 42e42 } ]\nap data\n^D\n$ ruby 1.rb\n[\n    [0] false,\n    [1] 42,\n    [2] [\n        [0] \"forty\",\n        [1] \"two\"\n    ],\n    [3] {\n           :class =\u003e Time \u003c Object,\n             :now =\u003e Fri Apr 02 19:55:53 -0700 2010,\n        :distance =\u003e 4.2e+43\n    }\n]\n```\n#### Hash\n\n```ruby\n$ cat \u003e 2.rb\nrequire \"awesome_print\"\ndata = { :now =\u003e Time.now, :class =\u003e Time.now.class, :distance =\u003e 42e42 }\nap data, :indent =\u003e -2  # \u003c-- Left align hash keys.\n^D\n$ ruby 2.rb\n{\n  :class    =\u003e Time \u003c Object,\n  :now      =\u003e Fri Apr 02 19:55:53 -0700 2010,\n  :distance =\u003e 4.2e+43\n}\n```\n\n#### Nested array\n\n```ruby\n$ cat \u003e 3.rb\nrequire \"awesome_print\"\ndata = [ false, 42, %w(forty two) ]\ndata \u003c\u003c data  # \u003c-- Nested array.\nap data, :multiline =\u003e false\n^D\n$ ruby 3.rb\n[ false, 42, [ \"forty\", \"two\" ], [...] ]\n\n```\n\n#### Class methods\n\n```ruby\n$ cat \u003e 4.rb\nrequire \"awesome_print\"\nclass Hello\n  def self.world(x, y, z = nil, \u0026blk)\n  end\nend\nap Hello.methods - Class.methods\n^D\n$ ruby 4.rb\n[\n    [0] world(x, y, *z, \u0026blk) Hello\n]\n\n```\n\n#### Object methods\n\n```ruby\n$ cat \u003e 5.rb\nrequire \"awesome_print\"\nap (''.methods - Object.methods).grep(/!/)\n^D\n$ ruby 5.rb\n[\n    [ 0] capitalize!()           String\n    [ 1]      chomp!(*arg1)      String\n    [ 2]       chop!()           String\n    [ 3]     delete!(*arg1)      String\n    [ 4]   downcase!()           String\n    [ 5]     encode!(*arg1)      String\n    [ 6]       gsub!(*arg1)      String\n    [ 7]     lstrip!()           String\n    [ 8]       next!()           String\n    [ 9]    reverse!()           String\n    [10]     rstrip!()           String\n    [11]      slice!(*arg1)      String\n    [12]    squeeze!(*arg1)      String\n    [13]      strip!()           String\n    [14]        sub!(*arg1)      String\n    [15]       succ!()           String\n    [16]   swapcase!()           String\n    [17]         tr!(arg1, arg2) String\n    [18]       tr_s!(arg1, arg2) String\n    [19]     upcase!()           String\n]\n\n```\n\n#### Compare output to value\n\n```ruby\n$ cat \u003e 6.rb\nrequire \"awesome_print\"\nap 42 == ap(42)\n^D\n$ ruby 6.rb\n42\ntrue\n\n```\n\n#### Array with default output limit\n\n```ruby\n$ cat \u003e 7.rb\nrequire \"awesome_print\"\nsome_array = (1..1000).to_a\nap some_array, :limit =\u003e true\n^D\n$ ruby 7.rb\n[\n    [  0] 1,\n    [  1] 2,\n    [  2] 3,\n    [  3] .. [996],\n    [997] 998,\n    [998] 999,\n    [999] 1000\n]\n```\n\n#### Array with specific output limit\n\n```ruby\n$ cat \u003e 8.rb\nrequire \"awesome_print\"\nsome_array = (1..1000).to_a\nap some_array, :limit =\u003e 5\n^D\n$ ruby 8.rb\n[\n    [  0] 1,\n    [  1] 2,\n    [  2] .. [997],\n    [998] 999,\n    [999] 1000\n]\n```\n\n#### Rails console\n```ruby\n$ rails console\nrails\u003e require \"awesome_print\"\nrails\u003e ap Account.limit(2).all\n[\n    [0] #\u003cAccount:0x1033220b8\u003e {\n                     :id =\u003e 1,\n                :user_id =\u003e 5,\n            :assigned_to =\u003e 7,\n                   :name =\u003e \"Hayes-DuBuque\",\n                 :access =\u003e \"Public\",\n                :website =\u003e \"http://www.hayesdubuque.com\",\n        :toll_free_phone =\u003e \"1-800-932-6571\",\n                  :phone =\u003e \"(111)549-5002\",\n                    :fax =\u003e \"(349)415-2266\",\n             :deleted_at =\u003e nil,\n             :created_at =\u003e Sat, 06 Mar 2010 09:46:10 UTC +00:00,\n             :updated_at =\u003e Sat, 06 Mar 2010 16:33:10 UTC +00:00,\n                  :email =\u003e \"info@hayesdubuque.com\",\n        :background_info =\u003e nil\n    },\n    [1] #\u003cAccount:0x103321ff0\u003e {\n                     :id =\u003e 2,\n                :user_id =\u003e 4,\n            :assigned_to =\u003e 4,\n                   :name =\u003e \"Ziemann-Streich\",\n                 :access =\u003e \"Public\",\n                :website =\u003e \"http://www.ziemannstreich.com\",\n        :toll_free_phone =\u003e \"1-800-871-0619\",\n                  :phone =\u003e \"(042)056-1534\",\n                    :fax =\u003e \"(106)017-8792\",\n             :deleted_at =\u003e nil,\n             :created_at =\u003e Tue, 09 Feb 2010 13:32:10 UTC +00:00,\n             :updated_at =\u003e Tue, 09 Feb 2010 20:05:01 UTC +00:00,\n                  :email =\u003e \"info@ziemannstreich.com\",\n        :background_info =\u003e nil\n    }\n]\nrails\u003e ap Account\nclass Account \u003c ActiveRecord::Base {\n                 :id =\u003e :integer,\n            :user_id =\u003e :integer,\n        :assigned_to =\u003e :integer,\n               :name =\u003e :string,\n             :access =\u003e :string,\n            :website =\u003e :string,\n    :toll_free_phone =\u003e :string,\n              :phone =\u003e :string,\n                :fax =\u003e :string,\n         :deleted_at =\u003e :datetime,\n         :created_at =\u003e :datetime,\n         :updated_at =\u003e :datetime,\n              :email =\u003e :string,\n    :background_info =\u003e :string\n}\nrails\u003e\n```\n\n### IRB integration ###\nTo use awesome_print as default formatter in irb and Rails console add the following\ncode to your ~/.irbrc file:\n\n```ruby\nrequire \"awesome_print\"\nAwesomePrint.irb!\n```\n\n### PRY integration ###\nIf you miss awesome_print's way of formatting output, here's how you can use it in place\nof the formatting which comes with pry. Add the following code to your `~/.pryrc` \nor your project's `./.pryrc`:\n\n```ruby\nrequire \"awesome_print\"\nAwesomePrint.pry!\n```\n\n### Logger Convenience Method ###\nawesome_print adds the 'ap' method to the Logger and ActiveSupport::BufferedLogger classes\nletting you call:\n\n    logger.ap object\n\nBy default, this logs at the :debug level. You can override that globally with:\n\n    :log_level =\u003e :info\n\nin the custom defaults (see below). You can also override on a per call basis with:\n\n    logger.ap object, :warn\n\n### ActionView Convenience Method ###\nawesome_print adds the 'ap' method to the ActionView::Base class making it available\nwithin Rails templates. For example:\n\n    \u003c%= ap @accounts.first %\u003e   # ERB\n    != ap @accounts.first       # HAML\n\nWith other web frameworks (ex: in Sinatra templates) you can explicitly request HTML\nformatting:\n\n    \u003c%= ap @accounts.first, :html =\u003e true %\u003e\n\n### String Convenience Methods ###\nUse methods such as `.red` to set string color:\n\n```ruby\nirb\u003e puts \"red text\".red\nred text # (it's red)\n```\n\n### Setting Custom Defaults ###\nYou can set your own default options by creating ``.aprc`` file in your home\ndirectory. Within that file assign your  defaults to ``AwesomePrint.defaults``.\nFor example:\n\n```ruby\n# ~/.aprc file.\nAwesomePrint.defaults = {\n  :indent =\u003e -2,\n  :color =\u003e {\n    :hash  =\u003e :pale,\n    :class =\u003e :white\n  }\n}\n```\n\n## Versioning\n\nAwesomePrint follows the [Semantic Versioning](http://semver.org/) standard.\n\n### Contributing ###\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for information.\n\n### License ###\nCopyright (c) 2010-2016 Michael Dvorkin and contributors\n\nhttp://www.dvorkin.net\n\n%w(mike dvorkin.net) * \"@\" || \"twitter.com/mid\"\n\nReleased under the MIT license. See LICENSE file for details.\n\n[gem_version_badge]: https://img.shields.io/gem/v/awesome_print.svg?style=flat\n[gem_downloads_badge]: http://img.shields.io/gem/dt/awesome_print.svg?style=flat\n[ruby_gems]: http://rubygems.org/gems/awesome_print\n[travis_ci]: http://travis-ci.org/awesome-print/awesome_print\n[travis_ci_badge]: https://img.shields.io/travis/awesome-print/awesome_print/master.svg?style=flat\n[code_climate]: https://codeclimate.com/github/awesome-print/awesome_print\n[code_climate_badge]: http://img.shields.io/codeclimate/github/awesome-print/awesome_print.svg?style=flat\n[code_climate_coverage_badge]: https://codeclimate.com/github/awesome-print/awesome_print/badges/coverage.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawesome-print%2Fawesome_print","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawesome-print%2Fawesome_print","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawesome-print%2Fawesome_print/lists"}