xprint 0.8.1 → 0.9.52

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/version.rb +2 -2
  3. data/lib/xprint.rb +357 -279
  4. metadata +8 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8e6e0778467e8ed1efb112fc5a6fb7ee2e5463e1338dbffaf73aeeb61a75d0f
4
- data.tar.gz: 43fef229c2551c8791d0b009cac768524fdb929a014701f16ed360981a014a7d
3
+ metadata.gz: 28bf765d84d5c5524bb16b450ec410d38458ac07eda20dde13671fb4d616b075
4
+ data.tar.gz: dae561c390ce9de47468327ecddfc32e997780b310f802384adbd358cb5c8138
5
5
  SHA512:
6
- metadata.gz: 301cc656d0b4d0e62c6cf0c13486866b4249e7668700f11bcd9e58d2c4a28cac9a033b9ed3de430f64afde2ccb46f008a46e232f4ef5ca943e5371d9b17ecde9
7
- data.tar.gz: 3ef89b719424f34e220ffc9aa77d4591dddb19fc695a64c257144fe3d1bf068b3569c8896b70ff85048a6fad0a4e4bcb6f722cd0af4c541259091228ff229c19
6
+ metadata.gz: 851b4ded37108b45c3bfb879038ce7c0256259f1b1f410f262f8bb97cb52fa36f000f30fa898bbfbb6de49415f2d908ff42f87fa7cb50d91e1732a45e14499bf
7
+ data.tar.gz: 3368c16e1ad863e91dbdc339774f78e898979e584bb82c257758b598c2c1d836f9e801c9584624f10461d4bed5e5bac2ef7ad042cbd60f252c892ed0ce576b9c
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module XPrint
2
- VERSION = '0.8.1'
3
- end
2
+ VERSION = '0.9.52'
3
+ end
data/lib/xprint.rb CHANGED
@@ -1,313 +1,391 @@
1
1
  require 'bigdecimal'
2
2
  require 'date'
3
+ require 'yaml'
3
4
 
5
+ # TODO: Add ability for alphabetically sorting
6
+ # items in hashes and objects.
4
7
  module XPrint
5
- @data_classes = [
6
- String, Integer, Float, TrueClass, FalseClass, NilClass,
7
- Symbol, Date, Time, DateTime, BigDecimal, Rational
8
- ]
9
- @hash_name_classes = @data_classes + [Proc]
10
- @tab = "\t"
11
- @indexes = true
12
- @full_proc_path = false
13
- @braces = true
14
- @date_format = '%F'
15
- @time_format = '%c'
16
- @datetime_format = '%FT%T%:z'
17
- @color = false
18
- @colors = {
19
- attribute: :blue,
20
- bigdecimal: :darkcyan,
21
- classname: :darkgreen,
22
- classobject: :green,
23
- date: :red,
24
- datetime: :purple,
25
- false: :darkred,
26
- float: :cyan,
27
- index: :darkgrey,
28
- integer: :cyan,
29
- module: :green,
30
- nil: :darkpurple,
31
- proc: :darkyellow,
32
- rational: :darkcyan,
33
- string: :yellow,
34
- struct: :green,
35
- symbol: :darkblue,
36
- time: :darkblue,
37
- true: :darkgreen
38
- }
39
- @color_codes = {
40
- black: "\e[30m",
41
- blue: "\e[94m",
42
- darkblue: "\e[34m",
43
- cyan: "\e[96m",
44
- darkcyan: "\e[36m",
45
- green: "\e[92m",
46
- darkgreen: "\e[32m",
47
- grey: "\e[37m",
48
- darkgrey: "\e[90m",
49
- red: "\e[91m",
50
- darkred: "\e[31m",
51
- purple: "\e[95m",
52
- darkpurple: "\e[35m",
53
- yellow: "\e[93m",
54
- darkyellow: "\e[33m",
55
- reset: "\e[0m"
56
- }
57
-
58
- def self.set(**kwargs)
59
- set_vars = {
60
- tab: ->(data) { @tab = data },
61
- indexes: ->(data) { @indexes = data },
62
- full_proc_path: ->(data) { @full_proc_path = data },
63
- braces: ->(data) { @braces = data },
64
- date_format: ->(data) { @date_format = data },
65
- time_format: ->(data) { @time_format = data },
66
- datetime_format: ->(data) { @datetime_format = data },
67
- color: ->(data) { @color = data }
68
- }
8
+ @data_classes = [
9
+ String, Integer, Float, TrueClass, FalseClass, NilClass,
10
+ Symbol, Date, Time, DateTime, BigDecimal, Rational
11
+ ]
12
+ @hash_name_classes = @data_classes + [Proc]
13
+ @tab = " "
14
+ @indexes = true
15
+ @full_proc_path = false
16
+ @braces = true
17
+ @date_format = '%F'
18
+ @time_format = '%c'
19
+ @datetime_format = '%FT%T%:z'
20
+ @hash_separator = ' => '
21
+ @commas = true
22
+ @color = true
23
+ @colors = {
24
+ attribute: :blue,
25
+ bigdecimal: :darkcyan,
26
+ classname: :darkgreen,
27
+ classobject: :green,
28
+ comma: :default,
29
+ curly_brace: :default,
30
+ date: :red,
31
+ datetime: :purple,
32
+ equals: :default,
33
+ false: :darkred,
34
+ float: :cyan,
35
+ hash_separator: :default,
36
+ index: :darkgrey,
37
+ integer: :cyan,
38
+ module: :green,
39
+ nil: :darkpurple,
40
+ parentheses: :default,
41
+ proc: :darkyellow,
42
+ rational: :darkcyan,
43
+ regexp: :darkyellow,
44
+ string: :yellow,
45
+ struct: :green,
46
+ square_brace: :default,
47
+ symbol: :darkblue,
48
+ time: :darkblue,
49
+ true: :darkgreen
50
+ }
51
+ @color_codes = {
52
+ black: "\e[30m",
53
+ blue: "\e[94m",
54
+ darkblue: "\e[34m",
55
+ cyan: "\e[96m",
56
+ darkcyan: "\e[36m",
57
+ green: "\e[92m",
58
+ darkgreen: "\e[32m",
59
+ grey: "\e[37m",
60
+ darkgrey: "\e[90m",
61
+ red: "\e[91m",
62
+ darkred: "\e[31m",
63
+ purple: "\e[95m",
64
+ darkpurple: "\e[35m",
65
+ yellow: "\e[93m",
66
+ darkyellow: "\e[33m",
67
+ default: "\e[0m"
68
+ }
69
+
70
+ def self.set(**kwargs)
71
+ kwargs.each do |keyword, arg|
72
+ instance_variable_set "@#{keyword}", arg
73
+ end
69
74
 
