awesome_print 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -17,6 +17,7 @@ tmtags
17
17
  coverage
18
18
  rdoc
19
19
  pkg
20
+ Gemfile.lock
20
21
 
21
22
  ## PROJECT::SPECIFIC
22
23
  .rvmrc
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 1.2.0 <-- NOTE: This is the *last* release supporting Ruby < v1.9.3 and Rails < v3.
2
+ - Added Sequel ORM plugin (Jonathan Davies)
3
+ - Added Ripple plugin (Ruby modeling layer for Riak, Scott Hyndman)
4
+ - Added NoBrainer plugin (Ruby ORM for RethinkDB, Nicolas Viennot)
5
+ - Added formatting for Ruby set objects (Richard Hall)
6
+ - Fixed HTML formatting (Mike McQuaid)
7
+ - Other minor bugs and enhancements
8
+
1
9
  1.1.0
2
10
  - Objects are no longer recursively formatted by default. Reenable by using :raw => true option.
3
11
  - ap(object) now returns nil when running under IRB or Pry
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
  gemspec
3
3
 
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- awesome_print (1.0.2)
4
+ awesome_print (1.1.0)
5
5
 
6
6
  GEM
7
- remote: http://rubygems.org/
7
+ remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.1.2)
9
+ diff-lcs (1.1.3)
10
10
  fakefs (0.3.2)
11
- rspec (2.6.0)
12
- rspec-core (~> 2.6.0)
13
- rspec-expectations (~> 2.6.0)
14
- rspec-mocks (~> 2.6.0)
15
- rspec-core (2.6.4)
16
- rspec-expectations (2.6.0)
17
- diff-lcs (~> 1.1.2)
18
- rspec-mocks (2.6.0)
11
+ rspec (2.11.0)
12
+ rspec-core (~> 2.11.0)
13
+ rspec-expectations (~> 2.11.0)
14
+ rspec-mocks (~> 2.11.0)
15
+ rspec-core (2.11.1)
16
+ rspec-expectations (2.11.2)
17
+ diff-lcs (~> 1.1.3)
18
+ rspec-mocks (2.11.2)
19
19
 
20
20
  PLATFORMS
21
21
  ruby
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2012 Michael Dvorkin
1
+ Copyright (c) 2010-2013 Michael Dvorkin
2
2
  http://www.dvorkin.net
3
3
  %w(mike dvorkin.net) * "@" || %w(mike fatfreecrm.com) * "@"
4
4
 
data/README.md CHANGED
@@ -3,6 +3,10 @@ Awesome Print is a Ruby library that pretty prints Ruby objects in full color
3
3
  exposing their internal structure with proper indentation. Rails ActiveRecord
4
4
  objects and usage within Rails templates are supported via included mixins.
5
5
 
6
+ __NOTE__: awesome_print v1.2.0 is the last release supporting Ruby versions
7
+ prior to v1.9.3 and Rails versions prior to v3.0. The upcoming awesome_print
8
+ v2.0 will *require* Ruby v1.9.3 or later and Rails v3.0 or later.
9
+
6
10
  ### Installation ###
7
11
  # Installing as Ruby gem
8
12
  $ gem install awesome_print
@@ -12,236 +16,251 @@ objects and usage within Rails templates are supported via included mixins.
12
16
 
13
17
  ### Usage ###
14
18
 
15
- require "awesome_print"
16
- ap object, options = {}
19
+ ```ruby
20
+ require "awesome_print"
21
+ ap object, options = {}
22
+ ```
17
23
 
18
24
  Default options:
19
25
 
