vedeu 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/borders_app.rb +60 -56
- data/lib/vedeu/buffers/all.rb +1 -0
- data/lib/vedeu/configuration/configuration.rb +2 -4
- data/lib/vedeu/cursor/all.rb +3 -6
- data/lib/vedeu/cursor/cursor.rb +4 -3
- data/lib/vedeu/cursor/move_cursor.rb +7 -4
- data/lib/vedeu/cursor/toggle_cursor.rb +0 -1
- data/lib/vedeu/dsl/components/border.rb +99 -0
- data/lib/vedeu/dsl/components/geometry.rb +1 -0
- data/lib/vedeu/dsl/components/keymap.rb +1 -1
- data/lib/vedeu/dsl/composition.rb +7 -12
- data/lib/vedeu/dsl/interface.rb +7 -8
- data/lib/vedeu/dsl/line.rb +1 -10
- data/lib/vedeu/dsl/stream.rb +0 -2
- data/lib/vedeu/input/key.rb +10 -6
- data/lib/vedeu/input/keymap.rb +10 -8
- data/lib/vedeu/models/menu.rb +0 -2
- data/lib/vedeu/models/model.rb +20 -0
- data/lib/vedeu/models/view/composition.rb +4 -17
- data/lib/vedeu/models/view/interface.rb +9 -21
- data/lib/vedeu/models/view/line.rb +4 -17
- data/lib/vedeu/models/view/stream.rb +4 -17
- data/lib/vedeu/output/all.rb +1 -0
- data/lib/vedeu/output/border.rb +2 -2
- data/lib/vedeu/output/compositor.rb +0 -4
- data/lib/vedeu/output/wordwrap.rb +146 -0
- data/lib/vedeu/repositories/repository.rb +3 -2
- data/lib/vedeu/support/console.rb +29 -6
- data/lib/vedeu/support/content_geometry.rb +2 -0
- data/lib/vedeu/support/coordinate.rb +9 -4
- data/lib/vedeu/support/position_validator.rb +28 -7
- data/lib/vedeu/support/sentence.rb +21 -1
- data/lib/vedeu/support/terminal.rb +0 -2
- data/lib/vedeu/support/trace.rb +48 -2
- data/lib/vedeu/support/visible.rb +2 -0
- data/test/lib/vedeu/cursor/all_test.rb +1 -1
- data/test/lib/vedeu/events/event_test.rb +7 -29
- data/test/lib/vedeu/input/key_test.rb +3 -3
- data/test/lib/vedeu/input/keymap_test.rb +3 -3
- data/test/lib/vedeu/output/wordwrap_test.rb +266 -0
- data/test/lib/vedeu/presentation/colour_test.rb +68 -33
- data/test/lib/vedeu/support/common_test.rb +10 -0
- data/test/lib/vedeu/support/console_test.rb +82 -0
- data/test/lib/vedeu/support/position_validator_test.rb +13 -0
- data/test/support/helpers/all.rb +0 -1
- data/vedeu.gemspec +8 -8
- metadata +19 -18
- data/test/support/helpers/misc.rb +0 -15
@@ -29,20 +29,29 @@ module Vedeu
|
|
29
29
|
|
30
30
|
attr_accessor :x, :y
|
31
31
|
|
32
|
+
# @param interface [Interface]
|
33
|
+
# @param x [Fixnum]
|
34
|
+
# @param y [Fixnum]
|
35
|
+
# @return [PositionValidator]
|
32
36
|
def self.validate(interface, x, y)
|
33
37
|
new(interface, x, y).validate
|
34
38
|
end
|
35
39
|
|
40
|
+
# @param interface [Interface]
|
41
|
+
# @param x [Fixnum]
|
42
|
+
# @param y [Fixnum]
|
43
|
+
# @return [PositionValidator]
|
36
44
|
def initialize(interface, x, y)
|
37
45
|
@interface = interface
|
38
46
|
@x = x
|
39
47
|
@y = y
|
40
48
|
end
|
41
49
|
|
50
|
+
# @return [PositionValidator]
|
42
51
|
def validate
|
43
52
|
terminal_validation
|
44
53
|
interface_validation
|
45
|
-
border_validation
|
54
|
+
border_validation if border?
|
46
55
|
|
47
56
|
self
|
48
57
|
end
|
@@ -66,14 +75,26 @@ module Vedeu
|
|
66
75
|
end
|
67
76
|
|
68
77
|
def border_validation
|
69
|
-
if
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@y = bottom - 2 if bottom? && y > (bottom - 1)
|
74
|
-
end
|
78
|
+
@x = left + 1 if left? && x < (left + 1)
|
79
|
+
@x = right - 2 if right? && x > (right - 1)
|
80
|
+
@y = top + 1 if top? && y < (top + 1)
|
81
|
+
@y = bottom - 2 if bottom? && y > (bottom - 1)
|
75
82
|
end
|
76
83
|
|
84
|
+
# def x
|
85
|
+
# @x = [[[[@x, tx].max, txn].min, left].max, right].min
|
86
|
+
# @x = border? && left? ? [@x, (left + 1)].max : @x
|
87
|
+
# @x = border? && right? ? [@x, (right - 2)].min : @x
|
88
|
+
# @x
|
89
|
+
# end
|
90
|
+
|
91
|
+
# def y
|
92
|
+
# @y = [[[[@y, ty].max, tyn].min, top].max, bottom].min
|
93
|
+
# @y = border? && top? ? [@y, (top + 1)].max : @y
|
94
|
+
# @y = border? && bottom? ? [@y, (bottom - 2)].min : @y
|
95
|
+
# @y
|
96
|
+
# end
|
97
|
+
|
77
98
|
end # PositionValidator
|
78
99
|
|
79
100
|
end # Vedeu
|
@@ -1,19 +1,32 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
+
# Take a collection of words (elements) and form a sentence from them.
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# elements = ['Hydrogen', 'Helium', 'Lithium']
|
7
|
+
# Vedeu::Sentence.construct(elements) # => 'Hydrogen, Helium and Lithium'
|
8
|
+
#
|
3
9
|
class Sentence
|
4
10
|
|
5
11
|
class << self
|
6
12
|
|
13
|
+
# @param elements [Array]
|
14
|
+
# @param label [String]
|
15
|
+
# @return [String]
|
7
16
|
def construct(elements, label = 'elements')
|
8
17
|
new(elements, label).construct
|
9
18
|
end
|
10
19
|
|
11
|
-
end
|
20
|
+
end
|
12
21
|
|
22
|
+
# @param elements [Array]
|
23
|
+
# @param label [String]
|
24
|
+
# @return [Vedeu::Sentence]
|
13
25
|
def initialize(elements, label)
|
14
26
|
@elements, @label = elements, label
|
15
27
|
end
|
16
28
|
|
29
|
+
# @return [String]
|
17
30
|
def construct
|
18
31
|
if one?
|
19
32
|
first
|
@@ -34,30 +47,37 @@ module Vedeu
|
|
34
47
|
|
35
48
|
attr_reader :elements, :label
|
36
49
|
|
50
|
+
# @return [Boolean]
|
37
51
|
def one?
|
38
52
|
count == 1
|
39
53
|
end
|
40
54
|
|
55
|
+
# @return [Boolean]
|
41
56
|
def two?
|
42
57
|
count == 2
|
43
58
|
end
|
44
59
|
|
60
|
+
# @return [Boolean]
|
45
61
|
def many?
|
46
62
|
count > 2
|
47
63
|
end
|
48
64
|
|
65
|
+
# @return [String]
|
49
66
|
def but_last
|
50
67
|
elements[0...-1].join(', ')
|
51
68
|
end
|
52
69
|
|
70
|
+
# @return [String]
|
53
71
|
def first
|
54
72
|
elements.first
|
55
73
|
end
|
56
74
|
|
75
|
+
# @return [String]
|
57
76
|
def last
|
58
77
|
elements[-1]
|
59
78
|
end
|
60
79
|
|
80
|
+
# @return [Fixnum]
|
61
81
|
def count
|
62
82
|
elements.size
|
63
83
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'vedeu/configuration/configuration'
|
2
|
-
require 'vedeu/support/common'
|
3
2
|
require 'vedeu/support/esc'
|
4
3
|
require 'vedeu/support/log'
|
5
4
|
|
@@ -11,7 +10,6 @@ module Vedeu
|
|
11
10
|
# @api private
|
12
11
|
module Terminal
|
13
12
|
|
14
|
-
include Vedeu::Common
|
15
13
|
extend self
|
16
14
|
|
17
15
|
# Opens a terminal screen in either `raw` or `cooked` mode. On exit,
|
data/lib/vedeu/support/trace.rb
CHANGED
@@ -166,40 +166,86 @@ module Vedeu
|
|
166
166
|
# 'Vedeu::API',
|
167
167
|
# 'Vedeu::Application',
|
168
168
|
# 'Vedeu::Background',
|
169
|
+
# 'Vedeu::Bindings',
|
170
|
+
# 'Vedeu::Border',
|
171
|
+
# 'Vedeu::BoundingArea',
|
172
|
+
# 'Vedeu::Buffer',
|
173
|
+
# 'Vedeu::Char',
|
174
|
+
# 'Vedeu::Chars',
|
169
175
|
'Vedeu::Coercions',
|
170
176
|
'Vedeu::Colour',
|
171
|
-
'Vedeu::Translator',
|
172
177
|
'Vedeu::Common',
|
173
178
|
# 'Vedeu::Composition',
|
174
179
|
# 'Vedeu::Compositor',
|
180
|
+
# 'Vedeu::Config::API',
|
181
|
+
# 'Vedeu::Config::CLI',
|
175
182
|
'Vedeu::Configuration',
|
183
|
+
# 'Vedeu::Console',
|
184
|
+
# 'Vedeu::ContentGeometry',
|
185
|
+
# 'Vedeu::Coordinate',
|
176
186
|
# 'Vedeu::Cursor',
|
177
|
-
# 'Vedeu::
|
187
|
+
# 'Vedeu::DisplayBuffer',
|
188
|
+
# 'Vedeu::DSL::Border',
|
189
|
+
# 'Vedeu::DSL::Colour',
|
190
|
+
# 'Vedeu::DSL::Composition',
|
191
|
+
# 'Vedeu::DSL::Geometry',
|
192
|
+
# 'Vedeu::DSL::Interface',
|
193
|
+
# 'Vedeu::DSL::Keymap',
|
194
|
+
# 'Vedeu::DSL::Line',
|
195
|
+
# 'Vedeu::DSL::Menu',
|
196
|
+
# 'Vedeu::DSL::Stream',
|
197
|
+
# 'Vedeu::DSL::Style',
|
198
|
+
# 'Vedeu::DSL::Text',
|
199
|
+
# 'Vedeu::DSL::Use',
|
200
|
+
# 'Vedeu::DSL::View',
|
178
201
|
'Vedeu::Esc',
|
179
202
|
'Vedeu::Event',
|
180
203
|
# 'Vedeu::Focus',
|
181
204
|
# 'Vedeu::Foreground',
|
182
205
|
'Vedeu::Geometry',
|
183
206
|
# 'Vedeu::Grid',
|
207
|
+
# 'Vedeu::Group',
|
184
208
|
# 'Vedeu::Input',
|
185
209
|
# 'Vedeu::Interface',
|
210
|
+
# 'Vedeu::Interfaces',
|
186
211
|
# 'Vedeu::Keymap',
|
212
|
+
# 'Vedeu::Keys',
|
213
|
+
# 'Vedeu::Key',
|
187
214
|
# 'Vedeu::Launcher',
|
188
215
|
# 'Vedeu::Line',
|
216
|
+
# 'Vedeu::Lines',
|
189
217
|
'Vedeu::Log',
|
218
|
+
# 'Vedeu::Mapper',
|
190
219
|
# 'Vedeu::Menu',
|
191
220
|
# 'Vedeu::Menus',
|
221
|
+
# 'Vedeu::Model',
|
222
|
+
# 'Vedeu::Model::Collection',
|
223
|
+
# 'Vedeu::MoveCursor',
|
224
|
+
# 'Vedeu::Node',
|
225
|
+
# 'Vedeu::Output',
|
192
226
|
'Vedeu::Position',
|
227
|
+
# 'Vedeu::PositionValidator',
|
193
228
|
'Vedeu::Presentation',
|
229
|
+
# 'Vedeu::Read',
|
194
230
|
# 'Vedeu::Refresh',
|
195
231
|
# 'Vedeu::Render',
|
196
232
|
'Vedeu::Repository',
|
233
|
+
# 'Vedeu::Sentence',
|
197
234
|
'Vedeu::Stream',
|
235
|
+
# 'Vedeu::Streams',
|
198
236
|
'Vedeu::Style',
|
199
237
|
'Vedeu::Terminal',
|
238
|
+
# 'Vedeu::Text',
|
239
|
+
# 'Vedeu::ToggleCursor',
|
200
240
|
'Vedeu::Trace',
|
241
|
+
'Vedeu::Translator',
|
242
|
+
# 'Vedeu::Traps',
|
243
|
+
# 'Vedeu::Trigger',
|
201
244
|
# 'Vedeu::View',
|
202
245
|
# 'Vedeu::Viewport',
|
246
|
+
# 'Vedeu::Visible',
|
247
|
+
# 'Vedeu::Write',
|
248
|
+
# 'Vedeu::Writer',
|
203
249
|
]
|
204
250
|
end
|
205
251
|
|
@@ -16,26 +16,6 @@ module Vedeu
|
|
16
16
|
it { subject.must_be_instance_of(TrueClass) }
|
17
17
|
end
|
18
18
|
|
19
|
-
# describe '.unbind' do
|
20
|
-
# let(:event_name) { :chlorine }
|
21
|
-
|
22
|
-
# before do
|
23
|
-
# Vedeu.bind(:chlorine) { :some_event }
|
24
|
-
# end
|
25
|
-
|
26
|
-
# subject { instance.unbind(event_name) }
|
27
|
-
|
28
|
-
# context 'when the event exists' do
|
29
|
-
# it { subject.must_be_instance_of(TrueClass) }
|
30
|
-
# end
|
31
|
-
|
32
|
-
# context 'when the event does not exist' do
|
33
|
-
# let(:event_name) { :does_not_exist }
|
34
|
-
|
35
|
-
# it { subject.must_be_instance_of(FalseClass) }
|
36
|
-
# end
|
37
|
-
# end
|
38
|
-
|
39
19
|
describe '#initialize' do
|
40
20
|
subject { instance }
|
41
21
|
|
@@ -67,20 +47,20 @@ module Vedeu
|
|
67
47
|
it 'returns the result of calling the closure when debouncing' do
|
68
48
|
event = Event.new(event_name, { debounce: 0.0025 }, closure)
|
69
49
|
event.trigger.must_equal(nil)
|
70
|
-
sleep 0.
|
50
|
+
sleep 0.001
|
71
51
|
event.trigger.must_equal(nil)
|
72
|
-
sleep 0.
|
52
|
+
sleep 0.001
|
73
53
|
event.trigger.must_equal(:event_triggered)
|
74
|
-
sleep 0.
|
54
|
+
sleep 0.001
|
75
55
|
event.trigger.must_equal(nil)
|
76
56
|
end
|
77
57
|
|
78
58
|
it 'returns the result of calling the closure when throttling' do
|
79
|
-
event = Event.new(event_name, { delay: 0.
|
59
|
+
event = Event.new(event_name, { delay: 0.002 }, closure)
|
80
60
|
event.trigger.must_equal(:event_triggered)
|
81
|
-
sleep 0.
|
61
|
+
sleep 0.001
|
82
62
|
event.trigger.must_equal(nil)
|
83
|
-
sleep 0.
|
63
|
+
sleep 0.001
|
84
64
|
event.trigger.must_equal(:event_triggered)
|
85
65
|
end
|
86
66
|
|
@@ -92,9 +72,7 @@ module Vedeu
|
|
92
72
|
|
93
73
|
describe '#unbind' do
|
94
74
|
context 'when the event exists' do
|
95
|
-
before
|
96
|
-
Vedeu.bind(:gallium) { :some_action }
|
97
|
-
end
|
75
|
+
before { Vedeu.bind(:gallium) { :some_action } }
|
98
76
|
|
99
77
|
it { Vedeu.unbind(:gallium).must_equal(true) }
|
100
78
|
end
|
@@ -8,13 +8,13 @@ module Vedeu
|
|
8
8
|
let(:instance) { described.new(input) { :output } }
|
9
9
|
let(:input) { 'a' }
|
10
10
|
|
11
|
-
describe '.
|
12
|
-
subject { described.
|
11
|
+
describe '.build' do
|
12
|
+
subject { described.build(input) { :output } }
|
13
13
|
|
14
14
|
it { subject.must_be_instance_of(Key) }
|
15
15
|
|
16
16
|
context 'when the required block is not given' do
|
17
|
-
subject { described.
|
17
|
+
subject { described.build(input) }
|
18
18
|
|
19
19
|
it { proc { subject }.must_raise(InvalidSyntax) }
|
20
20
|
end
|
@@ -15,7 +15,7 @@ module Vedeu
|
|
15
15
|
|
16
16
|
it { subject.must_be_instance_of(Keymap) }
|
17
17
|
it { subject.instance_variable_get('@name').must_equal(map_name) }
|
18
|
-
it { subject.instance_variable_get('@keys').must_be_instance_of(
|
18
|
+
it { subject.instance_variable_get('@keys').must_be_instance_of(Array) }
|
19
19
|
it { subject.instance_variable_get('@repository').must_equal(Vedeu.keymaps) }
|
20
20
|
end
|
21
21
|
|
@@ -32,7 +32,7 @@ module Vedeu
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'when the key is not already defined' do
|
35
|
-
it { subject.must_be_instance_of(Vedeu::
|
35
|
+
it { subject.must_be_instance_of(Vedeu::Keys) }
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -75,7 +75,7 @@ module Vedeu
|
|
75
75
|
describe '#keys' do
|
76
76
|
subject { instance.keys }
|
77
77
|
|
78
|
-
it { subject.must_be_instance_of(Vedeu::
|
78
|
+
it { subject.must_be_instance_of(Vedeu::Keys) }
|
79
79
|
end
|
80
80
|
|
81
81
|
describe '#name' do
|
@@ -0,0 +1,266 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Wordwrap do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Wordwrap }
|
8
|
+
let(:instance) { described.new(text, options) }
|
9
|
+
let(:text) { '' }
|
10
|
+
let(:options) {
|
11
|
+
{
|
12
|
+
ellipsis: '...',
|
13
|
+
width: width,
|
14
|
+
}
|
15
|
+
}
|
16
|
+
let(:width) { 30 }
|
17
|
+
|
18
|
+
let(:text_line) {
|
19
|
+
"Krypton (from Greek: κρυπτός kryptos 'the hidden one')."
|
20
|
+
}
|
21
|
+
let(:text_block) {
|
22
|
+
"Krypton (from Greek: κρυπτός kryptos 'the hidden one') is a chemical " \
|
23
|
+
"element with symbol Kr and atomic number 36. It is a member of group " \
|
24
|
+
"18 (noble gases) elements."
|
25
|
+
}
|
26
|
+
let(:text_newlines) {
|
27
|
+
"Krypton is a colorless, odorless, tasteless noble gas.\n" \
|
28
|
+
"It occurs in trace amounts in the atmosphere.\n" \
|
29
|
+
"It is isolated by fractionally distilling liquefied air.\n" \
|
30
|
+
"Krypton is often used with other rare gases in fluorescent lamps.\n"
|
31
|
+
}
|
32
|
+
let(:text_blanklines) {
|
33
|
+
"Krypton (from Greek: κρυπτός kryptos 'the hidden one').\n\n" \
|
34
|
+
"It is a chemical element with symbol Kr and atomic number 36.\n" \
|
35
|
+
"It is a member of group 18 (noble gases) elements.\n\n" \
|
36
|
+
"-- Wikipedia"
|
37
|
+
}
|
38
|
+
let(:text_line_objects) {
|
39
|
+
[
|
40
|
+
Vedeu::Line.new("Krypton is a colorless, odorless, tasteless noble gas."),
|
41
|
+
Vedeu::Line.new("It occurs in trace amounts in the atmosphere."),
|
42
|
+
Vedeu::Line.new("It is isolated by fractionally distilling liquefied air."),
|
43
|
+
Vedeu::Line.new("Krypton is often used with other rare gases in fluorescent lamps.")
|
44
|
+
]
|
45
|
+
}
|
46
|
+
|
47
|
+
describe '#initialize' do
|
48
|
+
subject { instance }
|
49
|
+
|
50
|
+
it { subject.must_be_instance_of(described) }
|
51
|
+
it { subject.instance_variable_get('@text').must_equal(text) }
|
52
|
+
it { subject.instance_variable_get('@options').must_equal(options) }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#prune' do
|
56
|
+
let(:text) { text_line }
|
57
|
+
|
58
|
+
subject { instance.prune }
|
59
|
+
|
60
|
+
context 'when the text is <= the pruning width' do
|
61
|
+
let(:width) { 80 }
|
62
|
+
|
63
|
+
it { subject.must_be_instance_of(String) }
|
64
|
+
|
65
|
+
it { subject.must_equal(
|
66
|
+
"Krypton (from Greek: κρυπτός kryptos 'the hidden one')."
|
67
|
+
) }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when the text is > the pruning width' do
|
71
|
+
context 'with a single line of text' do
|
72
|
+
it { subject.must_equal("Krypton (from Greek: κρυπτός...") }
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with a text block' do
|
76
|
+
let(:text) { text_block }
|
77
|
+
|
78
|
+
it { subject.must_equal("Krypton (from Greek: κρυπτός...") }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with a text block containing newlines' do
|
82
|
+
let(:text) { text_newlines }
|
83
|
+
|
84
|
+
it { subject.must_equal([
|
85
|
+
"Krypton is a colorless, odor...",
|
86
|
+
"It occurs in trace amounts i...",
|
87
|
+
"It is isolated by fractional...",
|
88
|
+
"Krypton is often used with o..."
|
89
|
+
])
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'with a text block containing newlines and blank lines' do
|
94
|
+
let(:text) { text_blanklines }
|
95
|
+
|
96
|
+
it { subject.must_equal([
|
97
|
+
"Krypton (from Greek: κρυπτός...",
|
98
|
+
"",
|
99
|
+
"It is a chemical element wit...",
|
100
|
+
"It is a member of group 18 (...",
|
101
|
+
"",
|
102
|
+
"-- Wikipedia..."
|
103
|
+
])
|
104
|
+
}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#wrap' do
|
110
|
+
subject { instance.wrap }
|
111
|
+
|
112
|
+
context 'with a single line of text' do
|
113
|
+
let(:text) { text_line }
|
114
|
+
|
115
|
+
it { subject.must_equal([
|
116
|
+
"Krypton (from Greek: κρυπτός",
|
117
|
+
"kryptos 'the hidden one')."
|
118
|
+
])
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'with a text block' do
|
123
|
+
let(:text) { text_block }
|
124
|
+
|
125
|
+
it { subject.must_equal([
|
126
|
+
"Krypton (from Greek: κρυπτός",
|
127
|
+
"kryptos 'the hidden one') is",
|
128
|
+
"a chemical element with",
|
129
|
+
"symbol Kr and atomic number",
|
130
|
+
"36. It is a member of group",
|
131
|
+
"18 (noble gases) elements."
|
132
|
+
])
|
133
|
+
}
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'with a text block containing newlines' do
|
137
|
+
let(:text) { text_newlines }
|
138
|
+
|
139
|
+
it { subject.must_equal([
|
140
|
+
"Krypton is a colorless,",
|
141
|
+
"odorless, tasteless noble",
|
142
|
+
"gas.",
|
143
|
+
"It occurs in trace amounts",
|
144
|
+
"in the atmosphere.",
|
145
|
+
"It is isolated by",
|
146
|
+
"fractionally distilling",
|
147
|
+
"liquefied air.",
|
148
|
+
"Krypton is often used with",
|
149
|
+
"other rare gases in",
|
150
|
+
"fluorescent lamps."
|
151
|
+
])
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'with a text block containing newlines and blank lines' do
|
156
|
+
let(:text) { text_blanklines }
|
157
|
+
|
158
|
+
it { subject.must_equal([
|
159
|
+
"Krypton (from Greek: κρυπτός",
|
160
|
+
"kryptos 'the hidden one').",
|
161
|
+
"",
|
162
|
+
"It is a chemical element",
|
163
|
+
"with symbol Kr and atomic",
|
164
|
+
"number 36.",
|
165
|
+
"It is a member of group 18",
|
166
|
+
"(noble gases) elements.",
|
167
|
+
"",
|
168
|
+
"-- Wikipedia"
|
169
|
+
])
|
170
|
+
}
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe '#as_lines' do
|
175
|
+
subject { instance.as_lines }
|
176
|
+
|
177
|
+
it { subject.must_be_instance_of(Vedeu::Lines) }
|
178
|
+
|
179
|
+
context 'with a single line of text' do
|
180
|
+
let(:text) { text_line }
|
181
|
+
|
182
|
+
it { subject.size.must_equal(1) }
|
183
|
+
end
|
184
|
+
|
185
|
+
context 'with a text block' do
|
186
|
+
let(:text) { text_block }
|
187
|
+
|
188
|
+
it { subject.size.must_equal(1) }
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'with a text block containing newlines' do
|
192
|
+
let(:text) { text_newlines }
|
193
|
+
|
194
|
+
it { subject.size.must_equal(4) }
|
195
|
+
end
|
196
|
+
|
197
|
+
context 'with a text block containing newlines and blank lines' do
|
198
|
+
let(:text) { text_blanklines }
|
199
|
+
|
200
|
+
it { subject.size.must_equal(6) }
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'alias method #prune_as_lines' do
|
204
|
+
subject { instance.prune_as_lines }
|
205
|
+
|
206
|
+
it { subject.must_be_instance_of(Vedeu::Lines) }
|
207
|
+
|
208
|
+
context 'with a single line of text' do
|
209
|
+
let(:text) { text_line }
|
210
|
+
|
211
|
+
it { subject.size.must_equal(1) }
|
212
|
+
end
|
213
|
+
|
214
|
+
context 'with a text block' do
|
215
|
+
let(:text) { text_block }
|
216
|
+
|
217
|
+
it { subject.size.must_equal(1) }
|
218
|
+
end
|
219
|
+
|
220
|
+
context 'with a text block containing newlines' do
|
221
|
+
let(:text) { text_newlines }
|
222
|
+
|
223
|
+
it { subject.size.must_equal(4) }
|
224
|
+
end
|
225
|
+
|
226
|
+
context 'with a text block containing newlines and blank lines' do
|
227
|
+
let(:text) { text_blanklines }
|
228
|
+
|
229
|
+
it { subject.size.must_equal(6) }
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
context 'alias method #wrap_as_lines' do
|
234
|
+
subject { instance.wrap_as_lines }
|
235
|
+
|
236
|
+
it { subject.must_be_instance_of(Vedeu::Lines) }
|
237
|
+
|
238
|
+
context 'with a single line of text' do
|
239
|
+
let(:text) { text_line }
|
240
|
+
|
241
|
+
it { subject.size.must_equal(2) }
|
242
|
+
end
|
243
|
+
|
244
|
+
context 'with a text block' do
|
245
|
+
let(:text) { text_block }
|
246
|
+
|
247
|
+
it { subject.size.must_equal(6) }
|
248
|
+
end
|
249
|
+
|
250
|
+
context 'with a text block containing newlines' do
|
251
|
+
let(:text) { text_newlines }
|
252
|
+
|
253
|
+
it { subject.size.must_equal(11) }
|
254
|
+
end
|
255
|
+
|
256
|
+
context 'with a text block containing newlines and blank lines' do
|
257
|
+
let(:text) { text_blanklines }
|
258
|
+
|
259
|
+
it { subject.size.must_equal(10) }
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
end # Wordwrap
|
265
|
+
|
266
|
+
end # Vedeu
|