vedeu 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +3 -0
- data/Rakefile +16 -7
- data/examples/borders_app.rb +58 -55
- data/lib/vedeu/api.rb +1 -1
- data/lib/vedeu/application.rb +25 -25
- data/lib/vedeu/bindings.rb +5 -7
- data/lib/vedeu/configuration/api.rb +0 -2
- data/lib/vedeu/configuration/cli.rb +0 -2
- data/lib/vedeu/configuration/configuration.rb +0 -2
- data/lib/vedeu/cursor/cursor.rb +0 -2
- data/lib/vedeu/debug.rb +2 -2
- data/lib/vedeu/distributed/server.rb +0 -2
- data/lib/vedeu/dsl/components/border.rb +15 -19
- data/lib/vedeu/dsl/components/geometry.rb +14 -18
- data/lib/vedeu/dsl/components/keymap.rb +28 -32
- data/lib/vedeu/dsl/composition.rb +27 -9
- data/lib/vedeu/events/all.rb +1 -0
- data/lib/vedeu/events/event.rb +6 -8
- data/lib/vedeu/events/events.rb +10 -0
- data/lib/vedeu/events/trigger.rb +6 -12
- data/lib/vedeu/geometry/grid.rb +0 -2
- data/lib/vedeu/geometry/position.rb +0 -2
- data/lib/vedeu/geometry/position_validator.rb +0 -14
- data/lib/vedeu/input/input.rb +0 -2
- data/lib/vedeu/models/collection.rb +0 -2
- data/lib/vedeu/models/focus.rb +0 -1
- data/lib/vedeu/models/geometry.rb +7 -3
- data/lib/vedeu/models/group.rb +0 -2
- data/lib/vedeu/models/menu.rb +23 -29
- data/lib/vedeu/models/model.rb +0 -2
- data/lib/vedeu/models/view/char.rb +14 -10
- data/lib/vedeu/models/view/composition.rb +7 -9
- data/lib/vedeu/models/view/interface.rb +0 -1
- data/lib/vedeu/models/view/line.rb +2 -3
- data/lib/vedeu/models/view/stream.rb +0 -3
- data/lib/vedeu/output/all.rb +1 -0
- data/lib/vedeu/output/background.rb +0 -2
- data/lib/vedeu/output/colour.rb +0 -2
- data/lib/vedeu/output/compositor.rb +0 -2
- data/lib/vedeu/output/foreground.rb +0 -2
- data/lib/vedeu/output/html_renderer.rb +6 -0
- data/lib/vedeu/output/index_position.rb +35 -0
- data/lib/vedeu/output/output.rb +3 -1
- data/lib/vedeu/output/position_index.rb +2 -2
- data/lib/vedeu/output/presentation.rb +0 -2
- data/lib/vedeu/output/style.rb +0 -1
- data/lib/vedeu/output/translator.rb +18 -20
- data/lib/vedeu/output/viewport.rb +76 -51
- data/lib/vedeu/output/virtual_terminal.rb +2 -1
- data/lib/vedeu/repositories/all.rb +4 -4
- data/lib/vedeu/repositories/repository.rb +0 -2
- data/lib/vedeu/support/coercions.rb +0 -2
- data/lib/vedeu/support/common.rb +0 -2
- data/lib/vedeu/support/esc.rb +0 -2
- data/lib/vedeu/support/log.rb +86 -3
- data/lib/vedeu/support/refresh.rb +0 -2
- data/lib/vedeu/support/sentence.rb +5 -9
- data/lib/vedeu/support/terminal.rb +0 -2
- data/lib/vedeu/support/trace.rb +0 -2
- data/lib/vedeu/support/visible.rb +1 -1
- data/test/lib/vedeu/configuration/api_test.rb +14 -0
- data/test/lib/vedeu/configuration/configuration_test.rb +10 -0
- data/test/lib/vedeu/distributed/server_test.rb +5 -0
- data/test/lib/vedeu/dsl/components/border_test.rb +7 -0
- data/test/lib/vedeu/dsl/components/geometry_test.rb +8 -3
- data/test/lib/vedeu/dsl/interface_test.rb +5 -0
- data/test/lib/vedeu/dsl/line_test.rb +4 -0
- data/test/lib/vedeu/dsl/shared/colour_test.rb +7 -7
- data/test/lib/vedeu/dsl/shared/style_test.rb +5 -2
- data/test/lib/vedeu/dsl/stream_test.rb +4 -1
- data/test/lib/vedeu/events/event_test.rb +6 -0
- data/test/lib/vedeu/geometry/bounding_area_test.rb +30 -30
- data/test/lib/vedeu/geometry/position_test.rb +5 -0
- data/test/lib/vedeu/models/view/char_test.rb +1 -14
- data/test/lib/vedeu/output/index_position_test.rb +64 -0
- data/test/lib/vedeu/output/style_test.rb +4 -0
- data/test/lib/vedeu/output/translator_test.rb +4 -0
- data/test/lib/vedeu/output/virtual_terminal_test.rb +2 -0
- data/test/lib/vedeu/output/wordwrap_test.rb +5 -0
- data/test/lib/vedeu/repositories/all_test.rb +3 -3
- data/test/lib/vedeu/repositories/repository_test.rb +8 -0
- data/test/lib/vedeu/support/console_test.rb +14 -0
- data/test/lib/vedeu/support/esc_test.rb +6 -0
- data/test/lib/vedeu/support/terminal_test.rb +13 -0
- data/vedeu.gemspec +4 -4
- metadata +12 -24
- data/test/integration/distributed_test.rb +0 -16
- data/test/integration/dsl/compositions_test.rb +0 -19
- data/test/integration/dsl/interfaces_test.rb +0 -193
- data/test/integration/dsl/keymaps_test.rb +0 -30
- data/test/integration/dsl/lines_test.rb +0 -104
- data/test/integration/dsl/menus_test.rb +0 -59
- data/test/integration/dsl/streams_test.rb +0 -103
- data/test/integration/dsl/views_test.rb +0 -45
@@ -4,9 +4,19 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Configuration do
|
6
6
|
|
7
|
+
let(:described) { Vedeu::Configuration }
|
8
|
+
|
7
9
|
before { Configuration.reset! }
|
8
10
|
after { test_configuration }
|
9
11
|
|
12
|
+
describe 'alias_methods' do
|
13
|
+
it { described.must_respond_to(:debug) }
|
14
|
+
it { described.must_respond_to(:drb) }
|
15
|
+
it { described.must_respond_to(:interactive) }
|
16
|
+
it { described.must_respond_to(:once) }
|
17
|
+
it { described.must_respond_to(:trace) }
|
18
|
+
end
|
19
|
+
|
10
20
|
describe '.default_system_keys' do
|
11
21
|
it 'returns the default system keys' do
|
12
22
|
Configuration.default_system_keys.must_equal({
|
@@ -28,6 +28,13 @@ module Vedeu
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
describe 'alias methods' do
|
32
|
+
it { instance.must_respond_to(:show_bottom) }
|
33
|
+
it { instance.must_respond_to(:show_left) }
|
34
|
+
it { instance.must_respond_to(:show_right) }
|
35
|
+
it { instance.must_respond_to(:show_top) }
|
36
|
+
end
|
37
|
+
|
31
38
|
describe '#initialize' do
|
32
39
|
it { instance.must_be_instance_of(Vedeu::DSL::Border) }
|
33
40
|
it { instance.instance_variable_get('@model').must_equal(model) }
|
@@ -6,12 +6,17 @@ module Vedeu
|
|
6
6
|
|
7
7
|
describe Geometry do
|
8
8
|
|
9
|
-
let(:described) { Vedeu::DSL::Geometry
|
9
|
+
let(:described) { Vedeu::DSL::Geometry }
|
10
|
+
let(:instance) { described.new(model) }
|
10
11
|
let(:model) { Vedeu::Geometry.new }
|
11
12
|
|
13
|
+
describe 'alias methods' do
|
14
|
+
it { instance.must_respond_to(:centred!) }
|
15
|
+
end
|
16
|
+
|
12
17
|
describe '#initialize' do
|
13
|
-
it {
|
14
|
-
it {
|
18
|
+
it { instance.must_be_instance_of(Vedeu::DSL::Geometry) }
|
19
|
+
it { instance.instance_variable_get('@model').must_equal(model) }
|
15
20
|
end
|
16
21
|
|
17
22
|
describe '#centred' do
|
@@ -17,6 +17,11 @@ module Vedeu
|
|
17
17
|
|
18
18
|
before { Vedeu.interfaces.reset }
|
19
19
|
|
20
|
+
describe 'alias methods' do
|
21
|
+
it { instance.must_respond_to(:keys) }
|
22
|
+
it { instance.must_respond_to(:line) }
|
23
|
+
end
|
24
|
+
|
20
25
|
describe '#initialize' do
|
21
26
|
it { instance.must_be_instance_of(Vedeu::DSL::Interface) }
|
22
27
|
it { instance.instance_variable_get('@model').must_equal(model) }
|
@@ -23,6 +23,10 @@ module Vedeu
|
|
23
23
|
let(:colour) { Vedeu::Colour.new }
|
24
24
|
let(:style) { Vedeu::Style.new }
|
25
25
|
|
26
|
+
describe 'alias methods' do
|
27
|
+
it { instance.must_respond_to(:stream) }
|
28
|
+
end
|
29
|
+
|
26
30
|
describe '#initialize' do
|
27
31
|
it { instance.must_be_instance_of(described) }
|
28
32
|
it { instance.instance_variable_get('@model').must_equal(model) }
|
@@ -7,12 +7,18 @@ module Vedeu
|
|
7
7
|
describe Colour do
|
8
8
|
|
9
9
|
let(:described) { Vedeu::DSL::Colour }
|
10
|
-
|
11
10
|
let(:dsl_klass) { Vedeu::DSL::Interface.new(model) }
|
12
11
|
let(:model) { Vedeu::Interface.new }
|
13
12
|
let(:background) { '#00ff00' }
|
14
13
|
let(:foreground) { '#ff00ff' }
|
15
14
|
|
15
|
+
describe 'alias methods' do
|
16
|
+
it { dsl_klass.must_respond_to(:bg) }
|
17
|
+
it { dsl_klass.must_respond_to(:bgcolor) }
|
18
|
+
it { dsl_klass.must_respond_to(:fg) }
|
19
|
+
it { dsl_klass.must_respond_to(:fgcolor) }
|
20
|
+
end
|
21
|
+
|
16
22
|
describe '#background' do
|
17
23
|
subject { dsl_klass.background(background) }
|
18
24
|
|
@@ -23,9 +29,6 @@ module Vedeu
|
|
23
29
|
{ background: '#00ff00', foreground: '' }
|
24
30
|
)
|
25
31
|
end
|
26
|
-
|
27
|
-
it { dsl_klass.must_respond_to(:bg) }
|
28
|
-
it { dsl_klass.must_respond_to(:bgcolor) }
|
29
32
|
end
|
30
33
|
|
31
34
|
describe '#foreground' do
|
@@ -38,9 +41,6 @@ module Vedeu
|
|
38
41
|
{ background: '', foreground: '#ff00ff' }
|
39
42
|
)
|
40
43
|
end
|
41
|
-
|
42
|
-
it { dsl_klass.must_respond_to(:fg) }
|
43
|
-
it { dsl_klass.must_respond_to(:fgcolor) }
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '#colour' do
|
@@ -6,11 +6,14 @@ module Vedeu
|
|
6
6
|
|
7
7
|
describe Style do
|
8
8
|
|
9
|
+
let(:described) { Vedeu::DSL::Style }
|
10
|
+
let(:instance) { Vedeu::DSL::ModelTestClass.new(model) }
|
11
|
+
let(:model) { Vedeu::ModelTestClass.new({}) }
|
12
|
+
|
9
13
|
describe '#style' do
|
10
|
-
let(:model) { Vedeu::ModelTestClass.new({}) }
|
11
14
|
let(:args) { :bold }
|
12
15
|
|
13
|
-
subject {
|
16
|
+
subject { instance.style(args) }
|
14
17
|
|
15
18
|
it { subject.must_be_instance_of(Vedeu::Style) }
|
16
19
|
end
|
@@ -8,8 +8,9 @@ module Vedeu
|
|
8
8
|
|
9
9
|
let(:described) { Vedeu::DSL::Stream }
|
10
10
|
let(:instance) { described.new(model) }
|
11
|
-
let(:model) { Vedeu::Stream.new }
|
11
|
+
let(:model) { Vedeu::Stream.new({ parent: parent }) }
|
12
12
|
let(:client) {}
|
13
|
+
let(:parent) { Vedeu::Line.new }
|
13
14
|
|
14
15
|
describe '#initialize' do
|
15
16
|
it { instance.must_be_instance_of(Vedeu::DSL::Stream) }
|
@@ -20,6 +21,8 @@ module Vedeu
|
|
20
21
|
describe '#stream' do
|
21
22
|
subject { instance.stream { } }
|
22
23
|
|
24
|
+
it { subject.must_be_instance_of(Vedeu::Streams) }
|
25
|
+
|
23
26
|
context 'when the block is not given' do
|
24
27
|
subject { instance.stream }
|
25
28
|
|
@@ -10,6 +10,12 @@ module Vedeu
|
|
10
10
|
let(:options) { {} }
|
11
11
|
let(:closure) { proc { :event_triggered } }
|
12
12
|
|
13
|
+
describe 'alias methods' do
|
14
|
+
it { described.must_respond_to(:event) }
|
15
|
+
it { described.must_respond_to(:register) }
|
16
|
+
it { described.must_respond_to(:unevent) }
|
17
|
+
end
|
18
|
+
|
13
19
|
describe '.bind' do
|
14
20
|
subject { described.bind(event_name, options) { :event_triggered } }
|
15
21
|
|
@@ -4,118 +4,118 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe BoundingArea do
|
6
6
|
|
7
|
-
let(:described) { BoundingArea
|
7
|
+
let(:described) { Vedeu::BoundingArea }
|
8
|
+
let(:instance) { described.new(height, width) }
|
8
9
|
let(:height) { 15 }
|
9
10
|
let(:width) { 40 }
|
10
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
|
+
|
11
19
|
describe '#initialize' do
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
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) }
|
15
23
|
end
|
16
24
|
|
17
25
|
describe '#height' do
|
18
26
|
it 'returns the height' do
|
19
|
-
|
27
|
+
instance.height.must_equal(height)
|
20
28
|
end
|
21
29
|
end
|
22
30
|
|
23
31
|
describe '#width' do
|
24
32
|
it 'returns the width' do
|
25
|
-
|
33
|
+
instance.width.must_equal(width)
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
29
37
|
describe '#top' do
|
30
38
|
context 'when an offset is provided' do
|
31
39
|
it 'returns the new top with the offset applied' do
|
32
|
-
|
40
|
+
instance.top(5).must_equal(6)
|
33
41
|
end
|
34
42
|
|
35
43
|
context 'when the offset is greater or equal to the height' do
|
36
44
|
it 'returns the height' do
|
37
|
-
|
45
|
+
instance.top(20).must_equal(15)
|
38
46
|
end
|
39
47
|
end
|
40
48
|
|
41
49
|
context 'when the offset is less than or equal to 1' do
|
42
|
-
it {
|
50
|
+
it { instance.top(-1).must_equal(1) }
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
46
54
|
context 'when an offset is not provided' do
|
47
|
-
it {
|
55
|
+
it { instance.top.must_equal(1) }
|
48
56
|
end
|
49
|
-
|
50
|
-
it { described.must_respond_to(:y) }
|
51
57
|
end
|
52
58
|
|
53
59
|
describe '#bottom' do
|
54
60
|
context 'when an offset is provided' do
|
55
61
|
it 'returns the new bottom with the offset applied' do
|
56
|
-
|
62
|
+
instance.bottom(5).must_equal(10)
|
57
63
|
end
|
58
64
|
|
59
65
|
context 'when the offset is greater or equal to the height' do
|
60
|
-
it {
|
66
|
+
it { instance.bottom(30).must_equal(1) }
|
61
67
|
end
|
62
68
|
|
63
69
|
context 'when the offset is less than 0' do
|
64
|
-
it {
|
70
|
+
it { instance.bottom(-1).must_equal(height) }
|
65
71
|
end
|
66
72
|
end
|
67
73
|
|
68
74
|
context 'when an offset is not provided' do
|
69
|
-
it {
|
75
|
+
it { instance.bottom.must_equal(15) }
|
70
76
|
end
|
71
|
-
|
72
|
-
it { described.must_respond_to(:yn) }
|
73
77
|
end
|
74
78
|
|
75
79
|
describe '#left' do
|
76
80
|
context 'when an offset is provided' do
|
77
81
|
it 'returns the new left with the offset applied' do
|
78
|
-
|
82
|
+
instance.left(5).must_equal(6)
|
79
83
|
end
|
80
84
|
|
81
85
|
context 'when the offset is greater or equal to the width' do
|
82
86
|
it 'returns the width' do
|
83
|
-
|
87
|
+
instance.left(50).must_equal(40)
|
84
88
|
end
|
85
89
|
end
|
86
90
|
|
87
91
|
context 'when the offset is less than or equal to 1' do
|
88
|
-
it {
|
92
|
+
it { instance.left(-1).must_equal(1) }
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
92
96
|
context 'when an offset is not provided' do
|
93
|
-
it {
|
97
|
+
it { instance.left.must_equal(1) }
|
94
98
|
end
|
95
|
-
|
96
|
-
it { described.must_respond_to(:x) }
|
97
99
|
end
|
98
100
|
|
99
101
|
describe '#right' do
|
100
102
|
context 'when an offset is provided' do
|
101
103
|
it 'returns the new right with the offset applied' do
|
102
|
-
|
104
|
+
instance.right(5).must_equal(35)
|
103
105
|
end
|
104
106
|
|
105
107
|
context 'when the offset is greater or equal to the width' do
|
106
|
-
it {
|
108
|
+
it { instance.right(50).must_equal(1) }
|
107
109
|
end
|
108
110
|
|
109
111
|
context 'when the offset is less than 0' do
|
110
|
-
it {
|
112
|
+
it { instance.right(-1).must_equal(40) }
|
111
113
|
end
|
112
114
|
end
|
113
115
|
|
114
116
|
context 'when an offset is not provided' do
|
115
|
-
it {
|
117
|
+
it { instance.right.must_equal(40) }
|
116
118
|
end
|
117
|
-
|
118
|
-
it { described.must_respond_to(:xn) }
|
119
119
|
end
|
120
120
|
|
121
121
|
end # BoundingArea
|
@@ -9,6 +9,11 @@ module Vedeu
|
|
9
9
|
let(:y) { 12 }
|
10
10
|
let(:x) { 19 }
|
11
11
|
|
12
|
+
describe 'alias methods' do
|
13
|
+
it { instance.must_respond_to(:first) }
|
14
|
+
it { instance.must_respond_to(:last) }
|
15
|
+
end
|
16
|
+
|
12
17
|
describe '#initialize' do
|
13
18
|
it { instance.must_be_instance_of(described) }
|
14
19
|
it { instance.instance_variable_get('@y').must_equal(y) }
|
@@ -37,21 +37,8 @@ module Vedeu
|
|
37
37
|
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
38
38
|
it { instance.instance_variable_get('@style').must_equal(style) }
|
39
39
|
it { instance.instance_variable_get('@value').must_equal(value) }
|
40
|
-
it { instance.instance_variable_get('@position').must_equal(position) }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#value' do
|
44
|
-
subject { instance.value }
|
45
|
-
|
46
|
-
context 'when the value is not set' do
|
47
|
-
let(:value) {}
|
48
40
|
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'when the value is set' do
|
53
|
-
it { subject.must_equal('a') }
|
54
|
-
end
|
41
|
+
it { instance.must_respond_to(:value) }
|
55
42
|
end
|
56
43
|
|
57
44
|
describe '#to_html' do
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe IndexPosition do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::IndexPosition }
|
8
|
+
let(:instance) { described.new(y, x) }
|
9
|
+
let(:y) { 6 }
|
10
|
+
let(:x) { 17 }
|
11
|
+
|
12
|
+
describe '#initialize' do
|
13
|
+
it { instance.must_be_instance_of(described) }
|
14
|
+
it { instance.instance_variable_get('@y').must_equal(7) }
|
15
|
+
it { instance.instance_variable_get('@x').must_equal(18) }
|
16
|
+
|
17
|
+
context 'when y is less than 0' do
|
18
|
+
let(:y) { -3 }
|
19
|
+
|
20
|
+
it { instance.instance_variable_get('@y').must_equal(1) }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when x is less than 0' do
|
24
|
+
let(:x) { -9 }
|
25
|
+
|
26
|
+
it { instance.instance_variable_get('@x').must_equal(1) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.[]' do
|
31
|
+
subject { described[y, x] }
|
32
|
+
|
33
|
+
it { subject.must_be_instance_of(Array) }
|
34
|
+
it { subject.must_equal([7, 18]) }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#[]' do
|
38
|
+
subject { instance.[] }
|
39
|
+
|
40
|
+
it { subject.must_be_instance_of(Array) }
|
41
|
+
it { subject.must_equal([7, 18]) }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'attr_reader' do
|
45
|
+
context '#y' do
|
46
|
+
subject { instance.y }
|
47
|
+
|
48
|
+
it { subject.must_equal(7) }
|
49
|
+
|
50
|
+
it { instance.must_respond_to(:first) }
|
51
|
+
end
|
52
|
+
|
53
|
+
context '#x' do
|
54
|
+
subject { instance.x }
|
55
|
+
|
56
|
+
it { subject.must_equal(18) }
|
57
|
+
|
58
|
+
it { instance.must_respond_to(:last) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end # IndexPosition
|
63
|
+
|
64
|
+
end # Vedeu
|
@@ -8,6 +8,10 @@ module Vedeu
|
|
8
8
|
let(:instance) { described.new(value) }
|
9
9
|
let(:value) { 'bold' }
|
10
10
|
|
11
|
+
describe 'alias methods' do
|
12
|
+
it { instance.must_respond_to(:escape_sequences) }
|
13
|
+
end
|
14
|
+
|
11
15
|
describe '#initialize' do
|
12
16
|
it { instance.must_be_instance_of(described) }
|
13
17
|
it { instance.instance_variable_get('@value').must_equal('bold') }
|