vedeu 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/LICENSE.txt +5 -0
- data/bin/vedeu +3 -1
- data/docs/api.md +2 -0
- data/examples/cursor_app/cursor_app.rb +22 -7
- data/examples/hello_world.rb +42 -0
- data/lib/vedeu.rb +5 -5
- data/lib/vedeu/api/api.rb +16 -33
- data/lib/vedeu/api/helpers.rb +86 -0
- data/lib/vedeu/api/interface.rb +60 -17
- data/lib/vedeu/api/keymap.rb +5 -0
- data/lib/vedeu/api/line.rb +52 -34
- data/lib/vedeu/api/menu.rb +1 -1
- data/lib/vedeu/api/stream.rb +0 -34
- data/lib/vedeu/configuration/api.rb +10 -10
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/launcher.rb +21 -6
- data/lib/vedeu/models/background.rb +1 -1
- data/lib/vedeu/models/composition.rb +1 -1
- data/lib/vedeu/models/cursor.rb +25 -35
- data/lib/vedeu/models/foreground.rb +1 -1
- data/lib/vedeu/models/geometry.rb +216 -6
- data/lib/vedeu/models/interface.rb +14 -16
- data/lib/vedeu/models/keymap.rb +38 -6
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/stream.rb +1 -1
- data/lib/vedeu/output/compositor.rb +1 -1
- data/lib/vedeu/output/render.rb +1 -5
- data/lib/vedeu/output/viewport.rb +37 -2
- data/lib/vedeu/repositories/buffers.rb +21 -27
- data/lib/vedeu/repositories/cursors.rb +3 -15
- data/lib/vedeu/repositories/focus.rb +2 -6
- data/lib/vedeu/repositories/groups.rb +1 -1
- data/lib/vedeu/repositories/interfaces.rb +1 -1
- data/lib/vedeu/repositories/keymaps.rb +26 -22
- data/lib/vedeu/repositories/menus.rb +1 -1
- data/lib/vedeu/repositories/offsets.rb +30 -12
- data/lib/vedeu/repositories/positional.rb +23 -0
- data/lib/vedeu/support/colour_translator.rb +1 -16
- data/lib/vedeu/support/esc.rb +23 -28
- data/lib/vedeu/support/event.rb +6 -14
- data/lib/vedeu/{output → support}/refresh.rb +0 -0
- data/lib/vedeu/support/registrar.rb +6 -14
- data/lib/vedeu/support/repository.rb +3 -2
- data/lib/vedeu/support/terminal.rb +9 -13
- data/lib/vedeu/support/trace.rb +2 -3
- data/test/integration/cursors_test.rb +9 -0
- data/test/integration/views/basic_view_test.rb +19 -0
- data/test/lib/vedeu/api/api_test.rb +28 -5
- data/test/lib/vedeu/api/composition_test.rb +7 -3
- data/test/lib/vedeu/api/defined_test.rb +9 -3
- data/test/lib/vedeu/api/helpers_test.rb +39 -5
- data/test/lib/vedeu/api/interface_test.rb +88 -8
- data/test/lib/vedeu/api/keymap_test.rb +5 -3
- data/test/lib/vedeu/api/line_test.rb +9 -3
- data/test/lib/vedeu/api/menu_test.rb +11 -7
- data/test/lib/vedeu/api/stream_test.rb +9 -31
- data/test/lib/vedeu/application_test.rb +25 -2
- data/test/lib/vedeu/configuration/api_test.rb +5 -3
- data/test/lib/vedeu/configuration/cli_test.rb +5 -3
- data/test/lib/vedeu/configuration/configuration_test.rb +5 -2
- data/test/lib/vedeu/input/input_test.rb +5 -2
- data/test/lib/vedeu/launcher_test.rb +37 -2
- data/test/lib/vedeu/models/background_test.rb +6 -2
- data/test/lib/vedeu/models/char_test.rb +9 -6
- data/test/lib/vedeu/models/colour_test.rb +6 -2
- data/test/lib/vedeu/models/composition_test.rb +4 -2
- data/test/lib/vedeu/models/cursor_test.rb +27 -16
- data/test/lib/vedeu/models/foreground_test.rb +6 -2
- data/test/lib/vedeu/models/geometry_test.rb +6 -2
- data/test/lib/vedeu/models/interface_test.rb +5 -2
- data/test/lib/vedeu/models/keymap_test.rb +6 -4
- data/test/lib/vedeu/models/line_test.rb +5 -2
- data/test/lib/vedeu/models/offset_test.rb +7 -3
- data/test/lib/vedeu/models/stream_test.rb +4 -2
- data/test/lib/vedeu/models/style_test.rb +5 -2
- data/test/lib/vedeu/output/clear_test.rb +6 -2
- data/test/lib/vedeu/output/compositor_test.rb +8 -4
- data/test/lib/vedeu/output/render_test.rb +9 -6
- data/test/lib/vedeu/output/view_test.rb +7 -3
- data/test/lib/vedeu/output/viewport_test.rb +42 -9
- data/test/lib/vedeu/repositories/buffers_test.rb +52 -12
- data/test/lib/vedeu/repositories/cursors_test.rb +4 -26
- data/test/lib/vedeu/repositories/events_test.rb +6 -2
- data/test/lib/vedeu/repositories/focus_test.rb +5 -2
- data/test/lib/vedeu/repositories/groups_test.rb +5 -2
- data/test/lib/vedeu/repositories/interfaces_test.rb +4 -2
- data/test/lib/vedeu/repositories/keymaps_test.rb +8 -2
- data/test/lib/vedeu/repositories/menus_test.rb +3 -2
- data/test/lib/vedeu/repositories/offsets_test.rb +26 -19
- data/test/lib/vedeu/repositories/positional_test.rb +50 -0
- data/test/lib/vedeu/support/coercions_test.rb +7 -3
- data/test/lib/vedeu/support/colour_translator_test.rb +6 -2
- data/test/lib/vedeu/support/common_test.rb +5 -3
- data/test/lib/vedeu/support/esc_test.rb +6 -2
- data/test/lib/vedeu/support/event_test.rb +6 -2
- data/test/lib/vedeu/support/grid_test.rb +9 -3
- data/test/lib/vedeu/support/keymap_validator_test.rb +5 -2
- data/test/lib/vedeu/support/log_test.rb +4 -2
- data/test/lib/vedeu/support/menu_test.rb +10 -2
- data/test/lib/vedeu/support/position_test.rb +10 -2
- data/test/lib/vedeu/support/presentation_test.rb +6 -3
- data/test/lib/vedeu/{output → support}/refresh_test.rb +6 -2
- data/test/lib/vedeu/support/registrar_test.rb +2 -2
- data/test/lib/vedeu/support/repository_test.rb +4 -3
- data/test/lib/vedeu/support/terminal_test.rb +6 -2
- data/test/lib/vedeu/support/trace_test.rb +17 -2
- data/test/lib/vedeu_test.rb +1 -1
- data/vedeu.gemspec +2 -2
- metadata +13 -13
- data/lib/vedeu/output/area.rb +0 -284
- data/lib/vedeu/support/move.rb +0 -50
- data/test/lib/vedeu/output/area_test.rb +0 -242
- data/test/lib/vedeu/support/move_test.rb +0 -35
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Keymaps do
|
5
6
|
|
6
7
|
describe '#add' do
|
@@ -147,6 +148,10 @@ module Vedeu
|
|
147
148
|
it 'returns the defined keys for all interfaces' do
|
148
149
|
Keymaps.interface_keys.must_equal(['d', 'e', 'f'])
|
149
150
|
end
|
151
|
+
|
152
|
+
it 'returns the defined keys for the specified interface' do
|
153
|
+
Keymaps.interface_keys('magnesium').must_equal(['e', 'f'])
|
154
|
+
end
|
150
155
|
end
|
151
156
|
|
152
157
|
describe '#registered?' do
|
@@ -227,5 +232,6 @@ module Vedeu
|
|
227
232
|
end
|
228
233
|
end
|
229
234
|
|
230
|
-
end
|
231
|
-
|
235
|
+
end # Keymaps
|
236
|
+
|
237
|
+
end # Vedeu
|
@@ -1,32 +1,39 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Offsets do
|
5
6
|
|
6
|
-
before
|
7
|
+
before do
|
8
|
+
Interfaces.reset
|
9
|
+
Registrar.record({ name: 'thorium' })
|
10
|
+
Terminal.console.stubs(:print)
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when no interfaces are defined' do
|
14
|
+
before { Interfaces.reset }
|
15
|
+
|
16
|
+
it { proc { Offsets.down }.must_raise(NoInterfacesDefined) }
|
7
17
|
|
8
|
-
|
9
|
-
it 'raises an exception if a :name attribute is not provided' do
|
10
|
-
proc { Offsets.add({ no_name: 'no_name' }) }
|
11
|
-
.must_raise(MissingRequired)
|
12
|
-
end
|
18
|
+
it { proc { Offsets.up }.must_raise(NoInterfacesDefined) }
|
13
19
|
|
14
|
-
it
|
15
|
-
|
16
|
-
|
20
|
+
it { proc { Offsets.right }.must_raise(NoInterfacesDefined) }
|
21
|
+
|
22
|
+
it { proc { Offsets.left }.must_raise(NoInterfacesDefined) }
|
17
23
|
end
|
18
24
|
|
19
|
-
|
20
|
-
before { Focus.stubs(:current).returns('
|
25
|
+
context 'when there is at least one interface defined' do
|
26
|
+
before { Focus.stubs(:current).returns('thorium') }
|
27
|
+
|
28
|
+
it { Offsets.down.must_be_instance_of(Array) }
|
21
29
|
|
22
|
-
it
|
23
|
-
Offsets.move(0, 1).must_be_instance_of(Offset)
|
24
|
-
end
|
30
|
+
it { Offsets.up.must_be_instance_of(Array) }
|
25
31
|
|
26
|
-
it
|
27
|
-
|
28
|
-
|
32
|
+
it { Offsets.right.must_be_instance_of(Array) }
|
33
|
+
|
34
|
+
it { Offsets.left.must_be_instance_of(Array) }
|
29
35
|
end
|
30
36
|
|
31
|
-
end
|
32
|
-
|
37
|
+
end # Offsets
|
38
|
+
|
39
|
+
end # Vedeu
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Positional do
|
6
|
+
|
7
|
+
before do
|
8
|
+
Offsets.reset
|
9
|
+
Cursors.reset
|
10
|
+
Registrar.record({ name: 'chromium' })
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#add' do
|
14
|
+
it 'raises an exception if a :name attribute is not provided' do
|
15
|
+
proc { Offsets.add({ no_name: 'no_name' }) }
|
16
|
+
.must_raise(MissingRequired)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns a new instance of Offset once stored' do
|
20
|
+
Offsets.add({ name: 'praseodymium' }).must_be_instance_of(Offset)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#add' do
|
25
|
+
let(:attributes) { { name: 'chromium' } }
|
26
|
+
|
27
|
+
it 'returns a new Cursor after registering' do
|
28
|
+
Cursors.add(attributes).must_be_instance_of(Cursor)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns a new Cursor after updating' do
|
32
|
+
Cursors.update(attributes).must_be_instance_of(Cursor)
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when the attributes do not have the :name key' do
|
36
|
+
let(:attributes) { { no_name_key: 'some_value' } }
|
37
|
+
|
38
|
+
it 'raises an exception' do
|
39
|
+
proc { Cursors.update(attributes) }.must_raise(MissingRequired)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'raises an exception' do
|
43
|
+
proc { Cursors.add(attributes) }.must_raise(MissingRequired)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Positional
|
49
|
+
|
50
|
+
end # Vedeu
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
class TestClass
|
5
6
|
include Coercions
|
6
7
|
|
@@ -10,9 +11,10 @@ module Vedeu
|
|
10
11
|
@attributes = attributes
|
11
12
|
@name = attributes[:name]
|
12
13
|
end
|
13
|
-
end
|
14
|
+
end # TestClass
|
14
15
|
|
15
16
|
describe Coercions do
|
17
|
+
|
16
18
|
describe '.coercer' do
|
17
19
|
[nil, [], {}].each do |empty_value|
|
18
20
|
it 'returns an empty collection when nil or empty' do
|
@@ -48,5 +50,7 @@ module Vedeu
|
|
48
50
|
coerced.first.attributes.must_equal({ name: "test3" })
|
49
51
|
end
|
50
52
|
end
|
51
|
-
|
52
|
-
end
|
53
|
+
|
54
|
+
end # Coercions
|
55
|
+
|
56
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe ColourTranslator do
|
6
|
+
|
5
7
|
describe '#initialize' do
|
6
8
|
it 'returns an instance of itself' do
|
7
9
|
colour = ''
|
@@ -9,5 +11,7 @@ module Vedeu
|
|
9
11
|
ColourTranslator.new(colour).must_be_instance_of(ColourTranslator)
|
10
12
|
end
|
11
13
|
end
|
12
|
-
|
13
|
-
end
|
14
|
+
|
15
|
+
end # ColourTranslator
|
16
|
+
|
17
|
+
end # Vedeu
|
@@ -6,9 +6,10 @@ class VedeuCommonClass
|
|
6
6
|
def defined_value_test(variable)
|
7
7
|
defined_value?(variable)
|
8
8
|
end
|
9
|
-
end
|
9
|
+
end # VedeuCommonClass
|
10
10
|
|
11
11
|
module Vedeu
|
12
|
+
|
12
13
|
describe Common do
|
13
14
|
|
14
15
|
describe '#defined_value?' do
|
@@ -28,5 +29,6 @@ module Vedeu
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
end
|
32
|
-
|
32
|
+
end # Common
|
33
|
+
|
34
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Esc do
|
6
|
+
|
5
7
|
describe 'colours defined via define_method' do
|
6
8
|
it 'returns an escape sequence for the foreground colour' do
|
7
9
|
Esc.magenta.must_equal("\e[35m")
|
@@ -111,5 +113,7 @@ module Vedeu
|
|
111
113
|
Esc.string('underline_off').must_equal("\e[24m")
|
112
114
|
end
|
113
115
|
end
|
114
|
-
|
115
|
-
end
|
116
|
+
|
117
|
+
end # Esc
|
118
|
+
|
119
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Event do
|
6
|
+
|
5
7
|
let(:closure) { proc { :event_triggered } }
|
6
8
|
let(:options) { {} }
|
7
9
|
|
@@ -37,5 +39,7 @@ module Vedeu
|
|
37
39
|
event.trigger.must_equal(:event_triggered)
|
38
40
|
end
|
39
41
|
end
|
40
|
-
|
41
|
-
end
|
42
|
+
|
43
|
+
end # Event
|
44
|
+
|
45
|
+
end # Vedeu
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
describe Fixnum do
|
4
|
+
|
4
5
|
describe '#columns' do
|
5
6
|
it 'returns the width if the value is in range' do
|
6
7
|
IO.console.stub :winsize, [25, 60] do
|
@@ -8,10 +9,13 @@ describe Fixnum do
|
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
11
|
-
|
12
|
+
|
13
|
+
end # Fixnum
|
12
14
|
|
13
15
|
module Vedeu
|
16
|
+
|
14
17
|
describe Grid do
|
18
|
+
|
15
19
|
describe '.columns' do
|
16
20
|
it 'raises an exception if the value is less than 1' do
|
17
21
|
proc { Grid.columns(0) }.must_raise(OutOfRange)
|
@@ -27,5 +31,7 @@ module Vedeu
|
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
30
|
-
|
31
|
-
end
|
34
|
+
|
35
|
+
end # Grid
|
36
|
+
|
37
|
+
end # Vedeu
|
@@ -1,10 +1,16 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Menu do
|
6
|
+
|
5
7
|
let(:collection) { ['hydrogen', 'carbon', 'nitrogen', 'oxygen'] }
|
6
8
|
let(:menu) { Menu.new(collection) }
|
7
9
|
|
10
|
+
describe '#initialize' do
|
11
|
+
it { skip }
|
12
|
+
end
|
13
|
+
|
8
14
|
describe '#current' do
|
9
15
|
it 'returns the current index' do
|
10
16
|
menu.current.must_equal(0)
|
@@ -229,5 +235,7 @@ module Vedeu
|
|
229
235
|
menu.size.must_equal(4)
|
230
236
|
end
|
231
237
|
end
|
232
|
-
|
233
|
-
end
|
238
|
+
|
239
|
+
end # Menu
|
240
|
+
|
241
|
+
end # Vedeu
|
@@ -1,7 +1,13 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Position do
|
6
|
+
|
7
|
+
describe '#initialize' do
|
8
|
+
it { skip }
|
9
|
+
end
|
10
|
+
|
5
11
|
describe '#to_s' do
|
6
12
|
it 'returns an escape sequence when no coordinates are provided' do
|
7
13
|
Position.new.to_s.must_equal("\e[1;1H")
|
@@ -15,5 +21,7 @@ module Vedeu
|
|
15
21
|
Position.new(4, 9).to_s { 'test' }.must_equal("\e[4;9Htest\e[4;9H")
|
16
22
|
end
|
17
23
|
end
|
18
|
-
|
19
|
-
end
|
24
|
+
|
25
|
+
end # Position
|
26
|
+
|
27
|
+
end # Vedeu
|
@@ -10,9 +10,10 @@ module Vedeu
|
|
10
10
|
style: ['bold']
|
11
11
|
}
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end # PresentationTestClass
|
14
14
|
|
15
15
|
describe Presentation do
|
16
|
+
|
16
17
|
let(:receiver) { PresentationTestClass.new }
|
17
18
|
|
18
19
|
describe '#colour' do
|
@@ -56,5 +57,7 @@ module Vedeu
|
|
56
57
|
)
|
57
58
|
end
|
58
59
|
end
|
59
|
-
|
60
|
-
end
|
60
|
+
|
61
|
+
end # Presentation
|
62
|
+
|
63
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Refresh do
|
6
|
+
|
5
7
|
describe '.all' do
|
6
8
|
it 'returns an empty collection when there are no registered ' \
|
7
9
|
'interfaces' do
|
@@ -32,5 +34,7 @@ module Vedeu
|
|
32
34
|
proc { Refresh.by_name('') }.must_raise(BufferNotFound)
|
33
35
|
end
|
34
36
|
end
|
35
|
-
|
36
|
-
end
|
37
|
+
|
38
|
+
end # Refresh
|
39
|
+
|
40
|
+
end # Vedeu
|