pretty_debug 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pretty_debug.rb +12 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e9cc1d872b100b9e023b64f3dfea1a9e5bbe693
4
- data.tar.gz: b83ca41ba30d40b5974f563c12edf25e92ec76b2
3
+ metadata.gz: 1943c286dac1792c1d50ebf266cd89ff8784758f
4
+ data.tar.gz: 30b6e3a0024d77dee661760de69dc1391d7d5ada
5
5
  SHA512:
6
- metadata.gz: 53192bd8782c059b05064862f6f379124ba25bcd7092f1b4f8547d688f190029f61cce86f7b2e6f5cf8cb68b26d433ab5031a778a62bc3bc5817b24421f71d3a
7
- data.tar.gz: f281cec4cd6fe9215c3ca2bf4405aba3482c47749bdaf72c679f1387213118dcd7d9fe36e5ac8adf01b2ad987e538bef58d0e8b7b61cedc57e3c3b563ab2ab30
6
+ metadata.gz: 8b10559df7e712fa1cf1ae3017d1b3c4a5e603b1f8248deba8377a9bdc92c7878b5ca90321558d40cf35ede371a452977c6a84ce147440df967fe0d207df6b83
7
+ data.tar.gz: 539192309569eff7e3691bd60e8b13fc756b7c5cb3088a74c6ce1b6f3bf153950bf511e819e07e77bdd0387eb6652d30187274f5e25d2c8a58985ce2df145d09
data/lib/pretty_debug.rb CHANGED
@@ -123,14 +123,18 @@ module Kernel
123
123
  else
124
124
  puts \
125
125
  PrettyDebug.message($!).color(:red),
126
- PrettyDebug.backtrace_locations($!)
127
- .align.map(&PrettyDebug.instance_variable_get(:@format))
126
+ PrettyDebug.backtrace_locations($!).to_puts
128
127
  end
129
128
  $stderr.reopen(IO::NULL)
130
129
  $stdout.reopen(IO::NULL)
131
130
  end
132
131
  end
133
132
 
133
+ class PrettyArray < Array
134
+ def to_puts; align.map(&PrettyDebug.instance_variable_get(:@format)) end
135
+ def inspect; to_puts.join($/) end
136
+ end
137
+
134
138
  class PrettyDebug
135
139
  def self.ignore &pr; @ignore = pr end
136
140
  def self.format &pr; @format = pr end
@@ -142,13 +146,15 @@ class PrettyDebug
142
146
  end
143
147
  def self.backtrace_locations e
144
148
  e.complement_backtrace_locations
145
- a = caller_locations(e.backtrace_locations)
146
- a.reject do |f, l, m|
149
+ a = beautify(e.backtrace_locations)
150
+ a.reject! do |f, l, m|
147
151
  @ignore.call(f, m) or
148
152
  f == __FILE__ or
149
153
  m =~ /\A<.*>\z/ # Such as `<top (required)>`, `<module:Foo>`.
150
- end rescue a
154
+ end rescue nil
155
+ PrettyArray.new(a)
151
156
  end
157
+ def self.caller_locations; PrettyArray.new(beautify(Kernel.caller_locations)) end
152
158
  Hook = %w[
153
159
  initialize
154
160
  method_missing
@@ -167,7 +173,7 @@ class PrettyDebug
167
173
  intitialize_clone
168
174
  intitialize_dup
169
175
  ]
170
- def self.caller_locations a
176
+ def self.beautify a
171
177
  a
172
178
  .map{|l| [l.absolute_path, l.lineno, l.label]}
173
179
  .transpose.tap do |_, _, ms|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty_debug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-02 00:00:00.000000000 Z
11
+ date: 2013-10-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: []