amazing_print 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +35 -0
  3. data/Appraisals +60 -0
  4. data/CHANGELOG.md +2 -0
  5. data/CONTRIBUTING.md +81 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +21 -0
  8. data/README.md +356 -0
  9. data/Rakefile +23 -0
  10. data/lib/amazing_print.rb +46 -0
  11. data/lib/amazing_print/colorize.rb +25 -0
  12. data/lib/amazing_print/core_ext/awesome_method_array.rb +82 -0
  13. data/lib/amazing_print/core_ext/class.rb +23 -0
  14. data/lib/amazing_print/core_ext/kernel.rb +25 -0
  15. data/lib/amazing_print/core_ext/logger.rb +21 -0
  16. data/lib/amazing_print/core_ext/method.rb +21 -0
  17. data/lib/amazing_print/core_ext/object.rb +23 -0
  18. data/lib/amazing_print/core_ext/string.rb +42 -0
  19. data/lib/amazing_print/custom_defaults.rb +57 -0
  20. data/lib/amazing_print/ext/action_view.rb +22 -0
  21. data/lib/amazing_print/ext/active_record.rb +103 -0
  22. data/lib/amazing_print/ext/active_support.rb +45 -0
  23. data/lib/amazing_print/ext/mongo_mapper.rb +125 -0
  24. data/lib/amazing_print/ext/mongoid.rb +68 -0
  25. data/lib/amazing_print/ext/nobrainer.rb +53 -0
  26. data/lib/amazing_print/ext/nokogiri.rb +45 -0
  27. data/lib/amazing_print/ext/ostruct.rb +27 -0
  28. data/lib/amazing_print/ext/ripple.rb +71 -0
  29. data/lib/amazing_print/ext/sequel.rb +55 -0
  30. data/lib/amazing_print/formatter.rb +120 -0
  31. data/lib/amazing_print/formatters.rb +14 -0
  32. data/lib/amazing_print/formatters/array_formatter.rb +139 -0
  33. data/lib/amazing_print/formatters/base_formatter.rb +148 -0
  34. data/lib/amazing_print/formatters/class_formatter.rb +24 -0
  35. data/lib/amazing_print/formatters/dir_formatter.rb +21 -0
  36. data/lib/amazing_print/formatters/file_formatter.rb +21 -0
  37. data/lib/amazing_print/formatters/hash_formatter.rb +106 -0
  38. data/lib/amazing_print/formatters/method_formatter.rb +21 -0
  39. data/lib/amazing_print/formatters/object_formatter.rb +82 -0
  40. data/lib/amazing_print/formatters/simple_formatter.rb +20 -0
  41. data/lib/amazing_print/formatters/struct_formatter.rb +74 -0
  42. data/lib/amazing_print/indentator.rb +17 -0
  43. data/lib/amazing_print/inspector.rb +175 -0
  44. data/lib/amazing_print/version.rb +10 -0
  45. data/lib/ap.rb +10 -0
  46. data/spec/active_record_helper.rb +30 -0
  47. data/spec/colors_spec.rb +114 -0
  48. data/spec/core_ext/logger_spec.rb +44 -0
  49. data/spec/core_ext/string_spec.rb +20 -0
  50. data/spec/ext/action_view_spec.rb +17 -0
  51. data/spec/ext/active_record_spec.rb +297 -0
  52. data/spec/ext/active_support_spec.rb +26 -0
  53. data/spec/ext/mongo_mapper_spec.rb +259 -0
  54. data/spec/ext/mongoid_spec.rb +66 -0
  55. data/spec/ext/nobrainer_spec.rb +58 -0
  56. data/spec/ext/nokogiri_spec.rb +50 -0
  57. data/spec/ext/ostruct_spec.rb +22 -0
  58. data/spec/ext/ripple_spec.rb +47 -0
  59. data/spec/formats_spec.rb +779 -0
  60. data/spec/methods_spec.rb +478 -0
  61. data/spec/misc_spec.rb +245 -0
  62. data/spec/objects_spec.rb +219 -0
  63. data/spec/spec_helper.rb +106 -0
  64. data/spec/support/active_record_data.rb +20 -0
  65. data/spec/support/active_record_data/3_2_diana.txt +24 -0
  66. data/spec/support/active_record_data/3_2_diana_legacy.txt +24 -0
  67. data/spec/support/active_record_data/3_2_multi.txt +50 -0
  68. data/spec/support/active_record_data/3_2_multi_legacy.txt +50 -0
  69. data/spec/support/active_record_data/4_0_diana.txt +98 -0
  70. data/spec/support/active_record_data/4_0_multi.txt +198 -0
  71. data/spec/support/active_record_data/4_1_diana.txt +97 -0
  72. data/spec/support/active_record_data/4_1_multi.txt +196 -0
  73. data/spec/support/active_record_data/4_2_diana.txt +109 -0
  74. data/spec/support/active_record_data/4_2_diana_legacy.txt +109 -0
  75. data/spec/support/active_record_data/4_2_multi.txt +220 -0
  76. data/spec/support/active_record_data/4_2_multi_legacy.txt +220 -0
  77. data/spec/support/active_record_data/5_0_diana.txt +105 -0
  78. data/spec/support/active_record_data/5_0_multi.txt +212 -0
  79. data/spec/support/active_record_data/5_1_diana.txt +104 -0
  80. data/spec/support/active_record_data/5_1_multi.txt +210 -0
  81. data/spec/support/active_record_data/5_2_diana.txt +104 -0
  82. data/spec/support/active_record_data/5_2_multi.txt +210 -0
  83. data/spec/support/active_record_data/6_0_diana.txt +104 -0
  84. data/spec/support/active_record_data/6_0_multi.txt +210 -0
  85. data/spec/support/ext_verifier.rb +41 -0
  86. data/spec/support/mongoid_versions.rb +22 -0
  87. data/spec/support/rails_versions.rb +50 -0
  88. metadata +243 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 806491a973073e36b330fad7b64e69dbc283647d2509609c5aa79d24269ee17b