20
- :indent => 4, # Indent using 4 spaces.
21
- :index => true, # Display array indices.
22
- :html => false, # Use ANSI color codes rather than HTML.
23
- :multiline => true, # Display in multiple lines.
24
- :plain => false, # Use colors.
25
- :raw => false, # Do not recursively format object instance variables.
26
- :sort_keys => false, # Do not sort hash keys.
27
- :limit => false, # Limit large output for arrays and hashes. Set to a boolean or integer.
28
- :color => {
29
- :args => :pale,
30
- :array => :white,
31
- :bigdecimal => :blue,
32
- :class => :yellow,
33
- :date => :greenish,
34
- :falseclass => :red,
35
- :fixnum => :blue,
36
- :float => :blue,
37
- :hash => :pale,
38
- :keyword => :cyan,
39
- :method => :purpleish,
40
- :nilclass => :red,
41
- :rational => :blue,
42
- :string => :yellowish,
43
- :struct => :pale,
44
- :symbol => :cyanish,
45
- :time => :greenish,
46
- :trueclass => :green,
47
- :variable => :cyanish
48
- }
26
+ ```ruby
27
+ :indent => 4, # Indent using 4 spaces.
28
+ :index => true, # Display array indices.
29
+ :html => false, # Use ANSI color codes rather than HTML.
30
+ :multiline => true, # Display in multiple lines.
31
+ :plain => false, # Use colors.
32
+ :raw => false, # Do not recursively format object instance variables.
33
+ :sort_keys => false, # Do not sort hash keys.
34
+ :limit => false, # Limit large output for arrays and hashes. Set to a boolean or integer.
35
+ :color => {
36
+ :args => :pale,
37
+ :array => :white,
38
+ :bigdecimal => :blue,
39
+ :class => :yellow,
40
+ :date => :greenish,
41
+ :falseclass => :red,
42
+ :fixnum => :blue,
43
+ :float => :blue,
44
+ :hash => :pale,
45
+ :keyword => :cyan,
46
+ :method => :purpleish,
47
+ :nilclass => :red,
48
+ :rational => :blue,
49
+ :string => :yellowish,
50
+ :struct => :pale,
51
+ :symbol => :cyanish,
52
+ :time => :greenish,
53
+ :trueclass => :green,
54
+ :variable => :cyanish
55
+ }
56
+ ```
49
57
 
50
58
  Supported color names:
51
59
 
52
- :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white
53
- :black, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :pale
60
+ ```ruby
61
+ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white
62
+ :black, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :pale
63
+ ```
54
64
 
55
65
  ### Examples ###
56
- $ cat > 1.rb
57
- require "awesome_print"
58
- data = [ false, 42, %w(forty two), { :now => Time.now, :class => Time.now.class, :distance => 42e42 } ]
59
- ap data
60
- ^D
61
- $ ruby 1.rb
62
- [
63
- [0] false,
64
- [1] 42,
65
- [2] [
66
- [0] "forty",
67
- [1] "two"
68
- ],
69
- [3] {
70
- :class => Time < Object,
71
- :now => Fri Apr 02 19:55:53 -0700 2010,
72
- :distance => 4.2e+43
73
- }
74
- ]
75
-
76
- $ cat > 2.rb
77
- require "awesome_print"
78
- data = { :now => Time.now, :class => Time.now.class, :distance => 42e42 }
79
- ap data, :indent => -2 # <-- Left align hash keys.
80
- ^D
81
- $ ruby 2.rb
82
- {
83
- :class => Time < Object,
84
- :now => Fri Apr 02 19:55:53 -0700 2010,
85
- :distance => 4.2e+43
86
- }
87
66
 
