vedeu 0.6.21 → 0.6.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/bin/vedeu_drb_server +1 -0
  4. data/docs/configuration.md +3 -0
  5. data/docs/events/refresh.md +5 -0
  6. data/docs/events/visibility.md +6 -0
  7. data/examples/hello_worlds.rb +79 -0
  8. data/lib/vedeu/all.rb +2 -2
  9. data/lib/vedeu/bindings/refresh.rb +8 -0
  10. data/lib/vedeu/bindings/visibility.rb +8 -0
  11. data/lib/vedeu/borders/border.rb +1 -1
  12. data/lib/vedeu/borders/render.rb +13 -10
  13. data/lib/vedeu/buffers/buffer.rb +5 -49
  14. data/lib/vedeu/buffers/refresh.rb +33 -15
  15. data/lib/vedeu/configuration/api.rb +32 -3
  16. data/lib/vedeu/configuration/configuration.rb +16 -2
  17. data/lib/vedeu/cursors/refresh.rb +1 -1
  18. data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -0
  19. data/lib/vedeu/editor/document.rb +1 -3
  20. data/lib/vedeu/logging/debug.rb +11 -8
  21. data/lib/vedeu/logging/timer.rb +18 -4
  22. data/lib/vedeu/models/interface.rb +18 -6
  23. data/lib/vedeu/models/views/view.rb +2 -9
  24. data/lib/vedeu/output/clear/interface.rb +93 -9
  25. data/lib/vedeu/output/direct.rb +0 -2
  26. data/lib/vedeu/output/viewport.rb +18 -16
  27. data/lib/vedeu/runtime/launcher.rb +25 -26
  28. data/lib/vedeu/version.rb +1 -1
  29. data/test/lib/vedeu/bindings/refresh_test.rb +1 -0
  30. data/test/lib/vedeu/bindings/visibility_test.rb +1 -0
  31. data/test/lib/vedeu/borders/border_test.rb +2 -2
  32. data/test/lib/vedeu/borders/render_test.rb +12 -69
  33. data/test/lib/vedeu/buffers/buffer_test.rb +0 -31
  34. data/test/lib/vedeu/buffers/refresh_test.rb +2 -10
  35. data/test/lib/vedeu/cursors/refresh_test.rb +2 -2
  36. data/test/lib/vedeu/editor/document_test.rb +3 -3
  37. data/test/lib/vedeu/logging/debug_test.rb +3 -3
  38. data/test/lib/vedeu/logging/timer_test.rb +24 -6
  39. data/test/lib/vedeu/models/interface_test.rb +4 -8
  40. data/test/lib/vedeu/models/views/view_test.rb +12 -22
  41. data/test/lib/vedeu/output/clear/interface_test.rb +7 -1
  42. data/test/lib/vedeu/output/viewport_test.rb +11 -190
  43. data/test/lib/vedeu/runtime/launcher_test.rb +2 -1
  44. data/test/lib/vedeu_test.rb +18 -19
  45. data/test/support/examples/borders_app.rb +4 -3
  46. data/test/support/examples/drb_app.rb +4 -3
  47. data/test/support/examples/editor_app.rb +3 -7
  48. data/test/support/examples/focus_app.rb +4 -4
  49. data/test/support/examples/hello_world.rb +5 -2
  50. data/test/support/examples/material_colours_app.rb +3 -42
  51. data/test/test_helper.rb +1 -0
  52. metadata +2 -1
@@ -7,12 +7,18 @@ module Vedeu
7
7
  describe Interface do
8
8
 
9
9
  let(:described) { Vedeu::Clear::Interface }
10
- let(:instance) { described.new(_name) }
10
+ let(:instance) { described.new(_name, options) }
11
+ let(:options) {
12
+ {
13
+ content_only: false,
14
+ }
15
+ }
11
16
  let(:_name) { 'Vedeu::Clear::Interface' }
12
17
 
13
18
  describe '#initialize' do
14
19
  it { instance.must_be_instance_of(described) }
15
20
  it { instance.instance_variable_get('@name').must_equal(_name) }
21
+ it { instance.instance_variable_get('@options').must_equal(options) }
16
22
  end
17
23
 
18
24
  describe '.render' do
@@ -38,211 +38,32 @@ module Vedeu
38
38
  end
39
39
 
40
40
  describe '.render' do
41
+ before do
42
+ Vedeu::Output::Output.stubs(:render)
43
+ end
44
+
41
45
  subject { described.render(view) }
42
46
 
43
47
  context 'when the interface is visible' do
