terminal-join 1.0.0 → 1.0.2

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: 548a3e0ae9f050dcfcf6fee502893afacef2318ce08116a3ea1f472d784341c5
4
- data.tar.gz: e2503fc99fdfd510783ac2b01724ff02fcba50d1df1e9dac10fa7b05ff9206d2
3
+ metadata.gz: fa3a600e917f98581b6748dae1b0c2669e0b82f7244bf3c84ca1d9f9f36432da
4
+ data.tar.gz: db772d40385fa0388045953d2550ece3b21cc680c2a6f71f3e7d5622feb60146
5
5
  SHA512:
6
- metadata.gz: dbdeb30f838c087e82fed5a43b2836e2496d93d1b4fcd9f5157c92f99f67ac27ecd10334d823b25afbb6059af1d22f63ee721cc415472b9b1c8ffdc349489b34
7
- data.tar.gz: 1ec681561df88b390eddf2a78159fdf4af569de34eaea596b6db338841d29701998cb7fd5d07745b624aff2974bf2e05e198ab5000935235b41a9be36c274d6b
6
+ metadata.gz: 194d3fa7e10d3ab167c2d874fa582485f161643db4fde13f2f154e426af76184ddbb4a81501a908380bbb8dedd47cb1673ec89684f3af7beb45c5a117f8a03aa
7
+ data.tar.gz: 5bedfc8cc87cadb239cbf9bea32202005065239858cf17ff011bbd7597076f376bd2487a5d0f3f339c3666e216ed2cc80b1a728ca62e969cd99bfba761bdaf31
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
- ## [1.0.0] - 2023-01-30
1
+ ## [1.0.2] - 2023-08-08
2
2
 
3
- - Initial release
3
+ - Fixed `style` bug when string have ansi code after last newline.
4
+
5
+ ## [1.0.1] - 2023-01-30
6
+
7
+ - Downgrade required Ruby version from `3.1.3` to `3.1.2`.
8
+
9
+ ## [1.0.0] - 2023-01-29
10
+
11
+ - Initial release.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Terminal
4
4
  class Join
5
- VERSION = '1.0.0'
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.0
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
@@ -80,14 +80,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 3.1.3
83
+ version: 3.1.2
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.4.5
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.