debug_helper 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +164 -31
- data/lib/debug_helper.rb +74 -33
- data/lib/debug_helper/version.rb +1 -1
- data/markdown/readme/Rakefile +8 -2
- data/markdown/readme/classes/array/mixed/show.md +8 -3
- data/markdown/readme/classes/array/mixed/show.yaml +8 -3
- data/markdown/readme/classes/hash/circular/show.md +6 -2
- data/markdown/readme/classes/hash/circular/show.yaml +6 -2
- data/markdown/readme/classes/hash/mixed/show.md +17 -6
- data/markdown/readme/classes/hash/mixed/show.yaml +17 -6
- data/markdown/readme/classes/hash/nested/show.md +18 -6
- data/markdown/readme/classes/hash/nested/show.yaml +18 -6
- data/markdown/readme/classes/hash/simple/show.md +9 -3
- data/markdown/readme/classes/hash/simple/show.yaml +9 -3
- data/markdown/readme/classes/object/datetime/show.md +1 -1
- data/markdown/readme/classes/object/datetime/show.yaml +1 -1
- data/markdown/readme/classes/string/multiline/show.md +7 -4
- data/markdown/readme/classes/string/multiline/show.yaml +7 -4
- data/markdown/readme/classes/string/simple/show.md +5 -2
- data/markdown/readme/classes/string/simple/show.yaml +5 -2
- data/markdown/readme/classes/struct/mixed/show.md +8 -3
- data/markdown/readme/classes/struct/mixed/show.yaml +8 -3
- data/markdown/readme/classes/symbol/simple/show.md +3 -1
- data/markdown/readme/classes/symbol/simple/show.yaml +3 -1
- data/markdown/readme/options/depth/show.md +77 -0
- data/markdown/readme/options/depth/show.rb +15 -0
- data/markdown/readme/options/depth/show.yaml +49 -0
- data/markdown/readme/options/depth/template.md +9 -0
- data/markdown/readme/template.md +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 406088664ae54129aca926d0cf20499386614ecf
|
4
|
+
data.tar.gz: d035993096295a1cec96701c0093c2f6486cfb17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1b4f3182d07acc36dacec517f6f919b99b2011efe909591a5d8ac81197c78540622fb9f8bf4ed85d7cf3cfccf6e57ce1f61deb2b67c7ac70246f1dd03e9fd6a
|
7
|
+
data.tar.gz: 9c2811314cf2210896b71530b0659ccd0180c4bbcce8fb98fb790f5c46154dab40a319a1c2f19115688a1a1677fe1f6f8ed25d02ae222661370efc1590235c12
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,6 +24,8 @@ For certain classes (see below), the analysis is very detailed.
|
|
24
24
|
|
25
25
|
For the collection classes ```Array```, ```Hash```, and ```Struct```, the analysis is also recursive; that is, the collection's values are themselves analyzed.
|
26
26
|
|
27
|
+
You can control the depth of recursion using option ```depth```. See [Options](#options).
|
28
|
+
|
27
29
|
Classes treated in detail:
|
28
30
|
|
29
31
|
- [Array](#array)
|
@@ -100,10 +102,15 @@ The output shows details of the array.
|
|
100
102
|
Array (message='My mixed array' size=3):
|
101
103
|
Element 0: Fixnum 0
|
102
104
|
Element 1:
|
103
|
-
String (size=3
|
104
|
-
|
105
|
+
String (size=3):
|
106
|
+
to_s: one
|
107
|
+
encoding: !ruby/encoding UTF-8
|
108
|
+
ascii_only?: true
|
109
|
+
bytesize: 3
|
105
110
|
Element 2:
|
106
|
-
Symbol (size=3
|
111
|
+
Symbol (size=3):
|
112
|
+
to_s: two
|
113
|
+
encoding: !ruby/encoding US-ASCII
|
107
114
|
```
|
108
115
|
|
109
116
|
#### Nested Arrays
|
@@ -184,15 +191,21 @@ The output shows details of the hash.
|
|
184
191
|
Hash (size=3 message='My simple hash'):
|
185
192
|
Pair 0:
|
186
193
|
Key:
|
187
|
-
Symbol (size=1
|
194
|
+
Symbol (size=1):
|
195
|
+
to_s: a
|
196
|
+
encoding: !ruby/encoding US-ASCII
|
188
197
|
Value: Fixnum 0
|
189
198
|
Pair 1:
|
190
199
|
Key:
|
191
|
-
Symbol (size=1
|
200
|
+
Symbol (size=1):
|
201
|
+
to_s: b
|
202
|
+
encoding: !ruby/encoding US-ASCII
|
192
203
|
Value: Fixnum 1
|
193
204
|
Pair 2:
|
194
205
|
Key:
|
195
|
-
Symbol (size=1
|
206
|
+
Symbol (size=1):
|
207
|
+
to_s: c
|
208
|
+
encoding: !ruby/encoding US-ASCII
|
196
209
|
Value: Fixnum 2
|
197
210
|
```
|
198
211
|
|
@@ -220,19 +233,30 @@ The output shows details of the hash.
|
|
220
233
|
Hash (size=3 message='My mixed hash'):
|
221
234
|
Pair 0:
|
222
235
|
Key:
|
223
|
-
Symbol (size=1
|
236
|
+
Symbol (size=1):
|
237
|
+
to_s: a
|
238
|
+
encoding: !ruby/encoding US-ASCII
|
224
239
|
Value: Fixnum 0
|
225
240
|
Pair 1:
|
226
241
|
Key:
|
227
|
-
Symbol (size=1
|
242
|
+
Symbol (size=1):
|
243
|
+
to_s: b
|
244
|
+
encoding: !ruby/encoding US-ASCII
|
228
245
|
Value:
|
229
|
-
String (size=3
|
230
|
-
|
246
|
+
String (size=3):
|
247
|
+
to_s: one
|
248
|
+
encoding: !ruby/encoding UTF-8
|
249
|
+
ascii_only?: true
|
250
|
+
bytesize: 3
|
231
251
|
Pair 2:
|
232
252
|
Key:
|
233
|
-
Symbol (size=1
|
253
|
+
Symbol (size=1):
|
254
|
+
to_s: c
|
255
|
+
encoding: !ruby/encoding US-ASCII
|
234
256
|
Value:
|
235
|
-
Symbol (size=3
|
257
|
+
Symbol (size=3):
|
258
|
+
to_s: two
|
259
|
+
encoding: !ruby/encoding US-ASCII
|
236
260
|
```
|
237
261
|
|
238
262
|
#### Nested Hashes
|
@@ -264,29 +288,41 @@ The output shows details of the hashes.
|
|
264
288
|
Hash (size=2 message='My nested hash'):
|
265
289
|
Pair 0:
|
266
290
|
Key:
|
267
|
-
Symbol (size=1
|
291
|
+
Symbol (size=1):
|
292
|
+
to_s: a
|
293
|
+
encoding: !ruby/encoding US-ASCII
|
268
294
|
Value:
|
269
295
|
Hash (size=2):
|
270
296
|
Pair 0:
|
271
297
|
Key:
|
272
|
-
Symbol (size=1
|
298
|
+
Symbol (size=1):
|
299
|
+
to_s: b
|
300
|
+
encoding: !ruby/encoding US-ASCII
|
273
301
|
Value: Fixnum 0
|
274
302
|
Pair 1:
|
275
303
|
Key:
|
276
|
-
Symbol (size=1
|
304
|
+
Symbol (size=1):
|
305
|
+
to_s: c
|
306
|
+
encoding: !ruby/encoding US-ASCII
|
277
307
|
Value: Fixnum 1
|
278
308
|
Pair 1:
|
279
309
|
Key:
|
280
|
-
Symbol (size=1
|
310
|
+
Symbol (size=1):
|
311
|
+
to_s: d
|
312
|
+
encoding: !ruby/encoding US-ASCII
|
281
313
|
Value:
|
282
314
|
Hash (size=2):
|
283
315
|
Pair 0:
|
284
316
|
Key:
|
285
|
-
Symbol (size=1
|
317
|
+
Symbol (size=1):
|
318
|
+
to_s: e
|
319
|
+
encoding: !ruby/encoding US-ASCII
|
286
320
|
Value: Fixnum 2
|
287
321
|
Pair 1:
|
288
322
|
Key:
|
289
|
-
Symbol (size=1
|
323
|
+
Symbol (size=1):
|
324
|
+
to_s: f
|
325
|
+
encoding: !ruby/encoding US-ASCII
|
290
326
|
Value: Fixnum 3
|
291
327
|
```
|
292
328
|
|
@@ -315,12 +351,16 @@ The circular reference is not followed.
|
|
315
351
|
Hash (size=1 message='My circular hashes'):
|
316
352
|
Pair 0:
|
317
353
|
Key:
|
318
|
-
Symbol (size=3
|
354
|
+
Symbol (size=3):
|
355
|
+
to_s: foo
|
356
|
+
encoding: !ruby/encoding US-ASCII
|
319
357
|
Value:
|
320
358
|
Hash (size=1):
|
321
359
|
Pair 0:
|
322
360
|
Key:
|
323
|
-
Symbol (size=3
|
361
|
+
Symbol (size=3):
|
362
|
+
to_s: bar
|
363
|
+
encoding: !ruby/encoding US-ASCII
|
324
364
|
Value: Hash {:foo=>{:bar=>{...}}}
|
325
365
|
```
|
326
366
|
### Struct
|
@@ -380,12 +420,17 @@ MyStruct (message='My mixed struct' size=3):
|
|
380
420
|
Member 1:
|
381
421
|
Name: :b
|
382
422
|
Value:
|
383
|
-
String (size=3
|
384
|
-
|
423
|
+
String (size=3):
|
424
|
+
to_s: one
|
425
|
+
encoding: !ruby/encoding UTF-8
|
426
|
+
ascii_only?: true
|
427
|
+
bytesize: 3
|
385
428
|
Member 2:
|
386
429
|
Name: :c
|
387
430
|
Value:
|
388
|
-
Symbol (size=3
|
431
|
+
Symbol (size=3):
|
432
|
+
to_s: two
|
433
|
+
encoding: !ruby/encoding US-ASCII
|
389
434
|
```
|
390
435
|
|
391
436
|
#### Nested Structs
|
@@ -496,8 +541,11 @@ The output shows details of the string.
|
|
496
541
|
```show.yaml```:
|
497
542
|
```yaml
|
498
543
|
---
|
499
|
-
String (message='My simple string' size=11
|
500
|
-
|
544
|
+
String (message='My simple string' size=11):
|
545
|
+
to_s: Lorem ipsum
|
546
|
+
encoding: !ruby/encoding UTF-8
|
547
|
+
ascii_only?: true
|
548
|
+
bytesize: 11
|
501
549
|
```
|
502
550
|
|
503
551
|
#### Multiline String
|
@@ -520,10 +568,13 @@ The output shows details of the string.
|
|
520
568
|
```show.yaml```:
|
521
569
|
```yaml
|
522
570
|
---
|
523
|
-
String (message='My multiline string' size=122
|
524
|
-
|
525
|
-
|
526
|
-
|
571
|
+
String (message='My multiline string' size=122):
|
572
|
+
to_s: |
|
573
|
+
Lorem Ipsum dolor sit amet,consectetur adipisicing elit,
|
574
|
+
sed doeiusmod tempor incididunt ut laboreet dolore magna aliqua.
|
575
|
+
encoding: !ruby/encoding UTF-8
|
576
|
+
ascii_only?: true
|
577
|
+
bytesize: 122
|
527
578
|
```
|
528
579
|
### Symbol
|
529
580
|
|
@@ -543,7 +594,9 @@ The output shows details of the symbol.
|
|
543
594
|
```show.yaml```:
|
544
595
|
```yaml
|
545
596
|
---
|
546
|
-
Symbol (message='My symbol' size=11
|
597
|
+
Symbol (message='My symbol' size=11):
|
598
|
+
to_s: lorem_ipsum
|
599
|
+
encoding: !ruby/encoding US-ASCII
|
547
600
|
```
|
548
601
|
### Object
|
549
602
|
|
@@ -567,7 +620,7 @@ The output shows details of the datetime.
|
|
567
620
|
|
568
621
|
```show.yaml```:
|
569
622
|
```yaml
|
570
|
-
--- DateTime (message='My datetime') 2018-07-
|
623
|
+
--- DateTime (message='My datetime') 2018-07-13T09:59:53-05:00
|
571
624
|
...
|
572
625
|
```
|
573
626
|
|
@@ -610,3 +663,83 @@ The output shows details of the regexp.
|
|
610
663
|
--- Regexp (message='My regexp') (?-mix:foo)
|
611
664
|
...
|
612
665
|
```
|
666
|
+
|
667
|
+
## Options
|
668
|
+
|
669
|
+
### Option ```depth```
|
670
|
+
|
671
|
+
This example shows how option ```depth``` affects output.
|
672
|
+
|
673
|
+
```show.rb```:
|
674
|
+
```ruby
|
675
|
+
require 'debug_helper'
|
676
|
+
|
677
|
+
ary = [0,
|
678
|
+
[1,
|
679
|
+
[2,
|
680
|
+
[3,
|
681
|
+
[4]
|
682
|
+
]
|
683
|
+
]
|
684
|
+
]
|
685
|
+
]
|
686
|
+
(1..5).each do |depth|
|
687
|
+
message = "Show depth #{depth}"
|
688
|
+
DebugHelper.show(ary, message, {:depth => depth})
|
689
|
+
end
|
690
|
+
```
|
691
|
+
|
692
|
+
The output shows output for various depths.
|
693
|
+
|
694
|
+
```show.yaml```:
|
695
|
+
```yaml
|
696
|
+
---
|
697
|
+
Array (message='Show depth 1' size=2):
|
698
|
+
Element 0: Fixnum 0
|
699
|
+
Element 1: Array [1, [2, [3, [4]]]]
|
700
|
+
---
|
701
|
+
Array (message='Show depth 2' size=2):
|
702
|
+
Element 0: Fixnum 0
|
703
|
+
Element 1:
|
704
|
+
Array (size=2):
|
705
|
+
Element 0: Fixnum 1
|
706
|
+
Element 1: Array [2, [3, [4]]]
|
707
|
+
---
|
708
|
+
Array (message='Show depth 3' size=2):
|
709
|
+
Element 0: Fixnum 0
|
710
|
+
Element 1:
|
711
|
+
Array (size=2):
|
712
|
+
Element 0: Fixnum 1
|
713
|
+
Element 1:
|
714
|
+
Array (size=2):
|
715
|
+
Element 0: Fixnum 2
|
716
|
+
Element 1: Array [3, [4]]
|
717
|
+
---
|
718
|
+
Array (message='Show depth 4' size=2):
|
719
|
+
Element 0: Fixnum 0
|
720
|
+
Element 1:
|
721
|
+
Array (size=2):
|
722
|
+
Element 0: Fixnum 1
|
723
|
+
Element 1:
|
724
|
+
Array (size=2):
|
725
|
+
Element 0: Fixnum 2
|
726
|
+
Element 1:
|
727
|
+
Array (size=2):
|
728
|
+
Element 0: Fixnum 3
|
729
|
+
Element 1: Array [4]
|
730
|
+
---
|
731
|
+
Array (message='Show depth 5' size=2):
|
732
|
+
Element 0: Fixnum 0
|
733
|
+
Element 1:
|
734
|
+
Array (size=2):
|
735
|
+
Element 0: Fixnum 1
|
736
|
+
Element 1:
|
737
|
+
Array (size=2):
|
738
|
+
Element 0: Fixnum 2
|
739
|
+
Element 1:
|
740
|
+
Array (size=2):
|
741
|
+
Element 0: Fixnum 3
|
742
|
+
Element 1:
|
743
|
+
Array (size=1):
|
744
|
+
Element 0: Fixnum 4
|
745
|
+
```
|
data/lib/debug_helper.rb
CHANGED
@@ -6,8 +6,8 @@ class DebugHelper
|
|
6
6
|
|
7
7
|
module Putd
|
8
8
|
|
9
|
-
def putd(obj, message)
|
10
|
-
DebugHelper.show(obj, message)
|
9
|
+
def putd(obj, message, options = {})
|
10
|
+
DebugHelper.show(obj, message, options)
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
@@ -15,25 +15,29 @@ class DebugHelper
|
|
15
15
|
attr_accessor \
|
16
16
|
:obj,
|
17
17
|
:message,
|
18
|
-
:object_ids
|
18
|
+
:object_ids,
|
19
|
+
:depth
|
19
20
|
|
20
|
-
def self.show(obj, message = obj.class)
|
21
|
-
debug_helper = DebugHelper.new(obj, message)
|
21
|
+
def self.show(obj, message = obj.class, options = {})
|
22
|
+
debug_helper = DebugHelper.new(obj, message, options)
|
22
23
|
x = debug_helper.send(:_show, obj, message, info = {})
|
23
24
|
puts x.to_yaml
|
24
25
|
end
|
25
26
|
|
26
27
|
private
|
27
28
|
|
28
|
-
def initialize(obj, message)
|
29
|
+
def initialize(obj, message, options)
|
29
30
|
self.obj = obj
|
30
31
|
self.message = message
|
32
|
+
self.depth = options[:depth] || 3
|
31
33
|
self.object_ids = []
|
32
34
|
end
|
33
35
|
|
34
36
|
def _show(obj, message, info)
|
35
37
|
if object_ids.include?(obj.object_id)
|
36
38
|
s = show_object(obj, message, info)
|
39
|
+
elsif depth == object_ids.size
|
40
|
+
s = show_object(obj, message, info)
|
37
41
|
else
|
38
42
|
object_ids.push(obj.object_id)
|
39
43
|
s = case
|
@@ -41,19 +45,15 @@ class DebugHelper
|
|
41
45
|
show_array(obj, message, info)
|
42
46
|
when obj.kind_of?(Hash)
|
43
47
|
show_hash(obj, message, info)
|
44
|
-
when obj.kind_of?(String)
|
45
|
-
show_string(obj, message, info)
|
46
48
|
when obj.kind_of?(Struct)
|
47
49
|
show_struct(obj, message, info)
|
48
|
-
when obj.kind_of?(Symbol)
|
49
|
-
show_symbol(obj, message, info)
|
50
50
|
# when obj.kind_of?(Range)
|
51
51
|
# when obj.kind_of?(Set)
|
52
52
|
else
|
53
53
|
show_object(obj, message, info)
|
54
54
|
end
|
55
|
+
object_ids.pop
|
55
56
|
end
|
56
|
-
object_ids.pop
|
57
57
|
s
|
58
58
|
end
|
59
59
|
|
@@ -86,19 +86,28 @@ class DebugHelper
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def show_object(obj, message, info)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
89
|
+
methods = methods_for_object(obj)
|
90
|
+
if methods.nil?
|
91
|
+
message_info = message.nil? ? '' : " (message='#{message}')"
|
92
|
+
"#{obj.class.name}#{message_info} #{obj}"
|
93
|
+
else
|
94
|
+
content = {}
|
95
|
+
attrs = {:message => message}
|
96
|
+
methods[:instance].each do |instance_method|
|
97
|
+
value = obj.send(instance_method)
|
98
|
+
if instance_method == :size
|
99
|
+
attrs.store(:size, value)
|
100
|
+
else
|
101
|
+
content.store(instance_method.to_s, value)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
methods[:class].each do |pair|
|
105
|
+
class_method, arguments = *pair
|
106
|
+
value = Object.const_get(obj.class.to_s).send(class_method, *arguments)
|
107
|
+
content.store(class_method.to_s, value)
|
108
|
+
end
|
109
|
+
_show_item(obj.class.name, content, attrs, info)
|
110
|
+
end
|
102
111
|
end
|
103
112
|
|
104
113
|
def show_struct(obj, message, info)
|
@@ -117,15 +126,6 @@ class DebugHelper
|
|
117
126
|
_show_item(obj.class.name, content, attrs, info)
|
118
127
|
end
|
119
128
|
|
120
|
-
def show_symbol(obj, message, info)
|
121
|
-
attrs = {
|
122
|
-
:message => message,
|
123
|
-
:size => obj.size,
|
124
|
-
:encoding => obj.encoding,
|
125
|
-
}
|
126
|
-
_show_item(obj.class.name, obj, attrs, info)
|
127
|
-
end
|
128
|
-
|
129
129
|
def _show_item(class_name, content, attrs, info)
|
130
130
|
message = attrs[:message]
|
131
131
|
unless message.nil?
|
@@ -141,8 +141,49 @@ class DebugHelper
|
|
141
141
|
attrs.each_pair do |key, value|
|
142
142
|
a.push("#{key}=#{value}") unless value.nil?
|
143
143
|
end
|
144
|
+
return class_name if a.empty?
|
144
145
|
attrs_s = a.join(' ')
|
145
146
|
"#{class_name} (#{attrs_s})"
|
146
147
|
end
|
147
148
|
|
149
|
+
def methods_for_object(obj)
|
150
|
+
methods = case
|
151
|
+
when obj.kind_of?(File)
|
152
|
+
{
|
153
|
+
# The instance forms of some of these require the file to be open.
|
154
|
+
:class => {
|
155
|
+
:path => [obj.path],
|
156
|
+
:atime => [obj.path],
|
157
|
+
:ctime => [obj.path],
|
158
|
+
:mtime => [obj.path],
|
159
|
+
:size => [obj.path],
|
160
|
+
},
|
161
|
+
:instance => [],
|
162
|
+
}
|
163
|
+
when obj.kind_of?(String)
|
164
|
+
{
|
165
|
+
:class => {},
|
166
|
+
:instance => [
|
167
|
+
:to_s,
|
168
|
+
:size,
|
169
|
+
:encoding,
|
170
|
+
:ascii_only?,
|
171
|
+
:bytesize,
|
172
|
+
]
|
173
|
+
}
|
174
|
+
when obj.kind_of?(Symbol)
|
175
|
+
{
|
176
|
+
:class => {},
|
177
|
+
:instance => [
|
178
|
+
:to_s,
|
179
|
+
:size,
|
180
|
+
:encoding,
|
181
|
+
]
|
182
|
+
}
|
183
|
+
else
|
184
|
+
nil
|
185
|
+
end
|
186
|
+
methods
|
187
|
+
end
|
188
|
+
|
148
189
|
end
|
data/lib/debug_helper/version.rb
CHANGED
data/markdown/readme/Rakefile
CHANGED
@@ -5,6 +5,12 @@ namespace :build do
|
|
5
5
|
desc 'Build README.md'
|
6
6
|
task :readme do
|
7
7
|
# Make output files.
|
8
|
+
Dir.chdir('options/depth') do
|
9
|
+
command = 'ruby show.rb > show.yaml'
|
10
|
+
system(command)
|
11
|
+
command = 'markdown_helper include --pristine template.md show.md'
|
12
|
+
system(command)
|
13
|
+
end
|
8
14
|
class_dir_names = nil
|
9
15
|
Dir.chdir('classes') do
|
10
16
|
class_names = %w/
|
@@ -21,9 +27,9 @@ namespace :build do
|
|
21
27
|
case_dir_names = Dir.glob('*').select {|f| File.directory? f}
|
22
28
|
case_dir_names.each do |case_dir_name|
|
23
29
|
Dir.chdir(case_dir_name) do
|
24
|
-
command =
|
30
|
+
command = 'ruby show.rb > show.yaml'
|
25
31
|
system(command)
|
26
|
-
command =
|
32
|
+
command = 'markdown_helper include --pristine template.md show.md'
|
27
33
|
system(command)
|
28
34
|
end
|
29
35
|
end
|
@@ -18,8 +18,13 @@ The output shows details of the array.
|
|
18
18
|
Array (message='My mixed array' size=3):
|
19
19
|
Element 0: Fixnum 0
|
20
20
|
Element 1:
|
21
|
-
String (size=3
|
22
|
-
|
21
|
+
String (size=3):
|
22
|
+
to_s: one
|
23
|
+
encoding: !ruby/encoding UTF-8
|
24
|
+
ascii_only?: true
|
25
|
+
bytesize: 3
|
23
26
|
Element 2:
|
24
|
-
Symbol (size=3
|
27
|
+
Symbol (size=3):
|
28
|
+
to_s: two
|
29
|
+
encoding: !ruby/encoding US-ASCII
|
25
30
|
```
|
@@ -2,7 +2,12 @@
|
|
2
2
|
Array (message='My mixed array' size=3):
|
3
3
|
Element 0: Fixnum 0
|
4
4
|
Element 1:
|
5
|
-
String (size=3
|
6
|
-
|
5
|
+
String (size=3):
|
6
|
+
to_s: one
|
7
|
+
encoding: !ruby/encoding UTF-8
|
8
|
+
ascii_only?: true
|
9
|
+
bytesize: 3
|
7
10
|
Element 2:
|
8
|
-
Symbol (size=3
|
11
|
+
Symbol (size=3):
|
12
|
+
to_s: two
|
13
|
+
encoding: !ruby/encoding US-ASCII
|
@@ -23,11 +23,15 @@ The circular reference is not followed.
|
|
23
23
|
Hash (size=1 message='My circular hashes'):
|
24
24
|
Pair 0:
|
25
25
|
Key:
|
26
|
-
Symbol (size=3
|
26
|
+
Symbol (size=3):
|
27
|
+
to_s: foo
|
28
|
+
encoding: !ruby/encoding US-ASCII
|
27
29
|
Value:
|
28
30
|
Hash (size=1):
|
29
31
|
Pair 0:
|
30
32
|
Key:
|
31
|
-
Symbol (size=3
|
33
|
+
Symbol (size=3):
|
34
|
+
to_s: bar
|
35
|
+
encoding: !ruby/encoding US-ASCII
|
32
36
|
Value: Hash {:foo=>{:bar=>{...}}}
|
33
37
|
```
|
@@ -2,10 +2,14 @@
|
|
2
2
|
Hash (size=1 message='My circular hashes'):
|
3
3
|
Pair 0:
|
4
4
|
Key:
|
5
|
-
Symbol (size=3
|
5
|
+
Symbol (size=3):
|
6
|
+
to_s: foo
|
7
|
+
encoding: !ruby/encoding US-ASCII
|
6
8
|
Value:
|
7
9
|
Hash (size=1):
|
8
10
|
Pair 0:
|
9
11
|
Key:
|
10
|
-
Symbol (size=3
|
12
|
+
Symbol (size=3):
|
13
|
+
to_s: bar
|
14
|
+
encoding: !ruby/encoding US-ASCII
|
11
15
|
Value: Hash {:foo=>{:bar=>{...}}}
|
@@ -22,17 +22,28 @@ The output shows details of the hash.
|
|
22
22
|
Hash (size=3 message='My mixed hash'):
|
23
23
|
Pair 0:
|
24
24
|
Key:
|
25
|
-
Symbol (size=1
|
25
|
+
Symbol (size=1):
|
26
|
+
to_s: a
|
27
|
+
encoding: !ruby/encoding US-ASCII
|
26
28
|
Value: Fixnum 0
|
27
29
|
Pair 1:
|
28
30
|
Key:
|
29
|
-
Symbol (size=1
|
31
|
+
Symbol (size=1):
|
32
|
+
to_s: b
|
33
|
+
encoding: !ruby/encoding US-ASCII
|
30
34
|
Value:
|
31
|
-
String (size=3
|
32
|
-
|
35
|
+
String (size=3):
|
36
|
+
to_s: one
|
37
|
+
encoding: !ruby/encoding UTF-8
|
38
|
+
ascii_only?: true
|
39
|
+
bytesize: 3
|
33
40
|
Pair 2:
|
34
41
|
Key:
|
35
|
-
Symbol (size=1
|
42
|
+
Symbol (size=1):
|
43
|
+
to_s: c
|
44
|
+
encoding: !ruby/encoding US-ASCII
|
36
45
|
Value:
|
37
|
-
Symbol (size=3
|
46
|
+
Symbol (size=3):
|
47
|
+
to_s: two
|
48
|
+
encoding: !ruby/encoding US-ASCII
|
38
49
|
```
|
@@ -2,16 +2,27 @@
|
|
2
2
|
Hash (size=3 message='My mixed hash'):
|
3
3
|
Pair 0:
|
4
4
|
Key:
|
5
|
-
Symbol (size=1
|
5
|
+
Symbol (size=1):
|
6
|
+
to_s: a
|
7
|
+
encoding: !ruby/encoding US-ASCII
|
6
8
|
Value: Fixnum 0
|
7
9
|
Pair 1:
|
8
10
|
Key:
|
9
|
-
Symbol (size=1
|
11
|
+
Symbol (size=1):
|
12
|
+
to_s: b
|
13
|
+
encoding: !ruby/encoding US-ASCII
|
10
14
|
Value:
|
11
|
-
String (size=3
|
12
|
-
|
15
|
+
String (size=3):
|
16
|
+
to_s: one
|
17
|
+
encoding: !ruby/encoding UTF-8
|
18
|
+
ascii_only?: true
|
19
|
+
bytesize: 3
|
13
20
|
Pair 2:
|
14
21
|
Key:
|
15
|
-
Symbol (size=1
|
22
|
+
Symbol (size=1):
|
23
|
+
to_s: c
|
24
|
+
encoding: !ruby/encoding US-ASCII
|
16
25
|
Value:
|
17
|
-
Symbol (size=3
|
26
|
+
Symbol (size=3):
|
27
|
+
to_s: two
|
28
|
+
encoding: !ruby/encoding US-ASCII
|
@@ -27,28 +27,40 @@ The output shows details of the hashes.
|
|
27
27
|
Hash (size=2 message='My nested hash'):
|
28
28
|
Pair 0:
|
29
29
|
Key:
|
30
|
-
Symbol (size=1
|
30
|
+
Symbol (size=1):
|
31
|
+
to_s: a
|
32
|
+
encoding: !ruby/encoding US-ASCII
|
31
33
|
Value:
|
32
34
|
Hash (size=2):
|
33
35
|
Pair 0:
|
34
36
|
Key:
|
35
|
-
Symbol (size=1
|
37
|
+
Symbol (size=1):
|
38
|
+
to_s: b
|
39
|
+
encoding: !ruby/encoding US-ASCII
|
36
40
|
Value: Fixnum 0
|
37
41
|
Pair 1:
|
38
42
|
Key:
|
39
|
-
Symbol (size=1
|
43
|
+
Symbol (size=1):
|
44
|
+
to_s: c
|
45
|
+
encoding: !ruby/encoding US-ASCII
|
40
46
|
Value: Fixnum 1
|
41
47
|
Pair 1:
|
42
48
|
Key:
|
43
|
-
Symbol (size=1
|
49
|
+
Symbol (size=1):
|
50
|
+
to_s: d
|
51
|
+
encoding: !ruby/encoding US-ASCII
|
44
52
|
Value:
|
45
53
|
Hash (size=2):
|
46
54
|
Pair 0:
|
47
55
|
Key:
|
48
|
-
Symbol (size=1
|
56
|
+
Symbol (size=1):
|
57
|
+
to_s: e
|
58
|
+
encoding: !ruby/encoding US-ASCII
|
49
59
|
Value: Fixnum 2
|
50
60
|
Pair 1:
|
51
61
|
Key:
|
52
|
-
Symbol (size=1
|
62
|
+
Symbol (size=1):
|
63
|
+
to_s: f
|
64
|
+
encoding: !ruby/encoding US-ASCII
|
53
65
|
Value: Fixnum 3
|
54
66
|
```
|
@@ -2,27 +2,39 @@
|
|
2
2
|
Hash (size=2 message='My nested hash'):
|
3
3
|
Pair 0:
|
4
4
|
Key:
|
5
|
-
Symbol (size=1
|
5
|
+
Symbol (size=1):
|
6
|
+
to_s: a
|
7
|
+
encoding: !ruby/encoding US-ASCII
|
6
8
|
Value:
|
7
9
|
Hash (size=2):
|
8
10
|
Pair 0:
|
9
11
|
Key:
|
10
|
-
Symbol (size=1
|
12
|
+
Symbol (size=1):
|
13
|
+
to_s: b
|
14
|
+
encoding: !ruby/encoding US-ASCII
|
11
15
|
Value: Fixnum 0
|
12
16
|
Pair 1:
|
13
17
|
Key:
|
14
|
-
Symbol (size=1
|
18
|
+
Symbol (size=1):
|
19
|
+
to_s: c
|
20
|
+
encoding: !ruby/encoding US-ASCII
|
15
21
|
Value: Fixnum 1
|
16
22
|
Pair 1:
|
17
23
|
Key:
|
18
|
-
Symbol (size=1
|
24
|
+
Symbol (size=1):
|
25
|
+
to_s: d
|
26
|
+
encoding: !ruby/encoding US-ASCII
|
19
27
|
Value:
|
20
28
|
Hash (size=2):
|
21
29
|
Pair 0:
|
22
30
|
Key:
|
23
|
-
Symbol (size=1
|
31
|
+
Symbol (size=1):
|
32
|
+
to_s: e
|
33
|
+
encoding: !ruby/encoding US-ASCII
|
24
34
|
Value: Fixnum 2
|
25
35
|
Pair 1:
|
26
36
|
Key:
|
27
|
-
Symbol (size=1
|
37
|
+
Symbol (size=1):
|
38
|
+
to_s: f
|
39
|
+
encoding: !ruby/encoding US-ASCII
|
28
40
|
Value: Fixnum 3
|
@@ -18,14 +18,20 @@ The output shows details of the hash.
|
|
18
18
|
Hash (size=3 message='My simple hash'):
|
19
19
|
Pair 0:
|
20
20
|
Key:
|
21
|
-
Symbol (size=1
|
21
|
+
Symbol (size=1):
|
22
|
+
to_s: a
|
23
|
+
encoding: !ruby/encoding US-ASCII
|
22
24
|
Value: Fixnum 0
|
23
25
|
Pair 1:
|
24
26
|
Key:
|
25
|
-
Symbol (size=1
|
27
|
+
Symbol (size=1):
|
28
|
+
to_s: b
|
29
|
+
encoding: !ruby/encoding US-ASCII
|
26
30
|
Value: Fixnum 1
|
27
31
|
Pair 2:
|
28
32
|
Key:
|
29
|
-
Symbol (size=1
|
33
|
+
Symbol (size=1):
|
34
|
+
to_s: c
|
35
|
+
encoding: !ruby/encoding US-ASCII
|
30
36
|
Value: Fixnum 2
|
31
37
|
```
|
@@ -2,13 +2,19 @@
|
|
2
2
|
Hash (size=3 message='My simple hash'):
|
3
3
|
Pair 0:
|
4
4
|
Key:
|
5
|
-
Symbol (size=1
|
5
|
+
Symbol (size=1):
|
6
|
+
to_s: a
|
7
|
+
encoding: !ruby/encoding US-ASCII
|
6
8
|
Value: Fixnum 0
|
7
9
|
Pair 1:
|
8
10
|
Key:
|
9
|
-
Symbol (size=1
|
11
|
+
Symbol (size=1):
|
12
|
+
to_s: b
|
13
|
+
encoding: !ruby/encoding US-ASCII
|
10
14
|
Value: Fixnum 1
|
11
15
|
Pair 2:
|
12
16
|
Key:
|
13
|
-
Symbol (size=1
|
17
|
+
Symbol (size=1):
|
18
|
+
to_s: c
|
19
|
+
encoding: !ruby/encoding US-ASCII
|
14
20
|
Value: Fixnum 2
|
@@ -1,2 +1,2 @@
|
|
1
|
-
--- DateTime (message='My datetime') 2018-07-
|
1
|
+
--- DateTime (message='My datetime') 2018-07-13T09:59:53-05:00
|
2
2
|
...
|
@@ -18,8 +18,11 @@ The output shows details of the string.
|
|
18
18
|
```show.yaml```:
|
19
19
|
```yaml
|
20
20
|
---
|
21
|
-
String (message='My multiline string' size=122
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
String (message='My multiline string' size=122):
|
22
|
+
to_s: |
|
23
|
+
Lorem Ipsum dolor sit amet,consectetur adipisicing elit,
|
24
|
+
sed doeiusmod tempor incididunt ut laboreet dolore magna aliqua.
|
25
|
+
encoding: !ruby/encoding UTF-8
|
26
|
+
ascii_only?: true
|
27
|
+
bytesize: 122
|
25
28
|
```
|
@@ -1,5 +1,8 @@
|
|
1
1
|
---
|
2
|
-
String (message='My multiline string' size=122
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
String (message='My multiline string' size=122):
|
3
|
+
to_s: |
|
4
|
+
Lorem Ipsum dolor sit amet,consectetur adipisicing elit,
|
5
|
+
sed doeiusmod tempor incididunt ut laboreet dolore magna aliqua.
|
6
|
+
encoding: !ruby/encoding UTF-8
|
7
|
+
ascii_only?: true
|
8
|
+
bytesize: 122
|
@@ -15,6 +15,9 @@ The output shows details of the string.
|
|
15
15
|
```show.yaml```:
|
16
16
|
```yaml
|
17
17
|
---
|
18
|
-
String (message='My simple string' size=11
|
19
|
-
|
18
|
+
String (message='My simple string' size=11):
|
19
|
+
to_s: Lorem ipsum
|
20
|
+
encoding: !ruby/encoding UTF-8
|
21
|
+
ascii_only?: true
|
22
|
+
bytesize: 11
|
20
23
|
```
|
@@ -23,10 +23,15 @@ MyStruct (message='My mixed struct' size=3):
|
|
23
23
|
Member 1:
|
24
24
|
Name: :b
|
25
25
|
Value:
|
26
|
-
String (size=3
|
27
|
-
|
26
|
+
String (size=3):
|
27
|
+
to_s: one
|
28
|
+
encoding: !ruby/encoding UTF-8
|
29
|
+
ascii_only?: true
|
30
|
+
bytesize: 3
|
28
31
|
Member 2:
|
29
32
|
Name: :c
|
30
33
|
Value:
|
31
|
-
Symbol (size=3
|
34
|
+
Symbol (size=3):
|
35
|
+
to_s: two
|
36
|
+
encoding: !ruby/encoding US-ASCII
|
32
37
|
```
|
@@ -6,9 +6,14 @@ MyStruct (message='My mixed struct' size=3):
|
|
6
6
|
Member 1:
|
7
7
|
Name: :b
|
8
8
|
Value:
|
9
|
-
String (size=3
|
10
|
-
|
9
|
+
String (size=3):
|
10
|
+
to_s: one
|
11
|
+
encoding: !ruby/encoding UTF-8
|
12
|
+
ascii_only?: true
|
13
|
+
bytesize: 3
|
11
14
|
Member 2:
|
12
15
|
Name: :c
|
13
16
|
Value:
|
14
|
-
Symbol (size=3
|
17
|
+
Symbol (size=3):
|
18
|
+
to_s: two
|
19
|
+
encoding: !ruby/encoding US-ASCII
|
@@ -0,0 +1,77 @@
|
|
1
|
+
### Option ```depth```
|
2
|
+
|
3
|
+
This example shows how option ```depth``` affects output.
|
4
|
+
|
5
|
+
```show.rb```:
|
6
|
+
```ruby
|
7
|
+
require 'debug_helper'
|
8
|
+
|
9
|
+
ary = [0,
|
10
|
+
[1,
|
11
|
+
[2,
|
12
|
+
[3,
|
13
|
+
[4]
|
14
|
+
]
|
15
|
+
]
|
16
|
+
]
|
17
|
+
]
|
18
|
+
(1..5).each do |depth|
|
19
|
+
message = "Show depth #{depth}"
|
20
|
+
DebugHelper.show(ary, message, {:depth => depth})
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
The output shows output for various depths.
|
25
|
+
|
26
|
+
```show.yaml```:
|
27
|
+
```yaml
|
28
|
+
---
|
29
|
+
Array (message='Show depth 1' size=2):
|
30
|
+
Element 0: Fixnum 0
|
31
|
+
Element 1: Array [1, [2, [3, [4]]]]
|
32
|
+
---
|
33
|
+
Array (message='Show depth 2' size=2):
|
34
|
+
Element 0: Fixnum 0
|
35
|
+
Element 1:
|
36
|
+
Array (size=2):
|
37
|
+
Element 0: Fixnum 1
|
38
|
+
Element 1: Array [2, [3, [4]]]
|
39
|
+
---
|
40
|
+
Array (message='Show depth 3' size=2):
|
41
|
+
Element 0: Fixnum 0
|
42
|
+
Element 1:
|
43
|
+
Array (size=2):
|
44
|
+
Element 0: Fixnum 1
|
45
|
+
Element 1:
|
46
|
+
Array (size=2):
|
47
|
+
Element 0: Fixnum 2
|
48
|
+
Element 1: Array [3, [4]]
|
49
|
+
---
|
50
|
+
Array (message='Show depth 4' size=2):
|
51
|
+
Element 0: Fixnum 0
|
52
|
+
Element 1:
|
53
|
+
Array (size=2):
|
54
|
+
Element 0: Fixnum 1
|
55
|
+
Element 1:
|
56
|
+
Array (size=2):
|
57
|
+
Element 0: Fixnum 2
|
58
|
+
Element 1:
|
59
|
+
Array (size=2):
|
60
|
+
Element 0: Fixnum 3
|
61
|
+
Element 1: Array [4]
|
62
|
+
---
|
63
|
+
Array (message='Show depth 5' size=2):
|
64
|
+
Element 0: Fixnum 0
|
65
|
+
Element 1:
|
66
|
+
Array (size=2):
|
67
|
+
Element 0: Fixnum 1
|
68
|
+
Element 1:
|
69
|
+
Array (size=2):
|
70
|
+
Element 0: Fixnum 2
|
71
|
+
Element 1:
|
72
|
+
Array (size=2):
|
73
|
+
Element 0: Fixnum 3
|
74
|
+
Element 1:
|
75
|
+
Array (size=1):
|
76
|
+
Element 0: Fixnum 4
|
77
|
+
```
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
Array (message='Show depth 1' size=2):
|
3
|
+
Element 0: Fixnum 0
|
4
|
+
Element 1: Array [1, [2, [3, [4]]]]
|
5
|
+
---
|
6
|
+
Array (message='Show depth 2' size=2):
|
7
|
+
Element 0: Fixnum 0
|
8
|
+
Element 1:
|
9
|
+
Array (size=2):
|
10
|
+
Element 0: Fixnum 1
|
11
|
+
Element 1: Array [2, [3, [4]]]
|
12
|
+
---
|
13
|
+
Array (message='Show depth 3' size=2):
|
14
|
+
Element 0: Fixnum 0
|
15
|
+
Element 1:
|
16
|
+
Array (size=2):
|
17
|
+
Element 0: Fixnum 1
|
18
|
+
Element 1:
|
19
|
+
Array (size=2):
|
20
|
+
Element 0: Fixnum 2
|
21
|
+
Element 1: Array [3, [4]]
|
22
|
+
---
|
23
|
+
Array (message='Show depth 4' size=2):
|
24
|
+
Element 0: Fixnum 0
|
25
|
+
Element 1:
|
26
|
+
Array (size=2):
|
27
|
+
Element 0: Fixnum 1
|
28
|
+
Element 1:
|
29
|
+
Array (size=2):
|
30
|
+
Element 0: Fixnum 2
|
31
|
+
Element 1:
|
32
|
+
Array (size=2):
|
33
|
+
Element 0: Fixnum 3
|
34
|
+
Element 1: Array [4]
|
35
|
+
---
|
36
|
+
Array (message='Show depth 5' size=2):
|
37
|
+
Element 0: Fixnum 0
|
38
|
+
Element 1:
|
39
|
+
Array (size=2):
|
40
|
+
Element 0: Fixnum 1
|
41
|
+
Element 1:
|
42
|
+
Array (size=2):
|
43
|
+
Element 0: Fixnum 2
|
44
|
+
Element 1:
|
45
|
+
Array (size=2):
|
46
|
+
Element 0: Fixnum 3
|
47
|
+
Element 1:
|
48
|
+
Array (size=1):
|
49
|
+
Element 0: Fixnum 4
|
data/markdown/readme/template.md
CHANGED
@@ -14,6 +14,8 @@ For certain classes (see below), the analysis is very detailed.
|
|
14
14
|
|
15
15
|
For the collection classes ```Array```, ```Hash```, and ```Struct```, the analysis is also recursive; that is, the collection's values are themselves analyzed.
|
16
16
|
|
17
|
+
You can control the depth of recursion using option ```depth```. See [Options](#options).
|
18
|
+
|
17
19
|
Classes treated in detail:
|
18
20
|
|
19
21
|
@[:markdown](class_links.md)
|
@@ -42,3 +44,7 @@ putd obj, message
|
|
42
44
|
Just be sure to ```include DebugHelper::Putd```.
|
43
45
|
|
44
46
|
@[:markdown](class_inclusions.md)
|
47
|
+
|
48
|
+
## Options
|
49
|
+
|
50
|
+
@[:markdown](options/depth/show.md)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debug_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- burdettelamar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -156,6 +156,10 @@ files:
|
|
156
156
|
- markdown/readme/classes/symbol/simple/template.md
|
157
157
|
- markdown/readme/classes/symbol/template.md
|
158
158
|
- markdown/readme/classes/template.md
|
159
|
+
- markdown/readme/options/depth/show.md
|
160
|
+
- markdown/readme/options/depth/show.rb
|
161
|
+
- markdown/readme/options/depth/show.yaml
|
162
|
+
- markdown/readme/options/depth/template.md
|
159
163
|
- markdown/readme/show_array.rb
|
160
164
|
- markdown/readme/show_hash.rb
|
161
165
|
- markdown/readme/template.md
|