4
+ data.tar.gz: 96ec9502e108582a6f54f01950d52b5de151928af721bcb8c4696f4a10baa14a
5
+ SHA512:
6
+ metadata.gz: 33030793c2ebf21436b3633a5316e961ad73e5caed621509a36447146ba452634ff5a5ab791002382e07fccf43e3f06b4fbea594e17cf057ae7839629ca2864e
7
+ data.tar.gz: d401f7bb5f85f052a6155864dfbbdb73c257f2b0e982226ecf203b6a024f05b8f3e30413d82ae2c02a983363fdd46a44c4ed7f6cfbe57395727d1eb69f0785c8
@@ -0,0 +1,35 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## RUBYMINE
17
+ .idea
18
+
19
+ ## PROJECT::GENERAL
20
+ coverage
21
+ rdoc
22
+ pkg
23
+ .ruby-version
24
+ gemfiles/*.gemfile.lock
25
+ Gemfile.lock
26
+ /tmp
27
+ /.bundle
28
+ /gemfiles/.bundle
29
+
30
+ ## PROJECT::RVM
31
+ .rvmrc
32
+
33
+ # PROJECT::RBENV
34
+ .ruby-gemset
35
+ .awesome-print/
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # appraise 'rails-4.2' do
4
+ # gem 'rails', '~> 4.2.0'
5
+ #
6
+ # # The last version that doesn't need Ruby 2.0 and works with version 4.2 of
7
+ # # Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby
8
+ # gem 'mime-types', '2.6.2', :platforms => :ruby_19
9
+ # end
10
+
11
+ appraise 'rails-5.1' do
12
+ gem 'activerecord-jdbcsqlite3-adapter', '~> 51.0', platform: :jruby
13
+ gem 'rails', '~> 5.1.0'
14
+ gem 'sqlite3', platform: :mri
15
+ end
16
+
17
+ appraise 'rails-5.2' do
18
+ gem 'activerecord-jdbcsqlite3-adapter', '~> 52.0', platform: :jruby
19
+ gem 'rails', '~> 5.2.0'
20
+ gem 'sqlite3', platform: :mri
21
+ end
22
+
23
+ appraise 'rails-6.0' do
24
+ gem 'activerecord-jdbcsqlite3-adapter', '~> 60.0', platform: :jruby
25
+ gem 'rails', '~> 6.0.0'
26
+ gem 'sqlite3', platform: :mri
27
+ end
28
+
29
+ appraise 'mongoid-4.0' do
30
+ # https://github.com/rails/rails/issues/34822#issuecomment-570670516
31
+ gem 'bigdecimal', '~> 1.4', platforms: :mri
32
+ gem 'mongoid', '~> 4.0.0'
33
+ end
34
+
35
+ appraise 'mongoid-5.0' do
36
+ # https://github.com/rails/rails/issues/34822#issuecomment-570670516
37
+ gem 'bigdecimal', '~> 1.4', platforms: :mri
38
+ gem 'mongoid', '~> 5.0.0'
39
+ end
40
+
41
+ appraise 'mongoid-6.0' do
42
+ gem 'mongoid', '~> 6.0.0'
43
+ end
44
+
45
+ # appraise 'mongo_mapper' do
46
+ # gem 'mongo_mapper'
47
+ # end
48
+ #
49
+ # appraise 'ripple' do
50
+ # gem 'tzinfo'
51
+ # gem 'ripple'
52
+ # end
53
+ #
54
+ # appraise 'nobrainer' do
55
+ # gem 'nobrainer'
56
+ #
57
+ # # When activesupport 5 was released, it required ruby 2.2.2 as a minimum.
58
+ # # Locking this down to 4.2.6 allows our Ruby 1.9 tests to keep working.
59
+ # gem 'activesupport', '4.2.6', :platforms => :ruby_19
60
+ # end
@@ -0,0 +1,2 @@
1
+ ## v1.0.0
2
+ - Initial Release.
@@ -0,0 +1,81 @@
1
+ # Contributing
2
+
3
+ We love pull requests. Here's a quick guide:
4
+
5
+ 1. Fork the repo.
6
+
7
+ 1. Create your feature branch (`git checkout -b my-new-feature`)
8
+
9
+ 1. Update CHANGELOG.md with a brief description of your changes under the `unreleased` heading.
10
+
11
+ 1. Add/Update tests were appropriate
12
+
13
+ 1. Commit your changes (`git commit -am 'Added some feature'`)
14
+
15
+ 1. Push to the branch (`git push origin my-new-feature`)
16
+
17
+ 1. Create new Pull Request
18
+
19
+ At this point you're waiting on us. We are not super fast at responding, but we will do our best to get to your PR as soon as time permits. We may suggest some changes, improvements or alternatives.
20
+
21
+ Some things that will increase the chance that your pull request is accepted is to follow the practices described on [Ruby style guide](https://github.com/bbatsov/ruby-style-guide), [Rails style guide](https://github.com/bbatsov/rails-style-guide) and [Better Specs](http://betterspecs.org/).
22
+
23
+ ## Specs
24
+
25
+ To run all the specs in all gemfiles just run:
26
+
27
+ ```
28
+ $ rake
29
+ ```
30
+
31
+ To run specs of a single gemfile run:
32
+
33
+ ```
34
+ $ appraisal rails-3.2 rake
35
+ ```
36
+
37
+ If you want to run a specific spec in a gemfile run:
38
+
39
+ ```
40
+ $ appraisal rails-3.2 rspec spec/colors_spec.rb
41
+ ```
42
+
43
+ ## Contributor Rolecall
44
+
45
+ Special thanks goes to amazing team of contributors, namely:
46
+
47
+ * 6fusion.com -- https://github.com/6fusion
48
+ * Adam Doppelt -- https://github.com/gurgeous
49
+ * Andrew O'Brien -- https://github.com/AndrewO
50
+ * Andrew Horsman -- https://github.com/basicxman
51
+ * Barry Allard -- https://github.com/steakknife
52
+ * Benoit Daloze -- http://github.com/eregon
53
+ * Brandon Zylstra -- https://github.com/brandondrew
54
+ * Dan Lynn -- https://github.com/danlynn
55
+ * Daniel Johnson -- https://github.com/adhd360
56
+ * Daniel Bretoi -- http://github.com/danielb2
57
+ * Eloy Duran -- http://github.com/alloy
58
+ * Elpizo Choi -- https://github.com/fuJiin
59
+ * Evan Senter -- https://github.com/evansenter
60
+ * George . -- https://github.com/gardelea
61
+ * Greg Weber -- https://github.com/gregwebs
62
+ * Jan Vansteenkiste -- https://github.com/vStone
63
+ * Jeff Felchner -- https://github.com/jfelchner
64
+ * Jonathan Davies -- send your Github URL ;-)
65
+ * Kevin Olbrich -- https://github.com/olbrich
66
+ * Matthew Schulkind -- https://github.com/mschulkind
67
+ * Mike McQuaid -- https://github.com/mikemcquaid
68
+ * Nami-Doc -- https://github.com/Nami-Doc
69
+ * Nicolas Viennot -- https://github.com/nviennot
70
+ * Nikolaj Nikolajsen -- https://github.com/nikolajsen
71
+ * Richard Hall -- https://github.com/richardardrichard
72
+ * Ryan Schlesinger -- https://github.com/ryansch
73
+ * Scott Hyndman -- https://github.com/shyndman
74
+ * Sean Gallagher -- http://github.com/torandu
75
+ * Stephan Hagemann -- https://github.com/shageman
76
+ * Tim Harper -- http://github.com/timcharper
77
+ * Tobias Crawley -- http://github.com/tobias
78
+ * Thibaut Barrère -- https://github.com/thbar
79
+ * Trevor Wennblom -- https://github.com/trevor
80
+ * vfrride -- https://github.com/vfrride
81
+ * Viktar Basharymau -- https://github.com/DNNX
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in amazing_print.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 AmazingPrint
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,356 @@
1
+ ## Amazing Print ##
2
+
3
+ [![RubyGems][gem_version_badge]][ruby_gems]
4
+ [![Travis CI][travis_ci_badge]][travis_ci]
5
+ [![Code Climate][code_climate_badge]][code_climate]
6
+ [![Code Climate Coverage][code_climate_coverage_badge]][code_climate]
7
+ [![RubyGems][gem_downloads_badge]][ruby_gems]
8
+ [![Gitter](https://badges.gitter.im/amazing-print/community.svg)](https://gitter.im/amazing-print/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
9
+
10
+ Amazing Print is a fork of [AmazingPrint](https://github.com/awesome-print/awesome_print) which became stale and should be used in it's place to avoid conflicts. It is a Ruby library that pretty prints Ruby objects in full color exposing their internal structure with proper indentation. Rails ActiveRecord objects and usage within Rails templates are supported via included mixins.
11
+
12
+ ### Supported Versions ###
13
+
14
+ - Ruby >= 2.3
15
+ - Rails >= 5.1
16
+
17
+ ### Installation ###
18
+ # Installing as Ruby gem
19
+ $ gem install amazing_print
20
+
21
+ # Cloning the repository
22
+ $ git clone git://github.com/amazing-print/amazing_print.git
23
+
24
+ ### Usage ###
25
+
26
+ ```ruby
27
+ require "amazing_print"
28
+ ap object, options = {}
29
+ ```
30
+
31
+ Default options:
32
+
33
+ ```ruby
34
+ indent: 4, # Number of spaces for indenting.
35
+ index: true, # Display array indices.
36
+ html: false, # Use ANSI color codes rather than HTML.
37
+ multiline: true, # Display in multiple lines.
38
+ plain: false, # Use colors.
39
+ raw: false, # Do not recursively format instance variables.
40
+ sort_keys: false, # Do not sort hash keys.
41
+ sort_vars: true, # Sort instance variables.
42
+ limit: false, # Limit arrays & hashes. Accepts bool or int.
43
+ ruby19_syntax: false, # Use Ruby 1.9 hash syntax in output.
44
+ class_name: :class, # Method called to report the instance class name. (e.g. :to_s)
45
+ object_id: true, # Show object id.
46
+ color: {
47
+ args: :pale,
48
+ array: :white,
49
+ bigdecimal: :blue,
50
+ class: :yellow,
51
+ date: :greenish,
52
+ falseclass: :red,
53
+ integer: :blue,
54
+ float: :blue,
55
+ hash: :pale,
56
+ keyword: :cyan,
57
+ method: :purpleish,
58
+ nilclass: :red,
59
+ rational: :blue,
60
+ string: :yellowish,
61
+ struct: :pale,
62
+ symbol: :cyanish,
63
+ time: :greenish,
64
+ trueclass: :green,
65
+ variable: :cyanish
66
+ }
67
+ ```
68
+
69
+ Supported color names:
70
+
71
+ ```ruby
72
+ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white
73
+ :black, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :pale
74
+ ```
75
+
76
+ Use `Object#ai` to return an ASCII encoded string:
77
+
78
+ ```ruby
79
+ irb> "awesome print".ai
80
+ => "\e[0;33m\"awesome print\"\e[0m"
81
+ ```
82
+
83
+ ### Examples ###
84
+
85
+ ```ruby
86
+ $ cat > 1.rb
87
+ require "amazing_print"
88
+ data = [ false, 42, %w(forty two), { :now => Time.now, :class => Time.now.class, :distance => 42e42 } ]
89
+ ap data
90
+ ^D
91
+ $ ruby 1.rb
92
+ [
93
+ [0] false,
94
+ [1] 42,
95
+ [2] [
96
+ [0] "forty",
97
+ [1] "two"
98
+ ],
99
+ [3] {
100
+ :class => Time < Object,
101
+ :now => Fri Apr 02 19:55:53 -0700 2010,
102
+ :distance => 4.2e+43
103
+ }
104
+ ]
105
+
106
+ $ cat > 2.rb
107
+ require "amazing_print"
108
+ data = { :now => Time.now, :class => Time.now.class, :distance => 42e42 }
109
+ ap data, :indent => -2 # <-- Left align hash keys.
110
+ ^D
111
+ $ ruby 2.rb
112
+ {
113
+ :class => Time < Object,
114
+ :now => Fri Apr 02 19:55:53 -0700 2010,
115
+ :distance => 4.2e+43
116
+ }
117
+
118
+ $ cat > 3.rb
119
+ require "amazing_print"
120
+ data = [ false, 42, %w(forty two) ]
121
+ data << data # <-- Nested array.
122
+ ap data, :multiline => false
123
+ ^D
124
+ $ ruby 3.rb
125
+ [ false, 42, [ "forty", "two" ], [...] ]
126
+
127
+ $ cat > 4.rb
128
+ require "amazing_print"
129
+ class Hello
130
+ def self.world(x, y, z = nil, &blk)
131
+ end
132
+ end
133
+ ap Hello.methods - Class.methods
134
+ ^D
135
+ $ ruby 4.rb
136
+ [
137
+ [0] world(x, y, *z, &blk) Hello
138
+ ]
139
+
140
+ $ cat > 5.rb
141
+ require "amazing_print"
142
+ ap (''.methods - Object.methods).grep(/!/)
143
+ ^D
144
+ $ ruby 5.rb
145
+ [
146
+ [ 0] capitalize!() String
147
+ [ 1] chomp!(*arg1) String
148
+ [ 2] chop!() String
149
+ [ 3] delete!(*arg1) String
150
+ [ 4] downcase!() String
151
+ [ 5] encode!(*arg1) String
152
+ [ 6] gsub!(*arg1) String
153
+ [ 7] lstrip!() String
154
+ [ 8] next!() String
155
+ [ 9] reverse!() String
156
+ [10] rstrip!() String
157
+ [11] slice!(*arg1) String
158
+ [12] squeeze!(*arg1) String
159
+ [13] strip!() String
160
+ [14] sub!(*arg1) String
161
+ [15] succ!() String
162
+ [16] swapcase!() String
163
+ [17] tr!(arg1, arg2) String
164
+ [18] tr_s!(arg1, arg2) String
165
+ [19] upcase!() String
166
+ ]
167
+
168
+ $ cat > 6.rb
169
+ require "amazing_print"
170
+ ap 42 == ap(42)
171
+ ^D
172
+ $ ruby 6.rb
173
+ 42
174
+ true
175
+ $ cat 7.rb
176
+ require "amazing_print"
177
+ some_array = (1..1000).to_a
178
+ ap some_array, :limit => true
179
+ ^D
180
+ $ ruby 7.rb
181
+ [
182
+ [ 0] 1,
183
+ [ 1] 2,
184
+ [ 2] 3,
185
+ [ 3] .. [996],
186
+ [997] 998,
187
+ [998] 999,
188
+ [999] 1000
189
+ ]
190
+
191
+ $ cat 8.rb
192
+ require "amazing_print"
193
+ some_array = (1..1000).to_a
194
+ ap some_array, :limit => 5
195
+ ^D
196
+ $ ruby 8.rb
197
+ [
198
+ [ 0] 1,
199
+ [ 1] 2,
200
+ [ 2] .. [997],
201
+ [998] 999,
202
+ [999] 1000
203
+ ]
204
+ ```
205
+
206
+ ### Example (Rails console) ###
207
+ ```ruby
208
+ $ rails console
209
+ rails> require "amazing_print"
210
+ rails> ap Account.limit(2).all
211
+ [
212
+ [0] #<Account:0x1033220b8> {
213
+ :id => 1,
214
+ :user_id => 5,
215
+ :assigned_to => 7,
216
+ :name => "Hayes-DuBuque",
217
+ :access => "Public",
218
+ :website => "http://www.hayesdubuque.com",
219
+ :toll_free_phone => "1-800-932-6571",
220
+ :phone => "(111)549-5002",
221
+ :fax => "(349)415-2266",
222
+ :deleted_at => nil,
223
+ :created_at => Sat, 06 Mar 2010 09:46:10 UTC +00:00,
224
+ :updated_at => Sat, 06 Mar 2010 16:33:10 UTC +00:00,
225
+ :email => "info@hayesdubuque.com",
226
+ :background_info => nil
227
+ },
228
+ [1] #<Account:0x103321ff0> {
229
+ :id => 2,
230
+ :user_id => 4,
231
+ :assigned_to => 4,
232
+ :name => "Ziemann-Streich",
233
+ :access => "Public",
234
+ :website => "http://www.ziemannstreich.com",
235
+ :toll_free_phone => "1-800-871-0619",
236
+ :phone => "(042)056-1534",
237
+ :fax => "(106)017-8792",
238
+ :deleted_at => nil,
239
+ :created_at => Tue, 09 Feb 2010 13:32:10 UTC +00:00,
240
+ :updated_at => Tue, 09 Feb 2010 20:05:01 UTC +00:00,
241
+ :email => "info@ziemannstreich.com",
242
+ :background_info => nil
243
+ }
244
+ ]
245
+ rails> ap Account
246
+ class Account < ActiveRecord::Base {
247
+ :id => :integer,
248
+ :user_id => :integer,
249
+ :assigned_to => :integer,
250
+ :name => :string,
251
+ :access => :string,
252
+ :website => :string,
253
+ :toll_free_phone => :string,
254
+ :phone => :string,
255
+ :fax => :string,
256
+ :deleted_at => :datetime,
257
+ :created_at => :datetime,
258
+ :updated_at => :datetime,
259
+ :email => :string,
260
+ :background_info => :string
261
+ }
262
+ rails>
263
+ ```
264
+
265
+ ### IRB integration ###
266
+ To use amazing_print as default formatter in irb and Rails console add the following
267
+ code to your ~/.irbrc file:
268
+
269
+ ```ruby
270
+ require "amazing_print"
271
+ AmazingPrint.irb!
272
+ ```
273
+
274
+ ### PRY integration ###
275
+ If you miss amazing_print's way of formatting output, here's how you can use it in place
276
+ of the formatting which comes with pry. Add the following code to your ~/.pryrc:
277
+
278
+ ```ruby
279
+ require "amazing_print"
280
+ AmazingPrint.pry!
281
+ ```
282
+
283
+ ### Logger Convenience Method ###
284
+ amazing_print adds the 'ap' method to the Logger and ActiveSupport::BufferedLogger classes
285
+ letting you call:
286
+
287
+ logger.ap object
288
+
289
+ By default, this logs at the :debug level. You can override that globally with:
290
+
291
+ :log_level => :info
292
+
293
+ in the custom defaults (see below). You can also override on a per call basis with:
294
+
295
+ logger.ap object, :warn
296
+
297
+ ### ActionView Convenience Method ###
298
+ amazing_print adds the 'ap' method to the ActionView::Base class making it available
299
+ within Rails templates. For example:
300
+
301
+ <%= ap @accounts.first %> # ERB
302
+ != ap @accounts.first # HAML
303
+
304
+ With other web frameworks (ex: in Sinatra templates) you can explicitly request HTML
305
+ formatting:
306
+
307
+ <%= ap @accounts.first, :html => true %>
308
+
309
+ ### String Convenience Methods ###
310
+ Use methods such as `.red` to set string color:
311
+
312
+ ```ruby
313
+ irb> puts "red text".red
314
+ red text # (it's red)
315
+ ```
316
+
317
+ ### Setting Custom Defaults ###
318
+ You can set your own default options by creating ``.aprc`` file in your home
319
+ directory. Within that file assign your defaults to ``AmazingPrint.defaults``.
320
+ For example:
321
+
322
+ ```ruby
323
+ # ~/.aprc file.
324
+ AmazingPrint.defaults = {
325
+ :indent => -2,
326
+ :color => {
327
+ :hash => :pale,
328
+ :class => :white
329
+ }
330
+ }
331
+ ```
332
+
333
+ ## Versioning
334
+
335
+ AmazingPrint follows the [Semantic Versioning](http://semver.org/) standard.
336
+
337
+ ### Contributing ###
338
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for information.
339
+
340
+ ### License ###
341
+ Copyright (c) 2010-2016 Michael Dvorkin and contributors
342
+
343
+ http://www.dvorkin.net
344
+
345
+ %w(mike dvorkin.net) * "@" || "twitter.com/mid"
346
+
347
+ Released under the MIT license. See LICENSE file for details.
348
+
349
+ [gem_version_badge]: https://img.shields.io/gem/v/amazing_print.svg?style=flat
350
+ [gem_downloads_badge]: http://img.shields.io/gem/dt/amazing_print.svg?style=flat
351
+ [ruby_gems]: http://rubygems.org/gems/amazing_print
352
+ [travis_ci]: http://travis-ci.org/amazing-print/amazing_print
353
+ [travis_ci_badge]: https://img.shields.io/travis/amazing-print/amazing_print/master.svg?style=flat
354
+ [code_climate]: https://codeclimate.com/github/amazing-print/amazing_print
355
+ [code_climate_badge]: http://img.shields.io/codeclimate/github/amazing-print/amazing_print.svg?style=flat
356
+ [code_climate_coverage_badge]: https://codeclimate.com/github/amazing-print/amazing_print/badges/coverage.svg