70
- kwargs.each do |keyword, arg|
71
- if set_vars.key? keyword
72
- set_vars[keyword].(arg)
73
- end
74
- end
75
+ return
76
+ end
77
+
78
+ def self.load_file(config)
79
+ config_data = YAML.load(File.read config)
80
+ config_data = symbolize_keys(config_data)
75
81
 
76
- return
77
- end
78
-
79
- def self.set_color_for(**kwargs)
80
- kwargs.each do |keyword, arg|
81
- @colors[keyword] = arg
82
- end
83
- end
84
-
85
- def self.set_color_code_for(**kwargs)
86
- kwargs.each do |keyword, arg|
87
- @color_codes[keyword] = arg
88
- end
82
+ set **config_data[:general] if config_data.key?
83
+
84
+ if config_data.key? :colors
85
+ color_data = config_data[:colors]
86
+
87
+ color_data.each do |name, color|
88
+ color_data[name] = color.to_sym
89
+ end
90
+
91
+ set_color_for **config_data[:colors]
89
92
  end
93
+
94
+ codekey = :'color codes'
95
+
96
+ set_color_code_for(**config_data[codekey]) if config_data.key codekey
97
+
98
+ return
99
+ end
100
+
101
+ def self.load(config)
102
+ calling_file = caller_locations.first.absolute_path
103
+ base_dir = File.dirname calling_file
104
+ relative_config = File.expand_path config, base_dir
105
+
106
+ load_file relative_config
107
+ end
90
108
 
91
- def self.xp(*args)
92
- args.each do |arg|
93
- xpanded_text = self.xpand(arg, tab: @tab)
94
109
 
95
- unless @braces
96
- xpanded_text = self.shift_indentation_down(xpanded_text).lstrip()
97
- end
98
110
 
99
- puts xpanded_text
100
- end
111
+ private_class_method def self.symbolize_keys(hash)
112
+ hash.inject({}) do |result, (key, value)|
113
+ new_key = key.to_sym
114
+ new_value = value.is_a?(Hash) ? symbolize_keys(value) : value
115
+
116
+ result[new_key] = new_value
117
+
118
+ result
101
119
  end
