vedeu 0.5.10 → 0.5.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +2 -1
- data/bin/vedeu +1 -4
- data/lib/vedeu/all.rb +8 -12
- data/lib/vedeu/bindings/drb.rb +2 -2
- data/lib/vedeu/bindings/system.rb +11 -7
- data/lib/vedeu/{output/virtual_terminal.rb → buffers/virtual_buffer.rb} +15 -8
- data/lib/vedeu/{output/virtual_buffer.rb → buffers/virtual_buffers.rb} +4 -4
- data/lib/vedeu/cursor/cursor.rb +2 -6
- data/lib/vedeu/cursor/reposition.rb +11 -6
- data/lib/vedeu/esc/esc.rb +4 -0
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/output/output.rb +1 -1
- data/lib/vedeu/plugins.rb +7 -3
- data/lib/vedeu/plugins/plugin.rb +4 -4
- data/lib/vedeu/refresh/refresh.rb +31 -0
- data/lib/vedeu/refresh/refresh_buffer.rb +53 -0
- data/lib/vedeu/{cursor → refresh}/refresh_cursor.rb +4 -4
- data/lib/vedeu/refresh/refresh_group.rb +59 -0
- data/lib/vedeu/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/{output/virtual_terminal_test.rb → buffers/virtual_buffer_test.rb} +16 -12
- data/test/lib/vedeu/{output/virtual_buffer_test.rb → buffers/virtual_buffers_test.rb} +3 -3
- data/test/lib/vedeu/cursor/cursors_test.rb +2 -0
- data/test/lib/vedeu/distributed/client_test.rb +13 -9
- data/test/lib/vedeu/distributed/server_test.rb +5 -0
- data/test/lib/vedeu/distributed/subprocess_test.rb +12 -1
- data/test/lib/vedeu/models/views/view_test.rb +41 -0
- data/test/lib/vedeu/output/output_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/html_test.rb +1 -1
- data/test/lib/vedeu/output/viewport_test.rb +15 -16
- data/test/lib/vedeu/plugins_test.rb +7 -0
- data/test/lib/vedeu/refresh/refresh_buffer_test.rb +50 -0
- data/test/lib/vedeu/{cursor → refresh}/refresh_cursor_test.rb +8 -6
- data/test/lib/vedeu/{output → refresh}/refresh_group_test.rb +4 -2
- data/test/lib/vedeu/refresh/refresh_test.rb +44 -0
- data/test/test_helper.rb +1 -1
- data/vedeu.gemspec +3 -3
- metadata +24 -55
- data/lib/vedeu/cli/generator/all.rb +0 -9
- data/lib/vedeu/cli/generator/application.rb +0 -133
- data/lib/vedeu/cli/generator/helpers.rb +0 -139
- data/lib/vedeu/cli/generator/templates/application/.gitignore +0 -1
- data/lib/vedeu/cli/generator/templates/application/.ruby-version +0 -1
- data/lib/vedeu/cli/generator/templates/application/Gemfile +0 -4
- data/lib/vedeu/cli/generator/templates/application/LICENSE.txt +0 -24
- data/lib/vedeu/cli/generator/templates/application/README.md +0 -18
- data/lib/vedeu/cli/generator/templates/application/app/controllers/application_controller.erb +0 -7
- data/lib/vedeu/cli/generator/templates/application/app/controllers/name.erb +0 -22
- data/lib/vedeu/cli/generator/templates/application/app/helpers/application_helper.erb +0 -9
- data/lib/vedeu/cli/generator/templates/application/app/helpers/name.erb +0 -11
- data/lib/vedeu/cli/generator/templates/application/app/models/keymaps/_global_.rb +0 -8
- data/lib/vedeu/cli/generator/templates/application/app/models/keymaps/name.erb +0 -3
- data/lib/vedeu/cli/generator/templates/application/app/views/interfaces/name.erb +0 -67
- data/lib/vedeu/cli/generator/templates/application/app/views/name.erb +0 -36
- data/lib/vedeu/cli/generator/templates/application/app/views/templates/name.erb +0 -0
- data/lib/vedeu/cli/generator/templates/application/application.erb +0 -22
- data/lib/vedeu/cli/generator/templates/application/bin/name +0 -9
- data/lib/vedeu/cli/generator/templates/application/config/app_name.erb +0 -1
- data/lib/vedeu/cli/generator/templates/application/config/configuration.erb +0 -33
- data/lib/vedeu/cli/generator/templates/application/lib/.gitkeep +0 -0
- data/lib/vedeu/cli/generator/templates/application/test/.gitkeep +0 -0
- data/lib/vedeu/cli/generator/templates/application/vendor/.gitkeep +0 -0
- data/lib/vedeu/cli/generator/view.rb +0 -86
- data/lib/vedeu/cli/main.rb +0 -39
- data/lib/vedeu/output/refresh.rb +0 -69
- data/lib/vedeu/output/refresh_group.rb +0 -41
- data/test/lib/vedeu/cli/generator/application_test.rb +0 -37
- data/test/lib/vedeu/cli/generator/helpers_test.rb +0 -197
- data/test/lib/vedeu/cli/generator/view_test.rb +0 -38
- data/test/lib/vedeu/cli/main_test.rb +0 -59
- data/test/lib/vedeu/output/refresh_test.rb +0 -63
@@ -12,8 +12,8 @@ module Vedeu
|
|
12
12
|
:width
|
13
13
|
|
14
14
|
# @param (see #initialize)
|
15
|
-
def self.
|
16
|
-
new(name).
|
15
|
+
def self.by_name(name = Vedeu.focus)
|
16
|
+
new(name).by_name
|
17
17
|
end
|
18
18
|
|
19
19
|
# Returns a new instance of Vedeu::RefreshCursor.
|
@@ -29,10 +29,10 @@ module Vedeu
|
|
29
29
|
# the view is also refreshed, causing the content to be offset also.
|
30
30
|
#
|
31
31
|
# @return [Array]
|
32
|
-
def
|
32
|
+
def by_name
|
33
33
|
Vedeu.log(type: :info, message: "Refreshing cursor: '#{name}'")
|
34
34
|
|
35
|
-
Vedeu
|
35
|
+
Vedeu.trigger(:_refresh_, name) if refresh_view?
|
36
36
|
|
37
37
|
Vedeu::Terminal.output(new_cursor.to_s)
|
38
38
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Refresh an interface, or collection of interfaces belonging to a group.
|
4
|
+
#
|
5
|
+
# The interfaces will be refreshed in z-index order, meaning that interfaces
|
6
|
+
# with a lower z-index will be drawn first. This means overlapping interfaces
|
7
|
+
# will be drawn as specified.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Vedeu.trigger(:_refresh_group_, group_name)
|
11
|
+
#
|
12
|
+
class RefreshGroup
|
13
|
+
|
14
|
+
include Vedeu::Common
|
15
|
+
|
16
|
+
# @param name [String] The name of the group to be refreshed.
|
17
|
+
# @return [Array|Vedeu::ModelNotFound] A collection of the names of
|
18
|
+
# interfaces refreshed, or an exception when the group was not found.
|
19
|
+
def self.by_name(name)
|
20
|
+
new(name).by_name
|
21
|
+
end
|
22
|
+
|
23
|
+
# Return a new instance of Vedeu::RefreshGroup.
|
24
|
+
#
|
25
|
+
# @param name [String]
|
26
|
+
# @return [Vedeu::RefreshGroup]
|
27
|
+
def initialize(name)
|
28
|
+
@name = name
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [void]
|
32
|
+
def by_name
|
33
|
+
Vedeu.timer("Refresh Group: '#{group_name}'") do
|
34
|
+
Vedeu.groups.by_name(group_name).by_zindex.each do |name|
|
35
|
+
Vedeu::RefreshBuffer.by_name(name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
# @!attribute [r] name
|
43
|
+
# @return [String]
|
44
|
+
attr_reader :name
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# @raise [Vedeu::MissingRequired] When the name is empty or nil.
|
49
|
+
# @return [String]
|
50
|
+
def group_name
|
51
|
+
return name if present?(name)
|
52
|
+
|
53
|
+
fail Vedeu::MissingRequired,
|
54
|
+
'Cannot refresh group with an empty group name.'
|
55
|
+
end
|
56
|
+
|
57
|
+
end # RefreshGroup
|
58
|
+
|
59
|
+
end # Vedeu
|
data/lib/vedeu/terminal.rb
CHANGED
@@ -220,9 +220,9 @@ module Vedeu
|
|
220
220
|
IO.console
|
221
221
|
end
|
222
222
|
|
223
|
-
# @return [
|
223
|
+
# @return [VirtualBuffer]
|
224
224
|
def virtual
|
225
|
-
@virtual ||= Vedeu::
|
225
|
+
@virtual ||= Vedeu::VirtualBuffer.new(height, width)
|
226
226
|
end
|
227
227
|
|
228
228
|
end # Terminal
|
data/lib/vedeu/version.rb
CHANGED
@@ -2,9 +2,9 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe VirtualBuffer do
|
6
6
|
|
7
|
-
let(:described) { Vedeu::
|
7
|
+
let(:described) { Vedeu::VirtualBuffer }
|
8
8
|
let(:instance) { described.new(height, width, renderer) }
|
9
9
|
let(:height) { 3 }
|
10
10
|
let(:width) { 3 }
|
@@ -24,6 +24,14 @@ module Vedeu
|
|
24
24
|
it { instance.must_respond_to(:width) }
|
25
25
|
end
|
26
26
|
|
27
|
+
describe '.output' do
|
28
|
+
let(:data) {}
|
29
|
+
|
30
|
+
subject { described.output(data) }
|
31
|
+
|
32
|
+
it { subject.must_be_instance_of(Array) }
|
33
|
+
end
|
34
|
+
|
27
35
|
describe '#cells' do
|
28
36
|
subject { instance.cells }
|
29
37
|
|
@@ -65,18 +73,14 @@ module Vedeu
|
|
65
73
|
end
|
66
74
|
|
67
75
|
describe '#output' do
|
68
|
-
|
69
|
-
|
70
|
-
subject { instance.output(data) }
|
71
|
-
|
72
|
-
it { subject.must_be_instance_of(Array) }
|
76
|
+
it { instance.must_respond_to(:output) }
|
73
77
|
end
|
74
78
|
|
75
|
-
|
76
|
-
|
79
|
+
describe '#render' do
|
80
|
+
subject { instance.render }
|
77
81
|
|
78
|
-
|
79
|
-
|
82
|
+
it { subject.must_be_instance_of(String) }
|
83
|
+
end
|
80
84
|
|
81
85
|
describe '#reset' do
|
82
86
|
subject { instance.reset }
|
@@ -120,6 +124,6 @@ module Vedeu
|
|
120
124
|
end
|
121
125
|
end
|
122
126
|
|
123
|
-
end #
|
127
|
+
end # VirtualBuffer
|
124
128
|
|
125
129
|
end # Vedeu
|
@@ -2,9 +2,9 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe VirtualBuffers do
|
6
6
|
|
7
|
-
let(:described) { Vedeu::
|
7
|
+
let(:described) { Vedeu::VirtualBuffers }
|
8
8
|
|
9
9
|
before { described.clear }
|
10
10
|
|
@@ -64,6 +64,6 @@ module Vedeu
|
|
64
64
|
it { described.must_respond_to(:reset) }
|
65
65
|
end
|
66
66
|
|
67
|
-
end #
|
67
|
+
end # VirtualBuffers
|
68
68
|
|
69
69
|
end # Vedeu
|
@@ -87,17 +87,21 @@ module Vedeu
|
|
87
87
|
end
|
88
88
|
|
89
89
|
context 'when the DRb server is available' do
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
90
|
+
let(:server) { mock('DRbObject', pid: 9876) }
|
91
|
+
|
92
|
+
before do
|
93
|
+
server.stubs(:shutdown)
|
94
|
+
DRbObject.stubs(:new_with_uri).returns(server)
|
95
|
+
Process.stubs(:kill)
|
96
|
+
end
|
95
97
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
98
|
+
it {
|
99
|
+
server.expects(:shutdown)
|
100
|
+
Process.expects(:kill)
|
101
|
+
subject
|
102
|
+
}
|
100
103
|
|
104
|
+
# @todo Add more tests.
|
101
105
|
# it { skip }
|
102
106
|
end
|
103
107
|
end
|
@@ -43,14 +43,19 @@ module Vedeu
|
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'when the server is enabled' do
|
46
|
+
before { Vedeu::Configuration.stubs(:drb?).returns(true) }
|
46
47
|
|
47
48
|
context 'and the server is running' do
|
49
|
+
before { DRb.stubs(:thread).returns(true) }
|
50
|
+
|
48
51
|
# @todo Add more tests.
|
49
52
|
# it { subject.must_equal(:running) }
|
50
53
|
# it { skip }
|
51
54
|
end
|
52
55
|
|
53
56
|
context 'and the server is not running' do
|
57
|
+
before { DRb.stubs(:thread).returns(false) }
|
58
|
+
|
54
59
|
# @todo Add more tests.
|
55
60
|
# it { subject.must_equal(:stopped) }
|
56
61
|
# it { skip }
|
@@ -25,7 +25,18 @@ module Vedeu
|
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#kill' do
|
28
|
-
|
28
|
+
before do
|
29
|
+
Process.stubs(:kill)
|
30
|
+
File.stubs(:unlink)
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { instance.kill }
|
34
|
+
|
35
|
+
it {
|
36
|
+
Process.expects(:kill)
|
37
|
+
File.expects(:unlink)
|
38
|
+
subject
|
39
|
+
}
|
29
40
|
end
|
30
41
|
|
31
42
|
end # Subprocess
|
@@ -28,10 +28,46 @@ module Vedeu
|
|
28
28
|
it { instance.must_respond_to(:zindex=) }
|
29
29
|
end
|
30
30
|
|
31
|
+
describe '#add' do
|
32
|
+
let(:child) {}
|
33
|
+
|
34
|
+
subject { instance.add(child) }
|
35
|
+
|
36
|
+
# @todo Add more tests.
|
37
|
+
# it { skip }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#value' do
|
41
|
+
subject { instance.value }
|
42
|
+
|
43
|
+
# @todo Add more tests.
|
44
|
+
# it { skip }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#render' do
|
48
|
+
subject { instance.render }
|
49
|
+
|
50
|
+
context 'when the view is not visible' do
|
51
|
+
it { subject.must_equal([]) }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when the view is visible' do
|
55
|
+
# @todo Add more tests.
|
56
|
+
# it { skip }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
31
60
|
describe '#store_immediate' do
|
61
|
+
before { Vedeu.stubs(:trigger) }
|
62
|
+
|
32
63
|
subject { instance.store_immediate }
|
33
64
|
|
34
65
|
it { subject.must_be_instance_of(described) }
|
66
|
+
|
67
|
+
it {
|
68
|
+
Vedeu.expects(:trigger).with(:_refresh_, _name)
|
69
|
+
subject
|
70
|
+
}
|
35
71
|
end
|
36
72
|
|
37
73
|
describe '#store_deferred' do
|
@@ -46,6 +82,11 @@ module Vedeu
|
|
46
82
|
end
|
47
83
|
end
|
48
84
|
|
85
|
+
describe '#visible?' do
|
86
|
+
# @todo Add more tests.
|
87
|
+
# it { skip }
|
88
|
+
end
|
89
|
+
|
49
90
|
end # View
|
50
91
|
|
51
92
|
end # Views
|
@@ -94,8 +94,7 @@ module Vedeu
|
|
94
94
|
end
|
95
95
|
|
96
96
|
context 'when there is content' do
|
97
|
-
context
|
98
|
-
"area - negative" do
|
97
|
+
context 'when the cursor y position is outside the viewable area' do
|
99
98
|
let(:ox) { -4 }
|
100
99
|
let(:oy) { -4 }
|
101
100
|
|
@@ -114,12 +113,12 @@ module Vedeu
|
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
117
|
-
context
|
118
|
-
context
|
116
|
+
context 'when the cursor y position is inside the viewable area' do
|
117
|
+
context 'when there is not enough content to fill the height' do
|
119
118
|
let(:ox) { 3 }
|
120
119
|
let(:oy) { 7 }
|
121
120
|
|
122
|
-
it
|
121
|
+
it 'renders the visible content' do
|
123
122
|
subject.must_equal(
|
124
123
|
"\e[1;1H\e[39m\e[49mb\n" \
|
125
124
|
"\e[1;2H\e[39m\e[49ma\n" \
|
@@ -134,11 +133,11 @@ module Vedeu
|
|
134
133
|
end
|
135
134
|
end
|
136
135
|
|
137
|
-
context
|
136
|
+
context 'when there is more content than the height' do
|
138
137
|
let(:ox) { 3 }
|
139
138
|
let(:oy) { 3 }
|
140
139
|
|
141
|
-
it
|
140
|
+
it 'is cropped to show only that which fits' do
|
142
141
|
subject.must_equal(
|
143
142
|
"\e[1;1H\e[39m\e[49mb\n" \
|
144
143
|
"\e[1;2H\e[39m\e[49ma\n" \
|
@@ -154,8 +153,8 @@ module Vedeu
|
|
154
153
|
end
|
155
154
|
end
|
156
155
|
|
157
|
-
context
|
158
|
-
context
|
156
|
+
context 'when the cursor x position is outside the viewable area' do
|
157
|
+
context 'but inside the content' do
|
159
158
|
let(:ox) { 6 }
|
160
159
|
let(:oy) { 6 }
|
161
160
|
|
@@ -174,11 +173,11 @@ module Vedeu
|
|
174
173
|
end
|
175
174
|
end
|
176
175
|
|
177
|
-
context
|
176
|
+
context 'and outside the content' do
|
178
177
|
let(:ox) { 7 }
|
179
178
|
let(:oy) { 7 }
|
180
179
|
|
181
|
-
it
|
180
|
+
it 'scrolls the content the correct position' do
|
182
181
|
subject.must_equal(
|
183
182
|
"\e[1;1H\e[39m\e[49mb\n" \
|
184
183
|
"\e[1;2H\e[39m\e[49ma\n" \
|
@@ -194,12 +193,12 @@ module Vedeu
|
|
194
193
|
end
|
195
194
|
end
|
196
195
|
|
197
|
-
context
|
198
|
-
context
|
196
|
+
context 'when the cursor x position is inside the viewable area' do
|
197
|
+
context 'when there is not enough content to fill the width' do
|
199
198
|
let(:ox) { 7 }
|
200
199
|
let(:oy) { 3 }
|
201
200
|
|
202
|
-
it
|
201
|
+
it 'renders the visible content' do
|
203
202
|
subject.must_equal(
|
204
203
|
"\e[1;1H\e[39m\e[49mb\n" \
|
205
204
|
"\e[1;2H\e[39m\e[49ma\n" \
|
@@ -214,11 +213,11 @@ module Vedeu
|
|
214
213
|
end
|
215
214
|
end
|
216
215
|
|
217
|
-
context
|
216
|
+
context 'when there is more content than the width' do
|
218
217
|
let(:ox) { 3 }
|
219
218
|
let(:oy) { 3 }
|
220
219
|
|
221
|
-
it
|
220
|
+
it 'is cropped to show only that which fits' do
|
222
221
|
subject.must_equal(
|
223
222
|
"\e[1;1H\e[39m\e[49mb\n" \
|
224
223
|
"\e[1;2H\e[39m\e[49ma\n" \
|
@@ -9,12 +9,14 @@ module Vedeu
|
|
9
9
|
|
10
10
|
describe '#initialize' do
|
11
11
|
it { instance.must_be_instance_of(described) }
|
12
|
+
it { instance.instance_variable_get('@plugins').must_equal([]) }
|
12
13
|
end
|
13
14
|
|
14
15
|
describe '#load' do
|
15
16
|
subject { instance.load }
|
16
17
|
|
17
18
|
it { subject.must_be_instance_of(Array) }
|
19
|
+
it { subject.must_equal([]) }
|
18
20
|
end
|
19
21
|
|
20
22
|
describe '#register' do
|
@@ -31,6 +33,11 @@ module Vedeu
|
|
31
33
|
subject { instance.find }
|
32
34
|
|
33
35
|
it { subject.must_be_instance_of(Array) }
|
36
|
+
|
37
|
+
context 'when it finds the vedeu_cli gem' do
|
38
|
+
it { subject.size.must_equal(1) }
|
39
|
+
it { subject.first.name.must_equal('cli') }
|
40
|
+
end
|
34
41
|
end
|
35
42
|
|
36
43
|
describe '#names' do
|