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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6e00ee9046e2a52f102878c9ea126bcabd3661792f19310ec690c0289c510dc
4
- data.tar.gz: e64b49f60c7a15cd7388271edb509f33a378388fc525735b034c650b981ce04d
3
+ metadata.gz: e4be7ba44cf30e38db54d223a59c21a0afec606e083cd005686fc42218a50010
4
+ data.tar.gz: 3fa85e08816119262aff2a4f476c5c8aea29456229beee3d0575f57edb709541
5
5
  SHA512:
6
- metadata.gz: 82ce47b42310e3e198398cbfc980c086d37d9f1ef75ef3f0ddf5b70cdcca525d25aab581d4ed416864ac652b44e810c50f97cc65c476a1a4b2e3734a211ede9b
7
- data.tar.gz: 314d8d29e0829444f34a958ae1ce6141586e00e30c3118e8aed1cb41e5ff73bd8db5e0513b2f069e29b36e2515ab9015dbad4820ddbccc45f4daf753af6e16d9
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
@@ -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
- if wrap_table?(args)
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
- if table_options&.key?('WordWrap')
36
- return table_options['WordWrap']
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
 
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Text
3
- VERSION = "0.2.55"
3
+ VERSION = "0.2.57"
4
4
  end
5
5
  end
@@ -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).strip
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.55
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: 2023-11-08 00:00:00.000000000 Z
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