102
-
103
- private_class_method def self.color_for(colorname)
104
- @color_codes[colorname]
120
+ end
121
+
122
+ def self.set_color_for(**kwargs)
123
+ kwargs.each do |keyword, arg|
124
+ @colors[keyword] = arg
105
125
  end
106
-
107
- private_class_method def self.reset_color()
108
- @color_codes[:reset]
126
+ end
127
+
128
+ def self.set_color_code_for(**kwargs)
129
+ kwargs.each do |keyword, arg|
130
+ @color_codes[keyword] = arg
109
131
  end
110
-
111
- private_class_method def self.colorize(text, type)
112
- if @color
113
- item_color = color_for @colors[type]
114
- "#{item_color}#{text}#{reset_color}"
115
- else
116
- text
117
- end
132
+ end
133
+
134
+ def self.xp(*args)
135
+ args.each do |arg|
136
+ xpanded_text = xpand(arg, tab: @tab)
137
+
138
+ xpanded_text = shift_indentation_down(xpanded_text).lstrip unless @braces
139
+
140
+ puts xpanded_text
118
141
  end
119
-
120
- private_class_method def self.shift_indentation_down(text)
121
- # Only shift if no
122
- return text if text.match?(/^\S/)
123
- result = ''
124
-
125
- text.each_line do |line|
126
- result += (
127
- if line.start_with? @tab
128
- line[@tab.length..-1]
129
- else
130
- line
131
- end
132
- )
133
- end
134
-
135
- return result
142
+ end
143
+
144
+ private_class_method def self.color_for(colorname)
145
+ @color_codes[colorname]
146
+ end
147
+
148
+ private_class_method def self.reset_color()
149
+ @color_codes[:default]
150
+ end
151
+
152
+ private_class_method def self.colorize(text, type)
153
+ if @color
154
+ item_color = color_for @colors[type]
155
+ "#{item_color}#{text}#{reset_color}"
156
+ else
157
+ text
136
158
  end
