multiline 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/multiline/array.rb +10 -1
- data/lib/multiline/string.rb +5 -3
- data/lib/multiline/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 431b29f444b6d70a33713579345f928f7860fc36183670aaf834f5f62736f9d4
|
4
|
+
data.tar.gz: 3a0210ef3cf88a07501068ac89d20c009ca0dbcb88f11f90d00f719f5afd4022
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
27
|
-
unicode-emoji (2.
|
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
|
|
data/lib/multiline/array.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
module Multiline
|
2
2
|
class Array < ::Array
|
3
3
|
def join(sep = $,, align: :center)
|
4
|
-
|
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
|
data/lib/multiline/string.rb
CHANGED
@@ -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.
|
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])
|
data/lib/multiline/version.rb
CHANGED
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.
|
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-
|
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
|