colorful_inspect 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +14 -3
  2. data/lib/colorful_inspect.rb +26 -22
  3. metadata +2 -2
data/README.md CHANGED
@@ -19,6 +19,7 @@ add colored formatting.
19
19
 
20
20
  Just require it and use pp as usual:
21
21
 
22
+ ```ruby
22
23
  require 'colorful_inspect'
23
24
 
24
25
  Person = Struct.new :first_name, :last_name
@@ -41,6 +42,7 @@ Just require it and use pp as usual:
41
42
  LoadError.new("could not find a good message"),
42
43
  PrettyPrint.new
43
44
  ]
45
+ ```
44
46
 
45
47
  And here's the output (without the colors):
46
48
 
@@ -115,7 +117,16 @@ And here's the output (without the colors):
115
117
 
116
118
  You can change the indentation as well as the used colors:
117
119
 
118
- ColorfulInspect.indent = 4 # defaults to two
120
+ ```ruby
121
+ ColorfulInspect.indent = 4 # defaults to two
119
122
 
120
- # pp ColorfulInspect.colors to see available colors :)
121
- ColorfulInspect.colors[:nil] = :red
123
+ # pp ColorfulInspect.colors to see available colors :)
124
+ ColorfulInspect.colors[:nil] = :red
125
+ ```
126
+
127
+ Colors can also be disabled and reactivated:
128
+
129
+ ```ruby
130
+ ColorfulInspect.colors.clear
131
+ ColorfulInspect.colors = ColorfulInspect.default_colors
132
+ ```
@@ -11,29 +11,29 @@ module ColorfulInspect
11
11
  attr_accessor :colors
12
12
  end
13
13
 
14
- self.indent = 2
15
-
16
- self.colors = {
17
- :numeric => [:blue, :bold],
18
- :bignum => [:blue],
19
- :fixnum => [:blue, :bold],
20
- :float => [:blue, :bold],
21
- :rational => [:blue],
22
- :true => [:green, :bold],
23
- :false => [:red, :bold],
14
+ module_function
15
+ def default_colors
16
+ {
17
+ :numeric => [:blue, :bold],
18
+ :bignum => [:blue],
19
+ :fixnum => [:blue, :bold],
20
+ :float => [:blue, :bold],
21
+ :rational => [:blue],
22
+ :true => [:green, :bold],
23
+ :false => [:red, :bold],
24
24
  :nil => [:red],
25
- :symbol => [:cyan, :bold],
26
- :string => [:green],
27
- :date => [:black],
28
- :time => [:black, :bold],
29
- :class => [:yellow, :bold],
30
- :module => [:yellow],
31
- :method => [:magenta],
32
- :exception => [:red],
33
- :ivar => [:cyan]
34
- }
25
+ :symbol => [:cyan, :bold],
26
+ :string => [:green],
27
+ :date => [:black],
28
+ :time => [:black, :bold],
29
+ :class => [:yellow, :bold],
30
+ :module => [:yellow],
31
+ :method => [:magenta],
32
+ :exception => [:red],
33
+ :ivar => [:cyan]
34
+ }
35
+ end
35
36
 
36
- module_function
37
37
  def group(q, open, close, &block)
38
38
  q.group(ColorfulInspect.indent, open, "\n#{q.genspace[q.indent]}#{close}",
39
39
  &block)
@@ -77,7 +77,7 @@ module ColorfulInspect
77
77
  end
78
78
 
79
79
  klass = if method.respond_to? :owner
80
- method.owner.name
80
+ method.owner.to_s
81
81
  elsif method.inspect =~ /Method: (.*?)#/
82
82
  $1
83
83
  end
@@ -89,6 +89,9 @@ module ColorfulInspect
89
89
 
90
90
  [method.name.to_s, args, klass.to_s, location]
91
91
  end
92
+
93
+ self.indent = 2
94
+ self.colors = default_colors
92
95
  end
93
96
 
94
97
  class Array
@@ -310,6 +313,7 @@ if $PROGRAM_NAME == __FILE__
310
313
  Time.now,
311
314
  String, Array, BasicObject, Enumerable,
312
315
  Array.instance_method(:each), 3.method(:succ), "foo".method(:pp),
316
+ File::Stat.instance_method(:mtime), Time.method(:now),
313
317
  Person.new("John", "Smith"),
314
318
  $stdout, $stdin,
315
319
  LoadError.new("could not find a good message"),
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: colorful_inspect
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Mon ou\xC3\xAFe"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-10 00:00:00 Z
13
+ date: 2011-06-14 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: term-ansicolor