88
- $ cat > 3.rb
89
- require "awesome_print"
90
- data = [ false, 42, %w(forty two) ]
91
- data << data # <-- Nested array.
92
- ap data, :multiline => false
93
- ^D
94
- $ ruby 3.rb
95
- [ false, 42, [ "forty", "two" ], [...] ]
96
-
97
- $ cat > 4.rb
98
- require "awesome_print"
99
- class Hello
100
- def self.world(x, y, z = nil, &blk)
101
- end
102
- end
103
- ap Hello.methods - Class.methods
104
- ^D
105
- $ ruby 4.rb
106
- [
107
- [0] world(x, y, *z, &blk) Hello
108
- ]
109
-
110
- $ cat > 5.rb
111
- require "awesome_print"
112
- ap (''.methods - Object.methods).grep(/!/)
113
- ^D
114
- $ ruby 5.rb
115
- [
116
- [ 0] capitalize!() String
117
- [ 1] chomp!(*arg1) String
118
- [ 2] chop!() String
119
- [ 3] delete!(*arg1) String
120
- [ 4] downcase!() String
121
- [ 5] encode!(*arg1) String
122
- [ 6] gsub!(*arg1) String
123
- [ 7] lstrip!() String
124
- [ 8] next!() String
125
- [ 9] reverse!() String
126
- [10] rstrip!() String
127
- [11] slice!(*arg1) String
128
- [12] squeeze!(*arg1) String
129
- [13] strip!() String
130
- [14] sub!(*arg1) String
131
- [15] succ!() String
132
- [16] swapcase!() String
133
- [17] tr!(arg1, arg2) String
134
- [18] tr_s!(arg1, arg2) String
135
- [19] upcase!() String
136
- ]
137
-
138
- $ cat > 6.rb
139
- require "awesome_print"
140
- ap 42 == ap(42)
141
- ^D
142
- $ ruby 6.rb
143
- 42
144
- true
145
- $ cat 7.rb
146
- require "awesome_print"
147
- some_array = (1..1000).to_a
148
- ap some_array, :limit => true
149
- ^D
150
- $ ruby 7.rb
151
- [
152
- [ 0] 1,
153
- [ 1] 2,
154
- [ 2] 3,
155
- [ 3] .. [996],
156
- [997] 998,
157
- [998] 999,
158
- [999] 1000
159
- ]
160
-
161
- $ cat 8.rb
162
- require "awesome_print"
163
- some_array = (1..1000).to_a
164
- ap some_array, :limit => 5
165
- ^D
166
- $ ruby 8.rb
167
- [
168
- [ 0] 1,
169
- [ 1] 2,
170
- [ 2] .. [997],
171
- [998] 999,
172
- [999] 1000
173
- ]
67
+ ```ruby
68
+ $ cat > 1.rb
69
+ require "awesome_print"
70
+ data = [ false, 42, %w(forty two), { :now => Time.now, :class => Time.now.class, :distance => 42e42 } ]
71
+ ap data
72
+ ^D
73
+ $ ruby 1.rb
74
+ [
75
+ [0] false,
76
+ [1] 42,
77
+ [2] [
78
+ [0] "forty",
79
+ [1] "two"
80
+ ],
81
+ [3] {
82
+ :class => Time < Object,
83
+ :now => Fri Apr 02 19:55:53 -0700 2010,
84
+ :distance => 4.2e+43
85
+ }
86
+ ]
87
+
88
+ $ cat > 2.rb
89
+ require "awesome_print"
90
+ data = { :now => Time.now, :class => Time.now.class, :distance => 42e42 }
91
+ ap data, :indent => -2 # <-- Left align hash keys.
92
+ ^D
93
+ $ ruby 2.rb
94
+ {
95
+ :class => Time < Object,
96
+ :now => Fri Apr 02 19:55:53 -0700 2010,
97
+ :distance => 4.2e+43
98
+ }
99
+
100
+ $ cat > 3.rb
101
+ require "awesome_print"
102
+ data = [ false, 42, %w(forty two) ]
103
+ data << data # <-- Nested array.
104
+ ap data, :multiline => false
105
+ ^D
106
+ $ ruby 3.rb
107
+ [ false, 42, [ "forty", "two" ], [...] ]
108
+
109
+ $ cat > 4.rb
110
+ require "awesome_print"
111
+ class Hello
112
+ def self.world(x, y, z = nil, &blk)
113
+ end
114
+ end
115
+ ap Hello.methods - Class.methods
116
+ ^D
117
+ $ ruby 4.rb
118
+ [
119
+ [0] world(x, y, *z, &blk) Hello
120
+ ]
121
+
122
+ $ cat > 5.rb
123
+ require "awesome_print"
124
+ ap (''.methods - Object.methods).grep(/!/)
125
+ ^D
126
+ $ ruby 5.rb
127
+ [
128
+ [ 0] capitalize!() String
129
+ [ 1] chomp!(*arg1) String
130
+ [ 2] chop!() String
131
+ [ 3] delete!(*arg1) String
132
+ [ 4] downcase!() String
133
+ [ 5] encode!(*arg1) String
134
+ [ 6] gsub!(*arg1) String
135
+ [ 7] lstrip!() String
136
+ [ 8] next!() String
137
+ [ 9] reverse!() String
138
+ [10] rstrip!() String
139
+ [11] slice!(*arg1) String
140
+ [12] squeeze!(*arg1) String
141
+ [13] strip!() String
142
+ [14] sub!(*arg1) String
143
+ [15] succ!() String
144
+ [16] swapcase!() String
145
+ [17] tr!(arg1, arg2) String
146
+ [18] tr_s!(arg1, arg2) String
147
+ [19] upcase!() String
148
+ ]
149
+
150
+ $ cat > 6.rb
151
+ require "awesome_print"
152
+ ap 42 == ap(42)
153
+ ^D
154
+ $ ruby 6.rb
155
+ 42
156
+ true
157
+ $ cat 7.rb
158
+ require "awesome_print"
159
+ some_array = (1..1000).to_a
160
+ ap some_array, :limit => true
161
+ ^D
162
+ $ ruby 7.rb
163
+ [
164
+ [ 0] 1,
165
+ [ 1] 2,
166
+ [ 2] 3,
167
+ [ 3] .. [996],
168
+ [997] 998,
169
+ [998] 999,
170
+ [999] 1000
171
+ ]
172
+
173
+ $ cat 8.rb
174
+ require "awesome_print"
175
+ some_array = (1..1000).to_a
176
+ ap some_array, :limit => 5
177
+ ^D
178
+ $ ruby 8.rb
179
+ [
180
+ [ 0] 1,
181
+ [ 1] 2,
182
+ [ 2] .. [997],
183
+ [998] 999,
184
+ [999] 1000
185
+ ]
186
+ ```
174
187
 
