vedeu 0.4.55 → 0.4.56
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu.rb +1 -1
- data/lib/vedeu/application.rb +2 -2
- data/lib/vedeu/buffers/buffer.rb +3 -3
- data/lib/vedeu/buffers/buffers.rb +1 -1
- data/lib/vedeu/buffers/display_buffer.rb +3 -3
- data/lib/vedeu/colours/colour.rb +1 -1
- data/lib/vedeu/colours/colour_translator.rb +4 -4
- data/lib/vedeu/configuration/api.rb +4 -4
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/configuration/configuration.rb +2 -2
- data/lib/vedeu/cursor/cursor.rb +5 -5
- data/lib/vedeu/cursor/cursors.rb +1 -1
- data/lib/vedeu/cursor/move.rb +8 -8
- data/lib/vedeu/cursor/reposition.rb +2 -2
- data/lib/vedeu/distributed/client.rb +1 -1
- data/lib/vedeu/distributed/server.rb +1 -1
- data/lib/vedeu/distributed/test_application.rb +1 -1
- data/lib/vedeu/distributed/uri.rb +1 -1
- data/lib/vedeu/dsl/border.rb +3 -3
- data/lib/vedeu/dsl/composition.rb +4 -4
- data/lib/vedeu/dsl/geometry.rb +4 -4
- data/lib/vedeu/dsl/group.rb +4 -4
- data/lib/vedeu/dsl/interface.rb +9 -9
- data/lib/vedeu/dsl/keymap.rb +10 -8
- data/lib/vedeu/dsl/line.rb +5 -5
- data/lib/vedeu/dsl/stream.rb +2 -2
- data/lib/vedeu/dsl/use.rb +2 -2
- data/lib/vedeu/dsl/view.rb +7 -7
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/events/events.rb +1 -1
- data/lib/vedeu/geometry/geometries.rb +1 -1
- data/lib/vedeu/geometry/grid.rb +8 -8
- data/lib/vedeu/geometry/position_validator.rb +1 -1
- data/lib/vedeu/input/input.rb +1 -1
- data/lib/vedeu/input/key.rb +2 -2
- data/lib/vedeu/input/keymap.rb +1 -1
- data/lib/vedeu/input/keymaps.rb +1 -1
- data/lib/vedeu/input/mapper.rb +3 -3
- data/lib/vedeu/launcher.rb +1 -1
- data/lib/vedeu/log.rb +7 -7
- data/lib/vedeu/models/all.rb +1 -2
- data/lib/vedeu/models/char.rb +1 -1
- data/lib/vedeu/models/composition.rb +2 -2
- data/lib/vedeu/models/{escape_char.rb → escape.rb} +5 -5
- data/lib/vedeu/models/focus.rb +5 -3
- data/lib/vedeu/models/groups.rb +1 -1
- data/lib/vedeu/models/interface.rb +1 -1
- data/lib/vedeu/models/interfaces.rb +1 -1
- data/lib/vedeu/models/line.rb +2 -2
- data/lib/vedeu/models/menu.rb +3 -3
- data/lib/vedeu/models/menus.rb +1 -1
- data/lib/vedeu/models/stream.rb +1 -1
- data/lib/vedeu/output/border.rb +2 -2
- data/lib/vedeu/output/borders.rb +1 -1
- data/lib/vedeu/output/html_char.rb +42 -21
- data/lib/vedeu/output/refresh.rb +4 -4
- data/lib/vedeu/output/renderers/html.rb +22 -5
- data/lib/vedeu/output/renderers/renderer_options.rb +4 -0
- data/lib/vedeu/output/style.rb +1 -1
- data/lib/vedeu/output/text.rb +1 -1
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/output/virtual_terminal.rb +2 -1
- data/lib/vedeu/repositories/collection.rb +1 -1
- data/lib/vedeu/repositories/repository.rb +9 -5
- data/lib/vedeu/templating/helpers.rb +4 -4
- data/lib/vedeu/templating/template.rb +6 -4
- data/lib/vedeu/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/cursor/cursor_test.rb +2 -2
- data/test/lib/vedeu/models/{escape_char_test.rb → escape_test.rb} +4 -4
- data/test/lib/vedeu/models/group_test.rb +12 -0
- data/test/lib/vedeu/output/compressor_test.rb +2 -2
- data/test/lib/vedeu/output/html_char_test.rb +9 -2
- data/test/lib/vedeu/repositories/all_test.rb +21 -0
- data/test/lib/vedeu/repositories/repository_test.rb +2 -2
- metadata +6 -4
data/lib/vedeu/models/focus.rb
CHANGED
@@ -50,11 +50,13 @@ module Vedeu
|
|
50
50
|
# Vedeu.focus_by_name('name')
|
51
51
|
#
|
52
52
|
# @param name [String] The interface to focus; must be defined.
|
53
|
-
# @raise [ModelNotFound] When the interface cannot be found.
|
53
|
+
# @raise [Vedeu::ModelNotFound] When the interface cannot be found.
|
54
54
|
# @return [String] The name of the interface now in focus.
|
55
55
|
def by_name(name)
|
56
|
-
|
57
|
-
|
56
|
+
unless registered?(name)
|
57
|
+
fail Vedeu::ModelNotFound, "Cannot focus '#{name}' as this interface " \
|
58
|
+
'has not been registered.'
|
59
|
+
end
|
58
60
|
|
59
61
|
storage.rotate!(storage.index(name))
|
60
62
|
|
data/lib/vedeu/models/groups.rb
CHANGED
data/lib/vedeu/models/line.rb
CHANGED
@@ -14,7 +14,7 @@ module Vedeu
|
|
14
14
|
member Vedeu::Stream
|
15
15
|
|
16
16
|
# @!attribute [rw] parent
|
17
|
-
# @return [Interface]
|
17
|
+
# @return [Vedeu::Interface]
|
18
18
|
attr_accessor :parent
|
19
19
|
|
20
20
|
# @!attribute [r] attributes
|
@@ -35,7 +35,7 @@ module Vedeu
|
|
35
35
|
@attributes.each { |key, value| instance_variable_set("@#{key}", value) }
|
36
36
|
end
|
37
37
|
|
38
|
-
# @param child []
|
38
|
+
# @param child [void]
|
39
39
|
# @return [void]
|
40
40
|
def add(child)
|
41
41
|
@_streams = @streams = collection.coerce(streams, self).add(child)
|
data/lib/vedeu/models/menu.rb
CHANGED
@@ -50,10 +50,10 @@ module Vedeu
|
|
50
50
|
# # ...
|
51
51
|
# end
|
52
52
|
#
|
53
|
-
# @raise [InvalidSyntax] The required block was not given.
|
53
|
+
# @raise [Vedeu::InvalidSyntax] The required block was not given.
|
54
54
|
# @return [API::Menu]
|
55
55
|
def self.menu(name = '', &block)
|
56
|
-
fail InvalidSyntax, 'block not given' unless block_given?
|
56
|
+
fail Vedeu::InvalidSyntax, 'block not given' unless block_given?
|
57
57
|
|
58
58
|
build({ name: name }, &block).store
|
59
59
|
end
|
@@ -65,7 +65,7 @@ module Vedeu
|
|
65
65
|
# @option attributes name [String]
|
66
66
|
# @option attributes current [Fixnum]
|
67
67
|
# @option attributes selected [Fixnum|NilClass]
|
68
|
-
# @return [Menu]
|
68
|
+
# @return [Vedeu::Menu]
|
69
69
|
def initialize(attributes = {})
|
70
70
|
@attributes = defaults.merge!(attributes)
|
71
71
|
|
data/lib/vedeu/models/menus.rb
CHANGED
data/lib/vedeu/models/stream.rb
CHANGED
data/lib/vedeu/output/border.rb
CHANGED
@@ -99,7 +99,7 @@ module Vedeu
|
|
99
99
|
# @option attributes horizontal [String] The horizontal border character.
|
100
100
|
# @option attributes name [String] The name of the interface to which this
|
101
101
|
# border relates.
|
102
|
-
# @option attributes style []
|
102
|
+
# @option attributes style [Vedeu::Style]
|
103
103
|
# @option attributes show_bottom [Boolean] Indicate whether the bottom
|
104
104
|
# border is to be shown.
|
105
105
|
# @option attributes show_left [Boolean] Indicate whether the left border
|
@@ -113,7 +113,7 @@ module Vedeu
|
|
113
113
|
# @option attributes top_left [String] The top left border character.
|
114
114
|
# @option attributes top_right [String] The top right border character.
|
115
115
|
# @option attributes vertical [String] The vertical border character.
|
116
|
-
# @return [Border]
|
116
|
+
# @return [Vedeu::Border]
|
117
117
|
def initialize(attributes = {})
|
118
118
|
@attributes = defaults.merge!(attributes)
|
119
119
|
|
data/lib/vedeu/output/borders.rb
CHANGED
@@ -2,7 +2,8 @@ require 'vedeu/common'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
# Represents a {Vedeu::Char} as a HTML
|
5
|
+
# Represents a {Vedeu::Char} as a HTML tag with value. By default, a table
|
6
|
+
# cell is used.
|
6
7
|
#
|
7
8
|
# @api private
|
8
9
|
class HTMLChar
|
@@ -10,22 +11,29 @@ module Vedeu
|
|
10
11
|
include Vedeu::Common
|
11
12
|
|
12
13
|
# @param char [Vedeu::Char]
|
14
|
+
# @param options [Hash<Symbol => String>]
|
15
|
+
# @option options start_tag [String]
|
16
|
+
# @option options end_tag [String]
|
13
17
|
# @return [String]
|
14
|
-
def self.render(char)
|
15
|
-
new(char).render
|
18
|
+
def self.render(char, options = {})
|
19
|
+
new(char, options).render
|
16
20
|
end
|
17
21
|
|
18
22
|
# Returns a new instance of Vedeu::HTMLChar.
|
19
23
|
#
|
20
24
|
# @param char [Vedeu::Char]
|
25
|
+
# @param options [Hash<Symbol => String>]
|
26
|
+
# @option options start_tag [String]
|
27
|
+
# @option options end_tag [String]
|
21
28
|
# @return [Vedeu::HTMLChar]
|
22
|
-
def initialize(char)
|
23
|
-
@char
|
29
|
+
def initialize(char, options = {})
|
30
|
+
@char = char
|
31
|
+
@options = options
|
24
32
|
end
|
25
33
|
|
26
34
|
# @return [String]
|
27
35
|
def render
|
28
|
-
|
36
|
+
[start_tag, tag_style, '>', tag_value, end_tag].join
|
29
37
|
end
|
30
38
|
|
31
39
|
protected
|
@@ -37,7 +45,7 @@ module Vedeu
|
|
37
45
|
private
|
38
46
|
|
39
47
|
# @return [String]
|
40
|
-
def
|
48
|
+
def tag_style
|
41
49
|
return '' unless border || present?(value)
|
42
50
|
|
43
51
|
" style='" \
|
@@ -48,7 +56,7 @@ module Vedeu
|
|
48
56
|
end
|
49
57
|
|
50
58
|
# @return [String]
|
51
|
-
def
|
59
|
+
def tag_value
|
52
60
|
return ' ' if border || !present?(value)
|
53
61
|
|
54
62
|
value
|
@@ -77,25 +85,15 @@ module Vedeu
|
|
77
85
|
|
78
86
|
# @return [String]
|
79
87
|
def fg
|
80
|
-
@fg ||=
|
88
|
+
@fg ||= colour(char, 'foreground', '#222')
|
81
89
|
end
|
82
90
|
|
83
91
|
# @return [String]
|
84
92
|
def bg
|
85
|
-
@bg ||=
|
93
|
+
@bg ||= colour(char, 'background', '#000')
|
86
94
|
end
|
87
95
|
|
88
|
-
# @
|
89
|
-
def colour_bg
|
90
|
-
colour(char, 'background', '#000')
|
91
|
-
end
|
92
|
-
|
93
|
-
# @return [String]
|
94
|
-
def colour_fg
|
95
|
-
colour(char, 'foreground', '#222')
|
96
|
-
end
|
97
|
-
|
98
|
-
# @param char []
|
96
|
+
# @param char [Vedeu::Char]
|
99
97
|
# @param type [String]
|
100
98
|
# @param default [String]
|
101
99
|
# @return [String]
|
@@ -126,6 +124,29 @@ module Vedeu
|
|
126
124
|
char.value
|
127
125
|
end
|
128
126
|
|
127
|
+
# @return [String]
|
128
|
+
def start_tag
|
129
|
+
options[:start_tag]
|
130
|
+
end
|
131
|
+
|
132
|
+
# @return [String]
|
133
|
+
def end_tag
|
134
|
+
options[:end_tag]
|
135
|
+
end
|
136
|
+
|
137
|
+
# @return [Hash<Symbol => String>]
|
138
|
+
def options
|
139
|
+
defaults.merge!(@options)
|
140
|
+
end
|
141
|
+
|
142
|
+
# @return [Hash<Symbol => String>]
|
143
|
+
def defaults
|
144
|
+
{
|
145
|
+
start_tag: '<td',
|
146
|
+
end_tag: '</td>',
|
147
|
+
}
|
148
|
+
end
|
149
|
+
|
129
150
|
end # HTMLChar
|
130
151
|
|
131
152
|
end # Vedeu
|
data/lib/vedeu/output/refresh.rb
CHANGED
@@ -30,7 +30,7 @@ module Vedeu
|
|
30
30
|
|
31
31
|
# Refresh the interface which is currently focussed.
|
32
32
|
#
|
33
|
-
# @return [Array|ModelNotFound|NilClass]
|
33
|
+
# @return [Array|Vedeu::ModelNotFound|NilClass]
|
34
34
|
def by_focus
|
35
35
|
by_name(Vedeu.focus) if Vedeu.focus
|
36
36
|
end
|
@@ -43,8 +43,8 @@ module Vedeu
|
|
43
43
|
# Vedeu::Refresh.by_group(group_name)
|
44
44
|
#
|
45
45
|
# @param group_name [String] The name of the group to be refreshed.
|
46
|
-
# @return [Array|ModelNotFound] A collection of the names of
|
47
|
-
# refreshed, or an exception if the group was not found.
|
46
|
+
# @return [Array|Vedeu::ModelNotFound] A collection of the names of
|
47
|
+
# interfaces refreshed, or an exception if the group was not found.
|
48
48
|
def by_group(group_name)
|
49
49
|
Vedeu.timer("Refresh Group: '#{group_name}'") do
|
50
50
|
Vedeu::RefreshGroup.by_name(group_name)
|
@@ -60,7 +60,7 @@ module Vedeu
|
|
60
60
|
#
|
61
61
|
# @param name [String] The name of the interface to be refreshed using the
|
62
62
|
# named buffer.
|
63
|
-
# @return [Array|ModelNotFound]
|
63
|
+
# @return [Array|Vedeu::ModelNotFound]
|
64
64
|
def by_name(name)
|
65
65
|
Vedeu.timer("Refresh Interface: '#{name}'") do
|
66
66
|
Vedeu.buffers.by_name(name).render
|
@@ -2,7 +2,8 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Renderers
|
4
4
|
|
5
|
-
# Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML
|
5
|
+
# Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML snippet;
|
6
|
+
# a table by default.
|
6
7
|
#
|
7
8
|
# @api private
|
8
9
|
class HTML < Vedeu::Renderers::File
|
@@ -10,6 +11,10 @@ module Vedeu
|
|
10
11
|
# Returns a new instance of Vedeu::Renderers::HTML.
|
11
12
|
#
|
12
13
|
# @param options [Hash]
|
14
|
+
# @option options content [String]
|
15
|
+
# @option options end_row_tag [String]
|
16
|
+
# @option options start_row_tag [String]
|
17
|
+
# @option options template [String]
|
13
18
|
# @return [Vedeu::Renderers::HTML]
|
14
19
|
def initialize(options = {})
|
15
20
|
@options = options || {}
|
@@ -33,14 +38,14 @@ module Vedeu
|
|
33
38
|
def html_body
|
34
39
|
out = ''
|
35
40
|
Array(content).each do |line|
|
36
|
-
out << "
|
41
|
+
out << "#{start_row_tag}\n"
|
37
42
|
line.each do |char|
|
38
43
|
if char.is_a?(Vedeu::Char)
|
39
44
|
out << char.to_html
|
40
45
|
out << "\n"
|
41
46
|
end
|
42
47
|
end
|
43
|
-
out << "
|
48
|
+
out << "#{end_row_tag}\n"
|
44
49
|
end
|
45
50
|
out
|
46
51
|
end
|
@@ -52,6 +57,16 @@ module Vedeu
|
|
52
57
|
options[:content]
|
53
58
|
end
|
54
59
|
|
60
|
+
# @return [String]
|
61
|
+
def end_row_tag
|
62
|
+
options[:end_row_tag]
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [String]
|
66
|
+
def start_row_tag
|
67
|
+
options[:start_row_tag]
|
68
|
+
end
|
69
|
+
|
55
70
|
# @return [String]
|
56
71
|
def template
|
57
72
|
options[:template]
|
@@ -69,8 +84,10 @@ module Vedeu
|
|
69
84
|
# @return [Hash<Symbol => void>]
|
70
85
|
def defaults
|
71
86
|
{
|
72
|
-
content:
|
73
|
-
|
87
|
+
content: '',
|
88
|
+
end_row_tag: '</tr>',
|
89
|
+
start_row_tag: '<tr>',
|
90
|
+
template: default_template,
|
74
91
|
}
|
75
92
|
end
|
76
93
|
|
@@ -5,6 +5,8 @@ module Vedeu
|
|
5
5
|
# @api private
|
6
6
|
module RendererOptions
|
7
7
|
|
8
|
+
# :nocov:
|
9
|
+
|
8
10
|
private
|
9
11
|
|
10
12
|
# Combines the options provided at instantiation with the default values.
|
@@ -21,6 +23,8 @@ module Vedeu
|
|
21
23
|
{}
|
22
24
|
end
|
23
25
|
|
26
|
+
# :nocov
|
27
|
+
|
24
28
|
end # RendererOptions
|
25
29
|
|
26
30
|
end # Vedeu
|
data/lib/vedeu/output/style.rb
CHANGED
data/lib/vedeu/output/text.rb
CHANGED
@@ -26,7 +26,7 @@ module Vedeu
|
|
26
26
|
# @option options model [Vedeu::Interface|Vedeu::Line|Vedeu::Stream]
|
27
27
|
# @option options pad [String]
|
28
28
|
# @option options width [Integer]
|
29
|
-
# @return [Text]
|
29
|
+
# @return [Vedeu::Text]
|
30
30
|
def initialize(value = '', options = {})
|
31
31
|
@value = value
|
32
32
|
@options = defaults.merge!(options)
|
@@ -39,7 +39,7 @@ module Vedeu
|
|
39
39
|
|
40
40
|
# Returns an instance of Vedeu::Viewport.
|
41
41
|
#
|
42
|
-
# @param interface [Interface] An instance of interface.
|
42
|
+
# @param interface [Vedeu::Interface] An instance of interface.
|
43
43
|
# @return [Viewport]
|
44
44
|
def initialize(interface)
|
45
45
|
@interface = interface
|
@@ -21,7 +21,8 @@ module Vedeu
|
|
21
21
|
#
|
22
22
|
# @param height [Fixnum]
|
23
23
|
# @param width [Fixnum]
|
24
|
-
# @param renderer [Object|Renderers::HTML] An object responding to
|
24
|
+
# @param renderer [Object|Vedeu::Renderers::HTML] An object responding to
|
25
|
+
# .render.
|
25
26
|
# @return [Vedeu::VirtualTerminal]
|
26
27
|
def initialize(height, width, renderer = Vedeu::Renderers::HTML.new)
|
27
28
|
@height = height
|
@@ -92,10 +92,12 @@ module Vedeu
|
|
92
92
|
# be found.
|
93
93
|
#
|
94
94
|
# @param name [String]
|
95
|
-
# @raise [ModelNotFound] When the model cannot be found with this
|
95
|
+
# @raise [Vedeu::ModelNotFound] When the model cannot be found with this
|
96
|
+
# name.
|
96
97
|
# @return [Hash<String => Object>]
|
97
98
|
def find!(name)
|
98
|
-
find(name) || fail(ModelNotFound,
|
99
|
+
find(name) || fail(Vedeu::ModelNotFound,
|
100
|
+
"Cannot find model by name: '#{name}'")
|
99
101
|
end
|
100
102
|
|
101
103
|
# Find a model by name, registers the model by name if not found.
|
@@ -156,11 +158,13 @@ module Vedeu
|
|
156
158
|
# Stores the model instance by name in the repository of the model.
|
157
159
|
#
|
158
160
|
# @param model [void] A model instance.
|
159
|
-
# @raise [MissingRequired] When the name attribute is not defined.
|
161
|
+
# @raise [Vedeu::MissingRequired] When the name attribute is not defined.
|
160
162
|
# @return [void] The model instance which was stored.
|
161
163
|
def store(model)
|
162
|
-
|
163
|
-
|
164
|
+
unless present?(model.name)
|
165
|
+
fail Vedeu::MissingRequired, "Cannot store model '#{model.class}' " \
|
166
|
+
'without a name attribute.'
|
167
|
+
end
|
164
168
|
|
165
169
|
log_store(model)
|
166
170
|
|