44
- # @todo Add more tests.
45
- # it { skip }
48
+ it {
49
+ Vedeu::Output::Output.expects(:render)
50
+ subject
51
+ }
46
52
  end
47
53
 
48
54
  context 'when the interface is not visible' do
49
55
  let(:visible) { false }
50
56
 
51
- it { subject.must_be_instance_of(Array) }
52
-
53
- it { subject.must_equal([]) }
57
+ it { subject.must_equal(nil) }
54
58
  end
55
59
  end
56
60
 
57
61
  describe '#render' do
58
- let(:cursor) {
59
- Vedeu::Cursors::Cursor.new(name: 'lithium',
60
- ox: ox,
61
- oy: oy,
62
- visible: true,
63
- x: x,
64
- y: y) }
65
- let(:lines) { [] }
66
- let(:ox) { 0 }
67
- let(:oy) { 0 }
68
- let(:x) { 1 }
69
- let(:y) { 1 }
70
-
71
- subject { instance.render }
72
-
73
- it { subject.must_be_instance_of(Array) }
74
-
75
- context 'when there is no content' do
76
- before { view.stubs(:lines).returns([]) }
77
-
78
- it { subject.must_equal([]) }
79
- end
62
+ it { instance.must_respond_to(:render) }
80
63
  end
81
64
 
82
65
  describe '#to_s' do
