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:
parent
ac770dad73
commit
8044d58a51
4 changed files with 54 additions and 37 deletions
45
README.md
45
README.md
|
@ -14,10 +14,12 @@ objects are supported via included mixin.
|
||||||
$ git clone git://github.com/michaeldv/awesome_print_.git
|
$ git clone git://github.com/michaeldv/awesome_print_.git
|
||||||
|
|
||||||
### Usage ###
|
### Usage ###
|
||||||
require "ap"
|
|
||||||
ap(object, options = {})
|
|
||||||
|
|
||||||
Default options:
|
require "ap"
|
||||||
|
ap object, options = {}
|
||||||
|
|
||||||
|
Default options:
|
||||||
|
|
||||||
:miltiline => true,
|
:miltiline => true,
|
||||||
:plain => false,
|
:plain => false,
|
||||||
:indent => 4,
|
:indent => 4,
|
||||||
|
@ -37,15 +39,18 @@ objects are supported via included mixin.
|
||||||
:trueclass => :green
|
:trueclass => :green
|
||||||
}
|
}
|
||||||
|
|
||||||
Supported color names:
|
Supported color names:
|
||||||
|
|
||||||
:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white
|
:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white
|
||||||
:black, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :pale
|
:black, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :pale
|
||||||
|
|
||||||
### Example (IRB) ###
|
### Examples ###
|
||||||
$ irb
|
$ cat > 1.rb
|
||||||
irb> require "ap"
|
require "ap"
|
||||||
irb> data = [ false, 42, %w(fourty two), { :now => Time.now, :class => Time.now.class, :distance => 42e42 } ]
|
data = [ false, 42, %w(fourty two), { :now => Time.now, :class => Time.now.class, :distance => 42e42 } ]
|
||||||
irb> ap data
|
ap data
|
||||||
|
^D
|
||||||
|
$ ruby 1.rb
|
||||||
[
|
[
|
||||||
[0] false,
|
[0] false,
|
||||||
[1] 42,
|
[1] 42,
|
||||||
|
@ -59,17 +64,29 @@ objects are supported via included mixin.
|
||||||
:distance => 4.2e+43
|
: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,
|
:class => Time < Object,
|
||||||
:now => Fri Apr 02 19:55:53 -0700 2010,
|
:now => Fri Apr 02 19:55:53 -0700 2010,
|
||||||
:distance => 4.2e+43
|
: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
|
$ ruby script/console
|
||||||
Loading development environment (Rails 2.3.5)
|
Loading development environment (Rails 2.3.5)
|
||||||
rails> require "ap"
|
rails> require "ap"
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
0.1.1
|
0.1.2
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = %q{awesome_print}
|
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.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Michael Dvorkin"]
|
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.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.email = %q{mike@dvorkin.net}
|
||||||
s.extra_rdoc_files = [
|
s.extra_rdoc_files = [
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# Awesome Print is freely distributable under the terms of MIT license.
|
# Awesome Print is freely distributable under the terms of MIT license.
|
||||||
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
# 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|
|
[ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i|
|
||||||
if STDOUT.tty? && ENV['TERM'] && ENV['TERM'] != 'dumb'
|
if STDOUT.tty? && ENV['TERM'] && ENV['TERM'] != 'dumb'
|
||||||
|
|
Loading…
Reference in a new issue