rex-text 0.2.55 → 0.2.56

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6e00ee9046e2a52f102878c9ea126bcabd3661792f19310ec690c0289c510dc
4
- data.tar.gz: e64b49f60c7a15cd7388271edb509f33a378388fc525735b034c650b981ce04d
3
+ metadata.gz: 228e101f378142e65d4e105177e035ebd678f1d70a0b7bbc6c8cea5a150f3594
4
+ data.tar.gz: 591ad72b7e3f1fadf4323c7092be9aff494d669311c7b628374009308d97d376
5
5
  SHA512:
6
- metadata.gz: 82ce47b42310e3e198398cbfc980c086d37d9f1ef75ef3f0ddf5b70cdcca525d25aab581d4ed416864ac652b44e810c50f97cc65c476a1a4b2e3734a211ede9b
7
- data.tar.gz: 314d8d29e0829444f34a958ae1ce6141586e00e30c3118e8aed1cb41e5ff73bd8db5e0513b2f069e29b36e2515ab9015dbad4820ddbccc45f4daf753af6e16d9
6
+ metadata.gz: e0d08ee5c96d5d0b7b6ba85fb01f18da3bc59e24bb34734f15130fc4d3db0ea14e4fe507e67dee157f3cebe17b30428420acac6020927f9478415c8cb807cba6
7
+ data.tar.gz: cb322c6675fbb09555e4cd1c3a3aac91bc56d6558e106057ff9731ac0e53d810549f2a319d3a7cd31541348b827bdbbb72e38fb5a918e7ac30db2c7d5a23335d
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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.56"
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.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: 2023-11-08 00:00:00.000000000 Z
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