83
- let(:cursor) {
84
- Vedeu::Cursors::Cursor.new(name: 'lithium',
85
- ox: ox,
86
- oy: oy,
87
- visible: true,
88
- x: x,
89
- y: y) }
90
- let(:lines) { [] }
91
- let(:ox) { 0 }
92
- let(:oy) { 0 }
93
- let(:x) { 1 }
94
- let(:y) { 1 }
95
-
96
- subject { instance.to_s }
97
-
98
- it { subject.must_be_instance_of(String) }
99
-
100
- context 'when there is no content' do
101
- before { view.stubs(:lines).returns([]) }
102
-
103
- it { subject.must_equal('') }
104
- end
105
-
106
- context 'when there is content' do
107
- context 'when the cursor y position is outside the viewable area' do
108
- let(:ox) { -4 }
109
- let(:oy) { -4 }
110
-
111
- it 'scrolls the content the correct position' do
112
- subject.must_equal(
113
- "\e[1;1H\e[39m\e[49mb\n" \
114
- "\e[1;2H\e[39m\e[49ma\n" \
115
- "\e[1;3H\e[39m\e[49mr\n" \
116
- "\e[2;1H\e[39m\e[49mc\n" \
117
- "\e[2;2H\e[39m\e[49ma\n" \
118
- "\e[2;3H\e[39m\e[49mr\n" \
119
- "\e[3;1H\e[39m\e[49mh\n" \
120
- "\e[3;2H\e[39m\e[49me\n" \
121
- "\e[3;3H\e[39m\e[49ml"
122
- )
123
- end
124
- end
125
-
126
- context 'when the cursor y position is inside the viewable area' do
127
- context 'when there is not enough content to fill the height' do
128
- let(:ox) { 3 }
129
- let(:oy) { 7 }
130
-
131
- it 'renders the visible content' do
132
- subject.must_equal(
133
- "\e[1;1H\e[39m\e[49mb\n" \
134
- "\e[1;2H\e[39m\e[49ma\n" \
135
- "\e[1;3H\e[39m\e[49mr\n" \
136
- "\e[2;1H\e[39m\e[49mc\n" \
137
- "\e[2;2H\e[39m\e[49ma\n" \
138
- "\e[2;3H\e[39m\e[49mr\n" \
139
- "\e[3;1H\e[39m\e[49mh\n" \
140
- "\e[3;2H\e[39m\e[49me\n" \
141
- "\e[3;3H\e[39m\e[49ml"
142
- )
143
- end
144
- end
145
-
146
- context 'when there is more content than the height' do
147
- let(:ox) { 3 }
148
- let(:oy) { 3 }
149
-
150
- it 'is cropped to show only that which fits' do
151
- subject.must_equal(
152
- "\e[1;1H\e[39m\e[49mb\n" \
153
- "\e[1;2H\e[39m\e[49ma\n" \
154
- "\e[1;3H\e[39m\e[49mr\n" \
155
- "\e[2;1H\e[39m\e[49mc\n" \
156
- "\e[2;2H\e[39m\e[49ma\n" \
157
- "\e[2;3H\e[39m\e[49mr\n" \
158
- "\e[3;1H\e[39m\e[49mh\n" \
159
- "\e[3;2H\e[39m\e[49me\n" \
160
- "\e[3;3H\e[39m\e[49ml"
161
- )
162
- end
163
- end
164
- end
165
-
166
- context 'when the cursor x position is outside the viewable area' do
167
- context 'but inside the content' do
168
- let(:ox) { 6 }
169
- let(:oy) { 6 }
170
-
171
- it 'scrolls the content the correct position' do
172
- subject.must_equal(
173
- "\e[1;1H\e[39m\e[49mb\n" \
174
- "\e[1;2H\e[39m\e[49ma\n" \
175
- "\e[1;3H\e[39m\e[49mr\n" \
176
- "\e[2;1H\e[39m\e[49mc\n" \
177
- "\e[2;2H\e[39m\e[49ma\n" \
178
- "\e[2;3H\e[39m\e[49mr\n" \
179
- "\e[3;1H\e[39m\e[49mh\n" \
180
- "\e[3;2H\e[39m\e[49me\n" \
181
- "\e[3;3H\e[39m\e[49ml"
182
- )
183
- end
184
- end
185
-
186
- context 'and outside the content' do
187
- let(:ox) { 7 }
188
- let(:oy) { 7 }
189
-
190
- it 'scrolls the content the correct position' do
191
- subject.must_equal(
192
- "\e[1;1H\e[39m\e[49mb\n" \
193
- "\e[1;2H\e[39m\e[49ma\n" \
194
- "\e[1;3H\e[39m\e[49mr\n" \
195
- "\e[2;1H\e[39m\e[49mc\n" \
196
- "\e[2;2H\e[39m\e[49ma\n" \
197
- "\e[2;3H\e[39m\e[49mr\n" \
198
- "\e[3;1H\e[39m\e[49mh\n" \
199
- "\e[3;2H\e[39m\e[49me\n" \
200
- "\e[3;3H\e[39m\e[49ml"
201
- )
202
- end
203
- end
204
- end
205
-
206
- context 'when the cursor x position is inside the viewable area' do
207
- context 'when there is not enough content to fill the width' do
208
- let(:ox) { 7 }
209
- let(:oy) { 3 }
210
-
211
- it 'renders the visible content' do
212
- subject.must_equal(
213
- "\e[1;1H\e[39m\e[49mb\n" \
214
- "\e[1;2H\e[39m\e[49ma\n" \
215
- "\e[1;3H\e[39m\e[49mr\n" \
216
- "\e[2;1H\e[39m\e[49mc\n" \
217
- "\e[2;2H\e[39m\e[49ma\n" \
218
- "\e[2;3H\e[39m\e[49mr\n" \
219
- "\e[3;1H\e[39m\e[49mh\n" \
220
- "\e[3;2H\e[39m\e[49me\n" \
221
- "\e[3;3H\e[39m\e[49ml"
222
- )
223
- end
224
- end
225
-
226
- context 'when there is more content than the width' do
227
- let(:ox) { 3 }
228
- let(:oy) { 3 }
229
-
230
- it 'is cropped to show only that which fits' do
231
- subject.must_equal(
232
- "\e[1;1H\e[39m\e[49mb\n" \
233
- "\e[1;2H\e[39m\e[49ma\n" \
234
- "\e[1;3H\e[39m\e[49mr\n" \
235
- "\e[2;1H\e[39m\e[49mc\n" \
236
- "\e[2;2H\e[39m\e[49ma\n" \
237
- "\e[2;3H\e[39m\e[49mr\n" \
238
- "\e[3;1H\e[39m\e[49mh\n" \
239
- "\e[3;2H\e[39m\e[49me\n" \
240
- "\e[3;3H\e[39m\e[49ml"
241
- )
242
- end
243
- end
244
- end
245
- end
66
+ it { instance.must_respond_to(:to_s) }
246
67
  end
247
68
 
248
69
  end # Viewport
@@ -46,7 +46,8 @@ module Vedeu
46
46
  subject { instance.execute! }
47
47
 
48
48
  it 'returns 0 for successful execution' do
49
- subject.must_equal(0)
49
+ subject
50
+ instance.exit_code.must_equal(0)
50
51
  end
51
52
 
52
53
  context 'when an uncaught exception occurs' do
@@ -3,35 +3,21 @@ require 'test_helper'
3
3
  describe Vedeu do
4
4
 
5
5
  it { Vedeu.must_respond_to(:background_colours) }
