terminal-join 1.0.1 → 1.0.2

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: af4f77b2eedaa198dd5276fd1b44e2906ad53f2425111441b09003c9f0993827
4
- data.tar.gz: ca825fc10dedb431f3c4b1e0b301ce0af35560068078a2ed46765fa488947cb7
3
+ metadata.gz: fa3a600e917f98581b6748dae1b0c2669e0b82f7244bf3c84ca1d9f9f36432da
4
+ data.tar.gz: db772d40385fa0388045953d2550ece3b21cc680c2a6f71f3e7d5622feb60146
5
5
  SHA512:
6
- metadata.gz: 2528e5cbdf18dba398b877dbb0f762d911280765d15964b616c84d2cb0587b54616cadcfd69aa56f29591d8f1c795c471bf355edc170499c45fc97fb394ef098
7
- data.tar.gz: 217f084bb96ef62fa5fd7db87f31144878e2efbf5fc35153ca41ca511cdc0fcbff4ddff7e38c5d213d28f4ae32204ab59b1d96b26fffd1a68c58a80636f7e213
6
+ metadata.gz: 194d3fa7e10d3ab167c2d874fa582485f161643db4fde13f2f154e426af76184ddbb4a81501a908380bbb8dedd47cb1673ec89684f3af7beb45c5a117f8a03aa
7
+ data.tar.gz: 5bedfc8cc87cadb239cbf9bea32202005065239858cf17ff011bbd7597076f376bd2487a5d0f3f339c3666e216ed2cc80b1a728ca62e969cd99bfba761bdaf31
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.0.2] - 2023-08-08
2
+
3
+ - Fixed `style` bug when string have ansi code after last newline.
4
+
1
5
  ## [1.0.1] - 2023-01-30
2
6
 
3
7
  - Downgrade required Ruby version from `3.1.3` to `3.1.2`.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Terminal
4
4
  class Join
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
6
6
  end
7
7
  end
data/lib/terminal/join.rb CHANGED
@@ -10,6 +10,7 @@ module Terminal
10
10
  def self.style(string, *ansi, halign: :center, valign: :center, width: 0, height: 0, margin: 0)
11
11
  margin = [margin, margin] unless margin.is_a?(Array)
12
12
  widths = Paint.unpaint(string).lines.map { Unicode::DisplayWidth.of _1.chomp }
13
+ widths = [0] if widths.empty?
13
14
  max_width = [width, *widths].max
14
15
  pad_width = max_width - widths.max + margin[0] * 2
15
16
  pad_height = [(height - string.lines.size), 0].max + margin[1] * 2
@@ -25,7 +26,7 @@ module Terminal
25
26
  center: pad_width / 2
26
27
  }[valign],
27
28
  Paint[line.chomp, *ansi] +
28
- Paint[' ' * (widths.max - widths[index]), *ansi || nil]
29
+ Paint[' ' * (widths.max - (widths[index] || 0)), *ansi || nil]
29
30
  )
30
31
  end
31
32
  .then do
@@ -51,7 +52,7 @@ module Terminal
51
52
  else
52
53
  strings.flat_map { [_1, separator] }[0...-1]
53
54
  end
54
- .map { self.style _1.to_s, halign: align, height: max_height }
55
+ .map { style _1.to_s, halign: align, height: max_height }
55
56
  .map { _1.lines.map(&:chomp) }
56
57
  .transpose.map(&:join).join("\n")
57
58
  end
@@ -66,7 +67,7 @@ module Terminal
66
67
  else
67
68
  strings.flat_map { [_1, separator] }[0...-1]
68
69
  end
69
- .map { self.style _1.to_s, valign: align, width: max_width }
70
+ .map { style _1.to_s, valign: align, width: max_width }
70
71
  .join("\n")
71
72
  end
72
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal-join
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - NNB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-29 00:00:00.000000000 Z
11
+ date: 2023-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paint
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.3.20
90
+ rubygems_version: 3.4.10
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Join ANSI strings horizontally/vertically with style.