vedeu 0.4.53 → 0.4.54
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/api.rb +68 -5
- data/lib/vedeu/bindings/system.rb +0 -15
- data/lib/vedeu/bindings/visibility.rb +57 -13
- data/lib/vedeu/buffers/buffer.rb +5 -56
- data/lib/vedeu/cursor/cursor.rb +24 -16
- data/lib/vedeu/exceptions.rb +1 -1
- data/lib/vedeu/models/group.rb +39 -4
- data/lib/vedeu/models/interface.rb +41 -5
- data/lib/vedeu/null/buffer.rb +5 -0
- data/lib/vedeu/null/interface.rb +15 -0
- data/lib/vedeu/output/all.rb +1 -1
- data/lib/vedeu/output/background.rb +1 -1
- data/lib/vedeu/output/clear/named_interface.rb +0 -2
- data/lib/vedeu/output/{translator.rb → colour_translator.rb} +5 -5
- data/lib/vedeu/output/foreground.rb +1 -1
- data/lib/vedeu/output/render_border.rb +0 -1
- data/lib/vedeu/repositories/model.rb +15 -6
- data/lib/vedeu/repositories/repositories/buffers.rb +6 -0
- data/lib/vedeu/repositories/repositories/cursors.rb +6 -0
- data/lib/vedeu/repositories/repositories/groups.rb +6 -0
- data/lib/vedeu/repositories/repositories/interfaces.rb +6 -0
- data/lib/vedeu/support/all.rb +1 -2
- data/lib/vedeu/support/template.rb +7 -0
- data/lib/vedeu/support/toggleable.rb +98 -0
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/api_test.rb +7 -1
- data/test/lib/vedeu/bindings/system_test.rb +5 -16
- data/test/lib/vedeu/bindings/visibility_test.rb +4 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +9 -91
- data/test/lib/vedeu/cursor/cursor_test.rb +4 -6
- data/test/lib/vedeu/dsl/geometry_test.rb +24 -0
- data/test/lib/vedeu/models/group_test.rb +16 -14
- data/test/lib/vedeu/models/interface_test.rb +1 -1
- data/test/lib/vedeu/null/buffer_test.rb +6 -0
- data/test/lib/vedeu/null/interface_test.rb +18 -0
- data/test/lib/vedeu/output/clear/named_interface_test.rb +10 -19
- data/test/lib/vedeu/output/{translator_test.rb → colour_translator_test.rb} +5 -5
- data/test/lib/vedeu/support/toggleable_test.rb +69 -0
- data/vedeu.gemspec +1 -1
- metadata +10 -13
- data/lib/vedeu/support/options.rb +0 -70
- data/lib/vedeu/support/visibility.rb +0 -122
- data/test/lib/vedeu/support/options_test.rb +0 -70
- data/test/lib/vedeu/support/visibility_test.rb +0 -95
@@ -0,0 +1,98 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Toggleable instance methods for certain models.
|
4
|
+
#
|
5
|
+
# @api private
|
6
|
+
module Toggleable
|
7
|
+
|
8
|
+
# @!attribute [rw] visible
|
9
|
+
# @return [Boolean] Whether the toggleable is visible.
|
10
|
+
attr_accessor :visible
|
11
|
+
alias_method :visible?, :visible
|
12
|
+
|
13
|
+
# @return [FalseClass]
|
14
|
+
def hide
|
15
|
+
@visible = false
|
16
|
+
|
17
|
+
store
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [TrueClass]
|
21
|
+
def show
|
22
|
+
@visible = true
|
23
|
+
|
24
|
+
store
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [FalseClass|TrueClass]
|
28
|
+
def toggle
|
29
|
+
if visible?
|
30
|
+
hide
|
31
|
+
|
32
|
+
else
|
33
|
+
show
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Toggleable class methods for models.
|
39
|
+
#
|
40
|
+
# @api private
|
41
|
+
module ClassMethods
|
42
|
+
|
43
|
+
# @param name [String]
|
44
|
+
# @return [void]
|
45
|
+
def hide(name = nil)
|
46
|
+
model_by_name(name, self.repository).hide
|
47
|
+
end
|
48
|
+
alias_method :hide_cursor, :hide
|
49
|
+
alias_method :hide_group, :hide
|
50
|
+
alias_method :hide_interface, :hide
|
51
|
+
|
52
|
+
# @param name [String]
|
53
|
+
# @return [void]
|
54
|
+
def show(name = nil)
|
55
|
+
model_by_name(name, self.repository).show
|
56
|
+
end
|
57
|
+
alias_method :show_cursor, :show
|
58
|
+
alias_method :show_group, :show
|
59
|
+
alias_method :show_interface, :show
|
60
|
+
|
61
|
+
# @param name [String]
|
62
|
+
# @return [void]
|
63
|
+
def toggle(name = nil)
|
64
|
+
model_by_name(name, self.repository).toggle
|
65
|
+
end
|
66
|
+
alias_method :toggle_cursor, :toggle
|
67
|
+
alias_method :toggle_group, :toggle
|
68
|
+
alias_method :toggle_interface, :toggle
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
# @param name [String]
|
73
|
+
# @param klass [void] The repository of the model.
|
74
|
+
# @return [void]
|
75
|
+
def model_by_name(name = nil, klass)
|
76
|
+
klass.by_name(model_name(name))
|
77
|
+
end
|
78
|
+
|
79
|
+
# @param name [String]
|
80
|
+
# @return [void]
|
81
|
+
def model_name(name = nil)
|
82
|
+
return name || Vedeu.focus
|
83
|
+
end
|
84
|
+
|
85
|
+
end # ClassMethods
|
86
|
+
|
87
|
+
# When this module is included in a class, provide ClassMethods as class
|
88
|
+
# methods for the class.
|
89
|
+
#
|
90
|
+
# @param klass [Class]
|
91
|
+
# @return [void]
|
92
|
+
def self.included(klass)
|
93
|
+
klass.send :extend, ClassMethods
|
94
|
+
end
|
95
|
+
|
96
|
+
end # Toggleable
|
97
|
+
|
98
|
+
end # Vedeu
|
data/lib/vedeu/version.rb
CHANGED
data/test/lib/vedeu/api_test.rb
CHANGED
@@ -52,7 +52,13 @@ module Vedeu
|
|
52
52
|
it { Vedeu.must_respond_to(:clear_by_group) }
|
53
53
|
it { Vedeu.must_respond_to(:hide_cursor) }
|
54
54
|
it { Vedeu.must_respond_to(:show_cursor) }
|
55
|
-
|
55
|
+
it { Vedeu.must_respond_to(:toggle_cursor) }
|
56
|
+
it { Vedeu.must_respond_to(:hide_group) }
|
57
|
+
it { Vedeu.must_respond_to(:show_group) }
|
58
|
+
it { Vedeu.must_respond_to(:toggle_group) }
|
59
|
+
it { Vedeu.must_respond_to(:hide_interface) }
|
60
|
+
it { Vedeu.must_respond_to(:show_interface) }
|
61
|
+
it { Vedeu.must_respond_to(:toggle_interface) }
|
56
62
|
end # API
|
57
63
|
|
58
64
|
end # Vedeu
|
@@ -7,36 +7,25 @@ module Vedeu
|
|
7
7
|
describe System do
|
8
8
|
|
9
9
|
context 'the system events needed by Vedeu to run are defined' do
|
10
|
-
it { Vedeu.bound?(:_clear_).must_equal(true) }
|
11
|
-
it { Vedeu.bound?(:_clear_group_).must_equal(true) }
|
12
10
|
it { Vedeu.bound?(:_cleanup_).must_equal(true) }
|
11
|
+
it { Vedeu.bound?(:_clear_).must_equal(true) }
|
13
12
|
it { Vedeu.bound?(:_command_).must_equal(true) }
|
14
13
|
it { Vedeu.bound?(:_exit_).must_equal(true) }
|
14
|
+
it { Vedeu.bound?(:_focus_by_name_).must_equal(true) }
|
15
|
+
it { Vedeu.bound?(:_focus_next_).must_equal(true) }
|
16
|
+
it { Vedeu.bound?(:_focus_prev_).must_equal(true) }
|
15
17
|
it { Vedeu.bound?(:_initialize_).must_equal(true) }
|
16
18
|
it { Vedeu.bound?(:_keypress_).must_equal(true) }
|
17
19
|
it { Vedeu.bound?(:_log_).must_equal(true) }
|
20
|
+
it { Vedeu.bound?(:_maximise_).must_equal(true) }
|
18
21
|
it { Vedeu.bound?(:_mode_switch_).must_equal(true) }
|
19
22
|
it { Vedeu.bound?(:_refresh_).must_equal(true) }
|
20
23
|
it { Vedeu.bound?(:_refresh_cursor_).must_equal(true) }
|
21
24
|
it { Vedeu.bound?(:_refresh_group_).must_equal(true) }
|
22
25
|
it { Vedeu.bound?(:_resize_).must_equal(true) }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'the geometry specific events are defined' do
|
26
|
-
it { Vedeu.bound?(:_maximise_).must_equal(true) }
|
27
26
|
it { Vedeu.bound?(:_unmaximise_).must_equal(true) }
|
28
27
|
end
|
29
28
|
|
30
|
-
context 'the focus specific events are defined' do
|
31
|
-
it { Vedeu.bound?(:_focus_by_name_).must_equal(true) }
|
32
|
-
it { Vedeu.bound?(:_focus_next_).must_equal(true) }
|
33
|
-
it { Vedeu.bound?(:_focus_prev_).must_equal(true) }
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'the refresh event for all registered interfaces is defined' do
|
37
|
-
it { Vedeu.bound?(:_refresh_).must_equal(true) }
|
38
|
-
end
|
39
|
-
|
40
29
|
end # System
|
41
30
|
|
42
31
|
end # Bindings
|
@@ -7,13 +7,17 @@ module Vedeu
|
|
7
7
|
describe Visibility do
|
8
8
|
|
9
9
|
context 'the visibility events are defined' do
|
10
|
+
it { Vedeu.bound?(:_clear_group_).must_equal(true) }
|
11
|
+
|
10
12
|
it { Vedeu.bound?(:_cursor_hide_).must_equal(true) }
|
11
13
|
it { Vedeu.bound?(:_cursor_show_).must_equal(true) }
|
12
14
|
it { Vedeu.bound?(:_hide_cursor_).must_equal(true) }
|
13
15
|
it { Vedeu.bound?(:_show_cursor_).must_equal(true) }
|
16
|
+
it { Vedeu.bound?(:_toggle_cursor_).must_equal(true) }
|
14
17
|
|
15
18
|
it { Vedeu.bound?(:_hide_group_).must_equal(true) }
|
16
19
|
it { Vedeu.bound?(:_show_group_).must_equal(true) }
|
20
|
+
it { Vedeu.bound?(:_toggle_group_).must_equal(true) }
|
17
21
|
|
18
22
|
it { Vedeu.bound?(:_hide_interface_).must_equal(true) }
|
19
23
|
it { Vedeu.bound?(:_show_interface_).must_equal(true) }
|
@@ -95,12 +95,6 @@ module Vedeu
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
describe '#clear' do
|
99
|
-
subject { instance.clear }
|
100
|
-
|
101
|
-
it { subject.must_be_instance_of(Array) }
|
102
|
-
end
|
103
|
-
|
104
98
|
describe '#front?' do
|
105
99
|
subject { instance.front? }
|
106
100
|
|
@@ -141,99 +135,25 @@ module Vedeu
|
|
141
135
|
end
|
142
136
|
|
143
137
|
describe '#hide' do
|
144
|
-
|
145
|
-
Vedeu::Interface.new({ name: _name, visible: visible }).store
|
146
|
-
}
|
147
|
-
let(:_name) { 'Buffer#hide' }
|
148
|
-
let(:visible) {}
|
149
|
-
|
150
|
-
before do
|
151
|
-
Vedeu::Output.stubs(:render)
|
152
|
-
Vedeu::Visibility.stubs(:hide)
|
153
|
-
end
|
138
|
+
before { Vedeu::Output.stubs(:render) }
|
154
139
|
|
155
140
|
subject { instance.hide }
|
156
141
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
Vedeu::Visibility.expects(:hide).with(interface)
|
162
|
-
subject
|
163
|
-
}
|
164
|
-
end
|
165
|
-
|
166
|
-
context 'when the interface is not visible' do
|
167
|
-
let(:visible) { false }
|
168
|
-
|
169
|
-
it { subject.must_be_instance_of(NilClass) }
|
170
|
-
end
|
142
|
+
it {
|
143
|
+
Vedeu::Output.expects(:render)
|
144
|
+
subject
|
145
|
+
}
|
171
146
|
end
|
172
147
|
|
173
148
|
describe '#show' do
|
174
|
-
|
175
|
-
Vedeu::Interface.new({ name: _name, visible: visible }).store
|
176
|
-
}
|
177
|
-
let(:_name) { 'Buffer#show' }
|
178
|
-
let(:visible) {}
|
179
|
-
|
180
|
-
before do
|
181
|
-
Vedeu::Output.stubs(:render)
|
182
|
-
Vedeu::Visibility.stubs(:show)
|
183
|
-
end
|
149
|
+
before { Vedeu::Output.stubs(:render) }
|
184
150
|
|
185
151
|
subject { instance.show }
|
186
152
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
it { subject.must_be_instance_of(NilClass) }
|
191
|
-
end
|
192
|
-
|
193
|
-
context 'when the interface is not visible' do
|
194
|
-
let(:visible) { false }
|
195
|
-
|
196
|
-
it {
|
197
|
-
Vedeu::Visibility.expects(:show).with(interface)
|
198
|
-
subject
|
199
|
-
}
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
describe '#toggle' do
|
204
|
-
let(:interface) {
|
205
|
-
Vedeu::Interface.new({ name: _name, visible: visible }).store
|
153
|
+
it {
|
154
|
+
Vedeu::Output.expects(:render)
|
155
|
+
subject
|
206
156
|
}
|
207
|
-
let(:_name) { 'Buffer#toggle' }
|
208
|
-
let(:visible) {}
|
209
|
-
|
210
|
-
before do
|
211
|
-
Vedeu::Output.stubs(:render)
|
212
|
-
end
|
213
|
-
|
214
|
-
subject { instance.toggle }
|
215
|
-
|
216
|
-
context 'when the interface is visible' do
|
217
|
-
let(:visible) { true }
|
218
|
-
|
219
|
-
before { Vedeu::Visibility.stubs(:hide) }
|
220
|
-
|
221
|
-
it {
|
222
|
-
Vedeu::Visibility.expects(:hide).with(interface)
|
223
|
-
subject
|
224
|
-
}
|
225
|
-
end
|
226
|
-
|
227
|
-
context 'when the interface is not visible' do
|
228
|
-
let(:visible) { false }
|
229
|
-
|
230
|
-
before { Vedeu::Visibility.stubs(:show) }
|
231
|
-
|
232
|
-
it {
|
233
|
-
Vedeu::Visibility.expects(:show).with(interface)
|
234
|
-
subject
|
235
|
-
}
|
236
|
-
end
|
237
157
|
end
|
238
158
|
|
239
159
|
describe '#render' do
|
@@ -241,8 +161,6 @@ module Vedeu
|
|
241
161
|
|
242
162
|
subject { instance.render }
|
243
163
|
|
244
|
-
it { instance.must_respond_to(:content) }
|
245
|
-
|
246
164
|
# @todo
|
247
165
|
# it { skip }
|
248
166
|
# it { subject.must_be_instance_of(Array) }
|
@@ -47,16 +47,14 @@ module Vedeu
|
|
47
47
|
it { instance.must_respond_to(:oy) }
|
48
48
|
it { instance.must_respond_to(:oy=) }
|
49
49
|
it { instance.must_respond_to(:state) }
|
50
|
-
it { instance.must_respond_to(:visible) }
|
51
|
-
it { instance.must_respond_to(:visible?) }
|
52
50
|
it { instance.must_respond_to(:x) }
|
53
51
|
it { instance.must_respond_to(:x=) }
|
54
52
|
it { instance.must_respond_to(:y) }
|
55
53
|
it { instance.must_respond_to(:y=) }
|
56
54
|
end
|
57
55
|
|
58
|
-
describe '#
|
59
|
-
subject { instance.
|
56
|
+
describe '#hide' do
|
57
|
+
subject { instance.hide }
|
60
58
|
|
61
59
|
it { subject.must_be_instance_of(Vedeu::EscapeChar) }
|
62
60
|
it { subject.to_s.must_equal("\e[?25l") }
|
@@ -77,8 +75,8 @@ module Vedeu
|
|
77
75
|
it { subject.must_be_instance_of(Vedeu::Position) }
|
78
76
|
end
|
79
77
|
|
80
|
-
describe '#
|
81
|
-
subject { instance.
|
78
|
+
describe '#show' do
|
79
|
+
subject { instance.show }
|
82
80
|
|
83
81
|
it { subject.must_be_instance_of(Vedeu::EscapeChar) }
|
84
82
|
it { subject.to_s.must_equal("\e[?25h") }
|
@@ -59,6 +59,18 @@ module Vedeu
|
|
59
59
|
subject { instance.columns(3) }
|
60
60
|
|
61
61
|
it { subject.must_equal(18) }
|
62
|
+
|
63
|
+
context 'DSL #columns' do
|
64
|
+
before { Vedeu.stubs(:width).returns(80) }
|
65
|
+
|
66
|
+
subject {
|
67
|
+
Vedeu.geometry 'geometry' do
|
68
|
+
width columns(8)
|
69
|
+
end
|
70
|
+
}
|
71
|
+
|
72
|
+
it { subject.width.must_equal(48) }
|
73
|
+
end
|
62
74
|
end
|
63
75
|
|
64
76
|
describe '#height' do
|
@@ -87,6 +99,18 @@ module Vedeu
|
|
87
99
|
subject { instance.rows(3) }
|
88
100
|
|
89
101
|
it { subject.must_equal(6) }
|
102
|
+
|
103
|
+
context 'DSL #rows' do
|
104
|
+
before { Vedeu.stubs(:height).returns(38) }
|
105
|
+
|
106
|
+
subject {
|
107
|
+
Vedeu.geometry 'geometry' do
|
108
|
+
height rows(8)
|
109
|
+
end
|
110
|
+
}
|
111
|
+
|
112
|
+
it { subject.height.must_equal(24) }
|
113
|
+
end
|
90
114
|
end
|
91
115
|
|
92
116
|
describe '#use' do
|
@@ -8,12 +8,15 @@ module Vedeu
|
|
8
8
|
let(:instance) { described.new(attributes) }
|
9
9
|
let(:attributes) {
|
10
10
|
{
|
11
|
-
name:
|
12
|
-
members:
|
11
|
+
name: _name,
|
12
|
+
members: members,
|
13
|
+
repository: Vedeu.groups,
|
14
|
+
visible: visible,
|
13
15
|
}
|
14
16
|
}
|
15
17
|
let(:_name) { 'organics' }
|
16
18
|
let(:members) { ['carbon', 'nitrogen', 'oxygen'] }
|
19
|
+
let(:visible) { true }
|
17
20
|
|
18
21
|
describe '#initialize' do
|
19
22
|
it { instance.must_be_instance_of(described) }
|
@@ -25,12 +28,21 @@ module Vedeu
|
|
25
28
|
it {
|
26
29
|
instance.instance_variable_get('@repository').must_equal(Vedeu.groups)
|
27
30
|
}
|
31
|
+
it { instance.instance_variable_get('@visible').must_equal(visible) }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'accessors' do
|
35
|
+
it { instance.must_respond_to(:name) }
|
36
|
+
it { instance.must_respond_to(:name=) }
|
37
|
+
it { instance.must_respond_to(:visible) }
|
38
|
+
it { instance.must_respond_to(:visible=) }
|
39
|
+
it { instance.must_respond_to(:visible?) }
|
28
40
|
end
|
29
41
|
|
30
42
|
describe '#add' do
|
31
43
|
subject { instance.add('hydrogen') }
|
32
44
|
|
33
|
-
it { subject.must_be_instance_of(Group) }
|
45
|
+
it { subject.must_be_instance_of(Vedeu::Group) }
|
34
46
|
|
35
47
|
context 'when the member already exists' do
|
36
48
|
it 'does not add the member again but returns a new Group' do
|
@@ -65,16 +77,6 @@ module Vedeu
|
|
65
77
|
end
|
66
78
|
end
|
67
79
|
|
68
|
-
describe '#name' do
|
69
|
-
subject { instance.name }
|
70
|
-
|
71
|
-
it { subject.must_equal('organics') }
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#name=' do
|
75
|
-
it { instance.must_respond_to(:name=) }
|
76
|
-
end
|
77
|
-
|
78
80
|
describe '#remove' do
|
79
81
|
let(:member) { 'hydrogen' }
|
80
82
|
|
@@ -104,7 +106,7 @@ module Vedeu
|
|
104
106
|
describe '#reset' do
|
105
107
|
subject { instance.reset }
|
106
108
|
|
107
|
-
it { subject.must_be_instance_of(Group) }
|
109
|
+
it { subject.must_be_instance_of(Vedeu::Group) }
|
108
110
|
it { subject.members.must_be_empty }
|
109
111
|
end
|
110
112
|
|