137
-
138
- def self.xpand(x, indent: '', tab: "\t")
139
-
140
- _indent = "#{tab}#{indent}"
141
-
142
- # X is a "primitive" kind of data that has no subitems, so
143
- # we can just print it.
144
- if x.class == String
145
- return colorize(x.inspect, :string)
146
- elsif x.class == Integer
147
- return colorize(x.inspect, :integer)
148
- elsif x.class == Float
149
- return colorize(x.inspect, :float)
150
- elsif x.class == TrueClass
151
- return colorize(x.inspect, :true)
152
- elsif x.class == FalseClass
153
- return colorize(x.inspect, :false)
154
- elsif x.class == NilClass
155
- return colorize(x.inspect, :nil)
156
- elsif x.class == Symbol
157
- return colorize(x.inspect, :symbol)
158
-
159
- # X is a Proc, print more compact version of standard Proc.inspect
160
- # text.
161
- elsif x.class == Proc
162
- type = x.lambda? ? 'Lambda' : 'Proc'
163
- source, line = x.source_location
164
- source = source.gsub('\\', '/')
165
-
166
- unless @full_proc_path
167
- source = source.split('/')[-2..-1].join('/')
168
- end
169
-
170
- return colorize("<#{type} @ #{source} [Line #{line}]>", :proc)
171
-
172
- elsif x.class == Class
173
- return colorize("<Class #{x}>", :classobject)
174
-
175
- # X is an Array, print list of all items.
176
- elsif x.class == Array
177
- result = "#{@braces ? '[' : ''}\n"
178
-
179
- x.each_with_index do |item, index|
180
- data = xpand(item, indent: _indent, tab: tab)
181
-
182
- result += "#{_indent}"
183
- result += "#{colorize("[#{index}]", :index)} " if @indexes
184
- result += "#{data}"
159
+ end
160
+
161
+ private_class_method def self.shift_indentation_down(text)
162
+ # Only shift if no
163
+ return text if text.match?(/^\S/)
185
164
 
186
- unless index + 1 == x.length
187
- result += "#{@braces ? ', ' : ''} \n"
188
- end
189
- end
190
-
191
- result += "\n#{indent}]" if @braces
192
- return result
193
-
194
- # X is a Hash, print all keys and values.
195
- elsif x.class == Hash
196
- result = "#{@braces ? '{' : ''}\n"
197
-
198
- longest_key = (
199
- x.keys.filter do |k, v|
200
- @hash_name_classes.include? k.class
201
- end.
202
- map do |k, v|
203
- k.to_s.length
204
- end.
205
- max()
206
- )
207
-
208
- longest_key = 0 if longest_key.nil?
165
+ result = ''
166
+
167
+ text.each_line do |line|
168
+ result += (
169
+ if line.start_with? @tab
170
+ line[@tab.length..-1]
171
+ else
172
+ line
173
+ end
174
+ )
175
+ end
209
176
 
210
- # Color codes throw the text length, so we need to add the
211
- # length of the color code and the code to reset the color
212
- # that wrap around the colored word.
213
- # The color code is like "\e[99m" and the reset "\e[0m",
214
- # so the total length to add when using color is 9.
215
- longest_key += 9 if @color
177
+ return result
178
+ end
179
+
180
+ def self.xpand(x, indent: '', tab: ' ')
216
181
 
217
- x.each_with_index do |(key, value), index|
218
- data_key = "#{xpand(key, indent: _indent, tab: tab)}"
219
-
220
- data_key = (
221
- if @hash_name_classes.include? key.class
222
- data_key.ljust(longest_key + 1)
223
- else
224
- data_key.ljust(data_key.length + longest_key)
225
- end
226
- )
227
-
228
- data_value = xpand(value, indent: _indent, tab: tab)
229
-
230
- result += "#{_indent}#{data_key} => #{data_value}"
231
-
232
- unless index + 1 == x.length
233
- result += "#{@braces ? ', ' : ''} \n"
234
- end
235
- end
236
-
237
- result += "\n#{indent}}" if @braces
182
+ _indent = "#{tab}#{indent}"
238
183
 
239
- return result
240
-
241
- # X is a commonly used special kind of object.
242
- elsif x.class == DateTime
243
- datetime = x.strftime @datetime_format
244
- return colorize("DateTime(#{datetime})", :datetime)
184
+ # X is a "primitive" kind of data that has no subitems, so
185
+ # we can just print it.
186
+ if x.class == String
187
+ return colorize(x.inspect, :string)
188
+ elsif x.class == Integer
189
+ return colorize(x.inspect, :integer)
190
+ elsif x.class == Float
191
+ return colorize(x.inspect, :float)
192
+ elsif x.class == TrueClass
193
+ return colorize(x.inspect, :true)
194
+ elsif x.class == FalseClass
195
+ return colorize(x.inspect, :false)
196
+ elsif x.class == NilClass
197
+ return colorize(x.inspect, :nil)
198
+ elsif x.class == Symbol
199
+ return colorize(x.inspect, :symbol)
200
+ elsif x.class == Regexp
201
+ return colorize(x.inspect, :regexp)
202
+
203
+ # X is a Proc, print more compact version of standard Proc.inspect
204
+ # text.
205
+ elsif x.class == Proc
206
+ type = x.lambda? ? 'Lambda' : 'Proc'
207
+ source, line = x.source_location
208
+ source = source.gsub('\\', '/')
209
+
210
+ unless @full_proc_path
211
+ source = source.split('/')[-2..-1].join('/')
212
+ end
213
+
214
+ return colorize("<#{type} @ #{source} [Line #{line}]>", :proc)
215
+
216
+ elsif x.class == Class
217
+ return colorize("<Class #{x}>", :classobject)
218
+
219
+ # X is an Array, print list of all items.
220
+ elsif x.class == Array
221
+ result = "#{@braces ? colorize('[', :square_brace) : ''}\n"
222
+ comma = colorize(',', :comma)
223
+
224
+ x.each_with_index do |item, index|
225
+ data = xpand(item, indent: _indent, tab: tab)
245
226
 
246
- elsif x.class == Date
247
- date = x.strftime @date_format
248
- return colorize("Date(#{date})", :date)
227
+ result += "#{_indent}"
228
+ if @indexes
229
+ adjustment = x.length.to_s.length + 3
230
+ # Account for characters used for color coding.
231
+ adjustment += 9 if @color
232
+
233
+ result += "#{colorize("[#{index}]", :index)} ".
234
+ ljust(adjustment)
235
+ end
236
+ result += "#{data}"
249
237
 
250
- elsif x.class == Time
251
- time = x.strftime @time_format
252
- return colorize("Time(#{time})", :time)
238
+ unless index + 1 == x.length
239
+ show_commas = @commas && @braces
240
+
241
+ result += "#{show_commas ? "#{comma}" : ''}"
242
+ result += "\n" unless result.end_with? "\n"
243
+ end
244
+ end
245
+
246
+ result += "\n#{indent}#{colorize(']', :square_brace)}" if @braces
247
+ return result
248
+
249
+ # X is a Hash, print all keys and values.
250
+ elsif x.class == Hash
251
+ comma = colorize(',', :comma)
252
+ result = "#{@braces ? colorize('{', :curly_brace) : ''}\n"
253
+
254
+ longest_key = (
255
+ x.keys.filter do |k, v|
256
+ @hash_name_classes.include? k.class
257
+ end.
258
+ map do |k, v|
259
+ k.to_s.length
260
+ end.
261
+ max()
262
+ )
263
+
264
+ longest_key = 0 if longest_key.nil?
265
+
266
+ # Color codes throw the text length, so we need to add the
267
+ # length of the color code and the code to reset the color
268
+ # that wrap around the colored word.
269
+ # The color code is like "\e[99m" and the reset "\e[0m",
270
+ # so the total length to add when using color is 9.
271
+ longest_key += 9 if @color
272
+
273
+ x.each_with_index do |(key, value), index|
274
+ data_key = "#{xpand(key, indent: _indent, tab: tab)}"
253
275
 
254
- elsif x.class == BigDecimal
255
- return colorize("BigDecimal(#{x.to_s('f')})", :bigdecimal)
276
+ data_key = (
277
+ if @hash_name_classes.include? key.class
278
+ data_key.ljust(longest_key + 1)
279
+ else
280
+ data_key.ljust(data_key.length + longest_key)
281
+ end
282
+ )
256
283
 
257
- elsif x.class == Rational
258
- return colorize("Rational(#{x})", :rational)
284
+ data_value = xpand(value, indent: _indent, tab: tab)
259
285
 
260
- # X is a Structure; essentially a special case of X being an object.
261
- elsif x.is_a? Struct
262
- struct_word = colorize('Struct', :struct)
263
- classname = colorize(x.class, :struct)
264
- result = "#{struct_word} #{classname}#{@braces ? '(' : ''}\n"
265
- longest_item = x.members.map { |m| m.to_s.length }.max()
266
-
267
- x.each_pair do |name, value|
268
- attr_name = colorize(name.to_s.ljust(longest_item), :attribute)
269
- attr_data = xpand(value, indent: _indent, tab: tab)
270
-
271
- result += "#{_indent}#{attr_name} = #{attr_data}\n"
272
- end
273
-
274
- result += "#{indent})" if @braces
275
-
276
- return result
286
+ hash_separator = colorize(@hash_separator, :hash_separator)
287
+ result += "#{_indent}#{data_key}#{hash_separator}#{data_value}"
277
288
 
278
- # X is any arbitrary object; print all instance variables.
279
- else
280
- is_module = x.class == Module
281
- classname = is_module ? "Module #{x}" : x.class
282
- classname = colorize(classname, is_module ? :module : :classname)
283
- result = "#{classname}#{@braces ? '(' : ''}"
284
- ivars = x.instance_variables
285
- result += "\n" if ivars.length > 0
286
- longest_var = ivars.map { |v| v.to_s.length }.max()
289
+ unless index + 1 == x.length
290
+ show_commas = @commas && @braces
291
+ result += "#{show_commas ? "#{comma} " : ''}"
292
+ result += "\n" unless result.end_with? "\n"
293
+ end
294
+ end
295
+
296
+ result += "\n#{indent}#{colorize('}', :curly_brace)}" if @braces
297
+
298
+ return result
299
+
300
+ # X is a commonly used special kind of object.
301
+ elsif x.class == DateTime
302
+ datetime = x.strftime @datetime_format
303
+ p1 = colorize('(', :parentheses)
304
+ p2 = colorize(')', :parentheses)
305
+ return colorize("DateTime#{p1}#{datetime}#{p2}", :datetime)
287
306
 
288
- ivars.each_with_index do |var, index|
289
- attr_name = var.to_s.ljust(longest_var)
290
- attr_name = colorize(attr_name, :attribute)
291
- attr_data = xpand(
292
- x.instance_variable_get(var),
293
- indent: _indent,
294
- tab: tab
295
- )
296
-
297
- result += "#{_indent}#{attr_name} = #{attr_data}\n"
298
- end
307
+ elsif x.class == Date
308
+ date = x.strftime @date_format
309
+ p1 = colorize('(', :parentheses)
310
+ p2 = colorize(')', :parentheses)
311
+ return colorize("Date#{p1}#{date}#{p2}", :date)
299
312
 
300
- result += "#{ivars.length > 0 ? indent: ''})" if @braces
313
+ elsif x.class == Time
314
+ time = x.strftime @time_format
315
+ p1 = colorize('(', :parentheses)
316
+ p2 = colorize(')', :parentheses)
317
+ return colorize("Time#{p1}#{time}#{p2}", :time)
301
318
 
302
- return result
303
- end
304
- end
319
+ elsif x.class == BigDecimal
320
+ p1 = colorize('(', :parentheses)
321
+ p2 = colorize(')', :parentheses)
322
+ return colorize("BigDecimal#{p1}#{x.to_s('f')}#{p2}", :bigdecimal)
323
+
324
+ elsif x.class == Rational
325
+ p1 = colorize('(', :parentheses)
326
+ p2 = colorize(')', :parentheses)
327
+ return colorize("Rational#{p1}#{x}#{p2}", :rational)
328
+
329
+ # X is a Structure; essentially a special case of X being an object.
330
+ elsif x.is_a? Struct
331
+ struct_word = colorize('Struct', :struct)
332
+ classname = colorize(x.class, :struct)
333
+ p1 = colorize('(', :parentheses)
334
+ p2 = colorize(')', :parentheses)
335
+ result = "#{struct_word} #{classname}#{@braces ? p1 : ''}\n"
336
+ longest_item = x.members.map { |m| m.to_s.length }.max()
337
+ eq_sign = colorize('=', :equals)
338
+
339
+ x.each_pair do |name, value|
340
+ attr_name = colorize(name.to_s.ljust(longest_item), :attribute)
341
+ attr_data = xpand(value, indent: _indent, tab: tab)
342
+
343
+ result += "#{_indent}#{attr_name} #{eq_sign} #{attr_data}"
344
+ result += "\n" unless result.end_with? "\n"
345
+ end
346
+
347
+ result += "#{indent}#{p2}" if @braces
348
+
349
+ return result
350
+
351
+ # X is any arbitrary object; print all instance variables.
352
+ else
353
+ p1 = colorize('(', :parentheses)
354
+ p2 = colorize(')', :parentheses)
355
+
356
+ is_module = x.class == Module
357
+ classname = is_module ? "Module #{x}" : x.class
358
+ classname = colorize(classname, is_module ? :module : :classname)
359
+ result = "#{classname}#{@braces ? p1 : ''}"
360
+ ivars = x.instance_variables
361
+ result += "\n" if ivars.length > 0
362
+ longest_var = ivars.map { |v| v.to_s.length }.max()
363
+ eq_sign = colorize('=', :equals)
364
+
365
+ ivars.each_with_index do |var, index|
366
+ attr_name = var.to_s.ljust(longest_var)
367
+ attr_name = colorize(attr_name, :attribute)
368
+ attr_data = xpand(
369
+ x.instance_variable_get(var),
370
+ indent: _indent,
371
+ tab: tab
372
+ )
373
+
374
+ result += "#{_indent}#{attr_name} #{eq_sign} #{attr_data}"
375
+ result += "\n" unless result.end_with? "\n"
376
+ end
377
+
378
+ result += "#{ivars.length > 0 ? indent : ''}#{p2}" if @braces
379
+
380
+ return result
381
+ end
382
+ end
305
383
  end
306
384
 
307
385
  def xp(*args)
308
- XPrint::xp(*args)
386
+ XPrint.xp(*args)
309
387
  end
310
388
 
311
389
  def xpand(item, tab: "\t")
312
- XPrint::xpand(item, tab: tab)
313
- end
390
+ XPrint.xpand(item, tab: tab)
391
+ end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xprint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - JCabr
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-21 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Gem that allows for pretty printing data over multiple lines and with
14
- indentation, and works with objects as well as basic data types.
14
+ indentation, and works with objects as well as basic data types. Also allows color,
15
+ and loading settings via a YAML config file.
15
16
  email:
16
17
  - jcabr.dev@gmail.com
17
18
  executables: []
@@ -24,7 +25,7 @@ homepage: https://github.com/JCabr/xprint.rb
24
25
  licenses:
25
26
  - MIT
26
27
  metadata: {}
27
- post_install_message:
28
+ post_install_message:
28
29
  rdoc_options: []
29
30
  require_paths:
30
31
  - lib
@@ -39,8 +40,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
41
42
  requirements: []
42
- rubygems_version: 3.1.2
43
- signing_key:
43
+ rubygems_version: 3.2.15
44
+ signing_key:
44
45
  specification_version: 4
45
46
  summary: Gem for pretty printing any kind of object.
46
47
  test_files: []