rex-text 0.2.55 → 0.2.56
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/rex/text/table.rb +4 -12
- data/lib/rex/text/version.rb +1 -1
- data/lib/rex/text/wrapped_table.rb +9 -2
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 228e101f378142e65d4e105177e035ebd678f1d70a0b7bbc6c8cea5a150f3594
|
4
|
+
data.tar.gz: 591ad72b7e3f1fadf4323c7092be9aff494d669311c7b628374009308d97d376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0d08ee5c96d5d0b7b6ba85fb01f18da3bc59e24bb34734f15130fc4d3db0ea14e4fe507e67dee157f3cebe17b30428420acac6020927f9478415c8cb807cba6
|
7
|
+
data.tar.gz: cb322c6675fbb09555e4cd1c3a3aac91bc56d6558e106057ff9731ac0e53d810549f2a319d3a7cd31541348b827bdbbb72e38fb5a918e7ac30db2c7d5a23335d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rex/text/table.rb
CHANGED
@@ -21,21 +21,13 @@ class Table
|
|
21
21
|
# To enforce all tables to be wrapped to the terminal's current width, call `Table.wrap_tables!`
|
22
22
|
# before invoking `Table.new` as normal.
|
23
23
|
def self.new(*args, &block)
|
24
|
-
|
25
|
-
table_options = args.first
|
26
|
-
return ::Rex::Text::WrappedTable.new(table_options)
|
27
|
-
end
|
28
|
-
return super(*args, &block)
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.wrap_table?(args)
|
32
|
-
return false unless wrapped_tables?
|
24
|
+
return super(*args, &block) unless wrap_table?(args)
|
33
25
|
|
34
26
|
table_options = args.first
|
35
|
-
|
36
|
-
|
37
|
-
end
|
27
|
+
::Rex::Text::WrappedTable.new(table_options)
|
28
|
+
end
|
38
29
|
|
30
|
+
def self.wrap_table?(args)
|
39
31
|
wrapped_tables?
|
40
32
|
end
|
41
33
|
|
data/lib/rex/text/version.rb
CHANGED
@@ -72,6 +72,7 @@ class WrappedTable
|
|
72
72
|
self.rows = []
|
73
73
|
|
74
74
|
self.width = opts['Width'] || ::IO.console&.winsize&.[](1) || ::BigDecimal::INFINITY
|
75
|
+
self.word_wrap = opts.fetch('WordWrap', true)
|
75
76
|
self.indent = opts['Indent'] || 0
|
76
77
|
self.cellpad = opts['CellPad'] || 2
|
77
78
|
self.prefix = opts['Prefix'] || ''
|
@@ -87,6 +88,7 @@ class WrappedTable
|
|
87
88
|
self.colprops[idx] = {}
|
88
89
|
self.colprops[idx]['Width'] = nil
|
89
90
|
self.colprops[idx]['WordWrap'] = true
|
91
|
+
self.colprops[idx]['Strip'] = true
|
90
92
|
self.colprops[idx]['Stylers'] = []
|
91
93
|
self.colprops[idx]['Formatters'] = []
|
92
94
|
self.colprops[idx]['ColumnStylers'] = []
|
@@ -328,7 +330,7 @@ class WrappedTable
|
|
328
330
|
|
329
331
|
attr_accessor :header, :headeri # :nodoc:
|
330
332
|
attr_accessor :columns, :rows, :colprops # :nodoc:
|
331
|
-
attr_accessor :width, :indent, :cellpad # :nodoc:
|
333
|
+
attr_accessor :width, :word_wrap, :indent, :cellpad # :nodoc:
|
332
334
|
attr_accessor :prefix, :postfix # :nodoc:
|
333
335
|
attr_accessor :sort_index, :sort_order, :scterm # :nodoc:
|
334
336
|
|
@@ -478,6 +480,8 @@ protected
|
|
478
480
|
# @param [Array<String>] values
|
479
481
|
# @param [Integer] optimal_widths
|
480
482
|
def chunk_values(values, optimal_widths)
|
483
|
+
return values.map { |value| [value] } unless word_wrap
|
484
|
+
|
481
485
|
# First split long strings into an array of chunks, where each chunk size is the calculated column width
|
482
486
|
values_as_chunks = values.each_with_index.map do |value, idx|
|
483
487
|
color_state = {}
|
@@ -586,6 +590,8 @@ protected
|
|
586
590
|
end
|
587
591
|
end
|
588
592
|
|
593
|
+
return display_width_metadata.map { |metadata| metadata[:max_display_width] } unless word_wrap
|
594
|
+
|
589
595
|
# Calculate the sizes set by the user
|
590
596
|
user_influenced_column_widths = colprops.map do |colprop|
|
591
597
|
if colprop['Width']
|
@@ -647,7 +653,8 @@ protected
|
|
647
653
|
end
|
648
654
|
|
649
655
|
def format_table_field(str, idx)
|
650
|
-
str_cp = str.to_s.encode('UTF-8', invalid: :replace, undef: :replace)
|
656
|
+
str_cp = str.to_s.encode('UTF-8', invalid: :replace, undef: :replace)
|
657
|
+
str_cp = str_cp.strip if colprops[idx]['Strip']
|
651
658
|
|
652
659
|
colprops[idx]['Formatters'].each do |f|
|
653
660
|
str_cp = f.format(str_cp)
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rex-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.56
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Metasploit Hackers
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
DgscAao7wB3xW2BWEp1KnaDWkf1x9ttgoBEYyuYwU7uatB67kBQG1PKvLt79wHvz
|
35
35
|
Dxs+KOjGbBRfMnPgVGYkORKVrZIwlaboHbDKxcVW5xv+oZc7KYXWGg==
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date:
|
37
|
+
date: 2024-02-22 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: rake
|
metadata.gz.sig
CHANGED
Binary file
|