object_inspector 0.8.2 → 0.9.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 +4 -4
- data/README.md +118 -95
- data/lib/object_inspector/formatters/base_formatter.rb +1 -1
- data/lib/object_inspector/formatters/combining_formatter.rb +5 -0
- data/lib/object_inspector/inspector.rb +3 -3
- data/lib/object_inspector/version.rb +1 -1
- data/lib/object_inspector.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50466d066a40b772c3d98ff85d1be9934a3011e9699261de12da2b620bec1785
|
4
|
+
data.tar.gz: 6deb6b097b7ee1c6d553754242ecbcc0683b3768c5906c139c279a6e07e21da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fccec790066ab69fad5c25d737c04b3c5698860d6acca5bc828e0be0a1186260060ad328c183dffc58012c9461405259de1ffb27b763e370df1cc48aa08459d4
|
7
|
+
data.tar.gz: a20c43a5d28088cd5ca7c0da08e1c456f8d4e0433faf7a552401855b66267c8b596e1beb7885ec9a80e829ac9b2523287ef2e3139122ca4b961d3cc54a0072ab
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Object Inspector takes Object#inspect to the next level. Specify any combination of identification attributes, flags, issues, info, and/or a name along with an optional, self-definable scope option to represent objects. Great for the console, logging, etc.
|
7
7
|
|
8
|
-
Why? Because object inspection code should be uniform
|
8
|
+
Why? Because object inspection code should be uniform and easy to build, and its output should be easy to read! Consistency improves readability.
|
9
9
|
|
10
10
|
If you'd like to just jump into an example: [Full Example](#full-example).
|
11
11
|
|
@@ -19,11 +19,15 @@ gem "object_inspector"
|
|
19
19
|
|
20
20
|
And then execute:
|
21
21
|
|
22
|
-
|
22
|
+
```sh
|
23
|
+
$ bundle
|
24
|
+
```
|
23
25
|
|
24
26
|
Or install it yourself:
|
25
27
|
|
26
|
-
|
28
|
+
```sh
|
29
|
+
$ gem install object_inspector
|
30
|
+
```
|
27
31
|
|
28
32
|
## Compatibility
|
29
33
|
|
@@ -42,19 +46,19 @@ gem "object_inspector", "0.6.3"
|
|
42
46
|
For Ruby 3.1 support, install object_inspector gem version 0.7.0.
|
43
47
|
|
44
48
|
```ruby
|
45
|
-
gem "object_inspector", "0.
|
49
|
+
gem "object_inspector", "0.7.0"
|
46
50
|
```
|
47
51
|
|
48
52
|
Object Inspector has no other dependencies.
|
49
53
|
|
50
54
|
## Configuration
|
51
55
|
|
52
|
-
Global/default values for Object Inspector can be configured via the ObjectInspector::Configuration object.
|
53
|
-
|
54
|
-
_Note: In a Rails app, the following would go in e.g. `config/initializers/object_inspector.rb`_
|
56
|
+
Global/default values for Object Inspector can be configured via the [ObjectInspector::Configuration] object.
|
55
57
|
|
56
58
|
```ruby
|
57
|
-
#
|
59
|
+
# config/initializers/object_inspector.rb
|
60
|
+
|
61
|
+
# Default values are shown. Customize to your liking.
|
58
62
|
ObjectInspector.configure do |config|
|
59
63
|
config.formatter_class = ObjectInspector::TemplatingFormatter
|
60
64
|
config.inspect_method_prefix = "inspect"
|
@@ -71,7 +75,7 @@ end
|
|
71
75
|
|
72
76
|
## Usage
|
73
77
|
|
74
|
-
|
78
|
+
Pass an object of any type into `ObjectInspector::Inspector.inspect`.
|
75
79
|
|
76
80
|
```ruby
|
77
81
|
class MyObject
|
@@ -83,11 +87,11 @@ end
|
|
83
87
|
MyObject.new.inspect # => "<MyObject>"
|
84
88
|
```
|
85
89
|
|
86
|
-
See
|
90
|
+
See: [Helper Usage](#helper-usage) for simpler usage.
|
87
91
|
|
88
92
|
### Output Customization
|
89
93
|
|
90
|
-
Use the `identification`, `flags`, `info`, and/or `name` options to customize inspect output.
|
94
|
+
Use the `identification`, `flags`, `issues`, `info`, and/or `name` options to customize inspect output.
|
91
95
|
|
92
96
|
```ruby
|
93
97
|
class MyObject
|
@@ -96,15 +100,17 @@ class MyObject
|
|
96
100
|
self,
|
97
101
|
identification: "My Object",
|
98
102
|
flags: "FLAG1 / FLAG2",
|
103
|
+
issues: "ISSUE1",
|
99
104
|
info: "INFO",
|
100
105
|
name: "NAME")
|
101
106
|
end
|
102
107
|
end
|
103
108
|
|
104
|
-
MyObject.new.inspect
|
109
|
+
MyObject.new.inspect
|
110
|
+
# => "<My Object(FLAG1 / FLAG2) !!ISSUE1!! INFO :: NAME>"
|
105
111
|
```
|
106
112
|
|
107
|
-
Or, define `inspect_identification`, `inspect_flags`, `inspect_info`, and/or `inspect_name` (or `display_name`) as either public or private methods on Object.
|
113
|
+
Or, define `inspect_identification`, `inspect_flags`, `inspect_issues`, `inspect_info`, and/or `inspect_name` (or `display_name`) as either public or private methods on Object.
|
108
114
|
|
109
115
|
```ruby
|
110
116
|
class MyObject
|
@@ -114,11 +120,11 @@ class MyObject
|
|
114
120
|
|
115
121
|
private
|
116
122
|
|
117
|
-
def inspect_identification
|
118
|
-
def inspect_flags
|
119
|
-
def inspect_issues
|
120
|
-
def inspect_info
|
121
|
-
def inspect_name
|
123
|
+
def inspect_identification = "My Object"
|
124
|
+
def inspect_flags = "FLAG1 / FLAG2"
|
125
|
+
def inspect_issues = "ISSUE1 | ISSUE2"
|
126
|
+
def inspect_info = "INFO"
|
127
|
+
def inspect_name = "NAME" # Or: def display_name = "NAME"
|
122
128
|
end
|
123
129
|
|
124
130
|
MyObject.new.inspect
|
@@ -127,7 +133,7 @@ MyObject.new.inspect
|
|
127
133
|
|
128
134
|
## Helper Usage
|
129
135
|
|
130
|
-
To save some typing, include ObjectInspector::InspectHelper into an object and ObjectInspector::Inspector.inspect will be called on `self` automatically.
|
136
|
+
To save some typing, include ObjectInspector::InspectHelper into an object and `ObjectInspector::Inspector.inspect` will be called on `self` automatically.
|
131
137
|
|
132
138
|
```ruby
|
133
139
|
class MyObject
|
@@ -164,11 +170,11 @@ class MyObject
|
|
164
170
|
|
165
171
|
private
|
166
172
|
|
167
|
-
def inspect_identification
|
168
|
-
def inspect_flags
|
169
|
-
def inspect_issues
|
170
|
-
def inspect_info
|
171
|
-
def inspect_name
|
173
|
+
def inspect_identification = "My Object"
|
174
|
+
def inspect_flags = "FLAG1 / FLAG2"
|
175
|
+
def inspect_issues = "ISSUE1 | ISSUE2"
|
176
|
+
def inspect_info = "INFO"
|
177
|
+
def inspect_name = "NAME" # Or: def display_name = "NAME"
|
172
178
|
end
|
173
179
|
|
174
180
|
MyObject.new.inspect
|
@@ -192,15 +198,16 @@ my_object.inspect(scope: <scope_name>)
|
|
192
198
|
|
193
199
|
Options:
|
194
200
|
|
195
|
-
- `:self` (Default)
|
196
|
-
- `:all
|
197
|
-
- `<custom
|
201
|
+
- `:self` (Default)--Is meant to confine object interrogation to self (don't interrogate neighboring objects).
|
202
|
+
- `:all`--Is meant to match on all scopes, regardless of their name.
|
203
|
+
- `<custom>`--Anything else that makes sense for the object to key on.
|
198
204
|
|
199
205
|
```ruby
|
200
206
|
scope = ObjectInspector::Scope.new
|
201
|
-
scope.self?
|
202
|
-
scope.verbose?
|
203
|
-
scope.complex?
|
207
|
+
scope.self? # => true
|
208
|
+
scope.verbose? # => false
|
209
|
+
scope.complex? # => false
|
210
|
+
scope.<anything>? # => false
|
204
211
|
```
|
205
212
|
|
206
213
|
#### Multiple Scope Names
|
@@ -223,6 +230,7 @@ scope = ObjectInspector::Scope.new(:all)
|
|
223
230
|
scope.self? # => true
|
224
231
|
scope.verbose? # => true
|
225
232
|
scope.complex? # => true
|
233
|
+
scope.all? # => true
|
226
234
|
```
|
227
235
|
|
228
236
|
### Scope blocks
|
@@ -240,20 +248,19 @@ scope.complex? { "MATCH" } # => "*"
|
|
240
248
|
ObjectInspector::Scope also offers helper methods for uniformly joining inspect elements:
|
241
249
|
|
242
250
|
```ruby
|
243
|
-
join_name
|
244
|
-
join_flags
|
245
|
-
|
251
|
+
join_name # Joins name parts with ` - ` by default
|
252
|
+
join_flags # Joins flags with ` / ` by default
|
253
|
+
join_issues # Joins issues with ` | ` by default
|
254
|
+
join_info # Joins info items with ` | ` by default
|
246
255
|
```
|
247
256
|
|
248
257
|
For example:
|
249
258
|
|
250
259
|
```ruby
|
251
|
-
scope = ObjectInspector::Scope.new(:
|
252
|
-
scope.join_name([1, 2, 3])
|
253
|
-
scope.join_name([1, 2, 3, nil]) # => "1 - 2 - 3"
|
254
|
-
scope.join_flags([1, 2, 3]) # => "1 / 2 / 3"
|
260
|
+
scope = ObjectInspector::Scope.new(:all)
|
261
|
+
scope.join_name([1, 2, 3, nil]) # => "1 - 2 - 3"
|
255
262
|
scope.join_flags([1, 2, 3, nil]) # => "1 / 2 / 3"
|
256
|
-
scope.
|
263
|
+
scope.join_issues([1, 2, 3, nil]) # => "1 | 2 | 3"
|
257
264
|
scope.join_info([1, 2, 3, nil]) # => "1 | 2 | 3"
|
258
265
|
```
|
259
266
|
|
@@ -272,11 +279,11 @@ class MyObject
|
|
272
279
|
end
|
273
280
|
|
274
281
|
def associated_object1
|
275
|
-
|
282
|
+
Data.define(:flags)["AO1_FLAG1"]
|
276
283
|
end
|
277
284
|
|
278
285
|
def associated_object2
|
279
|
-
|
286
|
+
Data.define(:flags)["AO2_FLAG1"]
|
280
287
|
end
|
281
288
|
|
282
289
|
# Or `def inspect_name`
|
@@ -304,8 +311,11 @@ class MyObject
|
|
304
311
|
scope.join_flags(flags)
|
305
312
|
end
|
306
313
|
|
307
|
-
def inspect_issues
|
308
|
-
|
314
|
+
def inspect_issues(scope:)
|
315
|
+
scope.join_issues([
|
316
|
+
"I1",
|
317
|
+
scope.verbose? { "VI2" },
|
318
|
+
])
|
309
319
|
end
|
310
320
|
|
311
321
|
def inspect_info(scope:)
|
@@ -319,37 +329,40 @@ end
|
|
319
329
|
|
320
330
|
my_object = MyObject.new("Name")
|
321
331
|
|
332
|
+
my_object.inspect
|
333
|
+
# => "<MyObject[2](DEFAULT_FLAG / *) !!I1 | *!! Default Info | * :: Name>"
|
334
|
+
|
335
|
+
my_object.inspect(scope: :self)
|
336
|
+
# => "<MyObject[2](DEFAULT_FLAG / *) !!I1 | *!! Default Info | * :: Name>"
|
337
|
+
|
322
338
|
my_object.inspect(scope: :complex)
|
323
|
-
# => "<MyObject[
|
339
|
+
# => "<MyObject[2](DEFAULT_FLAG / *) !!I1 | *!! Default Info | Complex Info | * :: Name>"
|
324
340
|
|
325
341
|
my_object.inspect(scope: :verbose)
|
326
|
-
# => "<MyObject[
|
342
|
+
# => "<MyObject[2](DEFAULT_FLAG / AO1_FLAG1 / AO2_FLAG1) !!I1 | VI2!! Default Info | Verbose Info :: Name>"
|
327
343
|
|
328
344
|
my_object.inspect(scope: %i[self complex verbose])
|
329
|
-
# => "<MyObject[
|
345
|
+
# => "<MyObject[2](DEFAULT_FLAG / AO1_FLAG1 / AO2_FLAG1) !!I1 | VI2!! Default Info | Complex Info | Verbose Info :: Name>"
|
330
346
|
|
331
347
|
my_object.inspect(scope: :all)
|
332
|
-
# => "<MyObject[
|
333
|
-
|
334
|
-
my_object.inspect
|
335
|
-
# => "<MyObject[a2:2](DEFAULT_FLAG / *) !!!!WARNING!!!! Default Info | * :: Name>"
|
348
|
+
# => "<MyObject[2](DEFAULT_FLAG / AO1_FLAG1 / AO2_FLAG1) !!I1 | VI2!! Default Info | Complex Info | Verbose Info :: Name>"
|
336
349
|
|
337
350
|
ObjectInspector.configuration.default_scope = :complex
|
338
351
|
my_object.inspect
|
339
|
-
# => "<MyObject[
|
352
|
+
# => "<MyObject[2](DEFAULT_FLAG / *) !!I1 | *!! Default Info | Complex Info | * :: Name>"
|
340
353
|
|
341
354
|
ObjectInspector.configuration.default_scope = %i[self complex verbose]
|
342
355
|
my_object.inspect
|
343
|
-
# => "<MyObject[
|
356
|
+
# => "<MyObject[2](DEFAULT_FLAG / AO1_FLAG1 / AO2_FLAG1) !!I1 | VI2!! Default Info | Complex Info | Verbose Info :: Name>"
|
344
357
|
|
345
358
|
ObjectInspector.configuration.default_scope = :all
|
346
359
|
my_object.inspect
|
347
|
-
# => "<MyObject[
|
360
|
+
# => "<MyObject[2](DEFAULT_FLAG / AO1_FLAG1 / AO2_FLAG1) !!I1 | VI2!! Default Info | Complex Info | Verbose Info :: Name>"
|
348
361
|
```
|
349
362
|
|
350
363
|
## Wrapped Objects
|
351
364
|
|
352
|
-
If the Object being inspected wraps another object
|
365
|
+
If the Object being inspected wraps another object--i.e. defines #to_model and #to_model returns an object other than self--the inspect output will re-inspect the wrapped object. The wrapper points to the wrapped object with an arrow (⇨).
|
353
366
|
|
354
367
|
```ruby
|
355
368
|
class MyWrapperObject
|
@@ -361,7 +374,7 @@ class MyWrapperObject
|
|
361
374
|
|
362
375
|
private
|
363
376
|
|
364
|
-
def inspect_flags
|
377
|
+
def inspect_flags = "WRAPPER_FLAG1"
|
365
378
|
end
|
366
379
|
|
367
380
|
class MyWrappedObject
|
@@ -369,8 +382,8 @@ class MyWrappedObject
|
|
369
382
|
|
370
383
|
private
|
371
384
|
|
372
|
-
def inspect_flags
|
373
|
-
def inspect_info
|
385
|
+
def inspect_flags = "FLAG1 / FLAG2"
|
386
|
+
def inspect_info = "INFO"
|
374
387
|
end
|
375
388
|
|
376
389
|
MyWrapperObject.new.inspect
|
@@ -424,10 +437,10 @@ class MyWrappedObject
|
|
424
437
|
|
425
438
|
private
|
426
439
|
|
427
|
-
def inspect_flags
|
428
|
-
def inspect_info
|
429
|
-
def inspect_issues
|
430
|
-
def inspect_name
|
440
|
+
def inspect_flags = "FLAG1"
|
441
|
+
def inspect_info = "INFO"
|
442
|
+
def inspect_issues = "ISSUE1"
|
443
|
+
def inspect_name = "NAME"
|
431
444
|
end
|
432
445
|
|
433
446
|
MyDelegatingWrapperObject.new(MyWrappedObject.new).inspect
|
@@ -442,10 +455,10 @@ When passed as an option (as opposed to being called via an Object-defined metho
|
|
442
455
|
class MyObject
|
443
456
|
include ObjectInspector::InspectorsHelper
|
444
457
|
|
445
|
-
def my_method1
|
446
|
-
def my_method2
|
458
|
+
def my_method1 = "Result1"
|
459
|
+
def my_method2 = "Result2"
|
447
460
|
|
448
|
-
def inspect_info
|
461
|
+
def inspect_info = :my_method2
|
449
462
|
end
|
450
463
|
|
451
464
|
MyObject.new.inspect(info: "my_method1") # => "<MyObject my_method1>"
|
@@ -461,17 +474,18 @@ Pass `nil` to any inspect method type to not display it:
|
|
461
474
|
class MyObject
|
462
475
|
include ObjectInspector::InspectorsHelper
|
463
476
|
|
464
|
-
def inspect_identification
|
465
|
-
def inspect_info
|
466
|
-
def inspect_flags
|
467
|
-
def inspect_issues
|
477
|
+
def inspect_identification = "My Object"
|
478
|
+
def inspect_info = "INFO"
|
479
|
+
def inspect_flags = "FLAG1"
|
480
|
+
def inspect_issues = "ISSUE1"
|
481
|
+
def inspect_name = "NAME"
|
468
482
|
end
|
469
483
|
|
470
484
|
MyObject.new.inspect
|
471
|
-
# => "<My Object(FLAG1) !!ISSUE1!! INFO>"
|
485
|
+
# => "<My Object(FLAG1) !!ISSUE1!! INFO :: NAME>"
|
472
486
|
MyObject.new.inspect(info: nil, flags: nil, issues: nil)
|
473
|
-
# => "<My Object>"
|
474
|
-
MyObject.new.inspect(identification: nil, info: nil, flags: nil, issues: nil)
|
487
|
+
# => "<My Object :: NAME>"
|
488
|
+
MyObject.new.inspect(identification: nil, info: nil, flags: nil, issues: nil, name: nil)
|
475
489
|
# => "<MyObject>"
|
476
490
|
```
|
477
491
|
|
@@ -490,11 +504,12 @@ class MyObject
|
|
490
504
|
include ObjectInspector::InspectorsHelper
|
491
505
|
|
492
506
|
def inspect
|
493
|
-
super(
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
507
|
+
super(
|
508
|
+
formatter: MyCustomFormatter,
|
509
|
+
identification: "IDENTIFICATION",
|
510
|
+
flags: "FLAG1 / FLAG2",
|
511
|
+
info: "INFO",
|
512
|
+
name: "NAME")
|
498
513
|
end
|
499
514
|
end
|
500
515
|
|
@@ -529,10 +544,10 @@ class MyObject
|
|
529
544
|
identify(:my_method1, :my_method2)
|
530
545
|
end
|
531
546
|
|
532
|
-
def inspect_flags
|
533
|
-
def inspect_issues
|
534
|
-
def inspect_info
|
535
|
-
def inspect_name
|
547
|
+
def inspect_flags = "FLAG1 / FLAG2"
|
548
|
+
def inspect_issues = "ISSUE1 | ISSUE2"
|
549
|
+
def inspect_info = "INFO"
|
550
|
+
def inspect_name = "NAME"
|
536
551
|
end
|
537
552
|
|
538
553
|
MyObject.new.inspect
|
@@ -543,51 +558,59 @@ MyObject.new.inspect
|
|
543
558
|
|
544
559
|
### Benchmarking Object Inspector
|
545
560
|
|
546
|
-
ObjectInspetor is ~
|
561
|
+
ObjectInspetor is ~2.75x slower than Ruby's default inspect, in Ruby v3.4.
|
547
562
|
|
548
563
|
Performance of Object Inspector can be tested by playing the [Object Inspector Benchmarking Script](https://github.com/pdobb/object_inspector/blob/master/script/benchmarking/object_inspector.rb) in the IRB console for this gem.
|
549
564
|
|
550
565
|
```ruby
|
551
566
|
load "script/benchmarking/object_inspector.rb"
|
567
|
+
# Reporting for: Ruby v3.4.2
|
568
|
+
#
|
569
|
+
# == Averaged =============================================================
|
570
|
+
# ...
|
571
|
+
#
|
552
572
|
# Comparison:
|
553
|
-
# Ruby:
|
554
|
-
# ObjectInspector::Inspector:
|
573
|
+
# Ruby: 58957.2 i/s
|
574
|
+
# ObjectInspector::Inspector: 21416.6 i/s - 2.75x slower
|
575
|
+
# == Done
|
555
576
|
```
|
556
577
|
|
557
578
|
### Benchmarking Formatters
|
558
579
|
|
559
|
-
[ObjectInspector::TemplatingFormatter]
|
580
|
+
[ObjectInspector::TemplatingFormatter]--which is the default Formatter--outperforms [ObjectInspector::CombiningFormatter] by about 30% on average.
|
560
581
|
|
561
582
|
Performance of Formatters can be tested by playing the [Formatters Benchmarking Scripts](https://github.com/pdobb/object_inspector/blob/master/script/benchmarking/formatters.rb) in the IRB console for this gem.
|
562
583
|
|
563
584
|
```ruby
|
564
585
|
load "script/benchmarking/formatters.rb"
|
586
|
+
# Reporting for: Ruby v3.4.2
|
587
|
+
#
|
565
588
|
# == Averaged =============================================================
|
566
589
|
# ...
|
567
590
|
#
|
568
591
|
# Comparison:
|
569
|
-
# ObjectInspector::TemplatingFormatter:
|
570
|
-
# ObjectInspector::CombiningFormatter:
|
571
|
-
#
|
592
|
+
# ObjectInspector::TemplatingFormatter: 65856.3 i/s
|
593
|
+
# ObjectInspector::CombiningFormatter: 60920.0 i/s - 1.08x slower
|
572
594
|
# == Done
|
573
595
|
```
|
574
596
|
|
575
597
|
#### Benchmarking Custom Formatters
|
576
598
|
|
577
|
-
Custom Formatters may be similarly gauged for comparison by
|
599
|
+
Custom Formatters may be similarly gauged for comparison by putting them into a constant `CUSTOM_FORMATTER_CLASSES` before playing the script in the IRB console for this gem.
|
578
600
|
|
579
601
|
```ruby
|
580
|
-
|
602
|
+
CUSTOM_FORMATTER_CLASSES = [MyCustomFormatter]
|
581
603
|
|
582
|
-
|
604
|
+
load "script/benchmarking/formatters.rb"
|
605
|
+
# Reporting for: Ruby v3.4.2
|
606
|
+
#
|
583
607
|
# == Averaged =============================================================
|
584
608
|
# ...
|
585
609
|
#
|
586
610
|
# Comparison:
|
587
|
-
# MyCustomFormatter:
|
588
|
-
# ObjectInspector::TemplatingFormatter:
|
589
|
-
# ObjectInspector::CombiningFormatter:
|
590
|
-
#
|
611
|
+
# MyCustomFormatter: 74227.7 i/s
|
612
|
+
# ObjectInspector::TemplatingFormatter: 66148.5 i/s - 1.12x slower
|
613
|
+
# ObjectInspector::CombiningFormatter: 63289.7 i/s - 1.17x slower
|
591
614
|
# == Done
|
592
615
|
```
|
593
616
|
|
@@ -601,13 +624,13 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
601
624
|
|
602
625
|
To test this gem:
|
603
626
|
|
604
|
-
```
|
627
|
+
```sh
|
605
628
|
rake
|
606
629
|
```
|
607
630
|
|
608
631
|
#### Linters
|
609
632
|
|
610
|
-
```
|
633
|
+
```sh
|
611
634
|
rubocop
|
612
635
|
|
613
636
|
reek
|
@@ -38,6 +38,7 @@ class ObjectInspector::CombiningFormatter < ObjectInspector::BaseFormatter
|
|
38
38
|
[
|
39
39
|
build_identification_string,
|
40
40
|
build_flags_string,
|
41
|
+
build_issues_string,
|
41
42
|
build_info_string,
|
42
43
|
build_name_string,
|
43
44
|
].compact
|
@@ -51,6 +52,10 @@ class ObjectInspector::CombiningFormatter < ObjectInspector::BaseFormatter
|
|
51
52
|
"(#{flags.to_s.upcase})" if flags
|
52
53
|
end
|
53
54
|
|
55
|
+
def build_issues_string
|
56
|
+
" !!#{issues.to_s.upcase}!!" if issues
|
57
|
+
end
|
58
|
+
|
54
59
|
def build_info_string
|
55
60
|
" #{info}" if info
|
56
61
|
end
|
@@ -36,7 +36,7 @@ class ObjectInspector::Inspector
|
|
36
36
|
**kwargs)
|
37
37
|
@object = object
|
38
38
|
@scope = ObjectInspector::Conversions.Scope(scope)
|
39
|
-
@
|
39
|
+
@formatter_class = formatter
|
40
40
|
@kwargs = kwargs
|
41
41
|
end
|
42
42
|
|
@@ -57,7 +57,7 @@ class ObjectInspector::Inspector
|
|
57
57
|
self.class.inspect(
|
58
58
|
extract_wrapped_object,
|
59
59
|
scope: @scope,
|
60
|
-
formatter: @
|
60
|
+
formatter: @formatter_class,
|
61
61
|
kwargs: @kwargs)
|
62
62
|
end
|
63
63
|
|
@@ -112,7 +112,7 @@ class ObjectInspector::Inspector
|
|
112
112
|
private
|
113
113
|
|
114
114
|
def formatter
|
115
|
-
@
|
115
|
+
@formatter_class.new(self)
|
116
116
|
end
|
117
117
|
|
118
118
|
# @return [String] if `key` is found in {#kwargs} or if {#object} responds to
|
data/lib/object_inspector.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: object_inspector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul DobbinSchmaltz
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: benchmark-ips
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
rubygems_version: 3.6.
|
113
|
+
rubygems_version: 3.6.6
|
114
114
|
specification_version: 4
|
115
115
|
summary: Object Inspector builds uniformly formatted inspect output with customizable
|
116
116
|
amounts of detail.
|