vedeu 0.4.15 → 0.4.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/examples/borders_app.rb +0 -2
- data/examples/colours_app.rb +0 -2
- data/examples/cursor_app.rb +0 -2
- data/examples/drb_app.rb +0 -2
- data/examples/focus_app.rb +0 -2
- data/examples/geometry_app.rb +0 -2
- data/examples/hello_world.rb +0 -2
- data/examples/lines_app.rb +0 -2
- data/examples/material_colours_app.rb +0 -2
- data/lib/vedeu/bindings.rb +2 -1
- data/lib/vedeu/buffers/buffer.rb +18 -10
- data/lib/vedeu/debug.rb +2 -1
- data/lib/vedeu/distributed/server.rb +14 -8
- data/lib/vedeu/dsl/composition.rb +3 -10
- data/lib/vedeu/dsl/line.rb +14 -11
- data/lib/vedeu/dsl/shared/colour.rb +2 -3
- data/lib/vedeu/geometry/coordinate.rb +0 -4
- data/lib/vedeu/geometry/position.rb +2 -1
- data/lib/vedeu/main_loop.rb +1 -1
- data/lib/vedeu/models/all.rb +2 -0
- data/lib/vedeu/models/char.rb +4 -6
- data/lib/vedeu/models/composition.rb +4 -2
- data/lib/vedeu/models/interface.rb +4 -18
- data/lib/vedeu/models/line.rb +4 -3
- data/lib/vedeu/models/null_interface.rb +15 -0
- data/lib/vedeu/models/stream.rb +4 -3
- data/lib/vedeu/output/border.rb +9 -12
- data/lib/vedeu/output/clear.rb +2 -2
- data/lib/vedeu/output/colour.rb +30 -8
- data/lib/vedeu/output/esc.rb +2 -1
- data/lib/vedeu/output/presentation.rb +37 -20
- data/lib/vedeu/output/renderers/all.rb +1 -0
- data/lib/vedeu/output/renderers/escape_sequence_renderer.rb +40 -0
- data/lib/vedeu/output/renderers/file_renderer.rb +9 -5
- data/lib/vedeu/output/renderers/html_renderer.rb +1 -1
- data/lib/vedeu/output/text.rb +1 -15
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/repositories/repositories/borders.rb +11 -11
- data/lib/vedeu/repositories/repositories/buffers.rb +11 -11
- data/lib/vedeu/repositories/repositories/cursors.rb +15 -15
- data/lib/vedeu/repositories/repositories/events_repository.rb +11 -11
- data/lib/vedeu/repositories/repositories/geometries.rb +11 -11
- data/lib/vedeu/repositories/repositories/groups.rb +11 -11
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +23 -10
- data/lib/vedeu/repositories/repositories/keymaps.rb +11 -11
- data/lib/vedeu/repositories/repositories/menus.rb +11 -11
- data/test/lib/vedeu/buffers/buffer_test.rb +4 -6
- data/test/lib/vedeu/distributed/server_test.rb +101 -3
- data/test/lib/vedeu/dsl/view_test.rb +6 -0
- data/test/lib/vedeu/input/input_test.rb +1 -1
- data/test/lib/vedeu/models/char_test.rb +18 -2
- data/test/lib/vedeu/models/composition_test.rb +0 -2
- data/test/lib/vedeu/models/interface_test.rb +12 -17
- data/test/lib/vedeu/models/line_test.rb +0 -2
- data/test/lib/vedeu/models/null_interface_test.rb +9 -0
- data/test/lib/vedeu/models/stream_test.rb +0 -2
- data/test/lib/vedeu/output/border_test.rb +2 -4
- data/test/lib/vedeu/output/clear_test.rb +17 -0
- data/test/lib/vedeu/output/colour_test.rb +139 -0
- data/test/lib/vedeu/output/output_test.rb +15 -13
- data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +46 -0
- data/test/lib/vedeu/output/renderers/file_renderer_test.rb +27 -4
- data/test/lib/vedeu/output/renderers/html_renderer_test.rb +14 -3
- data/test/lib/vedeu/repositories/repositories/interfaces_repository_test.rb +8 -0
- data/test/test_helper.rb +3 -2
- data/vedeu.gemspec +4 -4
- metadata +18 -10
@@ -132,7 +132,7 @@ module Vedeu
|
|
132
132
|
# change the viewport by on either the y or x axis) determined by the offset
|
133
133
|
# (the cursor's y or x offset position.
|
134
134
|
#
|
135
|
-
# @param offset [Fixnum] The cursor's
|
135
|
+
# @param offset [Fixnum] The cursor's oy or ox values.
|
136
136
|
# @param dimension [Fixnum] Either the height or width.
|
137
137
|
# @return [Fixnum]
|
138
138
|
def content_offset(offset, dimension)
|
@@ -5,19 +5,19 @@ module Vedeu
|
|
5
5
|
#
|
6
6
|
class Borders < Repository
|
7
7
|
|
8
|
-
|
9
|
-
def self.borders
|
10
|
-
@borders ||= reset! # Vedeu::Borders.new(Vedeu::Border)
|
11
|
-
end
|
8
|
+
class << self
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
# @return [Vedeu::Borders]
|
11
|
+
def borders
|
12
|
+
@borders ||= reset!
|
13
|
+
end
|
14
|
+
alias_method :repository, :borders
|
15
|
+
|
16
|
+
# @return [Vedeu::Borders]
|
17
|
+
def reset!
|
18
|
+
@borders = Vedeu::Borders.register_repository(Vedeu::Border)
|
19
|
+
end
|
17
20
|
|
18
|
-
# @return [Vedeu::Borders]
|
19
|
-
def self.reset!
|
20
|
-
@borders = Vedeu::Borders.register_repository(Vedeu::Border)
|
21
21
|
end
|
22
22
|
|
23
23
|
# @param name [String] The name of the stored border.
|
@@ -4,19 +4,19 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Buffers < Repository
|
6
6
|
|
7
|
-
|
8
|
-
def self.buffers
|
9
|
-
@buffers ||= reset!
|
10
|
-
end
|
7
|
+
class << self
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# @return [Vedeu::Buffers]
|
10
|
+
def buffers
|
11
|
+
@buffers ||= reset!
|
12
|
+
end
|
13
|
+
alias_method :repository, :buffers
|
14
|
+
|
15
|
+
# @return [Vedeu::Buffers]
|
16
|
+
def reset!
|
17
|
+
@buffers = Vedeu::Buffers.register_repository(Vedeu::Buffer)
|
18
|
+
end
|
16
19
|
|
17
|
-
# @return [Vedeu::Buffers]
|
18
|
-
def self.reset!
|
19
|
-
@buffers = Vedeu::Buffers.register_repository(Vedeu::Buffer)
|
20
20
|
end
|
21
21
|
|
22
22
|
# @param name [String] The name of buffer to clear.
|
@@ -4,24 +4,24 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Cursors < Repository
|
6
6
|
|
7
|
-
|
8
|
-
def self.cursors
|
9
|
-
@cursors ||= reset!
|
10
|
-
end
|
7
|
+
class << self
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# @return [Vedeu::Cursors]
|
10
|
+
def cursors
|
11
|
+
@cursors ||= reset!
|
12
|
+
end
|
13
|
+
alias_method :repository, :cursors
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
# @return [Vedeu::Cursor]
|
16
|
+
def cursor
|
17
|
+
cursors.by_name(Vedeu.focus) if Vedeu.focus
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [Vedeu::Cursors]
|
21
|
+
def reset!
|
22
|
+
@cursors = Vedeu::Cursors.register_repository(Vedeu::Cursor)
|
23
|
+
end
|
21
24
|
|
22
|
-
# @return [Vedeu::Cursors]
|
23
|
-
def self.reset!
|
24
|
-
@cursors = Vedeu::Cursors.register_repository(Vedeu::Cursor)
|
25
25
|
end
|
26
26
|
|
27
27
|
# @param name [String] The name of the stored cursor.
|
@@ -4,19 +4,19 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class EventsRepository < Repository
|
6
6
|
|
7
|
-
|
8
|
-
def self.events
|
9
|
-
@events ||= reset!
|
10
|
-
end
|
7
|
+
class << self
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# @return [Vedeu::EventsRepository]
|
10
|
+
def events
|
11
|
+
@events ||= reset!
|
12
|
+
end
|
13
|
+
alias_method :repository, :events
|
14
|
+
|
15
|
+
# @return [Vedeu::EventsRepository]
|
16
|
+
def reset!
|
17
|
+
@events = Vedeu::EventsRepository.new(Vedeu::Events)
|
18
|
+
end
|
16
19
|
|
17
|
-
# @return [Vedeu::EventsRepository]
|
18
|
-
def self.reset!
|
19
|
-
@events = Vedeu::EventsRepository.new(Vedeu::Events)
|
20
20
|
end
|
21
21
|
|
22
22
|
end # EventsRepository
|
@@ -5,19 +5,19 @@ module Vedeu
|
|
5
5
|
#
|
6
6
|
class Geometries < Repository
|
7
7
|
|
8
|
-
|
9
|
-
def self.geometries
|
10
|
-
@geometries ||= reset!
|
11
|
-
end
|
8
|
+
class << self
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
# @return [Vedeu::Geometries]
|
11
|
+
def geometries
|
12
|
+
@geometries ||= reset!
|
13
|
+
end
|
14
|
+
alias_method :repository, :geometries
|
15
|
+
|
16
|
+
# @return [Vedeu::Geometries]
|
17
|
+
def reset!
|
18
|
+
@geometries = Vedeu::Geometries.register_repository(Vedeu::Geometry)
|
19
|
+
end
|
17
20
|
|
18
|
-
# @return [Vedeu::Geometries]
|
19
|
-
def self.reset!
|
20
|
-
@geometries = Vedeu::Geometries.new(Vedeu::Geometry)
|
21
21
|
end
|
22
22
|
|
23
23
|
# @param name [String] The name of the stored geometry.
|
@@ -4,19 +4,19 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Groups < Repository
|
6
6
|
|
7
|
-
|
8
|
-
def self.groups
|
9
|
-
@groups ||= reset!
|
10
|
-
end
|
7
|
+
class << self
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# @return [Vedeu::Groups]
|
10
|
+
def groups
|
11
|
+
@groups ||= reset!
|
12
|
+
end
|
13
|
+
alias_method :repository, :groups
|
14
|
+
|
15
|
+
# @return [Vedeu::Groups]
|
16
|
+
def reset!
|
17
|
+
@groups = Vedeu::Groups.register_repository(Vedeu::Group)
|
18
|
+
end
|
16
19
|
|
17
|
-
# @return [Vedeu::Groups]
|
18
|
-
def self.reset!
|
19
|
-
@groups = Vedeu::Groups.new(Vedeu::Group)
|
20
20
|
end
|
21
21
|
|
22
22
|
end # Groups
|
@@ -4,19 +4,32 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class InterfacesRepository < Repository
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
@
|
10
|
-
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# @return [Vedeu::InterfacesRepository]
|
10
|
+
def interfaces
|
11
|
+
@interfaces ||= reset!
|
12
|
+
end
|
13
|
+
alias_method :repository, :interfaces
|
14
|
+
|
15
|
+
# @return [Vedeu::InterfacesRepository]
|
16
|
+
def reset!
|
17
|
+
@interfaces = Vedeu::InterfacesRepository.
|
18
|
+
register_repository(Vedeu::Interface)
|
19
|
+
end
|
11
20
|
|
12
|
-
# @return [Vedeu::InterfacesRepository]
|
13
|
-
def self.repository
|
14
|
-
Vedeu.interfaces
|
15
21
|
end
|
16
22
|
|
17
|
-
# @
|
18
|
-
|
19
|
-
|
23
|
+
# @param name [String]
|
24
|
+
# @return [Vedeu::Interface|Vedeu::NullInterface]
|
25
|
+
def by_name(name)
|
26
|
+
if registered?(name)
|
27
|
+
find(name)
|
28
|
+
|
29
|
+
else
|
30
|
+
Vedeu::NullInterface.new(name: name)
|
31
|
+
|
32
|
+
end
|
20
33
|
end
|
21
34
|
|
22
35
|
end # InterfacesRepository
|
@@ -4,19 +4,19 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Keymaps < Repository
|
6
6
|
|
7
|
-
|
8
|
-
def self.keymaps
|
9
|
-
@keymaps ||= reset!
|
10
|
-
end
|
7
|
+
class << self
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# @return [Vedeu::Keymaps]
|
10
|
+
def keymaps
|
11
|
+
@keymaps ||= reset!
|
12
|
+
end
|
13
|
+
alias_method :repository, :keymaps
|
14
|
+
|
15
|
+
# @return [Vedeu::Keymaps]
|
16
|
+
def reset!
|
17
|
+
@keymaps = Vedeu::Keymaps.register_repository(Vedeu::Keymap)
|
18
|
+
end
|
16
19
|
|
17
|
-
# @return [Vedeu::Keymaps]
|
18
|
-
def self.reset!
|
19
|
-
@keymaps = Vedeu::Keymaps.new(Vedeu::Keymap)
|
20
20
|
end
|
21
21
|
|
22
22
|
end # Keymaps
|
@@ -4,19 +4,19 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Menus < Repository
|
6
6
|
|
7
|
-
|
8
|
-
def self.menus
|
9
|
-
@menus ||= reset!
|
10
|
-
end
|
7
|
+
class << self
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# @return [Vedeu::Menus]
|
10
|
+
def menus
|
11
|
+
@menus ||= reset!
|
12
|
+
end
|
13
|
+
alias_method :repository, :menus
|
14
|
+
|
15
|
+
# @return [Vedeu::Menus]
|
16
|
+
def reset!
|
17
|
+
@menus = Vedeu::Menus.register_repository(Vedeu::Menu)
|
18
|
+
end
|
16
19
|
|
17
|
-
# @return [Vedeu::Menus]
|
18
|
-
def self.reset!
|
19
|
-
@menus = Vedeu::Menus.new(Vedeu::Menu)
|
20
20
|
end
|
21
21
|
|
22
22
|
end # Menus
|
@@ -63,14 +63,14 @@ module Vedeu
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
# describe '#
|
67
|
-
#
|
66
|
+
# describe '#render' do
|
67
|
+
# before { Vedeu::Output.stubs(:render) }
|
68
|
+
|
69
|
+
# subject { instance.render }
|
68
70
|
|
69
71
|
# it { subject.must_be_instance_of(Array) }
|
70
72
|
|
71
73
|
# context 'when there is content on the back buffer' do
|
72
|
-
# before { Vedeu::Output.stubs(:render) }
|
73
|
-
|
74
74
|
# let(:back) {
|
75
75
|
# Vedeu.interface 'buffer' do
|
76
76
|
# lines do
|
@@ -119,7 +119,6 @@ module Vedeu
|
|
119
119
|
# end
|
120
120
|
|
121
121
|
# context 'when there is content on the front buffer' do
|
122
|
-
# before { Vedeu::Output.stubs(:render) }
|
123
122
|
# let(:buffer) { :front }
|
124
123
|
# let(:front) {
|
125
124
|
# Vedeu.interface 'buffer' do
|
@@ -139,7 +138,6 @@ module Vedeu
|
|
139
138
|
# end
|
140
139
|
|
141
140
|
# context 'when there is content on the previous buffer' do
|
142
|
-
# before { Vedeu::Output.stubs(:render) }
|
143
141
|
# let(:buffer) { :previous }
|
144
142
|
# let(:previous) {
|
145
143
|
# Vedeu.interface 'buffer' do
|
@@ -9,6 +9,13 @@ module Vedeu
|
|
9
9
|
let(:described) { Vedeu::Distributed::Server }
|
10
10
|
let(:instance) { described.instance }
|
11
11
|
let(:configuration) {}
|
12
|
+
let(:enabled) { false }
|
13
|
+
let(:running) { false }
|
14
|
+
|
15
|
+
before do
|
16
|
+
Vedeu::Configuration.stubs(:drb?).returns(enabled)
|
17
|
+
DRb.stubs(:thread).returns(running)
|
18
|
+
end
|
12
19
|
|
13
20
|
describe 'alias_methods' do
|
14
21
|
it { instance.must_respond_to(:read) }
|
@@ -17,16 +24,17 @@ module Vedeu
|
|
17
24
|
|
18
25
|
describe '.input' do
|
19
26
|
let(:data) {}
|
27
|
+
let(:type) { :keypress }
|
20
28
|
|
21
|
-
subject { described.input(data) }
|
29
|
+
subject { described.input(data, type) }
|
22
30
|
|
23
|
-
it { Vedeu.expects(:trigger); subject }
|
31
|
+
it { Vedeu.expects(:trigger).with(:_drb_input_, nil, :keypress); subject }
|
24
32
|
end
|
25
33
|
|
26
34
|
describe '.output' do
|
27
35
|
subject { described.output }
|
28
36
|
|
29
|
-
it { Vedeu.expects(:trigger); subject }
|
37
|
+
it { Vedeu.expects(:trigger).with(:_drb_retrieve_output_); subject }
|
30
38
|
end
|
31
39
|
|
32
40
|
describe '#pid' do
|
@@ -40,22 +48,112 @@ module Vedeu
|
|
40
48
|
|
41
49
|
describe '.restart' do
|
42
50
|
subject { described.restart }
|
51
|
+
|
52
|
+
# it { subject.must_be_instance_of(NilClass) }
|
53
|
+
context 'when the server is not enabled' do
|
54
|
+
it { subject.must_equal(:drb_not_enabled) }
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when the server is enabled' do
|
58
|
+
|
59
|
+
context 'and the server is running' do
|
60
|
+
# it { subject.must_equal(:running) }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'and the server is not running' do
|
64
|
+
# it { subject.must_equal(:stopped) }
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
43
68
|
end
|
44
69
|
|
45
70
|
describe '.shutdown' do
|
46
71
|
subject { described.shutdown }
|
72
|
+
|
73
|
+
context 'when the server is not enabled' do
|
74
|
+
it { subject.must_equal(:drb_not_enabled) }
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when the server is enabled' do
|
78
|
+
let(:enabled) { true }
|
79
|
+
|
80
|
+
before do
|
81
|
+
Vedeu::Terminal.stubs(:restore_screen)
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'and the server is running' do
|
85
|
+
# it { subject.must_equal(:running) }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'and the server is not running' do
|
89
|
+
# it { subject.must_equal(:stopped) }
|
90
|
+
end
|
91
|
+
|
92
|
+
it { Vedeu.expects(:trigger).with(:_exit_); subject }
|
93
|
+
|
94
|
+
end
|
47
95
|
end
|
48
96
|
|
49
97
|
describe '.start' do
|
50
98
|
subject { described.start }
|
99
|
+
|
100
|
+
context 'when the server is not enabled' do
|
101
|
+
it { subject.must_equal(:drb_not_enabled) }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'when the server is enabled' do
|
105
|
+
|
106
|
+
context 'and the server is running' do
|
107
|
+
# it { subject.must_equal(:running) }
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'and the server is not running' do
|
111
|
+
# it { subject.must_equal(:stopped) }
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
51
115
|
end
|
52
116
|
|
53
117
|
describe '.status' do
|
54
118
|
subject { described.status }
|
119
|
+
|
120
|
+
context 'when the server is not enabled' do
|
121
|
+
it { subject.must_equal(:drb_not_enabled) }
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'when the server is enabled' do
|
125
|
+
let(:enabled) { true }
|
126
|
+
|
127
|
+
context 'and the server is running' do
|
128
|
+
let(:running) { true }
|
129
|
+
|
130
|
+
it { subject.must_equal(:running) }
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'and the server is not running' do
|
134
|
+
it { subject.must_equal(:stopped) }
|
135
|
+
end
|
136
|
+
end
|
55
137
|
end
|
56
138
|
|
57
139
|
describe '.stop' do
|
58
140
|
subject { described.stop }
|
141
|
+
|
142
|
+
context 'when the server is not enabled' do
|
143
|
+
it { subject.must_equal(:drb_not_enabled) }
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'when the server is enabled' do
|
147
|
+
|
148
|
+
context 'and the server is running' do
|
149
|
+
# it { subject.must_equal(:running) }
|
150
|
+
end
|
151
|
+
|
152
|
+
context 'and the server is not running' do
|
153
|
+
# it { subject.must_equal(:stopped) }
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
59
157
|
end
|
60
158
|
|
61
159
|
end # Server
|