multiline 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/multiline.rb +18 -0
- data/lib/multiline/string.rb +6 -2
- data/lib/multiline/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e4b279e2d4c27090f9424529c28b260862d04de2444aa2f83cad11f28819c6e
|
4
|
+
data.tar.gz: e5be0628c69c379a768e1100c0cc16aa032c30c6c9a73743624255e5b05a3c94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4c27c453f9c182349aa46195b41c44423a9d7958bcce8b3dbe61fc2f9f0b9e150eb9e59a7983b45a6bc3959e9cf10a4690016ed8b9e7b0c380b373a26abc2bb
|
7
|
+
data.tar.gz: 85dc0fa3fcb1f1b0ace95209415ce2e2896066dcb84392a149895671882b8762cbba413cb5caeb8b02fad7d6474a79c7e66ee68698a6b71f35f9f84469e78e78
|
data/Gemfile.lock
CHANGED
data/lib/multiline.rb
CHANGED
@@ -6,5 +6,23 @@ require "multiline/string"
|
|
6
6
|
require "multiline/array"
|
7
7
|
|
8
8
|
module Multiline
|
9
|
+
def self.config=(config)
|
10
|
+
@config = config
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.config
|
14
|
+
@config
|
15
|
+
end
|
16
|
+
|
9
17
|
class Error < StandardError; end
|
18
|
+
class Configure
|
19
|
+
attr_accessor :display_width_ambiguous, :display_width_overwrite
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
self.display_width_ambiguous = 1
|
23
|
+
self.display_width_overwrite = {}
|
24
|
+
end
|
25
|
+
end
|
10
26
|
end
|
27
|
+
|
28
|
+
Multiline.config = Multiline::Configure.new
|
data/lib/multiline/string.rb
CHANGED
@@ -4,8 +4,12 @@ module Multiline
|
|
4
4
|
def initialize(str = "")
|
5
5
|
@buf = str.split(/\n/)
|
6
6
|
@row = @buf.count || 0
|
7
|
-
@col = @buf.map{|line| Unicode::DisplayWidth.of(line
|
8
|
-
|
7
|
+
@col = @buf.map{|line| Unicode::DisplayWidth.of(line,
|
8
|
+
Multiline.config.display_width_ambiguous,
|
9
|
+
Multiline.config.display_width_overwrite) }.max || 0
|
10
|
+
@buf = @buf.map{|line| line + " " * (@col - Unicode::DisplayWidth.of(line,
|
11
|
+
Multiline.config.display_width_ambiguous,
|
12
|
+
Multiline.config.display_width_overwrite)) }
|
9
13
|
end
|
10
14
|
|
11
15
|
def +(other)
|
data/lib/multiline/version.rb
CHANGED