175
188
  ### Example (Rails console) ###
176
- $ rails console
177
- rails> require "awesome_print"
178
- rails> ap Account.all(:limit => 2)
179
- [
180
- [0] #<Account:0x1033220b8> {
181
- :id => 1,
182
- :user_id => 5,
183
- :assigned_to => 7,
184
- :name => "Hayes-DuBuque",
185
- :access => "Public",
186
- :website => "http://www.hayesdubuque.com",
187
- :toll_free_phone => "1-800-932-6571",
188
- :phone => "(111)549-5002",
189
- :fax => "(349)415-2266",
190
- :deleted_at => nil,
191
- :created_at => Sat, 06 Mar 2010 09:46:10 UTC +00:00,
192
- :updated_at => Sat, 06 Mar 2010 16:33:10 UTC +00:00,
193
- :email => "info@hayesdubuque.com",
194
- :background_info => nil
195
- },
196
- [1] #<Account:0x103321ff0> {
197
- :id => 2,
198
- :user_id => 4,
199
- :assigned_to => 4,
200
- :name => "Ziemann-Streich",
201
- :access => "Public",
202
- :website => "http://www.ziemannstreich.com",
203
- :toll_free_phone => "1-800-871-0619",
204
- :phone => "(042)056-1534",
205
- :fax => "(106)017-8792",
206
- :deleted_at => nil,
207
- :created_at => Tue, 09 Feb 2010 13:32:10 UTC +00:00,
208
- :updated_at => Tue, 09 Feb 2010 20:05:01 UTC +00:00,
209
- :email => "info@ziemannstreich.com",
210
- :background_info => nil
211
- }
212
- ]
213
- rails> ap Account
214
- class Account < ActiveRecord::Base {
215
- :id => :integer,
216
- :user_id => :integer,
217
- :assigned_to => :integer,
218
- :name => :string,
219
- :access => :string,
220
- :website => :string,
221
- :toll_free_phone => :string,
222
- :phone => :string,
223
- :fax => :string,
224
- :deleted_at => :datetime,
225
- :created_at => :datetime,
226
- :updated_at => :datetime,
227
- :email => :string,
228
- :background_info => :string
189
+ ```ruby
190
+ $ rails console
191
+ rails> require "awesome_print"
192
+ rails> ap Account.limit(2).all
193
+ [
194
+ [0] #<Account:0x1033220b8> {
195
+ :id => 1,
196
+ :user_id => 5,
197
+ :assigned_to => 7,
198
+ :name => "Hayes-DuBuque",
199
+ :access => "Public",
200
+ :website => "http://www.hayesdubuque.com",
201
+ :toll_free_phone => "1-800-932-6571",
202
+ :phone => "(111)549-5002",
203
+ :fax => "(349)415-2266",
204
+ :deleted_at => nil,
205
+ :created_at => Sat, 06 Mar 2010 09:46:10 UTC +00:00,
206
+ :updated_at => Sat, 06 Mar 2010 16:33:10 UTC +00:00,
207
+ :email => "info@hayesdubuque.com",
208
+ :background_info => nil
209
+ },
210
+ [1] #<Account:0x103321ff0> {
211
+ :id => 2,
212
+ :user_id => 4,
213
+ :assigned_to => 4,
214
+ :name => "Ziemann-Streich",
215
+ :access => "Public",
216
+ :website => "http://www.ziemannstreich.com",
217
+ :toll_free_phone => "1-800-871-0619",
218
+ :phone => "(042)056-1534",
219
+ :fax => "(106)017-8792",
220
+ :deleted_at => nil,
221
+ :created_at => Tue, 09 Feb 2010 13:32:10 UTC +00:00,
222
+ :updated_at => Tue, 09 Feb 2010 20:05:01 UTC +00:00,
223
+ :email => "info@ziemannstreich.com",
224
+ :background_info => nil
229
225
  }
230
- rails>
226
+ ]
227
+ rails> ap Account
228
+ class Account < ActiveRecord::Base {
229
+ :id => :integer,
230
+ :user_id => :integer,
231
+ :assigned_to => :integer,
232
+ :name => :string,
233
+ :access => :string,
234
+ :website => :string,
235
+ :toll_free_phone => :string,
236
+ :phone => :string,
237
+ :fax => :string,
238
+ :deleted_at => :datetime,
239
+ :created_at => :datetime,
240
+ :updated_at => :datetime,
241
+ :email => :string,
242
+ :background_info => :string
243
+ }
244
+ rails>
245
+ ```
231
246
 
232
247
  ### IRB integration ###
233
248
  To use awesome_print as default formatter in irb and Rails console add the following
234
249
  code to your ~/.irbrc file:
235
250
 
236
- require "awesome_print"
237
- AwesomePrint.irb!
251
+ ```ruby
252
+ require "awesome_print"
253
+ AwesomePrint.irb!
254
+ ```
238
255
 
239
256
  ### PRY integration ###
240
257
  If you miss awesome_print's way of formatting output, here's how you can use it in place
241
258
  of the formatting which comes with pry. Add the following code to your ~/.pryrc:
242
259
 
243
- require "awesome_print"
244
- AwesomePrint.pry!
260
+ ```ruby
261
+ require "awesome_print"
262
+ AwesomePrint.pry!
263
+ ```
245
264
 
246
265
  ### Logger Convenience Method ###
247
266
  awesome_print adds the 'ap' method to the Logger and ActiveSupport::BufferedLogger classes
@@ -274,14 +293,16 @@ You can set your own default options by creating ``.aprc`` file in your home
274
293
  directory. Within that file assign your defaults to ``AwesomePrint.defaults``.
275
294
  For example:
276
295
 
277
- # ~/.aprc file.
278
- AwesomePrint.defaults = {
279
- :indent => -2,
280
- :color => {
281
- :hash => :pale,
282
- :class => :white
283
- }
284
- }
296
+ ```ruby
297
+ # ~/.aprc file.
298
+ AwesomePrint.defaults = {
299
+ :indent => -2,
300
+ :color => {
301
+ :hash => :pale,
302
+ :class => :white
303
+ }
304
+ }
305
+ ```
285
306
 
286
307
  ### Running Specs ###
287
308
 
@@ -294,10 +315,12 @@ For example:
294
315
  * Make your feature addition or bug fix.
295
316
  * Add specs for it, making sure $ rake spec is all green.
296
317
  * Commit, do not mess with rakefile, version, or history.
297
- * Send me commit URL (*do not* send me pull requests).
318
+ * Send commit URL (*do not* send pull requests).
298
319
 
299
320
  ### Contributors ###
321
+ Special thanks goes to awesome team of contributors, namely:
300
322
 
323
+ * 6fusion.com -- https://github.com/6fusion
301
324
  * Adam Doppelt -- https://github.com/gurgeous
302
325
  * Andrew O'Brien -- https://github.com/AndrewO
303
326
  * Andrew Horsman -- https://github.com/basicxman
@@ -312,21 +335,32 @@ For example:
312
335
  * Evan Senter -- https://github.com/evansenter
313
336
  * George . -- https://github.com/gardelea
314
337
  * Greg Weber -- https://github.com/gregwebs
338
+ * Jan Vansteenkiste -- https://github.com/vStone
315
339
  * Jeff Felchner -- https://github.com/jfelchner
340
+ * Jonathan Davies -- send your Github URL ;-)
341
+ * Kevin Olbrich -- https://github.com/olbrich
342
+ * Matthew Schulkind -- https://github.com/mschulkind
343
+ * Mike McQuaid -- https://github.com/mikemcquaid
344
+ * Nami-Doc -- https://github.com/Nami-Doc
345
+ * Nicolas Viennot -- https://github.com/nviennot
316
346
  * Nikolaj Nikolajsen -- https://github.com/nikolajsen
347
+ * Richard Hall -- https://github.com/richardardrichard
317
348
  * Ryan Schlesinger -- https://github.com/ryansch
349
+ * Scott Hyndman -- https://github.com/shyndman
318
350
  * Sean Gallagher -- http://github.com/torandu
319
351
  * Stephan Hagemann -- https://github.com/shageman
320
352
  * Tim Harper -- http://github.com/timcharper
321
353
  * Tobias Crawley -- http://github.com/tobias
322
354
  * Thibaut Barrère -- https://github.com/thbar
355
+ * Trevor Wennblom -- https://github.com/trevor
356
+ * vfrride -- https://github.com/vfrride
323
357
  * Viktar Basharymau -- https://github.com/DNNX
324
358
 
325
359
  ### License ###
326
- Copyright (c) 2010-2012 Michael Dvorkin
360
+ Copyright (c) 2010-2013 Michael Dvorkin
327
361
 
328
362
  http://www.dvorkin.net
329
363
 
330
- %w(mike dvorkin.net) * "@" || %w(mike fatfreecrm.com) * "@"
364
+ %w(mike dvorkin.net) * "@" || "twitter.com/mid"
331
365
 
332
366
  Released under the MIT license. See LICENSE file for details.