vedeu 0.6.19 → 0.6.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/configuration.md +6 -4
- data/docs/dsl.md +23 -21
- data/docs/events/system.md +9 -9
- data/docs/getting_started.md +54 -48
- data/docs/object_graph.md +4 -4
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/api/external.rb +10 -10
- data/lib/vedeu/api/internal.rb +2 -2
- data/lib/vedeu/bindings/application.rb +5 -2
- data/lib/vedeu/bindings/bindings.rb +15 -2
- data/lib/vedeu/bindings/movement.rb +10 -5
- data/lib/vedeu/bindings/refresh.rb +1 -1
- data/lib/vedeu/bindings/system.rb +1 -1
- data/lib/vedeu/bindings/visibility.rb +20 -37
- data/lib/vedeu/cursors/cursor.rb +1 -14
- data/lib/vedeu/dsl/all.rb +0 -1
- data/lib/vedeu/dsl/interface.rb +1 -1
- data/lib/vedeu/esc/colours.rb +1 -1
- data/lib/vedeu/geometry/geometry.rb +19 -25
- data/lib/vedeu/groups/all.rb +16 -0
- data/lib/vedeu/{output/clear/group.rb → groups/clear.rb} +7 -7
- data/lib/vedeu/{dsl/group.rb → groups/dsl.rb} +10 -10
- data/lib/vedeu/{models → groups}/group.rb +14 -31
- data/lib/vedeu/{output/refresh/refresh_group.rb → groups/refresh.rb} +7 -7
- data/lib/vedeu/groups/repository.rb +24 -0
- data/lib/vedeu/models/all.rb +0 -2
- data/lib/vedeu/models/interface.rb +0 -12
- data/lib/vedeu/models/toggleable.rb +1 -1
- data/lib/vedeu/output/clear/all.rb +0 -1
- data/lib/vedeu/output/wordwrap.rb +3 -5
- data/lib/vedeu/repositories/model.rb +8 -1
- data/lib/vedeu/runtime/main_loop.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/api/external_test.rb +1 -1
- data/test/lib/vedeu/bindings/application_test.rb +1 -0
- data/test/lib/vedeu/bindings/bindings_test.rb +27 -0
- data/test/lib/vedeu/borders/border_test.rb +43 -37
- data/test/lib/vedeu/borders/render_test.rb +5 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +9 -7
- data/test/lib/vedeu/cursors/cursor_test.rb +11 -9
- data/test/lib/vedeu/distributed/test_application_test.rb +18 -16
- data/test/lib/vedeu/dsl/interface_test.rb +2 -2
- data/test/lib/vedeu/editor/cursor_test.rb +18 -16
- data/test/lib/vedeu/editor/document_test.rb +7 -5
- data/test/lib/vedeu/esc/actions_test.rb +0 -2
- data/test/lib/vedeu/esc/borders_test.rb +0 -2
- data/test/lib/vedeu/esc/colours_test.rb +0 -2
- data/test/lib/vedeu/events/aliases_test.rb +1 -1
- data/test/lib/vedeu/geometry/area_test.rb +10 -8
- data/test/lib/vedeu/geometry/dsl_test.rb +2 -2
- data/test/lib/vedeu/geometry/geometry_test.rb +18 -30
- data/test/lib/vedeu/geometry/position_test.rb +6 -4
- data/test/lib/vedeu/{output/clear/group_test.rb → groups/clear_test.rb} +8 -8
- data/test/lib/vedeu/{dsl/group_test.rb → groups/dsl_test.rb} +8 -8
- data/test/lib/vedeu/{models → groups}/group_test.rb +12 -10
- data/test/lib/vedeu/{output/refresh/refresh_group_test.rb → groups/refresh_test.rb} +7 -7
- data/test/lib/vedeu/{models/groups_test.rb → groups/repository_test.rb} +6 -6
- data/test/lib/vedeu/menus/menu_test.rb +7 -5
- data/test/lib/vedeu/models/cell_test.rb +5 -3
- data/test/lib/vedeu/models/interface_test.rb +18 -42
- data/test/lib/vedeu/models/toggleable_test.rb +5 -3
- data/test/lib/vedeu/models/views/char_test.rb +8 -6
- data/test/lib/vedeu/models/views/composition_test.rb +6 -4
- data/test/lib/vedeu/models/views/line_test.rb +5 -3
- data/test/lib/vedeu/models/views/stream_test.rb +9 -7
- data/test/lib/vedeu/models/views/view_test.rb +30 -12
- data/test/lib/vedeu/output/presentation/style_test.rb +4 -2
- data/test/lib/vedeu/plugins/plugin_test.rb +8 -6
- data/test/lib/vedeu/repositories/collection_test.rb +8 -6
- data/test/lib/vedeu/runtime/application_test.rb +1 -1
- data/test/test_helper.rb +1 -0
- metadata +18 -17
- data/lib/vedeu/models/groups.rb +0 -24
@@ -1,6 +1,6 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Groups
|
4
4
|
|
5
5
|
# Interfaces can be associated with one another by being members
|
6
6
|
# of the same Group. A Group is a collection of interface names.
|
@@ -14,7 +14,7 @@ module Vedeu
|
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :name
|
16
16
|
|
17
|
-
# Return a new instance of Vedeu::
|
17
|
+
# Return a new instance of Vedeu::Groups::Group.
|
18
18
|
#
|
19
19
|
# @note
|
20
20
|
# A group being visible or not may not necessarily mean the
|
@@ -29,7 +29,7 @@ module Vedeu
|
|
29
29
|
# The storage for all Group models.
|
30
30
|
# @option attributes visible [Boolean] Whether the group is
|
31
31
|
# visible or not.
|
32
|
-
# @return [Vedeu::
|
32
|
+
# @return [Vedeu::Groups::Group]
|
33
33
|
def initialize(attributes = {})
|
34
34
|
defaults.merge!(attributes).each do |key, value|
|
35
35
|
instance_variable_set("@#{key}", value)
|
@@ -39,11 +39,11 @@ module Vedeu
|
|
39
39
|
# Add a member to the group by name.
|
40
40
|
#
|
41
41
|
# @param member [String]
|
42
|
-
# @return [Vedeu::
|
42
|
+
# @return [Vedeu::Groups::Group]
|
43
43
|
def add(member)
|
44
44
|
attrs = attributes.merge!(members: members.add(member))
|
45
45
|
|
46
|
-
Vedeu::
|
46
|
+
Vedeu::Groups::Group.new(attrs).store
|
47
47
|
end
|
48
48
|
|
49
49
|
# Returns the attributes of the group.
|
@@ -79,13 +79,11 @@ module Vedeu
|
|
79
79
|
# Vedeu.trigger(:_hide_group_, name)
|
80
80
|
# Vedeu.hide_group(name)
|
81
81
|
#
|
82
|
-
# @return [Vedeu::
|
82
|
+
# @return [Vedeu::Groups::Group]
|
83
83
|
def hide
|
84
84
|
super
|
85
85
|
|
86
|
-
@members.each
|
87
|
-
Vedeu::Models::Interface.hide_interface(member)
|
88
|
-
end
|
86
|
+
@members.each { |member| Vedeu.trigger(:_hide_interface_, member) }
|
89
87
|
|
90
88
|
self
|
91
89
|
end
|
@@ -100,20 +98,20 @@ module Vedeu
|
|
100
98
|
# Remove a member from the group by name.
|
101
99
|
#
|
102
100
|
# @param member [String]
|
103
|
-
# @return [Vedeu::
|
101
|
+
# @return [Vedeu::Groups::Group]
|
104
102
|
def remove(member)
|
105
103
|
attrs = attributes.merge!(members: members.delete(member))
|
106
104
|
|
107
|
-
Vedeu::
|
105
|
+
Vedeu::Groups::Group.new(attrs).store
|
108
106
|
end
|
109
107
|
|
110
108
|
# Remove all members from the group.
|
111
109
|
#
|
112
|
-
# @return [Vedeu::
|
110
|
+
# @return [Vedeu::Groups::Group]
|
113
111
|
def reset
|
114
112
|
attrs = defaults.merge!(name: name)
|
115
113
|
|
116
|
-
Vedeu::
|
114
|
+
Vedeu::Groups::Group.new(attrs).store
|
117
115
|
end
|
118
116
|
|
119
117
|
# Show the named group of interfaces, or without a name, the
|
@@ -123,26 +121,11 @@ module Vedeu
|
|
123
121
|
# Vedeu.trigger(:_show_group_, name)
|
124
122
|
# Vedeu.show_group(name)
|
125
123
|
#
|
126
|
-
# @return [Vedeu::
|
124
|
+
# @return [Vedeu::Groups::Group]
|
127
125
|
def show
|
128
126
|
super
|
129
127
|
|
130
|
-
@members.each
|
131
|
-
Vedeu::Models::Interface.show_interface(member)
|
132
|
-
end
|
133
|
-
|
134
|
-
self
|
135
|
-
end
|
136
|
-
|
137
|
-
# Toggle the visibility of the group with the given name.
|
138
|
-
#
|
139
|
-
# @example
|
140
|
-
# Vedeu.trigger(:_toggle_group, name)
|
141
|
-
# Vedeu.toggle_group(name)
|
142
|
-
#
|
143
|
-
# @return [Vedeu::Models::Group]
|
144
|
-
def toggle
|
145
|
-
super
|
128
|
+
@members.each { |member| Vedeu.trigger(:_show_interface_, member) }
|
146
129
|
|
147
130
|
self
|
148
131
|
end
|
@@ -170,6 +153,6 @@ module Vedeu
|
|
170
153
|
|
171
154
|
end # Group
|
172
155
|
|
173
|
-
end #
|
156
|
+
end # Groups
|
174
157
|
|
175
158
|
end # Vedeu
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Groups
|
4
4
|
|
5
5
|
# Refresh an interface, or collection of interfaces belonging to a
|
6
6
|
# group.
|
@@ -12,7 +12,7 @@ module Vedeu
|
|
12
12
|
# @example
|
13
13
|
# Vedeu.trigger(:_refresh_group_, group_name)
|
14
14
|
#
|
15
|
-
class
|
15
|
+
class Refresh
|
16
16
|
|
17
17
|
include Vedeu::Common
|
18
18
|
|
@@ -24,10 +24,10 @@ module Vedeu
|
|
24
24
|
new(name).by_name
|
25
25
|
end
|
26
26
|
|
27
|
-
# Return a new instance of Vedeu::
|
27
|
+
# Return a new instance of Vedeu::Groups::Refresh.
|
28
28
|
#
|
29
29
|
# @param name [String]
|
30
|
-
# @return [Vedeu::
|
30
|
+
# @return [Vedeu::Groups::Refresh]
|
31
31
|
def initialize(name)
|
32
32
|
@name = name
|
33
33
|
end
|
@@ -36,7 +36,7 @@ module Vedeu
|
|
36
36
|
def by_name
|
37
37
|
Vedeu.timer("Refresh Group: '#{group_name}'") do
|
38
38
|
Vedeu.groups.by_name(group_name).by_zindex.each do |name|
|
39
|
-
Vedeu
|
39
|
+
Vedeu.trigger(:_refresh_view_, name)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -59,8 +59,8 @@ module Vedeu
|
|
59
59
|
'Cannot refresh group with an empty group name.'
|
60
60
|
end
|
61
61
|
|
62
|
-
end #
|
62
|
+
end # Refresh
|
63
63
|
|
64
|
-
end #
|
64
|
+
end # Groups
|
65
65
|
|
66
66
|
end # Vedeu
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Groups
|
4
|
+
|
5
|
+
# Allows the storing of view groups.
|
6
|
+
#
|
7
|
+
class Repository < Vedeu::Repositories::Repository
|
8
|
+
|
9
|
+
singleton_class.send(:alias_method, :groups, :repository)
|
10
|
+
|
11
|
+
null Vedeu::Groups::Group
|
12
|
+
real Vedeu::Groups::Group
|
13
|
+
|
14
|
+
end # Groups
|
15
|
+
|
16
|
+
class Group
|
17
|
+
|
18
|
+
repo Vedeu::Groups::Repository.repository
|
19
|
+
|
20
|
+
end # Group
|
21
|
+
|
22
|
+
end # Groups
|
23
|
+
|
24
|
+
end # Vedeu
|
data/lib/vedeu/models/all.rb
CHANGED
@@ -87,18 +87,6 @@ module Vedeu
|
|
87
87
|
Vedeu.buffers.by_name(name).show
|
88
88
|
end
|
89
89
|
|
90
|
-
# Toggle the visibility of the interface with the given name.
|
91
|
-
#
|
92
|
-
# @example
|
93
|
-
# Vedeu.toggle_interface(name)
|
94
|
-
#
|
95
|
-
# @return [void]
|
96
|
-
def toggle
|
97
|
-
return hide if visible?
|
98
|
-
|
99
|
-
show
|
100
|
-
end
|
101
|
-
|
102
90
|
private
|
103
91
|
|
104
92
|
# The default values for a new instance of this class.
|
@@ -38,10 +38,8 @@ module Vedeu
|
|
38
38
|
def prune
|
39
39
|
return text if text.size <= pruned_width
|
40
40
|
|
41
|
-
|
42
|
-
split_lines.reduce([])
|
43
|
-
acc << ellipsis_string(line)
|
44
|
-
end
|
41
|
+
if split_lines.size > 1
|
42
|
+
split_lines.reduce([]) { |a, e| a << ellipsis_string(e) }
|
45
43
|
|
46
44
|
else
|
47
45
|
ellipsis_string(text)
|
@@ -71,7 +69,7 @@ module Vedeu
|
|
71
69
|
processed << reformatted
|
72
70
|
end
|
73
71
|
|
74
|
-
processed.reduce([]) { |
|
72
|
+
processed.reduce([]) { |a, e| a << e.join(' ') }
|
75
73
|
end
|
76
74
|
|
77
75
|
protected
|
@@ -107,10 +107,16 @@ module Vedeu
|
|
107
107
|
Object.const_get(dsl_class).new(self, client)
|
108
108
|
end
|
109
109
|
|
110
|
+
# @note If a block is given, store the model, return the model
|
111
|
+
# after yielding.
|
110
112
|
# @todo Perhaps some validation could be added here?
|
111
113
|
# @return [void] The model instance stored in the repository.
|
112
114
|
def store
|
113
|
-
repository.store(self)
|
115
|
+
new_model = repository.store(self)
|
116
|
+
|
117
|
+
yield if block_given?
|
118
|
+
|
119
|
+
new_model
|
114
120
|
end
|
115
121
|
|
116
122
|
private
|
@@ -123,6 +129,7 @@ module Vedeu
|
|
123
129
|
when 'Border' then 'Vedeu::Borders::DSL'
|
124
130
|
when 'Buffer' then 'Vedeu::Buffers::DSL'
|
125
131
|
when 'Geometry' then 'Vedeu::Geometry::DSL'
|
132
|
+
when 'Group' then 'Vedeu::Groups::DSL'
|
126
133
|
when 'Menu' then 'Vedeu::Menus::DSL'
|
127
134
|
# when 'ModelTestClass' then 'Vedeu::Repositories::ModelTestClass::DSL'
|
128
135
|
else
|
@@ -24,11 +24,11 @@ module Vedeu
|
|
24
24
|
while @loop
|
25
25
|
yield
|
26
26
|
|
27
|
-
Vedeu
|
27
|
+
Vedeu.trigger(:_hide_cursor_)
|
28
28
|
|
29
29
|
Vedeu::Terminal::Buffer.render
|
30
30
|
|
31
|
-
Vedeu
|
31
|
+
Vedeu.trigger(:_show_cursor_)
|
32
32
|
|
33
33
|
safe_exit_point!
|
34
34
|
end
|
data/lib/vedeu/version.rb
CHANGED
@@ -32,7 +32,7 @@ module Vedeu
|
|
32
32
|
it { Vedeu.must_respond_to(:group) }
|
33
33
|
|
34
34
|
describe 'Vedeu.height' do
|
35
|
-
before { Terminal.stubs(:size).returns([25, 40]) }
|
35
|
+
before { Vedeu::Terminal.stubs(:size).returns([25, 40]) }
|
36
36
|
|
37
37
|
it { Vedeu.must_respond_to(:height) }
|
38
38
|
it { Vedeu.height.must_equal(25) }
|
@@ -77,6 +77,33 @@ module Vedeu
|
|
77
77
|
it { subject.must_equal(true) }
|
78
78
|
end
|
79
79
|
|
80
|
+
describe '.setup_aliases!' do
|
81
|
+
before do
|
82
|
+
Vedeu::Bindings::Application.stubs(:setup_aliases!)
|
83
|
+
Vedeu::Bindings::Movement.stubs(:setup_aliases!)
|
84
|
+
Vedeu::Bindings::Visibility.stubs(:setup_aliases!)
|
85
|
+
end
|
86
|
+
|
87
|
+
subject { described.setup_aliases! }
|
88
|
+
|
89
|
+
it {
|
90
|
+
Vedeu::Bindings::Application.expects(:setup_aliases!)
|
91
|
+
subject
|
92
|
+
}
|
93
|
+
|
94
|
+
it {
|
95
|
+
Vedeu::Bindings::Movement.expects(:setup_aliases!)
|
96
|
+
subject
|
97
|
+
}
|
98
|
+
|
99
|
+
it {
|
100
|
+
Vedeu::Bindings::Visibility.expects(:setup_aliases!)
|
101
|
+
subject
|
102
|
+
}
|
103
|
+
|
104
|
+
it { subject.must_equal(true) }
|
105
|
+
end
|
106
|
+
|
80
107
|
end # Bindings
|
81
108
|
|
82
109
|
end # Vedeu
|
@@ -32,8 +32,6 @@ module Vedeu
|
|
32
32
|
}
|
33
33
|
let(:geometry) {}
|
34
34
|
|
35
|
-
before { Vedeu.geometries.stubs(:by_name).returns(geometry) }
|
36
|
-
|
37
35
|
describe '.build' do
|
38
36
|
subject {
|
39
37
|
described.build(attributes) do
|
@@ -53,40 +51,42 @@ module Vedeu
|
|
53
51
|
end
|
54
52
|
|
55
53
|
describe 'accessors' do
|
56
|
-
it {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
54
|
+
it {
|
55
|
+
instance.must_respond_to(:attributes)
|
56
|
+
instance.must_respond_to(:attributes=)
|
57
|
+
instance.must_respond_to(:bottom_left)
|
58
|
+
instance.must_respond_to(:bottom_left=)
|
59
|
+
instance.must_respond_to(:bottom_right)
|
60
|
+
instance.must_respond_to(:bottom_right=)
|
61
|
+
instance.must_respond_to(:caption)
|
62
|
+
instance.must_respond_to(:caption=)
|
63
|
+
instance.must_respond_to(:horizontal)
|
64
|
+
instance.must_respond_to(:horizontal=)
|
65
|
+
instance.must_respond_to(:show_bottom)
|
66
|
+
instance.must_respond_to(:bottom?)
|
67
|
+
instance.must_respond_to(:show_bottom=)
|
68
|
+
instance.must_respond_to(:show_left)
|
69
|
+
instance.must_respond_to(:left?)
|
70
|
+
instance.must_respond_to(:show_left=)
|
71
|
+
instance.must_respond_to(:show_right)
|
72
|
+
instance.must_respond_to(:right?)
|
73
|
+
instance.must_respond_to(:show_right=)
|
74
|
+
instance.must_respond_to(:show_top)
|
75
|
+
instance.must_respond_to(:top?)
|
76
|
+
instance.must_respond_to(:show_top=)
|
77
|
+
instance.must_respond_to(:title)
|
78
|
+
instance.must_respond_to(:title=)
|
79
|
+
instance.must_respond_to(:top_left)
|
80
|
+
instance.must_respond_to(:top_left=)
|
81
|
+
instance.must_respond_to(:top_right)
|
82
|
+
instance.must_respond_to(:top_right=)
|
83
|
+
instance.must_respond_to(:vertical)
|
84
|
+
instance.must_respond_to(:vertical=)
|
85
|
+
instance.must_respond_to(:name)
|
86
|
+
instance.must_respond_to(:enabled)
|
87
|
+
instance.must_respond_to(:enabled=)
|
88
|
+
instance.must_respond_to(:enabled?)
|
89
|
+
}
|
90
90
|
end
|
91
91
|
|
92
92
|
describe 'border offset methods; bx, bxn, by, byn' do
|
@@ -116,9 +116,11 @@ module Vedeu
|
|
116
116
|
x: 2,
|
117
117
|
xn: 6,
|
118
118
|
y: 2,
|
119
|
-
yn:
|
119
|
+
yn: 6)
|
120
120
|
}
|
121
121
|
|
122
|
+
before { Vedeu.geometries.stubs(:by_name).returns(geometry) }
|
123
|
+
|
122
124
|
describe '#bx' do
|
123
125
|
subject { instance.bx }
|
124
126
|
|
@@ -213,6 +215,8 @@ module Vedeu
|
|
213
215
|
Vedeu::Geometry::Geometry.new(name: 'borders', width: 8)
|
214
216
|
}
|
215
217
|
|
218
|
+
before { Vedeu.geometries.stubs(:by_name).returns(geometry) }
|
219
|
+
|
216
220
|
subject { instance.width }
|
217
221
|
|
218
222
|
context 'when the border is not enabled' do
|
@@ -265,6 +269,8 @@ module Vedeu
|
|
265
269
|
Vedeu::Geometry::Geometry.new(name: 'borders', height: 5)
|
266
270
|
}
|
267
271
|
|
272
|
+
before { Vedeu.geometries.stubs(:by_name).returns(geometry) }
|
273
|
+
|
268
274
|
subject { instance.height }
|
269
275
|
|
270
276
|
context 'when the border is not enabled' do
|