6
- it { Vedeu.must_respond_to(:borders) }
7
- it { Vedeu.must_respond_to(:buffers) }
8
- it { Vedeu.must_respond_to(:cursors) }
9
- it { Vedeu.must_respond_to(:debug) }
10
- it { Vedeu.must_respond_to(:documents) }
11
- it { Vedeu.must_respond_to(:events) }
12
- it { Vedeu.must_respond_to(:foreground_colours) }
13
- it { Vedeu.must_respond_to(:geometries) }
14
- it { Vedeu.must_respond_to(:groups) }
15
- it { Vedeu.must_respond_to(:interfaces) }
16
- it { Vedeu.must_respond_to(:keymaps) }
17
- it { Vedeu.must_respond_to(:menus) }
18
- it { Vedeu.must_respond_to(:ready!) }
19
- it { Vedeu.must_respond_to(:ready?) }
20
- it { Vedeu.must_respond_to(:renderer) }
21
- it { Vedeu.must_respond_to(:renderers) }
22
- it { Vedeu.must_respond_to(:resize) }
23
- it { Vedeu.must_respond_to(:timer) }
24
-
25
6
  it { Vedeu.must_respond_to(:bind) }
26
7
  it { Vedeu.must_respond_to(:bind_alias) }
27
8
  it { Vedeu.must_respond_to(:border) }
9
+ it { Vedeu.must_respond_to(:borders) }
28
10
  it { Vedeu.must_respond_to(:bound?) }
11
+ it { Vedeu.must_respond_to(:buffers) }
29
12
  it { Vedeu.must_respond_to(:clear) }
30
13
  it { Vedeu.must_respond_to(:clear_by_group) }
31
14
  it { Vedeu.must_respond_to(:clear_by_name) }
15
+ it { Vedeu.must_respond_to(:clear_content_by_name) }
32
16
  it { Vedeu.must_respond_to(:configuration) }
33
17
  it { Vedeu.must_respond_to(:configure) }
34
18
  it { Vedeu.must_respond_to(:cursor) }
19
+ it { Vedeu.must_respond_to(:cursors) }
20
+ it { Vedeu.must_respond_to(:documents) }
35
21
  it { Vedeu.must_respond_to(:drb_restart) }
36
22
  it { Vedeu.must_respond_to(:drb_start) }
37
23
  it { Vedeu.must_respond_to(:drb_status) }
@@ -43,9 +29,12 @@ describe Vedeu do
43
29
  it { Vedeu.must_respond_to(:focus_next) }
44
30
  it { Vedeu.must_respond_to(:focus_previous) }
45
31
  it { Vedeu.must_respond_to(:focussed?) }
32
+ it { Vedeu.must_respond_to(:foreground_colours) }
33
+ it { Vedeu.must_respond_to(:geometries) }
46
34
  it { Vedeu.must_respond_to(:geometry) }
47
35
  it { Vedeu.must_respond_to(:goto) }
48
36
  it { Vedeu.must_respond_to(:group) }
37
+ it { Vedeu.must_respond_to(:groups) }
49
38
 
50
39
  describe 'Vedeu.height' do
51
40
  before { Vedeu::Terminal.stubs(:size).returns([25, 40]) }
@@ -58,17 +47,27 @@ describe Vedeu do
58
47
  it { Vedeu.must_respond_to(:hide_group) }
59
48
  it { Vedeu.must_respond_to(:hide_interface) }
60
49
  it { Vedeu.must_respond_to(:interface) }
50
+ it { Vedeu.must_respond_to(:interfaces) }
61
51
  it { Vedeu.must_respond_to(:keymap) }
52
+ it { Vedeu.must_respond_to(:keymaps) }
62
53
  it { Vedeu.must_respond_to(:keypress) }
63
54
  it { Vedeu.must_respond_to(:log) }
64
55
  it { Vedeu.must_respond_to(:log_stderr) }
65
56
  it { Vedeu.must_respond_to(:log_stdout) }
66
57
  it { Vedeu.must_respond_to(:menu) }
58
+ it { Vedeu.must_respond_to(:menus) }
59
+ it { Vedeu.must_respond_to(:profile) }
60
+ it { Vedeu.must_respond_to(:ready!) }
61
+ it { Vedeu.must_respond_to(:ready?) }
67
62
  it { Vedeu.must_respond_to(:render) }
68
63
  it { Vedeu.must_respond_to(:renders) }
64
+ it { Vedeu.must_respond_to(:renderer) }
65
+ it { Vedeu.must_respond_to(:renderers) }
66
+ it { Vedeu.must_respond_to(:resize) }
69
67
  it { Vedeu.must_respond_to(:show_cursor) }
70
68
  it { Vedeu.must_respond_to(:show_group) }
71
69
  it { Vedeu.must_respond_to(:show_interface) }
