terminal-join 1.0.2 → 1.0.3

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: fa3a600e917f98581b6748dae1b0c2669e0b82f7244bf3c84ca1d9f9f36432da
4
- data.tar.gz: db772d40385fa0388045953d2550ece3b21cc680c2a6f71f3e7d5622feb60146
3
+ metadata.gz: 4632ed70f1e9f11fd27622d9a3275adc5620d42feb6f756d517bf06e71450664
4
+ data.tar.gz: 9d4c892f9f18caa6169fd335fffcac2ca21c7225d101265244d36448486e3866
5
5
  SHA512:
6
- metadata.gz: 194d3fa7e10d3ab167c2d874fa582485f161643db4fde13f2f154e426af76184ddbb4a81501a908380bbb8dedd47cb1673ec89684f3af7beb45c5a117f8a03aa
7
- data.tar.gz: 5bedfc8cc87cadb239cbf9bea32202005065239858cf17ff011bbd7597076f376bd2487a5d0f3f339c3666e216ed2cc80b1a728ca62e969cd99bfba761bdaf31
6
+ metadata.gz: 52a73493b0b3e6a07ab821cc5c475395ad4029ac80a878e2f0ad43b6e3ddde97453b01928ce1666b1c1f3aad1caf309eb8ced68f6f4e51a3f19702d22bf93122
7
+ data.tar.gz: 3e61d912fb3feaa607a270b45810bb75dfb8336fec8d9405fef166c92aeaf511b04053e23add74d7a91157e4c7fe1c246933ac5e7a18844a513f0f04c82ac2cf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [1.0.2] - 2023-08-14
2
+
3
+ - Change `Terminal::Join` from class to module.
4
+ - Added `.rbs`.
5
+
1
6
  ## [1.0.2] - 2023-08-08
2
7
 
3
8
  - Fixed `style` bug when string have ansi code after last newline.
data/Gemfile CHANGED
@@ -8,3 +8,5 @@ gemspec
8
8
  gem 'rake', '~> 13.0'
9
9
 
10
10
  gem 'rubocop', '~> 1.21'
11
+
12
+ gem 'rbs'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Terminal
4
- class Join
5
- VERSION = '1.0.2'
4
+ module Join
5
+ VERSION = '1.0.3'
6
6
  end
7
7
  end
data/lib/terminal/join.rb CHANGED
@@ -6,8 +6,10 @@ require 'unicode/display_width'
6
6
  require_relative 'join/version'
7
7
 
8
8
  module Terminal
9
- class Join
10
- def self.style(string, *ansi, halign: :center, valign: :center, width: 0, height: 0, margin: 0)
9
+ module Join
10
+ module_function
11
+
12
+ def style(string, *ansi, halign: :center, valign: :center, width: 0, height: 0, margin: 0)
11
13
  margin = [margin, margin] unless margin.is_a?(Array)
12
14
  widths = Paint.unpaint(string).lines.map { Unicode::DisplayWidth.of _1.chomp }
13
15
  widths = [0] if widths.empty?
@@ -43,7 +45,7 @@ module Terminal
43
45
  .join("\n")
44
46
  end
45
47
 
46
- def self.horizontal(*strings, separator: nil, align: :center, &block)
48
+ def horizontal(*strings, separator: nil, align: :center, &block)
47
49
  max_height = strings.flatten.map { _1.to_s.lines.size }.max
48
50
  separator = block.call max_height if block
49
51
 
@@ -57,7 +59,7 @@ module Terminal
57
59
  .transpose.map(&:join).join("\n")
58
60
  end
59
61
 
60
- def self.vertical(*strings, separator: nil, align: :center, &block)
62
+ def vertical(*strings, separator: nil, align: :center, &block)
61
63
  Paint.unpaint(strings.flatten.join("\n"))
62
64
  .lines.map { Unicode::DisplayWidth.of _1 }.max => max_width
63
65
  separator = block.call max_width if block
data/sig/ansi_layout.rbs CHANGED
@@ -1,6 +1,9 @@
1
1
  module Terminal
2
- class Join
3
- VERSION: String
4
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
2
+ module Join
3
+ def self?.style: (untyped string, *untyped ansi, ?halign: Symbol, ?valign: Symbol, ?width: Integer, ?height: Integer, ?margin: Integer) -> untyped
4
+
5
+ def self?.horizontal: (*untyped strings, ?separator: untyped?, ?align: Symbol) ?{ () -> untyped } -> untyped
6
+
7
+ def self?.vertical: (*untyped strings, ?separator: untyped?, ?align: Symbol) ?{ () -> untyped } -> untyped
5
8
  end
6
9
  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.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - NNB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-08 00:00:00.000000000 Z
11
+ date: 2023-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paint