multiline 0.2.1 → 0.2.3

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: 7e4b279e2d4c27090f9424529c28b260862d04de2444aa2f83cad11f28819c6e
4
- data.tar.gz: e5be0628c69c379a768e1100c0cc16aa032c30c6c9a73743624255e5b05a3c94
3
+ metadata.gz: 431b29f444b6d70a33713579345f928f7860fc36183670aaf834f5f62736f9d4
4
+ data.tar.gz: 3a0210ef3cf88a07501068ac89d20c009ca0dbcb88f11f90d00f719f5afd4022
5
5
  SHA512:
6
- metadata.gz: f4c27c453f9c182349aa46195b41c44423a9d7958bcce8b3dbe61fc2f9f0b9e150eb9e59a7983b45a6bc3959e9cf10a4690016ed8b9e7b0c380b373a26abc2bb
7
- data.tar.gz: 85dc0fa3fcb1f1b0ace95209415ce2e2896066dcb84392a149895671882b8762cbba413cb5caeb8b02fad7d6474a79c7e66ee68698a6b71f35f9f84469e78e78
6
+ metadata.gz: 565888792feadcd6bb1f0f18bfd9020c0b0c8586b5c6e217c1e08ead76470144ab7b6308bf1e4745103ad66cda4691ffab47507d06b8a127bae5b56fd517a110
7
+ data.tar.gz: 10ccdf972ed1daa858d40fb87c2800e00647bac5c58b4a785c33ff7c1d7e5b14bedcb9d25ff1668f06118c6eb53355dc7c66b4a70ffb9891e499a7ea7277c0b0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- multiline (0.2.1)
4
+ multiline (0.2.3)
5
5
  unicode-display_width
6
6
  unicode-emoji
7
7
 
@@ -23,8 +23,8 @@ GEM
23
23
  diff-lcs (>= 1.2.0, < 2.0)
24
24
  rspec-support (~> 3.10.0)
25
25
  rspec-support (3.10.2)
26
- unicode-display_width (2.0.0)
27
- unicode-emoji (2.8.0)
26
+ unicode-display_width (2.1.0)
27
+ unicode-emoji (2.9.0)
28
28
  unicode-version (~> 1.0)
29
29
  unicode-version (1.1.0)
30
30
 
@@ -1,7 +1,16 @@
1
1
  module Multiline
2
2
  class Array < ::Array
3
3
  def join(sep = $,, align: :center)
4
- buf = Multiline::String.new
4
+ max_row = self.map{|str|
5
+ case str
6
+ when ::String
7
+ str.split(/\n/).length
8
+ when Multiline::String
9
+ str.row
10
+ end
11
+ }.max
12
+
13
+ buf = Multiline::String.new("", max_row)
5
14
  self.each_with_index do |str, index|
6
15
  case str
7
16
  when ::String
@@ -1,9 +1,9 @@
1
1
  module Multiline
2
2
  class String
3
3
  attr_reader :row, :col, :buf
4
- def initialize(str = "")
4
+ def initialize(str = "", buf_row = nil)
5
5
  @buf = str.split(/\n/)
6
- @row = @buf.count || 0
6
+ @row = [@buf.length, buf_row].compact.max rescue binding.irb
7
7
  @col = @buf.map{|line| Unicode::DisplayWidth.of(line,
8
8
  Multiline.config.display_width_ambiguous,
9
9
  Multiline.config.display_width_overwrite) }.max || 0
@@ -20,6 +20,8 @@ module Multiline
20
20
 
21
21
  def concat(*arguments, align: :center)
22
22
  arguments.each do |arg|
23
+ org_col = @col
24
+ org_row = @row
23
25
  @col += arg.col
24
26
  @row = [@row, arg.row].max
25
27
 
@@ -39,7 +41,7 @@ module Multiline
39
41
  end
40
42
 
41
43
  for index in 0...row do
42
- buf[index] ||= ""
44
+ buf[index] ||= " " * org_col
43
45
  line = buf[index]
44
46
  if index >= start_row && index < end_row
45
47
  line.concat(arg.buf[index - start_row])
@@ -1,3 +1,3 @@
1
1
  module Multiline
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshio Maki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2021-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unicode-display_width