rex-text 0.2.55 → 0.2.57
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/lang.rb +14 -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: e4be7ba44cf30e38db54d223a59c21a0afec606e083cd005686fc42218a50010
|
4
|
+
data.tar.gz: 3fa85e08816119262aff2a4f476c5c8aea29456229beee3d0575f57edb709541
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eb8d6ff25261432871a027fa4ebe77cc47fa3ae9711af39f6ad64a4ab403e64a6f14ec31f5c04c863d16d2ae831f17f7eeee59b603ace8f6dd37f23e0b2dc66
|
7
|
+
data.tar.gz: ca4408939a10094725332ac3c7a82d8b7d6a3de2dbe60b8fee39c80f5123f24125f9365a5b84afcce6de714de3c4cf3b223f44f44272836109089f7158e4a0a2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rex/text/lang.rb
CHANGED
@@ -217,5 +217,19 @@ module Rex
|
|
217
217
|
return wordwrap(str, 0, wrap, '', '# ')
|
218
218
|
end
|
219
219
|
|
220
|
+
#
|
221
|
+
# Converts to a zig style array of bytes
|
222
|
+
#
|
223
|
+
def self.to_zig(str, wrap = DefaultWrap, name = "buf")
|
224
|
+
return numhexify(str, wrap, '', '', "\nconst #{name}: []const u8 = \&.{\n", "};", ',')
|
225
|
+
end
|
226
|
+
|
227
|
+
#
|
228
|
+
# Creates a zig-style comment
|
229
|
+
#
|
230
|
+
def self.to_zig_comment(str, wrap = DefaultWrap)
|
231
|
+
return wordwrap(str, 0, wrap, '', '// ')
|
232
|
+
end
|
233
|
+
|
220
234
|
end
|
221
235
|
end
|
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.57
|
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-03-28 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: rake
|
metadata.gz.sig
CHANGED
Binary file
|