xprint 0.7.9 → 0.8.1
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/lib/version.rb +1 -1
- data/lib/xprint.rb +9 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8e6e0778467e8ed1efb112fc5a6fb7ee2e5463e1338dbffaf73aeeb61a75d0f
|
4
|
+
data.tar.gz: 43fef229c2551c8791d0b009cac768524fdb929a014701f16ed360981a014a7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 301cc656d0b4d0e62c6cf0c13486866b4249e7668700f11bcd9e58d2c4a28cac9a033b9ed3de430f64afde2ccb46f008a46e232f4ef5ca943e5371d9b17ecde9
|
7
|
+
data.tar.gz: 3ef89b719424f34e220ffc9aa77d4591dddb19fc695a64c257144fe3d1bf068b3569c8896b70ff85048a6fad0a4e4bcb6f722cd0af4c541259091228ff229c19
|
data/lib/version.rb
CHANGED
data/lib/xprint.rb
CHANGED
@@ -4,7 +4,7 @@ require 'date'
|
|
4
4
|
module XPrint
|
5
5
|
@data_classes = [
|
6
6
|
String, Integer, Float, TrueClass, FalseClass, NilClass,
|
7
|
-
Symbol
|
7
|
+
Symbol, Date, Time, DateTime, BigDecimal, Rational
|
8
8
|
]
|
9
9
|
@hash_name_classes = @data_classes + [Proc]
|
10
10
|
@tab = "\t"
|
@@ -26,10 +26,12 @@ module XPrint
|
|
26
26
|
float: :cyan,
|
27
27
|
index: :darkgrey,
|
28
28
|
integer: :cyan,
|
29
|
+
module: :green,
|
29
30
|
nil: :darkpurple,
|
30
31
|
proc: :darkyellow,
|
31
32
|
rational: :darkcyan,
|
32
33
|
string: :yellow,
|
34
|
+
struct: :green,
|
33
35
|
symbol: :darkblue,
|
34
36
|
time: :darkblue,
|
35
37
|
true: :darkgreen
|
@@ -257,8 +259,8 @@ module XPrint
|
|
257
259
|
|
258
260
|
# X is a Structure; essentially a special case of X being an object.
|
259
261
|
elsif x.is_a? Struct
|
260
|
-
struct_word = colorize('Struct', :
|
261
|
-
classname = colorize(x.class, :
|
262
|
+
struct_word = colorize('Struct', :struct)
|
263
|
+
classname = colorize(x.class, :struct)
|
262
264
|
result = "#{struct_word} #{classname}#{@braces ? '(' : ''}\n"
|
263
265
|
longest_item = x.members.map { |m| m.to_s.length }.max()
|
264
266
|
|
@@ -275,8 +277,9 @@ module XPrint
|
|
275
277
|
|
276
278
|
# X is any arbitrary object; print all instance variables.
|
277
279
|
else
|
278
|
-
|
279
|
-
classname =
|
280
|
+
is_module = x.class == Module
|
281
|
+
classname = is_module ? "Module #{x}" : x.class
|
282
|
+
classname = colorize(classname, is_module ? :module : :classname)
|
280
283
|
result = "#{classname}#{@braces ? '(' : ''}"
|
281
284
|
ivars = x.instance_variables
|
282
285
|
result += "\n" if ivars.length > 0
|
@@ -307,4 +310,4 @@ end
|
|
307
310
|
|
308
311
|
def xpand(item, tab: "\t")
|
309
312
|
XPrint::xpand(item, tab: tab)
|
310
|
-
end
|
313
|
+
end
|