vedeu 0.6.21 → 0.6.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/bin/vedeu_drb_server +1 -0
- data/docs/configuration.md +3 -0
- data/docs/events/refresh.md +5 -0
- data/docs/events/visibility.md +6 -0
- data/examples/hello_worlds.rb +79 -0
- data/lib/vedeu/all.rb +2 -2
- data/lib/vedeu/bindings/refresh.rb +8 -0
- data/lib/vedeu/bindings/visibility.rb +8 -0
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/render.rb +13 -10
- data/lib/vedeu/buffers/buffer.rb +5 -49
- data/lib/vedeu/buffers/refresh.rb +33 -15
- data/lib/vedeu/configuration/api.rb +32 -3
- data/lib/vedeu/configuration/configuration.rb +16 -2
- data/lib/vedeu/cursors/refresh.rb +1 -1
- data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -0
- data/lib/vedeu/editor/document.rb +1 -3
- data/lib/vedeu/logging/debug.rb +11 -8
- data/lib/vedeu/logging/timer.rb +18 -4
- data/lib/vedeu/models/interface.rb +18 -6
- data/lib/vedeu/models/views/view.rb +2 -9
- data/lib/vedeu/output/clear/interface.rb +93 -9
- data/lib/vedeu/output/direct.rb +0 -2
- data/lib/vedeu/output/viewport.rb +18 -16
- data/lib/vedeu/runtime/launcher.rb +25 -26
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/bindings/refresh_test.rb +1 -0
- data/test/lib/vedeu/bindings/visibility_test.rb +1 -0
- data/test/lib/vedeu/borders/border_test.rb +2 -2
- data/test/lib/vedeu/borders/render_test.rb +12 -69
- data/test/lib/vedeu/buffers/buffer_test.rb +0 -31
- data/test/lib/vedeu/buffers/refresh_test.rb +2 -10
- data/test/lib/vedeu/cursors/refresh_test.rb +2 -2
- data/test/lib/vedeu/editor/document_test.rb +3 -3
- data/test/lib/vedeu/logging/debug_test.rb +3 -3
- data/test/lib/vedeu/logging/timer_test.rb +24 -6
- data/test/lib/vedeu/models/interface_test.rb +4 -8
- data/test/lib/vedeu/models/views/view_test.rb +12 -22
- data/test/lib/vedeu/output/clear/interface_test.rb +7 -1
- data/test/lib/vedeu/output/viewport_test.rb +11 -190
- data/test/lib/vedeu/runtime/launcher_test.rb +2 -1
- data/test/lib/vedeu_test.rb +18 -19
- data/test/support/examples/borders_app.rb +4 -3
- data/test/support/examples/drb_app.rb +4 -3
- data/test/support/examples/editor_app.rb +3 -7
- data/test/support/examples/focus_app.rb +4 -4
- data/test/support/examples/hello_world.rb +5 -2
- data/test/support/examples/material_colours_app.rb +3 -42
- data/test/test_helper.rb +1 -0
- metadata +2 -1
@@ -20,7 +20,7 @@ module Vedeu
|
|
20
20
|
stdout = STDOUT,
|
21
21
|
stderr = STDERR,
|
22
22
|
kernel = Kernel)
|
23
|
-
new(argv, stdin, stdout, stderr, kernel).
|
23
|
+
new(argv, stdin, stdout, stderr, kernel).execute!
|
24
24
|
end
|
25
25
|
# :nocov:
|
26
26
|
|
@@ -45,47 +45,35 @@ module Vedeu
|
|
45
45
|
@exit_code = 1
|
46
46
|
end
|
47
47
|
|
48
|
-
# :nocov:
|
49
|
-
# If debugging is enabled, execute the application within the
|
50
|
-
# debugging context. At the moment, this simple uses 'ruby-prof'
|
51
|
-
# to profile the running application.
|
52
|
-
#
|
53
|
-
# @return [void]
|
54
|
-
def debug_execute!
|
55
|
-
if configuration.debug?
|
56
|
-
Vedeu.debug { execute! }
|
57
|
-
|
58
|
-
else
|
59
|
-
execute!
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
terminate!
|
64
|
-
end
|
65
|
-
# :nocov:
|
66
|
-
|
67
48
|
# Alters the STD[IN|OUT|ERR] to those requested by the client
|
68
49
|
# application, then starts the application. If an uncaught
|
69
50
|
# exception occurs during the application runtime, we exit
|
70
51
|
# ungracefully with any error message(s).
|
71
52
|
#
|
53
|
+
# If profiling is enabled, execute the application within the
|
54
|
+
# profiling context. At the moment, this simple uses 'ruby-prof'
|
55
|
+
# to profile the running application.
|
56
|
+
#
|
72
57
|
# @return [void]
|
73
58
|
def execute!
|
74
59
|
$stdin = @stdin
|
75
60
|
$stdout = @stdout
|
76
61
|
$stderr = @stderr
|
77
62
|
|
78
|
-
Vedeu::Runtime::Application.start(configuration)
|
63
|
+
optionally_profile { Vedeu::Runtime::Application.start(configuration) }
|
79
64
|
|
80
65
|
@exit_code = 0
|
81
66
|
|
67
|
+
terminate!
|
68
|
+
|
82
69
|
rescue StandardError => uncaught_exception
|
83
|
-
|
70
|
+
output = if configuration.debug?
|
71
|
+
uncaught_exception.backtrace.join("\n")
|
72
|
+
else
|
73
|
+
uncaught_exception.message
|
74
|
+
end
|
84
75
|
|
85
|
-
|
86
|
-
Vedeu.log_stdout(type: :error,
|
87
|
-
message: uncaught_exception.backtrace.join("\n"))
|
88
|
-
end
|
76
|
+
Vedeu.log_stdout(type: :error, message: output)
|
89
77
|
end
|
90
78
|
|
91
79
|
protected
|
@@ -96,6 +84,17 @@ module Vedeu
|
|
96
84
|
|
97
85
|
private
|
98
86
|
|
87
|
+
# @return [void]
|
88
|
+
def optionally_profile
|
89
|
+
if configuration.profile?
|
90
|
+
Vedeu.profile { yield }
|
91
|
+
|
92
|
+
else
|
93
|
+
yield
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
99
98
|
# :nocov:
|
100
99
|
# Terminates the application after resetting $stdin, $stdout and
|
101
100
|
# $stderr.
|
data/lib/vedeu/version.rb
CHANGED
@@ -11,6 +11,7 @@ module Vedeu
|
|
11
11
|
it { Vedeu.bound?(:_refresh_cursor_).must_equal(true) }
|
12
12
|
it { Vedeu.bound?(:_refresh_group_).must_equal(true) }
|
13
13
|
it { Vedeu.bound?(:_refresh_view_).must_equal(true) }
|
14
|
+
it { Vedeu.bound?(:_refresh_view_content_).must_equal(true) }
|
14
15
|
end
|
15
16
|
|
16
17
|
end # Refresh
|
@@ -10,6 +10,7 @@ module Vedeu
|
|
10
10
|
it { Vedeu.bound?(:_clear_).must_equal(true) }
|
11
11
|
it { Vedeu.bound?(:_clear_group_).must_equal(true) }
|
12
12
|
it { Vedeu.bound?(:_clear_view_).must_equal(true) }
|
13
|
+
it { Vedeu.bound?(:_clear_view_content_).must_equal(true) }
|
13
14
|
|
14
15
|
it { Vedeu.bound?(:_cursor_hide_).must_equal(true) }
|
15
16
|
it { Vedeu.bound?(:_cursor_show_).must_equal(true) }
|
@@ -408,12 +408,12 @@ module Vedeu
|
|
408
408
|
end
|
409
409
|
|
410
410
|
describe '#render' do
|
411
|
-
before { Vedeu::Borders::Render.stubs(:
|
411
|
+
before { Vedeu::Borders::Render.stubs(:render) }
|
412
412
|
|
413
413
|
subject { instance.render }
|
414
414
|
|
415
415
|
it {
|
416
|
-
Vedeu::Borders::Render.expects(:
|
416
|
+
Vedeu::Borders::Render.expects(:render).with(instance)
|
417
417
|
subject
|
418
418
|
}
|
419
419
|
end
|
@@ -28,8 +28,6 @@ module Vedeu
|
|
28
28
|
let(:show_left) { true }
|
29
29
|
let(:show_right) { true }
|
30
30
|
|
31
|
-
it { described.must_respond_to(:with) }
|
32
|
-
|
33
31
|
describe '#initialize' do
|
34
32
|
it { instance.must_be_instance_of(described) }
|
35
33
|
it { instance.instance_variable_get('@border').must_equal(border) }
|
@@ -39,86 +37,31 @@ module Vedeu
|
|
39
37
|
it { instance.must_respond_to(:render) }
|
40
38
|
end
|
41
39
|
|
42
|
-
describe '.
|
40
|
+
describe '.render' do
|
43
41
|
let(:geometry) {
|
44
42
|
Vedeu::Geometry::Geometry.new(name: _name, x: 1, xn: 7, y: 1, yn: 4)
|
45
43
|
}
|
46
44
|
let(:interface) {
|
47
|
-
Vedeu::Models::Interface.new(name: _name, visible:
|
45
|
+
Vedeu::Models::Interface.new(name: _name, visible: true)
|
48
46
|
}
|
49
47
|
before do
|
50
48
|
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
51
49
|
Vedeu.interfaces.stubs(:by_name).returns(interface)
|
52
50
|
end
|
53
51
|
|
54
|
-
subject { described.
|
55
|
-
|
56
|
-
context 'when the interface is not visible' do
|
57
|
-
it { subject.must_equal([]) }
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when the interface is visible' do
|
61
|
-
let(:visible) { true }
|
62
|
-
|
63
|
-
context 'when the border is not enabled' do
|
64
|
-
it { subject.must_equal([]) }
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when the border is enabled' do
|
68
|
-
let(:enabled) { true }
|
69
|
-
|
70
|
-
context 'and a title is given' do
|
71
|
-
let(:title) { 'T' }
|
72
|
-
|
73
|
-
# @todo Add more tests.
|
74
|
-
it { subject.size.must_equal(18) }
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'and a title is not given' do
|
78
|
-
# @todo Add more tests.
|
79
|
-
it { subject.size.must_equal(18) }
|
80
|
-
end
|
52
|
+
subject { described.render(border) }
|
81
53
|
|
82
|
-
|
83
|
-
|
54
|
+
context 'when the border is enabled' do
|
55
|
+
let(:enabled) { true }
|
84
56
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
# @todo Add more tests.
|
91
|
-
it { subject.size.must_equal(18) }
|
92
|
-
end
|
93
|
-
|
94
|
-
context 'and the left side is disabled' do
|
95
|
-
let(:show_left) { false }
|
96
|
-
|
97
|
-
# @todo Add more tests.
|
98
|
-
it { subject.size.must_equal(16) }
|
99
|
-
end
|
100
|
-
|
101
|
-
context 'and the right side is disabled' do
|
102
|
-
let(:show_right) { false }
|
103
|
-
|
104
|
-
# @todo Add more tests.
|
105
|
-
it { subject.size.must_equal(16) }
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'and the top side is disabled' do
|
109
|
-
let(:show_top) { false }
|
110
|
-
|
111
|
-
# @todo Add more tests.
|
112
|
-
it { subject.size.must_equal(13) }
|
113
|
-
end
|
114
|
-
|
115
|
-
context 'and the bottom side is disabled' do
|
116
|
-
let(:show_bottom) { false }
|
57
|
+
it {
|
58
|
+
Vedeu::Output::Output.expects(:render)
|
59
|
+
subject
|
60
|
+
}
|
61
|
+
end
|
117
62
|
|
118
|
-
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
63
|
+
context 'when the border is not enabled' do
|
64
|
+
it { subject.must_equal(nil) }
|
122
65
|
end
|
123
66
|
end
|
124
67
|
|
@@ -103,32 +103,6 @@ module Vedeu
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
describe '#hide' do
|
107
|
-
before { Vedeu.stubs(:trigger) }
|
108
|
-
|
109
|
-
subject { instance.hide }
|
110
|
-
|
111
|
-
it {
|
112
|
-
Vedeu.expects(:trigger).with(:_clear_view_, _name)
|
113
|
-
subject
|
114
|
-
}
|
115
|
-
end
|
116
|
-
|
117
|
-
describe '#show' do
|
118
|
-
before do
|
119
|
-
Vedeu.stubs(:log)
|
120
|
-
# Vedeu::Clear::Interface.stubs(:render)
|
121
|
-
Vedeu::Output::Output.stubs(:render)
|
122
|
-
end
|
123
|
-
|
124
|
-
subject { instance.show }
|
125
|
-
|
126
|
-
it {
|
127
|
-
Vedeu::Output::Output.expects(:render)
|
128
|
-
subject
|
129
|
-
}
|
130
|
-
end
|
131
|
-
|
132
106
|
describe '#render' do
|
133
107
|
before {
|
134
108
|
Vedeu.stubs(:log)
|
@@ -136,11 +110,6 @@ module Vedeu
|
|
136
110
|
}
|
137
111
|
|
138
112
|
subject { instance.render }
|
139
|
-
|
140
|
-
it {
|
141
|
-
Vedeu::Output::Output.expects(:render)
|
142
|
-
subject
|
143
|
-
}
|
144
113
|
end
|
145
114
|
|
146
115
|
end # Buffer
|
@@ -30,16 +30,8 @@ module Vedeu
|
|
30
30
|
end
|
31
31
|
|
32
32
|
context 'when Vedeu is ready' do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when the name is present' do
|
40
|
-
# @todo Add more tests.
|
41
|
-
# it { skip }
|
42
|
-
end
|
33
|
+
# @todo Add more tests.
|
34
|
+
# it { skip }
|
43
35
|
end
|
44
36
|
end
|
45
37
|
|
@@ -48,14 +48,14 @@ module Vedeu
|
|
48
48
|
let(:oy) { 3 }
|
49
49
|
|
50
50
|
it 'refreshes the view' do
|
51
|
-
Vedeu.expects(:trigger).with(:
|
51
|
+
Vedeu.expects(:trigger).with(:_refresh_view_content_, _name)
|
52
52
|
subject
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'when the cursors offset position is inside the viewable area' do
|
57
57
|
it 'does not refresh the view' do
|
58
|
-
Vedeu.expects(:trigger).with(:
|
58
|
+
Vedeu.expects(:trigger).with(:_refresh_view_content_, _name).never
|
59
59
|
subject
|
60
60
|
end
|
61
61
|
end
|
@@ -59,12 +59,12 @@ module Vedeu
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#clear' do
|
62
|
-
before { Vedeu.stubs(:trigger).with(:
|
62
|
+
before { Vedeu.stubs(:trigger).with(:_clear_view_content_, _name) }
|
63
63
|
|
64
64
|
subject { instance.clear }
|
65
65
|
|
66
66
|
it {
|
67
|
-
Vedeu.expects(:trigger).with(:
|
67
|
+
Vedeu.expects(:trigger).with(:_clear_view_content_, _name)
|
68
68
|
subject
|
69
69
|
}
|
70
70
|
end
|
@@ -183,7 +183,7 @@ module Vedeu
|
|
183
183
|
let(:output) { "\e[1;1HA\e[2;1HB\e[3;1HC\e[1;1H\e[?25h" }
|
184
184
|
|
185
185
|
before {
|
186
|
-
Vedeu.stubs(:trigger).with(:
|
186
|
+
Vedeu.stubs(:trigger).with(:_clear_view_content_, _name)
|
187
187
|
Vedeu::Output::Output.stubs(:render)
|
188
188
|
}
|
189
189
|
|
@@ -12,18 +12,18 @@ module Vedeu
|
|
12
12
|
File.stubs(:open).with('/tmp/profile.html', 'w').returns(:some_code)
|
13
13
|
end
|
14
14
|
|
15
|
-
describe '.
|
15
|
+
describe '.profile' do
|
16
16
|
let(:filename) { 'profile.html' }
|
17
17
|
let(:some_code) { :some_code }
|
18
18
|
|
19
19
|
context 'when the block is not given' do
|
20
|
-
subject { described.
|
20
|
+
subject { described.profile(filename) }
|
21
21
|
|
22
22
|
it { subject.must_equal(nil) }
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'when the block is given' do
|
26
|
-
subject { described.
|
26
|
+
subject { described.profile(filename) { some_code } }
|
27
27
|
|
28
28
|
it {
|
29
29
|
::File.expects(:open).with('/tmp/profile.html', 'w')
|
@@ -28,13 +28,31 @@ module Vedeu
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#measure' do
|
31
|
-
|
31
|
+
context 'when the block is given' do
|
32
|
+
subject { instance.measure { :thing_to_be_measured } }
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
context 'when debugging is enabled' do
|
35
|
+
before { Vedeu::Configuration.stubs(:debug?).returns(true) }
|
36
|
+
|
37
|
+
it {
|
38
|
+
Vedeu.expects(:log).with(type: :timer,
|
39
|
+
message: "Testing took 0.0ms.")
|
40
|
+
subject
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when debugging is disabled' do
|
45
|
+
before { Vedeu::Configuration.stubs(:debug?).returns(false) }
|
46
|
+
|
47
|
+
it { subject.must_equal(:thing_to_be_measured) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when the block is not given' do
|
52
|
+
subject { instance.measure }
|
53
|
+
|
54
|
+
it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
|
55
|
+
end
|
38
56
|
end
|
39
57
|
|
40
58
|
end # Timer
|
@@ -70,27 +70,23 @@ module Vedeu
|
|
70
70
|
end
|
71
71
|
|
72
72
|
describe '#hide' do
|
73
|
-
|
74
|
-
|
75
|
-
before { Vedeu.buffers.stubs(:by_name).returns(buffer) }
|
73
|
+
before { Vedeu.stubs(:trigger) }
|
76
74
|
|
77
75
|
subject { instance.hide }
|
78
76
|
|
79
77
|
it {
|
80
|
-
Vedeu.
|
78
|
+
Vedeu.expects(:trigger).with(:_clear_view_, _name)
|
81
79
|
subject
|
82
80
|
}
|
83
81
|
end
|
84
82
|
|
85
83
|
describe '#show' do
|
86
|
-
|
87
|
-
|
88
|
-
before { Vedeu.buffers.stubs(:by_name).returns(buffer) }
|
84
|
+
before { Vedeu.stubs(:trigger) }
|
89
85
|
|
90
86
|
subject { instance.show }
|
91
87
|
|
92
88
|
it {
|
93
|
-
Vedeu.
|
89
|
+
Vedeu.expects(:trigger).with(:_refresh_view_, _name)
|
94
90
|
subject
|
95
91
|
}
|
96
92
|
end
|
@@ -60,32 +60,22 @@ module Vedeu
|
|
60
60
|
end
|
61
61
|
|
62
62
|
describe '#render' do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
it { subject.must_equal([]) }
|
63
|
+
before do
|
64
|
+
Vedeu.stubs(:trigger).with(:_clear_view_content_, _name)
|
65
|
+
Vedeu::Output::Viewport.stubs(:render).with(instance)
|
67
66
|
end
|
68
67
|
|
69
|
-
|
70
|
-
let(:interface) { Vedeu::Models::Interface.new(visible: true) }
|
71
|
-
let(:border) { Vedeu::Borders::Border.new(name: _name, enabled: false) }
|
68
|
+
subject { instance.render }
|
72
69
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
Vedeu.borders.stubs(:by_name).with(_name).returns(border)
|
78
|
-
border.stubs(:render)
|
79
|
-
end
|
70
|
+
it {
|
71
|
+
Vedeu.expects(:trigger).with(:_clear_view_content_, _name)
|
72
|
+
subject
|
73
|
+
}
|
80
74
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
border.expects(:render)
|
86
|
-
subject
|
87
|
-
}
|
88
|
-
end
|
75
|
+
it {
|
76
|
+
Vedeu::Output::Viewport.expects(:render).with(instance)
|
77
|
+
subject
|
78
|
+
}
|
89
79
|
end
|
90
80
|
|
91
81
|
describe '#store_immediate' do
|