70
+ it { Vedeu.must_respond_to(:timer) }
72
71
  it { Vedeu.must_respond_to(:toggle_cursor) }
73
72
  it { Vedeu.must_respond_to(:toggle_group) }
74
73
  it { Vedeu.must_respond_to(:toggle_interface) }
@@ -7,17 +7,18 @@ require 'vedeu'
7
7
  #
8
8
  # If you have cloned this repository from GitHub, you can run this example:
9
9
  #
10
- # ./examples/borders_app.rb
10
+ # ./test/support/examples/borders_app.rb
11
11
  #
12
12
  class VedeuBordersApp
13
13
 
14
14
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
15
15
 
16
- # Be aware that running an application with debugging enabled will affect
16
+ # Be aware that running an application with profiling enabled will affect
17
17
  # performance.
18
18
  Vedeu.configure do
19
- # debug!
19
+ debug!
20
20
  log '/tmp/vedeu_borders_app.log'
21
+ # profile!
21
22
  raw!
22
23
  run_once!
23
24
  standalone!
@@ -6,17 +6,18 @@ require 'vedeu'
6
6
  # An example application to demonstrate the DRb server.
7
7
  # If you have cloned this repository from GitHub, you can run this example:
8
8
  #
9
- # ./examples/drb_app.rb
9
+ # ./test/support/examples/drb_app.rb
10
10
  #
11
11
  class VedeuTestApplication
12
12
 
13
13
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
14
14
 
15
- # Be aware that running an application with debugging enabled will affect
15
+ # Be aware that running an application with profiling enabled will affect
16
16
  # performance.
17
17
  Vedeu.configure do
18
18
  log '/tmp/vedeu_test_helper.log'
19
- # debug!
19
+ debug!
20
+ # profile!
20
21
  drb!
21
22
  drb_host 'localhost'
22
23
  drb_port 21_420
@@ -8,23 +8,19 @@ require 'vedeu'
8
8
  #
9
9
  # If you have cloned this repository from GitHub, you can run this example:
10
10
  #
11
- # ./examples/material_colours_app.rb
12
- #
13
- # Running this application once, and immediately exiting produces the diagram
14
- # at `./examples/material_colours_app_20150721.svg`. Hopefully this will help
15
- # you to understand how parts of Vedeu work together. Questions are always
16
- # welcome at `https://github.com/gavinlaking/vedeu/issues`
11
+ # ./test/support/examples/material_colours_app.rb
17
12
  #
18
13
  class VedeuEditorApp
19
14
 
20
15
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
21
16
 
22
- # Be aware that running an application with debugging enabled will affect
17
+ # Be aware that running an application with profiling enabled will affect
23
18
  # performance.
24
19
  Vedeu.configure do
25
20
  debug!
26
21
  fake!
27
22
  log '/tmp/vedeu_editor_app.log'
23
+ # profile!
28
24
  # renderers Vedeu::Renderers::File.new
29
25
  end
30
26
 
@@ -7,8 +7,7 @@ require 'vedeu'
7
7
  #
8
8
  # If you have cloned this repository from GitHub, you can run this example:
9
9
  #
10
- # ./examples/focus_app.rb
11
- #
10
+ # ./test/support/examples/focus_app.rb
12
11
  #
13
12
  # First, we set up the interfaces, noting that 'copper' should have focus when
14
13
  # the application starts. Also note that 'status' should not show a cursor.
@@ -20,11 +19,12 @@ class VedeuFocusApp
20
19
 
21
20
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
22
21
 
23
- # Be aware that running an application with debugging enabled will affect
22
+ # Be aware that running an application with profiling enabled will affect
24
23
  # performance.
25
24
  Vedeu.configure do
26
- # debug!
25
+ debug!
27
26
  log '/tmp/vedeu_focus_app.log'
27
+ # profile!
28
28
  end
29
29
 
30
30
  update = proc do
@@ -7,15 +7,18 @@ require 'vedeu'
7
7
  #
8
8
  # If you have cloned this repository from GitHub, you can run this example:
9
9
  #
10
- # ./examples/hello_world.rb
10
+ # ./test/support/examples/hello_world.rb
11
11
  #
12
12
  class HelloWorldApp
13
13
 
14
14
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
15
15
 
16
+ # Be aware that running an application with profiling enabled will affect
17
+ # performance.
16
18
  Vedeu.configure do
17
- # debug!
19
+ debug!
18
20
  log '/tmp/vedeu_hello_world.log'
21
+ # profile!
19
22
  end
20
23
 
21
24
  Vedeu.interface 'messages' do