monospace_text_formatter 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/Changelog
CHANGED
@@ -85,6 +85,10 @@ module MonospaceTextFormatter
|
|
85
85
|
@to_s ||= lines.join("\n")
|
86
86
|
end
|
87
87
|
|
88
|
+
def inspect
|
89
|
+
%Q(#<#{self.class} #{to_s.inspect}>)
|
90
|
+
end
|
91
|
+
|
88
92
|
private
|
89
93
|
|
90
94
|
def to_chunk_if_string(string)
|
@@ -95,6 +99,10 @@ module MonospaceTextFormatter
|
|
95
99
|
Chunk.new(string)
|
96
100
|
end
|
97
101
|
|
102
|
+
def new_line(string, attrs={})
|
103
|
+
Line.new(string, attrs)
|
104
|
+
end
|
105
|
+
|
98
106
|
def aligned_all_lines
|
99
107
|
@aligned_all_lines ||= all_lines.each do |line|
|
100
108
|
line.attributes(:align => align, :fill => fill, :width => width)
|
@@ -111,9 +119,9 @@ module MonospaceTextFormatter
|
|
111
119
|
when :top
|
112
120
|
[]
|
113
121
|
when :middle
|
114
|
-
Array.new(((@fixed_height - content_lines.size) / 2.0).floor,
|
122
|
+
Array.new(((@fixed_height - content_lines.size) / 2.0).floor, new_line(""))
|
115
123
|
when :bottom
|
116
|
-
Array.new(@fixed_height - content_lines.size,
|
124
|
+
Array.new(@fixed_height - content_lines.size, new_line(""))
|
117
125
|
end
|
118
126
|
else
|
119
127
|
[]
|
@@ -124,9 +132,9 @@ module MonospaceTextFormatter
|
|
124
132
|
@empty_bottom_lines ||= if @fixed_height && fill && !fill.empty?
|
125
133
|
case valign
|
126
134
|
when :top
|
127
|
-
Array.new(@fixed_height - content_lines.size,
|
135
|
+
Array.new(@fixed_height - content_lines.size, new_line(""))
|
128
136
|
when :middle
|
129
|
-
Array.new(((@fixed_height - content_lines.size) / 2.0).ceil,
|
137
|
+
Array.new(((@fixed_height - content_lines.size) / 2.0).ceil, new_line(""))
|
130
138
|
when :bottom
|
131
139
|
[]
|
132
140
|
end
|
@@ -138,7 +146,7 @@ module MonospaceTextFormatter
|
|
138
146
|
def content_lines
|
139
147
|
return @content_lines unless @content_lines.nil?
|
140
148
|
return @content_lines = [] if @fixed_width == 0 && @fixed_height.nil?
|
141
|
-
return @content_lines = [
|
149
|
+
return @content_lines = [new_line("")] if @original_chunk.empty?
|
142
150
|
|
143
151
|
@remaining_chunk = @original_chunk.duplicate
|
144
152
|
@line_chunks = []
|
@@ -152,7 +160,7 @@ module MonospaceTextFormatter
|
|
152
160
|
end
|
153
161
|
|
154
162
|
common_width = @fixed_width || @line_chunks.map { |chunk| chunk.display_length }.max
|
155
|
-
@content_lines = @line_chunks.map { |chunk|
|
163
|
+
@content_lines = @line_chunks.map { |chunk| new_line(chunk, :width => common_width, :omission => omission) }
|
156
164
|
end
|
157
165
|
end
|
158
166
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monospace_text_formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-18 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &75602160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *75602160
|
25
25
|
description: Formats monospaced text into a line or visual box of defined 'width'
|
26
26
|
and 'height' boundaries (expressed in number of characters).
|
27
27
|
email: jacekmikrut.software@gmail.com
|