debug_helper 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +21 -0
- data/README.md +593 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/debug_helper.gemspec +37 -0
- data/lib/debug_helper.rb +154 -0
- data/lib/debug_helper/version.rb +3 -0
- data/markdown/readme/Rakefile +53 -0
- data/markdown/readme/class_inclusions.md +6 -0
- data/markdown/readme/class_links.md +5 -0
- data/markdown/readme/classes/array/circular/show.md +27 -0
- data/markdown/readme/classes/array/circular/show.rb +7 -0
- data/markdown/readme/classes/array/circular/show.yaml +5 -0
- data/markdown/readme/classes/array/circular/template.md +11 -0
- data/markdown/readme/classes/array/mixed/show.md +25 -0
- data/markdown/readme/classes/array/mixed/show.rb +4 -0
- data/markdown/readme/classes/array/mixed/show.yaml +8 -0
- data/markdown/readme/classes/array/mixed/template.md +9 -0
- data/markdown/readme/classes/array/nested/show.md +28 -0
- data/markdown/readme/classes/array/nested/show.rb +4 -0
- data/markdown/readme/classes/array/nested/show.yaml +11 -0
- data/markdown/readme/classes/array/nested/template.md +9 -0
- data/markdown/readme/classes/array/simple/show.md +22 -0
- data/markdown/readme/classes/array/simple/show.rb +4 -0
- data/markdown/readme/classes/array/simple/show.yaml +5 -0
- data/markdown/readme/classes/array/simple/template.md +9 -0
- data/markdown/readme/classes/array/template.md +9 -0
- data/markdown/readme/classes/hash/circular/show.md +33 -0
- data/markdown/readme/classes/hash/circular/show.rb +7 -0
- data/markdown/readme/classes/hash/circular/show.yaml +11 -0
- data/markdown/readme/classes/hash/circular/template.md +11 -0
- data/markdown/readme/classes/hash/mixed/show.md +38 -0
- data/markdown/readme/classes/hash/mixed/show.rb +8 -0
- data/markdown/readme/classes/hash/mixed/show.yaml +17 -0
- data/markdown/readme/classes/hash/mixed/template.md +9 -0
- data/markdown/readme/classes/hash/nested/show.md +54 -0
- data/markdown/readme/classes/hash/nested/show.rb +13 -0
- data/markdown/readme/classes/hash/nested/show.yaml +28 -0
- data/markdown/readme/classes/hash/nested/template.md +9 -0
- data/markdown/readme/classes/hash/simple/show.md +31 -0
- data/markdown/readme/classes/hash/simple/show.rb +4 -0
- data/markdown/readme/classes/hash/simple/show.yaml +14 -0
- data/markdown/readme/classes/hash/simple/template.md +9 -0
- data/markdown/readme/classes/hash/template.md +9 -0
- data/markdown/readme/classes/object/datetime/show.md +19 -0
- data/markdown/readme/classes/object/datetime/show.rb +4 -0
- data/markdown/readme/classes/object/datetime/show.yaml +2 -0
- data/markdown/readme/classes/object/datetime/template.md +9 -0
- data/markdown/readme/classes/object/range/show.md +19 -0
- data/markdown/readme/classes/object/range/show.rb +4 -0
- data/markdown/readme/classes/object/range/show.yaml +2 -0
- data/markdown/readme/classes/object/range/template.md +9 -0
- data/markdown/readme/classes/object/regexp/show.md +19 -0
- data/markdown/readme/classes/object/regexp/show.rb +4 -0
- data/markdown/readme/classes/object/regexp/show.yaml +2 -0
- data/markdown/readme/classes/object/regexp/template.md +9 -0
- data/markdown/readme/classes/object/template.md +11 -0
- data/markdown/readme/classes/string/multiline/show.md +25 -0
- data/markdown/readme/classes/string/multiline/show.rb +7 -0
- data/markdown/readme/classes/string/multiline/show.yaml +5 -0
- data/markdown/readme/classes/string/multiline/template.md +9 -0
- data/markdown/readme/classes/string/simple/show.md +20 -0
- data/markdown/readme/classes/string/simple/show.rb +4 -0
- data/markdown/readme/classes/string/simple/show.yaml +3 -0
- data/markdown/readme/classes/string/simple/template.md +9 -0
- data/markdown/readme/classes/string/template.md +5 -0
- data/markdown/readme/classes/struct/circular/show.md +45 -0
- data/markdown/readme/classes/struct/circular/show.rb +8 -0
- data/markdown/readme/classes/struct/circular/show.yaml +22 -0
- data/markdown/readme/classes/struct/circular/template.md +11 -0
- data/markdown/readme/classes/struct/mixed/show.md +32 -0
- data/markdown/readme/classes/struct/mixed/show.rb +5 -0
- data/markdown/readme/classes/struct/mixed/show.yaml +14 -0
- data/markdown/readme/classes/struct/mixed/template.md +9 -0
- data/markdown/readme/classes/struct/nested/show.md +43 -0
- data/markdown/readme/classes/struct/nested/show.rb +8 -0
- data/markdown/readme/classes/struct/nested/show.yaml +22 -0
- data/markdown/readme/classes/struct/nested/template.md +9 -0
- data/markdown/readme/classes/struct/simple/show.md +29 -0
- data/markdown/readme/classes/struct/simple/show.rb +5 -0
- data/markdown/readme/classes/struct/simple/show.yaml +11 -0
- data/markdown/readme/classes/struct/simple/template.md +9 -0
- data/markdown/readme/classes/struct/template.md +9 -0
- data/markdown/readme/classes/symbol/simple/show.md +18 -0
- data/markdown/readme/classes/symbol/simple/show.rb +3 -0
- data/markdown/readme/classes/symbol/simple/show.yaml +2 -0
- data/markdown/readme/classes/symbol/simple/template.md +9 -0
- data/markdown/readme/classes/symbol/template.md +3 -0
- data/markdown/readme/classes/template.md +12 -0
- data/markdown/readme/show_array.rb +3 -0
- data/markdown/readme/show_hash.rb +3 -0
- data/markdown/readme/template.md +25 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fb6a987450802b19bf3b2e7627185c7bbacee42f
|
4
|
+
data.tar.gz: 22252b082a4f4c6073b39bcb018d25826a097a2d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6892932fd1b46356cb94ea20e9ca6c259710c84d73742253dec38c63b6c12c7c2541dc6ba863cc91c21dc8f4496ce15e48662492cd0e90cac2a3d73ecdb3266d
|
7
|
+
data.tar.gz: da0a37b7abacf2e4721902551e4b26edcaec71e3b3a129e633f3b2fbb8a53dcfe28bf214d09593695c78b5ccff03ad3a7f2944780943e6dcd7774a7fa4627f18
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at burdettelamar@yahoo.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
debug_helper (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
minitest (5.11.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
|
12
|
+
PLATFORMS
|
13
|
+
x64-mingw32
|
14
|
+
|
15
|
+
DEPENDENCIES
|
16
|
+
bundler (~> 1.16)
|
17
|
+
debug_helper!
|
18
|
+
minitest (~> 5.0)
|
19
|
+
rake (~> 10.0)
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 burdettelamar
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,593 @@
|
|
1
|
+
# Debug Helper
|
2
|
+
|
3
|
+
If (like me), your debugging style is [printf debugging](https://en.wikipedia.org/wiki/Debugging#Techniques), you will have shoved this into your code many times:
|
4
|
+
|
5
|
+
```show_hash.rb```:
|
6
|
+
```ruby
|
7
|
+
hash.each_pair do |key, value|
|
8
|
+
p [key, value]
|
9
|
+
end
|
10
|
+
```
|
11
|
+
|
12
|
+
And this:
|
13
|
+
|
14
|
+
```show_array.rb```:
|
15
|
+
```ruby
|
16
|
+
array.each_with_index do |item, i|
|
17
|
+
p [i, item]
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
This helper assists in debugging by printing an analysis of a given object. The analysis is a ```yaml``` structure, and is written to ```stdout```.
|
22
|
+
|
23
|
+
For certain classes (see below), the analysis is very detailed.
|
24
|
+
|
25
|
+
For the collection classes ```Array```, ```Hash```, and ```Struct```, the analysis is also recursive; that is, the collection's values are themselves analyzed.
|
26
|
+
|
27
|
+
Classes treated in detail:
|
28
|
+
|
29
|
+
- [Array](#array)
|
30
|
+
- [Hash](#hash)
|
31
|
+
- [Struct](#struct)
|
32
|
+
- [String](#string)
|
33
|
+
- [Symbol](#symbol)
|
34
|
+
|
35
|
+
Others are treated as:
|
36
|
+
|
37
|
+
- [Object](#object)
|
38
|
+
|
39
|
+
### Array
|
40
|
+
|
41
|
+
#### Simple Array
|
42
|
+
|
43
|
+
This example shows a simple array of integers.
|
44
|
+
|
45
|
+
```show.rb```:
|
46
|
+
```ruby
|
47
|
+
require 'debug_helper'
|
48
|
+
|
49
|
+
ary = [5, 10, 15]
|
50
|
+
DebugHelper.show(ary, 'My simple array')
|
51
|
+
```
|
52
|
+
|
53
|
+
The output shows details of the array.
|
54
|
+
|
55
|
+
```show.yaml```:
|
56
|
+
```yaml
|
57
|
+
---
|
58
|
+
Array (name='My simple array' size=3):
|
59
|
+
Element 0: Fixnum 5
|
60
|
+
Element 1: Fixnum 10
|
61
|
+
Element 2: Fixnum 15
|
62
|
+
```
|
63
|
+
|
64
|
+
#### Mixed Array
|
65
|
+
|
66
|
+
This example shows an array of mixed values.
|
67
|
+
|
68
|
+
```show.rb```:
|
69
|
+
```ruby
|
70
|
+
require 'debug_helper'
|
71
|
+
|
72
|
+
ary = [0, 'one', :two]
|
73
|
+
DebugHelper.show(ary, 'My mixed array')
|
74
|
+
```
|
75
|
+
|
76
|
+
The output shows details of the array.
|
77
|
+
|
78
|
+
```show.yaml```:
|
79
|
+
```yaml
|
80
|
+
---
|
81
|
+
Array (name='My mixed array' size=3):
|
82
|
+
Element 0: Fixnum 0
|
83
|
+
Element 1:
|
84
|
+
String (size=3 encoding=UTF-8 ascii_only=true bytesize=3):
|
85
|
+
- one
|
86
|
+
Element 2:
|
87
|
+
Symbol (size=3 encoding=US-ASCII): :two
|
88
|
+
```
|
89
|
+
|
90
|
+
#### Nested Arrays
|
91
|
+
|
92
|
+
This example shows nested arrays.
|
93
|
+
|
94
|
+
```show.rb```:
|
95
|
+
```ruby
|
96
|
+
require 'debug_helper'
|
97
|
+
|
98
|
+
ary = [0, [1, 2], [3, 4]]
|
99
|
+
DebugHelper.show(ary, 'My nested arrays')
|
100
|
+
```
|
101
|
+
|
102
|
+
The output shows details of the arrays.
|
103
|
+
|
104
|
+
```show.yaml```:
|
105
|
+
```yaml
|
106
|
+
---
|
107
|
+
Array (name='My nested arrays' size=3):
|
108
|
+
Element 0: Fixnum 0
|
109
|
+
Element 1:
|
110
|
+
Array (size=2):
|
111
|
+
Element 0: Fixnum 1
|
112
|
+
Element 1: Fixnum 2
|
113
|
+
Element 2:
|
114
|
+
Array (size=2):
|
115
|
+
Element 0: Fixnum 3
|
116
|
+
Element 1: Fixnum 4
|
117
|
+
```
|
118
|
+
|
119
|
+
#### Circular Arrays
|
120
|
+
|
121
|
+
This example shows arrays that make a circular reference.
|
122
|
+
|
123
|
+
```show.rb```:
|
124
|
+
```ruby
|
125
|
+
require 'debug_helper'
|
126
|
+
|
127
|
+
ary_0 = []
|
128
|
+
ary_1 = []
|
129
|
+
ary_0.push(ary_1)
|
130
|
+
ary_1.push(ary_0)
|
131
|
+
DebugHelper.show(ary_0, 'My circular arrays')
|
132
|
+
```
|
133
|
+
|
134
|
+
The output shows details of the arrays.
|
135
|
+
|
136
|
+
The circular reference is not followed.
|
137
|
+
|
138
|
+
```show.yaml```:
|
139
|
+
```yaml
|
140
|
+
---
|
141
|
+
Array (name='My circular arrays' size=1):
|
142
|
+
Element 0:
|
143
|
+
Array (size=1):
|
144
|
+
Element 0: Array [[[...]]]
|
145
|
+
```
|
146
|
+
### Hash
|
147
|
+
|
148
|
+
#### Simple Hash
|
149
|
+
|
150
|
+
This example shows a simple hash.
|
151
|
+
|
152
|
+
```show.rb```:
|
153
|
+
```ruby
|
154
|
+
require 'debug_helper'
|
155
|
+
|
156
|
+
hash = {:a => 0, :b => 1, :c => 2}
|
157
|
+
DebugHelper.show(hash, 'My simple hash')
|
158
|
+
```
|
159
|
+
|
160
|
+
The output shows details of the hash.
|
161
|
+
|
162
|
+
```show.yaml```:
|
163
|
+
```yaml
|
164
|
+
---
|
165
|
+
Hash (size=3 name='My simple hash'):
|
166
|
+
Pair 0:
|
167
|
+
Key:
|
168
|
+
Symbol (size=1 encoding=US-ASCII): :a
|
169
|
+
Value: Fixnum 0
|
170
|
+
Pair 1:
|
171
|
+
Key:
|
172
|
+
Symbol (size=1 encoding=US-ASCII): :b
|
173
|
+
Value: Fixnum 1
|
174
|
+
Pair 2:
|
175
|
+
Key:
|
176
|
+
Symbol (size=1 encoding=US-ASCII): :c
|
177
|
+
Value: Fixnum 2
|
178
|
+
```
|
179
|
+
|
180
|
+
#### Mixed Hash
|
181
|
+
|
182
|
+
This example shows a hash of mixed values.
|
183
|
+
|
184
|
+
```show.rb```:
|
185
|
+
```ruby
|
186
|
+
require 'debug_helper'
|
187
|
+
|
188
|
+
hash = {
|
189
|
+
:a => 0,
|
190
|
+
:b => 'one',
|
191
|
+
:c => :two,
|
192
|
+
}
|
193
|
+
DebugHelper.show(hash, 'My mixed hash')
|
194
|
+
```
|
195
|
+
|
196
|
+
The output shows details of the hash.
|
197
|
+
|
198
|
+
```show.yaml```:
|
199
|
+
```yaml
|
200
|
+
---
|
201
|
+
Hash (size=3 name='My mixed hash'):
|
202
|
+
Pair 0:
|
203
|
+
Key:
|
204
|
+
Symbol (size=1 encoding=US-ASCII): :a
|
205
|
+
Value: Fixnum 0
|
206
|
+
Pair 1:
|
207
|
+
Key:
|
208
|
+
Symbol (size=1 encoding=US-ASCII): :b
|
209
|
+
Value:
|
210
|
+
String (size=3 encoding=UTF-8 ascii_only=true bytesize=3):
|
211
|
+
- one
|
212
|
+
Pair 2:
|
213
|
+
Key:
|
214
|
+
Symbol (size=1 encoding=US-ASCII): :c
|
215
|
+
Value:
|
216
|
+
Symbol (size=3 encoding=US-ASCII): :two
|
217
|
+
```
|
218
|
+
|
219
|
+
#### Nested Hashes
|
220
|
+
|
221
|
+
This example shows nested hashes.
|
222
|
+
|
223
|
+
```show.rb```:
|
224
|
+
```ruby
|
225
|
+
require 'debug_helper'
|
226
|
+
|
227
|
+
hash = {
|
228
|
+
:a => {
|
229
|
+
:b => 0,
|
230
|
+
:c => 1,
|
231
|
+
},
|
232
|
+
:d => {
|
233
|
+
:e => 2,
|
234
|
+
:f => 3,
|
235
|
+
}
|
236
|
+
}
|
237
|
+
DebugHelper.show(hash, 'My nested hash')
|
238
|
+
```
|
239
|
+
|
240
|
+
The output shows details of the hashes.
|
241
|
+
|
242
|
+
```show.yaml```:
|
243
|
+
```yaml
|
244
|
+
---
|
245
|
+
Hash (size=2 name='My nested hash'):
|
246
|
+
Pair 0:
|
247
|
+
Key:
|
248
|
+
Symbol (size=1 encoding=US-ASCII): :a
|
249
|
+
Value:
|
250
|
+
Hash (size=2):
|
251
|
+
Pair 0:
|
252
|
+
Key:
|
253
|
+
Symbol (size=1 encoding=US-ASCII): :b
|
254
|
+
Value: Fixnum 0
|
255
|
+
Pair 1:
|
256
|
+
Key:
|
257
|
+
Symbol (size=1 encoding=US-ASCII): :c
|
258
|
+
Value: Fixnum 1
|
259
|
+
Pair 1:
|
260
|
+
Key:
|
261
|
+
Symbol (size=1 encoding=US-ASCII): :d
|
262
|
+
Value:
|
263
|
+
Hash (size=2):
|
264
|
+
Pair 0:
|
265
|
+
Key:
|
266
|
+
Symbol (size=1 encoding=US-ASCII): :e
|
267
|
+
Value: Fixnum 2
|
268
|
+
Pair 1:
|
269
|
+
Key:
|
270
|
+
Symbol (size=1 encoding=US-ASCII): :f
|
271
|
+
Value: Fixnum 3
|
272
|
+
```
|
273
|
+
|
274
|
+
#### Circular Hashes
|
275
|
+
|
276
|
+
This example shows hashes that make a circular reference.
|
277
|
+
|
278
|
+
```show.rb```:
|
279
|
+
```ruby
|
280
|
+
require 'debug_helper'
|
281
|
+
|
282
|
+
hash_0 = {}
|
283
|
+
hash_1 = {}
|
284
|
+
hash_0.store(:foo, hash_1)
|
285
|
+
hash_1.store(:bar, hash_0)
|
286
|
+
DebugHelper.show(hash_0, 'My circular hashes')
|
287
|
+
```
|
288
|
+
|
289
|
+
The output shows details of the hashes.
|
290
|
+
|
291
|
+
The circular reference is not followed.
|
292
|
+
|
293
|
+
```show.yaml```:
|
294
|
+
```yaml
|
295
|
+
---
|
296
|
+
Hash (size=1 name='My circular hashes'):
|
297
|
+
Pair 0:
|
298
|
+
Key:
|
299
|
+
Symbol (size=3 encoding=US-ASCII): :foo
|
300
|
+
Value:
|
301
|
+
Hash (size=1):
|
302
|
+
Pair 0:
|
303
|
+
Key:
|
304
|
+
Symbol (size=3 encoding=US-ASCII): :bar
|
305
|
+
Value: Hash {:foo=>{:bar=>{...}}}
|
306
|
+
```
|
307
|
+
### Struct
|
308
|
+
|
309
|
+
#### Simple Struct
|
310
|
+
|
311
|
+
This example shows a simple struct.
|
312
|
+
|
313
|
+
```show.rb```:
|
314
|
+
```ruby
|
315
|
+
require 'debug_helper'
|
316
|
+
|
317
|
+
MyStruct = Struct.new(:a, :b, :c)
|
318
|
+
struct = MyStruct.new(0, 1, 2)
|
319
|
+
DebugHelper.show(struct, 'My simple struct')
|
320
|
+
```
|
321
|
+
|
322
|
+
The output shows details of the struct.
|
323
|
+
|
324
|
+
```show.yaml```:
|
325
|
+
```yaml
|
326
|
+
---
|
327
|
+
MyStruct (name='My simple struct' size=3):
|
328
|
+
Member 0:
|
329
|
+
Name: :a
|
330
|
+
Value: Fixnum 0
|
331
|
+
Member 1:
|
332
|
+
Name: :b
|
333
|
+
Value: Fixnum 1
|
334
|
+
Member 2:
|
335
|
+
Name: :c
|
336
|
+
Value: Fixnum 2
|
337
|
+
```
|
338
|
+
|
339
|
+
#### Mixed Struct
|
340
|
+
|
341
|
+
This example shows a struct of mixed values.
|
342
|
+
|
343
|
+
```show.rb```:
|
344
|
+
```ruby
|
345
|
+
require 'debug_helper'
|
346
|
+
|
347
|
+
MyStruct = Struct.new(:a, :b, :c)
|
348
|
+
struct = MyStruct.new(0, 'one', :two)
|
349
|
+
DebugHelper.show(struct, 'My mixed struct')
|
350
|
+
```
|
351
|
+
|
352
|
+
The output shows details of the struct.
|
353
|
+
|
354
|
+
```show.yaml```:
|
355
|
+
```yaml
|
356
|
+
---
|
357
|
+
MyStruct (name='My mixed struct' size=3):
|
358
|
+
Member 0:
|
359
|
+
Name: :a
|
360
|
+
Value: Fixnum 0
|
361
|
+
Member 1:
|
362
|
+
Name: :b
|
363
|
+
Value:
|
364
|
+
String (size=3 encoding=UTF-8 ascii_only=true bytesize=3):
|
365
|
+
- one
|
366
|
+
Member 2:
|
367
|
+
Name: :c
|
368
|
+
Value:
|
369
|
+
Symbol (size=3 encoding=US-ASCII): :two
|
370
|
+
```
|
371
|
+
|
372
|
+
#### Nested Structs
|
373
|
+
|
374
|
+
This example shows nested structs.
|
375
|
+
|
376
|
+
```show.rb```:
|
377
|
+
```ruby
|
378
|
+
require 'debug_helper'
|
379
|
+
|
380
|
+
MyStruct_0 = Struct.new(:a, :b)
|
381
|
+
MyStruct_1 = Struct.new(:c, :d)
|
382
|
+
struct_1a = MyStruct_1.new(2, 3)
|
383
|
+
struct_1b = MyStruct_1.new(4, 5)
|
384
|
+
struct_0 = MyStruct_0.new(struct_1a, struct_1b)
|
385
|
+
DebugHelper.show(struct_0, 'My nested struct')
|
386
|
+
```
|
387
|
+
|
388
|
+
The output shows details of the structs.
|
389
|
+
|
390
|
+
```show.yaml```:
|
391
|
+
```yaml
|
392
|
+
---
|
393
|
+
MyStruct_0 (name='My nested struct' size=2):
|
394
|
+
Member 0:
|
395
|
+
Name: :a
|
396
|
+
Value:
|
397
|
+
MyStruct_1 (size=2):
|
398
|
+
Member 0:
|
399
|
+
Name: :c
|
400
|
+
Value: Fixnum 2
|
401
|
+
Member 1:
|
402
|
+
Name: :d
|
403
|
+
Value: Fixnum 3
|
404
|
+
Member 1:
|
405
|
+
Name: :b
|
406
|
+
Value:
|
407
|
+
MyStruct_1 (size=2):
|
408
|
+
Member 0:
|
409
|
+
Name: :c
|
410
|
+
Value: Fixnum 4
|
411
|
+
Member 1:
|
412
|
+
Name: :d
|
413
|
+
Value: Fixnum 5
|
414
|
+
```
|
415
|
+
|
416
|
+
#### Circular Structs
|
417
|
+
|
418
|
+
This example shows structs that make a circular reference.
|
419
|
+
|
420
|
+
```show.rb```:
|
421
|
+
```ruby
|
422
|
+
require 'debug_helper'
|
423
|
+
|
424
|
+
MyStruct = Struct.new(:a, :b, :c)
|
425
|
+
struct_0 = MyStruct.new(0, 1, 2)
|
426
|
+
struct_1 = MyStruct.new(3, 4, 5)
|
427
|
+
struct_0.a = struct_1
|
428
|
+
struct_1.a = struct_0
|
429
|
+
DebugHelper.show(struct_0, 'My circular struct')
|
430
|
+
```
|
431
|
+
|
432
|
+
The output shows details of the structs.
|
433
|
+
|
434
|
+
The circular reference is not followed.
|
435
|
+
|
436
|
+
```show.yaml```:
|
437
|
+
```yaml
|
438
|
+
---
|
439
|
+
MyStruct (name='My circular struct' size=3):
|
440
|
+
Member 0:
|
441
|
+
Name: :a
|
442
|
+
Value:
|
443
|
+
MyStruct (size=3):
|
444
|
+
Member 0:
|
445
|
+
Name: :a
|
446
|
+
Value: 'MyStruct #<struct MyStruct a=#<struct MyStruct a=#<struct MyStruct:...>,
|
447
|
+
b=4, c=5>, b=1, c=2>'
|
448
|
+
Member 1:
|
449
|
+
Name: :b
|
450
|
+
Value: Fixnum 4
|
451
|
+
Member 2:
|
452
|
+
Name: :c
|
453
|
+
Value: Fixnum 5
|
454
|
+
Member 1:
|
455
|
+
Name: :b
|
456
|
+
Value: Fixnum 1
|
457
|
+
Member 2:
|
458
|
+
Name: :c
|
459
|
+
Value: Fixnum 2
|
460
|
+
```
|
461
|
+
### String
|
462
|
+
|
463
|
+
#### Simple String
|
464
|
+
|
465
|
+
This example shows a simple string.
|
466
|
+
|
467
|
+
```show.rb```:
|
468
|
+
```ruby
|
469
|
+
require 'debug_helper'
|
470
|
+
|
471
|
+
s = 'Lorem ipsum'
|
472
|
+
DebugHelper.show(s, 'My simple string')
|
473
|
+
```
|
474
|
+
|
475
|
+
The output shows details of the string.
|
476
|
+
|
477
|
+
```show.yaml```:
|
478
|
+
```yaml
|
479
|
+
---
|
480
|
+
String (name='My simple string' size=11 encoding=UTF-8 ascii_only=true bytesize=11):
|
481
|
+
- Lorem ipsum
|
482
|
+
```
|
483
|
+
|
484
|
+
#### Multiline String
|
485
|
+
|
486
|
+
This example shows a multiline string.
|
487
|
+
|
488
|
+
```show.rb```:
|
489
|
+
```ruby
|
490
|
+
require 'debug_helper'
|
491
|
+
|
492
|
+
s = <<EOT
|
493
|
+
Lorem Ipsum dolor sit amet,consectetur adipisicing elit,
|
494
|
+
sed doeiusmod tempor incididunt ut laboreet dolore magna aliqua.
|
495
|
+
EOT
|
496
|
+
DebugHelper.show(s, 'My multiline string')
|
497
|
+
```
|
498
|
+
|
499
|
+
The output shows details of the string.
|
500
|
+
|
501
|
+
```show.yaml```:
|
502
|
+
```yaml
|
503
|
+
---
|
504
|
+
String (name='My multiline string' size=122 encoding=UTF-8 ascii_only=true bytesize=122):
|
505
|
+
- |
|
506
|
+
Lorem Ipsum dolor sit amet,consectetur adipisicing elit,
|
507
|
+
sed doeiusmod tempor incididunt ut laboreet dolore magna aliqua.
|
508
|
+
```
|
509
|
+
### Symbol
|
510
|
+
|
511
|
+
#### Simple Symbol
|
512
|
+
|
513
|
+
This example shows a simple symbol.
|
514
|
+
|
515
|
+
```show.rb```:
|
516
|
+
```ruby
|
517
|
+
require 'debug_helper'
|
518
|
+
|
519
|
+
DebugHelper.show(:lorem_ipsum, 'My symbol')
|
520
|
+
```
|
521
|
+
|
522
|
+
The output shows details of the symbol.
|
523
|
+
|
524
|
+
```show.yaml```:
|
525
|
+
```yaml
|
526
|
+
---
|
527
|
+
Symbol (name='My symbol' size=11 encoding=US-ASCII): :lorem_ipsum
|
528
|
+
```
|
529
|
+
### Object
|
530
|
+
|
531
|
+
Classes not mentioned above are not analyzed, but are treated more simply.
|
532
|
+
|
533
|
+
A few examples are shown below.
|
534
|
+
|
535
|
+
#### DateTime
|
536
|
+
|
537
|
+
This example shows a datetime.
|
538
|
+
|
539
|
+
```show.rb```:
|
540
|
+
```ruby
|
541
|
+
require 'debug_helper'
|
542
|
+
|
543
|
+
datetime = DateTime.now
|
544
|
+
DebugHelper.show(datetime, 'My datetime')
|
545
|
+
```
|
546
|
+
|
547
|
+
The output shows details of the datetime.
|
548
|
+
|
549
|
+
```show.yaml```:
|
550
|
+
```yaml
|
551
|
+
--- DateTime (name='My datetime') 2018-06-29T18:32:57-05:00
|
552
|
+
...
|
553
|
+
```
|
554
|
+
|
555
|
+
#### Range
|
556
|
+
|
557
|
+
This example shows a range.
|
558
|
+
|
559
|
+
```show.rb```:
|
560
|
+
```ruby
|
561
|
+
require 'debug_helper'
|
562
|
+
|
563
|
+
range = Range.new(0, 9)
|
564
|
+
DebugHelper.show(range, 'My range')
|
565
|
+
```
|
566
|
+
|
567
|
+
The output shows details of the range.
|
568
|
+
|
569
|
+
```show.yaml```:
|
570
|
+
```yaml
|
571
|
+
--- Range (name='My range') 0..9
|
572
|
+
...
|
573
|
+
```
|
574
|
+
|
575
|
+
#### Regexp
|
576
|
+
|
577
|
+
This example shows a regexp.
|
578
|
+
|
579
|
+
```show.rb```:
|
580
|
+
```ruby
|
581
|
+
require 'debug_helper'
|
582
|
+
|
583
|
+
regexp = Regexp.new('foo')
|
584
|
+
DebugHelper.show(regexp, 'My regexp')
|
585
|
+
```
|
586
|
+
|
587
|
+
The output shows details of the regexp.
|
588
|
+
|
589
|
+
```show.yaml```:
|
590
|
+
```yaml
|
591
|
+
--- Regexp (name='My regexp') (?-mix:foo)
|
592
|
+
...
|
593
|
+
```
|