vedeu 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/api.rb +8 -0
- data/lib/vedeu/application.rb +2 -0
- data/lib/vedeu/bindings.rb +3 -0
- data/lib/vedeu/configuration/configuration.rb +1 -1
- data/lib/vedeu/cursor/cursor.rb +1 -1
- data/lib/vedeu/cursor/move.rb +1 -1
- data/lib/vedeu/cursor/refresh_cursor.rb +2 -0
- data/lib/vedeu/cursor/toggle.rb +1 -1
- data/lib/vedeu/debug.rb +36 -1
- data/lib/vedeu/distributed/client.rb +2 -0
- data/lib/vedeu/distributed/subprocess.rb +2 -0
- data/lib/vedeu/distributed/test_application.rb +2 -0
- data/lib/vedeu/distributed/uri.rb +2 -0
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/events/trigger.rb +2 -0
- data/lib/vedeu/geometry/all.rb +0 -1
- data/lib/vedeu/geometry/area.rb +22 -0
- data/lib/vedeu/geometry/centre.rb +2 -0
- data/lib/vedeu/geometry/content.rb +2 -0
- data/lib/vedeu/geometry/coordinate.rb +2 -0
- data/lib/vedeu/geometry/dimension.rb +2 -0
- data/lib/vedeu/geometry/geometry.rb +8 -3
- data/lib/vedeu/geometry/grid.rb +2 -0
- data/lib/vedeu/geometry/index_position.rb +21 -0
- data/lib/vedeu/geometry/limit.rb +2 -0
- data/lib/vedeu/geometry/position.rb +1 -1
- data/lib/vedeu/geometry/position_index.rb +2 -0
- data/lib/vedeu/geometry/position_validator.rb +2 -0
- data/lib/vedeu/input/input.rb +1 -1
- data/lib/vedeu/input/key.rb +1 -1
- data/lib/vedeu/input/keymap.rb +2 -0
- data/lib/vedeu/input/mapper.rb +8 -0
- data/lib/vedeu/launcher.rb +2 -0
- data/lib/vedeu/main_loop.rb +1 -3
- data/lib/vedeu/models/cell.rb +2 -0
- data/lib/vedeu/models/composition.rb +1 -1
- data/lib/vedeu/models/group.rb +1 -1
- data/lib/vedeu/models/interface.rb +35 -3
- data/lib/vedeu/models/line.rb +6 -1
- data/lib/vedeu/models/menu.rb +1 -1
- data/lib/vedeu/models/stream.rb +6 -17
- data/lib/vedeu/output/all.rb +3 -2
- data/lib/vedeu/output/background.rb +26 -0
- data/lib/vedeu/output/border.rb +105 -25
- data/lib/vedeu/output/clear.rb +17 -10
- data/lib/vedeu/output/colour.rb +1 -1
- data/lib/vedeu/output/compositor.rb +4 -1
- data/lib/vedeu/output/foreground.rb +26 -0
- data/lib/vedeu/output/html_char.rb +2 -0
- data/lib/vedeu/output/null_border.rb +49 -0
- data/lib/vedeu/output/output.rb +8 -44
- data/lib/vedeu/output/renderers/all.rb +3 -0
- data/lib/vedeu/output/{renderer.rb → renderers/file_renderer.rb} +14 -6
- data/lib/vedeu/output/{html_renderer.rb → renderers/html_renderer.rb} +3 -1
- data/lib/vedeu/output/renderers/terminal_renderer.rb +50 -0
- data/lib/vedeu/output/text.rb +1 -1
- data/lib/vedeu/output/translator.rb +21 -2
- data/lib/vedeu/output/viewport.rb +17 -50
- data/lib/vedeu/output/virtual_terminal.rb +2 -0
- data/lib/vedeu/output/wordwrap.rb +2 -0
- data/lib/vedeu/repositories/all.rb +82 -0
- data/lib/vedeu/repositories/collection.rb +16 -0
- data/lib/vedeu/repositories/repository.rb +2 -0
- data/lib/vedeu/support/log.rb +3 -0
- data/lib/vedeu/support/sentence.rb +2 -0
- data/lib/vedeu/support/template.rb +2 -0
- data/lib/vedeu/support/terminal.rb +6 -1
- data/lib/vedeu/support/trace.rb +2 -0
- data/lib/vedeu/support/visible.rb +6 -0
- data/test/lib/vedeu/dsl/components/border_test.rb +0 -270
- data/test/lib/vedeu/dsl/shared/text_test.rb +19 -0
- data/test/lib/vedeu/geometry/area_test.rb +32 -0
- data/test/lib/vedeu/geometry/index_position_test.rb +36 -0
- data/test/lib/vedeu/models/interface_test.rb +42 -1
- data/test/lib/vedeu/models/line_test.rb +15 -1
- data/test/lib/vedeu/models/stream_test.rb +15 -1
- data/test/lib/vedeu/output/background_test.rb +4 -2
- data/test/lib/vedeu/output/border_test.rb +229 -127
- data/test/lib/vedeu/output/clear_test.rb +14 -0
- data/test/lib/vedeu/output/foreground_test.rb +4 -2
- data/test/lib/vedeu/output/null_border_test.rb +53 -0
- data/test/lib/vedeu/output/output_test.rb +2 -0
- data/test/lib/vedeu/output/{renderer_test.rb → renderers/file_renderer_test.rb} +5 -5
- data/test/lib/vedeu/output/renderers/html_renderer_test.rb +71 -0
- data/test/lib/vedeu/output/renderers/terminal_renderer_test.rb +24 -0
- data/test/lib/vedeu/output/viewport_test.rb +100 -74
- data/vedeu.gemspec +1 -1
- metadata +15 -11
- data/lib/vedeu/geometry/bounding_area.rb +0 -136
- data/test/lib/vedeu/geometry/bounding_area_test.rb +0 -123
- data/test/lib/vedeu/output/html_renderer_test.rb +0 -42
@@ -1,136 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Provides coordinates based on the height and width provided.
|
4
|
-
# Coordinates always start from 1, 1.
|
5
|
-
#
|
6
|
-
class BoundingArea
|
7
|
-
|
8
|
-
# @!attribute [r] height
|
9
|
-
# @return [Fixnum]
|
10
|
-
attr_reader :height
|
11
|
-
|
12
|
-
# @!attribute [r] width
|
13
|
-
# @return [Fixnum]
|
14
|
-
attr_reader :width
|
15
|
-
|
16
|
-
# Returns an instance of BoundingArea.
|
17
|
-
#
|
18
|
-
# @param height [Fixnum]
|
19
|
-
# @param width [Fixnum]
|
20
|
-
# @return [Vedeu::BoundingArea]
|
21
|
-
def initialize(height, width)
|
22
|
-
@height = height
|
23
|
-
@width = width
|
24
|
-
end
|
25
|
-
|
26
|
-
# Returns the top line (y) coordinate for the console.
|
27
|
-
#
|
28
|
-
# @example
|
29
|
-
# # height = 20
|
30
|
-
#
|
31
|
-
# top # => 1
|
32
|
-
# top(5) # => 6
|
33
|
-
# top(-5) # => 1
|
34
|
-
# top(25) # => 20
|
35
|
-
#
|
36
|
-
# @param offset [Fixnum] When provided, returns the top coordinate plus
|
37
|
-
# the offset.
|
38
|
-
# @return [Fixnum]
|
39
|
-
def top(offset = 0)
|
40
|
-
if offset >= height
|
41
|
-
height
|
42
|
-
|
43
|
-
elsif offset <= 1
|
44
|
-
1
|
45
|
-
|
46
|
-
else
|
47
|
-
1 + offset
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
51
|
-
alias_method :y, :top
|
52
|
-
|
53
|
-
# Returns the bottom line (yn) coordinate for the console.
|
54
|
-
#
|
55
|
-
# @example
|
56
|
-
# # height = 20
|
57
|
-
#
|
58
|
-
# bottom # => 20
|
59
|
-
# bottom(5) # => 15
|
60
|
-
# bottom(-5) # => 20
|
61
|
-
# bottom(25) # => 1
|
62
|
-
#
|
63
|
-
# @param offset [Fixnum] When provided, returns the bottom coordinate minus
|
64
|
-
# the offset.
|
65
|
-
# @return [Fixnum]
|
66
|
-
def bottom(offset = 0)
|
67
|
-
if offset >= height
|
68
|
-
1
|
69
|
-
|
70
|
-
elsif offset < 0
|
71
|
-
height
|
72
|
-
|
73
|
-
else
|
74
|
-
height - offset
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
alias_method :yn, :bottom
|
79
|
-
|
80
|
-
# Returns the leftmost column (x) coordinate for the console.
|
81
|
-
#
|
82
|
-
# @example
|
83
|
-
# # width = 40
|
84
|
-
#
|
85
|
-
# left # => 1
|
86
|
-
# left(5) # => 6
|
87
|
-
# left(-5) # => 1
|
88
|
-
# left(45) # => 40
|
89
|
-
#
|
90
|
-
# @param offset [Fixnum] When provided, returns the left coordinate plus
|
91
|
-
# the offset.
|
92
|
-
# @return [Fixnum]
|
93
|
-
def left(offset = 0)
|
94
|
-
if offset >= width
|
95
|
-
width
|
96
|
-
|
97
|
-
elsif offset <= 1
|
98
|
-
1
|
99
|
-
|
100
|
-
else
|
101
|
-
1 + offset
|
102
|
-
|
103
|
-
end
|
104
|
-
end
|
105
|
-
alias_method :x, :left
|
106
|
-
|
107
|
-
# Returns the rightmost column (yn) coordinate for the console.
|
108
|
-
#
|
109
|
-
# @example
|
110
|
-
# # width = 40
|
111
|
-
#
|
112
|
-
# right # => 40
|
113
|
-
# right(5) # => 35
|
114
|
-
# right(-5) # => 40
|
115
|
-
# right(45) # => 1
|
116
|
-
#
|
117
|
-
# @param offset [Fixnum] When provided, returns the right coordinate minus
|
118
|
-
# the offset.
|
119
|
-
# @return [Fixnum]
|
120
|
-
def right(offset = 0)
|
121
|
-
if offset >= width
|
122
|
-
1
|
123
|
-
|
124
|
-
elsif offset < 0
|
125
|
-
width
|
126
|
-
|
127
|
-
else
|
128
|
-
width - offset
|
129
|
-
|
130
|
-
end
|
131
|
-
end
|
132
|
-
alias_method :xn, :right
|
133
|
-
|
134
|
-
end # BoundingArea
|
135
|
-
|
136
|
-
end # Vedeu
|
@@ -1,123 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe BoundingArea do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::BoundingArea }
|
8
|
-
let(:instance) { described.new(height, width) }
|
9
|
-
let(:height) { 15 }
|
10
|
-
let(:width) { 40 }
|
11
|
-
|
12
|
-
describe 'alias methods' do
|
13
|
-
it { instance.must_respond_to(:y) }
|
14
|
-
it { instance.must_respond_to(:yn) }
|
15
|
-
it { instance.must_respond_to(:x) }
|
16
|
-
it { instance.must_respond_to(:xn) }
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#initialize' do
|
20
|
-
it { instance.must_be_instance_of(BoundingArea) }
|
21
|
-
it { instance.instance_variable_get('@height').must_equal(height) }
|
22
|
-
it { instance.instance_variable_get('@width').must_equal(width) }
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#height' do
|
26
|
-
it 'returns the height' do
|
27
|
-
instance.height.must_equal(height)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#width' do
|
32
|
-
it 'returns the width' do
|
33
|
-
instance.width.must_equal(width)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#top' do
|
38
|
-
context 'when an offset is provided' do
|
39
|
-
it 'returns the new top with the offset applied' do
|
40
|
-
instance.top(5).must_equal(6)
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when the offset is greater or equal to the height' do
|
44
|
-
it 'returns the height' do
|
45
|
-
instance.top(20).must_equal(15)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'when the offset is less than or equal to 1' do
|
50
|
-
it { instance.top(-1).must_equal(1) }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'when an offset is not provided' do
|
55
|
-
it { instance.top.must_equal(1) }
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#bottom' do
|
60
|
-
context 'when an offset is provided' do
|
61
|
-
it 'returns the new bottom with the offset applied' do
|
62
|
-
instance.bottom(5).must_equal(10)
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'when the offset is greater or equal to the height' do
|
66
|
-
it { instance.bottom(30).must_equal(1) }
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when the offset is less than 0' do
|
70
|
-
it { instance.bottom(-1).must_equal(height) }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'when an offset is not provided' do
|
75
|
-
it { instance.bottom.must_equal(15) }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#left' do
|
80
|
-
context 'when an offset is provided' do
|
81
|
-
it 'returns the new left with the offset applied' do
|
82
|
-
instance.left(5).must_equal(6)
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'when the offset is greater or equal to the width' do
|
86
|
-
it 'returns the width' do
|
87
|
-
instance.left(50).must_equal(40)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'when the offset is less than or equal to 1' do
|
92
|
-
it { instance.left(-1).must_equal(1) }
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'when an offset is not provided' do
|
97
|
-
it { instance.left.must_equal(1) }
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#right' do
|
102
|
-
context 'when an offset is provided' do
|
103
|
-
it 'returns the new right with the offset applied' do
|
104
|
-
instance.right(5).must_equal(35)
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'when the offset is greater or equal to the width' do
|
108
|
-
it { instance.right(50).must_equal(1) }
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'when the offset is less than 0' do
|
112
|
-
it { instance.right(-1).must_equal(40) }
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
context 'when an offset is not provided' do
|
117
|
-
it { instance.right.must_equal(40) }
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
end # BoundingArea
|
122
|
-
|
123
|
-
end # Vedeu
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe HTMLRenderer do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::HTMLRenderer }
|
8
|
-
let(:instance) { described.new(output) }
|
9
|
-
let(:output) {}
|
10
|
-
|
11
|
-
describe '#initialize' do
|
12
|
-
it { instance.must_be_instance_of(Vedeu::HTMLRenderer) }
|
13
|
-
it { instance.instance_variable_get('@output').must_equal(output) }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#render' do
|
17
|
-
subject { instance.render }
|
18
|
-
|
19
|
-
it { subject.must_be_instance_of(String) }
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '.to_file' do
|
23
|
-
before { File.stubs(:open) }
|
24
|
-
|
25
|
-
subject { described.to_file(output, path) }
|
26
|
-
|
27
|
-
context 'when a path is given' do
|
28
|
-
let(:path) { '/tmp/test_vedeu_html_renderer.html' }
|
29
|
-
|
30
|
-
#it { subject.must_equal('') }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when a path is not given' do
|
34
|
-
let(:path) {}
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end # HTMLRenderer
|
41
|
-
|
42
|
-
end # Vedeu
|