1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

Release 0.1.2

This commit is contained in:
Mike Dvorkin 2010-04-05 21:21:57 -07:00
parent ac770dad73
commit 8044d58a51
4 changed files with 54 additions and 37 deletions

View file

@ -14,10 +14,12 @@ objects are supported via included mixin.
$ git clone git://github.com/michaeldv/awesome_print_.git
### Usage ###
require "ap"
ap(object, options = {})
Default options:
require "ap"
ap object, options = {}
Default options:
:miltiline => true,
:plain => false,
:indent => 4,
@ -37,15 +39,18 @@ objects are supported via included mixin.
:trueclass => :green
}
Supported color names:
Supported color names:
:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white
:black, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :pale
### Example (IRB) ###
$ irb
irb> require "ap"
irb> data = [ false, 42, %w(fourty two), { :now => Time.now, :class => Time.now.class, :distance => 42e42 } ]
irb> ap data
### Examples ###
$ cat > 1.rb
require "ap"
data = [ false, 42, %w(fourty two), { :now => Time.now, :class => Time.now.class, :distance => 42e42 } ]
ap data
^D
$ ruby 1.rb
[
[0] false,
[1] 42,
@ -59,17 +64,29 @@ objects are supported via included mixin.
:distance => 4.2e+43
}
]
irb> ap data[3], :indent => -2 # Left align hash keys.
$ cat > 2.rb
require "ap"
data = { :now => Time.now, :class => Time.now.class, :distance => 42e42 }
ap data, :indent => -2 # <-- Left align hash keys.
^D
$ ruby 2.rb
{
:class => Time < Object,
:now => Fri Apr 02 19:55:53 -0700 2010,
:distance => 4.2e+43
}
irb> ap data, :multiline => false
[ false, 42, [ "fourty", "two" ], { :class => Time < Object, :distance => 4.2e+43, :now => Fri Apr 02 19:44:52 -0700 2010 } ]
irb>
### Example (Rails) ###
$ cat > 3.rb
require "ap"
data = [ false, 42, %w(fourty two) ]
data << data # <-- Nested array.
ap data, :multiline => false
^D
$ ruby 3.rb
[ false, 42, [ "fourty", "two" ], [...] ]
### Example (Rails console) ###
$ ruby script/console
Loading development environment (Rails 2.3.5)
rails> require "ap"

View file

@ -1 +1 @@
0.1.1
0.1.2

View file

@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{awesome_print}
s.version = "0.1.1"
s.version = "0.1.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Michael Dvorkin"]
s.date = %q{2010-04-04}
s.date = %q{2010-04-05}
s.description = %q{Great Ruby dubugging companion: pretty print Ruby objects to visualize their structure. Supports Rails ActiveRecord objects via included mixin.}
s.email = %q{mike@dvorkin.net}
s.extra_rdoc_files = [

View file

@ -3,7 +3,7 @@
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
class String # :nodoc:
class String
[ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i|
if STDOUT.tty? && ENV['TERM'] && ENV['TERM'] != 'dumb'