vedeu 0.6.10 → 0.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vedeu/all.rb +17 -103
- data/lib/vedeu/api/all.rb +15 -0
- data/lib/vedeu/api/internal.rb +4 -0
- data/lib/vedeu/application/all.rb +6 -0
- data/lib/vedeu/bindings/all.rb +32 -0
- data/lib/vedeu/bindings/bindings.rb +0 -14
- data/lib/vedeu/bindings/refresh.rb +8 -2
- data/lib/vedeu/bindings/system.rb +1 -0
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/repository.rb +1 -1
- data/lib/vedeu/buffers/buffer.rb +2 -4
- data/lib/vedeu/buffers/repository.rb +1 -1
- data/lib/vedeu/colours/background.rb +1 -1
- data/lib/vedeu/colours/backgrounds.rb +1 -1
- data/lib/vedeu/colours/foreground.rb +1 -1
- data/lib/vedeu/colours/foregrounds.rb +1 -1
- data/lib/vedeu/colours/translator.rb +4 -3
- data/lib/vedeu/configuration/api.rb +2 -1
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/cursors/cursor.rb +26 -26
- data/lib/vedeu/cursors/repository.rb +1 -1
- data/lib/vedeu/distributed/all.rb +16 -0
- data/lib/vedeu/distributed/test_application.rb +3 -3
- data/lib/vedeu/dsl/all.rb +22 -0
- data/lib/vedeu/dsl/composition.rb +43 -40
- data/lib/vedeu/dsl/dsl.rb +6 -3
- data/lib/vedeu/dsl/group.rb +23 -16
- data/lib/vedeu/dsl/interface.rb +48 -38
- data/lib/vedeu/dsl/keymap.rb +6 -7
- data/lib/vedeu/dsl/line.rb +6 -3
- data/lib/vedeu/dsl/stream.rb +2 -1
- data/lib/vedeu/editor/cursor.rb +1 -3
- data/lib/vedeu/editor/document.rb +4 -5
- data/lib/vedeu/editor/documents.rb +1 -1
- data/lib/vedeu/editor/line.rb +2 -3
- data/lib/vedeu/editor/lines.rb +2 -3
- data/lib/vedeu/esc/all.rb +14 -0
- data/lib/vedeu/esc/colours.rb +8 -4
- data/lib/vedeu/esc/esc.rb +89 -84
- data/lib/vedeu/events/aliases.rb +1 -2
- data/lib/vedeu/events/collection.rb +1 -1
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/events/repository.rb +1 -1
- data/lib/vedeu/events/trigger.rb +11 -9
- data/lib/vedeu/geometry/dimension.rb +1 -3
- data/lib/vedeu/geometry/generic_coordinate.rb +1 -3
- data/lib/vedeu/geometry/geometry.rb +1 -1
- data/lib/vedeu/geometry/repository.rb +3 -3
- data/lib/vedeu/input/all.rb +3 -0
- data/lib/vedeu/input/keymap.rb +10 -11
- data/lib/vedeu/input/keymaps.rb +1 -1
- data/lib/vedeu/input/keys.rb +1 -1
- data/lib/vedeu/input/mapper.rb +14 -12
- data/lib/vedeu/logging/all.rb +3 -0
- data/lib/vedeu/logging/log.rb +4 -2
- data/lib/vedeu/menus/menu.rb +2 -4
- data/lib/vedeu/menus/repository.rb +1 -1
- data/lib/vedeu/models/all.rb +15 -0
- data/lib/vedeu/models/cell.rb +1 -1
- data/lib/vedeu/models/escape.rb +1 -1
- data/lib/vedeu/models/group.rb +4 -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/views/char.rb +1 -1
- data/lib/vedeu/models/views/collections/chars.rb +1 -1
- data/lib/vedeu/models/views/collections/lines.rb +1 -1
- data/lib/vedeu/models/views/collections/streams.rb +1 -1
- data/lib/vedeu/models/views/collections/view_collection.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +8 -6
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/all.rb +12 -0
- data/lib/vedeu/output/clear/named_group.rb +2 -1
- data/lib/vedeu/output/clear/named_interface.rb +5 -4
- data/lib/vedeu/output/compressor.rb +1 -0
- data/lib/vedeu/output/output.rb +3 -0
- data/lib/vedeu/output/presentation/colour.rb +10 -10
- data/lib/vedeu/output/presentation/presentation.rb +9 -9
- data/lib/vedeu/output/presentation/style.rb +2 -2
- data/lib/vedeu/output/refresh/refresh.rb +35 -0
- data/lib/vedeu/output/refresh/refresh_group.rb +66 -0
- data/lib/vedeu/output/renderers/all.rb +17 -0
- data/lib/vedeu/output/renderers/escape_sequence.rb +4 -2
- data/lib/vedeu/output/renderers/file.rb +7 -6
- data/lib/vedeu/output/renderers/html.rb +9 -7
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/renderer_options.rb +24 -20
- data/lib/vedeu/output/renderers/terminal.rb +1 -1
- data/lib/vedeu/output/renderers/text.rb +1 -1
- data/lib/vedeu/output/wordwrap.rb +7 -4
- data/lib/vedeu/plugins/all.rb +2 -0
- data/lib/vedeu/repositories/all.rb +16 -0
- data/lib/vedeu/repositories/collection.rb +93 -89
- data/lib/vedeu/repositories/model.rb +113 -102
- data/lib/vedeu/repositories/registerable.rb +60 -56
- data/lib/vedeu/repositories/repository.rb +161 -156
- data/lib/vedeu/repositories/store.rb +70 -66
- data/lib/vedeu/runtime/all.rb +15 -0
- data/lib/vedeu/runtime/launcher.rb +19 -16
- data/lib/vedeu/templating/all.rb +6 -0
- data/lib/vedeu/terminal/all.rb +14 -0
- data/lib/vedeu/terminal/buffer.rb +8 -7
- data/lib/vedeu/terminal/mode.rb +11 -10
- data/lib/vedeu/terminal/terminal.rb +50 -45
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/cursors/cursor_test.rb +4 -2
- data/test/lib/vedeu/editor/cursor_test.rb +0 -3
- data/test/lib/vedeu/esc/esc_test.rb +58 -54
- data/test/lib/vedeu/events/collection_test.rb +1 -1
- data/test/lib/vedeu/input/keys_test.rb +1 -1
- data/test/lib/vedeu/input/mapper_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/chars_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/lines_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/streams_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/view_collection_test.rb +1 -1
- data/test/lib/vedeu/output/refresh/refresh_group_test.rb +43 -0
- data/test/lib/vedeu/output/refresh/refresh_test.rb +50 -0
- data/test/lib/vedeu/output/renderers/renderer_options_test.rb +8 -4
- data/test/lib/vedeu/output/renderers_test.rb +2 -1
- data/test/lib/vedeu/repositories/collection_test.rb +105 -101
- data/test/lib/vedeu/repositories/model_test.rb +56 -52
- data/test/lib/vedeu/repositories/registerable_test.rb +36 -32
- data/test/lib/vedeu/repositories/repository_test.rb +178 -174
- data/test/lib/vedeu/repositories/store_test.rb +109 -105
- data/test/support/examples/material_colours_app.rb +0 -1
- data/test/support/helpers/model_test_class.rb +50 -46
- data/test/test_helper.rb +2 -2
- metadata +21 -9
- data/lib/vedeu/refresh/refresh.rb +0 -31
- data/lib/vedeu/refresh/refresh_group.rb +0 -59
- data/out_ +0 -50
- data/test/lib/vedeu/refresh/refresh_group_test.rb +0 -39
- data/test/lib/vedeu/refresh/refresh_test.rb +0 -46
data/lib/vedeu/terminal/mode.rb
CHANGED
@@ -8,8 +8,8 @@ module Vedeu
|
|
8
8
|
|
9
9
|
extend self
|
10
10
|
|
11
|
-
# Returns a boolean indicating whether the terminal is currently
|
12
|
-
# `cooked` mode.
|
11
|
+
# Returns a boolean indicating whether the terminal is currently
|
12
|
+
# in `cooked` mode.
|
13
13
|
#
|
14
14
|
# @return [Boolean]
|
15
15
|
def cooked_mode?
|
@@ -23,8 +23,8 @@ module Vedeu
|
|
23
23
|
@mode = :cooked
|
24
24
|
end
|
25
25
|
|
26
|
-
# Returns a boolean indicating whether the terminal is currently
|
27
|
-
# mode.
|
26
|
+
# Returns a boolean indicating whether the terminal is currently
|
27
|
+
# in `fake` mode.
|
28
28
|
#
|
29
29
|
# @return [Boolean]
|
30
30
|
def fake_mode?
|
@@ -38,8 +38,8 @@ module Vedeu
|
|
38
38
|
@mode = :fake
|
39
39
|
end
|
40
40
|
|
41
|
-
# Returns a boolean indicating whether the terminal is currently
|
42
|
-
# mode.
|
41
|
+
# Returns a boolean indicating whether the terminal is currently
|
42
|
+
# in `raw` mode.
|
43
43
|
#
|
44
44
|
# @return [Boolean]
|
45
45
|
def raw_mode?
|
@@ -53,8 +53,8 @@ module Vedeu
|
|
53
53
|
@mode = :raw
|
54
54
|
end
|
55
55
|
|
56
|
-
# Toggles the terminal's mode between `cooked`, `fake` and
|
57
|
-
# depending on its current mode.
|
56
|
+
# Toggles the terminal's mode between `cooked`, `fake` and
|
57
|
+
# `raw`, depending on its current mode.
|
58
58
|
#
|
59
59
|
# @return [Symbol]
|
60
60
|
def switch_mode!
|
@@ -64,8 +64,9 @@ module Vedeu
|
|
64
64
|
raw_mode!
|
65
65
|
end
|
66
66
|
|
67
|
-
# Returns the mode of the terminal, either `:cooked`, `:fake` or
|
68
|
-
# Can change throughout the lifespan of the client
|
67
|
+
# Returns the mode of the terminal, either `:cooked`, `:fake` or
|
68
|
+
# `:raw`. Can change throughout the lifespan of the client
|
69
|
+
# application.
|
69
70
|
#
|
70
71
|
# @return [Symbol]
|
71
72
|
def mode
|
@@ -1,17 +1,19 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
# This module is the direct interface between Vedeu and your
|
4
|
-
# console, via Ruby's IO core library.
|
3
|
+
# This module is the direct interface between Vedeu and your
|
4
|
+
# terminal/ console, via Ruby's IO core library.
|
5
5
|
#
|
6
6
|
module Terminal
|
7
7
|
|
8
8
|
include Vedeu::Terminal::Mode
|
9
9
|
extend self
|
10
10
|
|
11
|
-
# Opens a terminal screen in either `raw` or `cooked` mode. On
|
12
|
-
# attempts to restore the screen. See
|
11
|
+
# Opens a terminal screen in either `raw` or `cooked` mode. On
|
12
|
+
# exit, attempts to restore the screen. See
|
13
|
+
# {Vedeu::Terminal#restore_screen}.
|
13
14
|
#
|
14
|
-
# @raise [Vedeu::Error::InvalidSyntax] The required block was not
|
15
|
+
# @raise [Vedeu::Error::InvalidSyntax] The required block was not
|
16
|
+
# given.
|
15
17
|
# @return [Array]
|
16
18
|
def open
|
17
19
|
fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
|
@@ -27,8 +29,8 @@ module Vedeu
|
|
27
29
|
restore_screen
|
28
30
|
end
|
29
31
|
|
30
|
-
# Takes input from the user via the keyboard. Accepts special keys
|
31
|
-
# the F-Keys etc, by capturing the entire sequence.
|
32
|
+
# Takes input from the user via the keyboard. Accepts special keys
|
33
|
+
# like the F-Keys etc, by capturing the entire sequence.
|
32
34
|
#
|
33
35
|
# @return [String]
|
34
36
|
def input
|
@@ -53,9 +55,10 @@ module Vedeu
|
|
53
55
|
end
|
54
56
|
alias_method :write, :output
|
55
57
|
|
56
|
-
# When the terminal emit the 'SIGWINCH' signal, Vedeu can
|
57
|
-
# and attempt to redraw the current interface with
|
58
|
-
# success. Can also be used to simulate a
|
58
|
+
# When the terminal emit the 'SIGWINCH' signal, Vedeu can
|
59
|
+
# intercept this and attempt to redraw the current interface with
|
60
|
+
# varying degrees of success. Can also be used to simulate a
|
61
|
+
# terminal resize.
|
59
62
|
#
|
60
63
|
# @example
|
61
64
|
# Vedeu.resize
|
@@ -74,7 +77,7 @@ module Vedeu
|
|
74
77
|
def initialize_screen(mode)
|
75
78
|
Vedeu.log(type: :info, message: "Terminal entering '#{mode}' mode")
|
76
79
|
|
77
|
-
output(Esc.string('screen_init'))
|
80
|
+
output(Vedeu::EscapeSequences::Esc.string('screen_init'))
|
78
81
|
|
79
82
|
yield if block_given?
|
80
83
|
end
|
@@ -86,55 +89,53 @@ module Vedeu
|
|
86
89
|
#
|
87
90
|
# @return [String]
|
88
91
|
def clear
|
89
|
-
|
90
|
-
|
91
|
-
output(Esc.string('clear'))
|
92
|
+
output(Vedeu::EscapeSequences::Esc.string('clear'))
|
92
93
|
end
|
93
94
|
|
94
|
-
# Attempts to tidy up the screen just before the application
|
95
|
-
# The cursor is shown, colours are reset to terminal
|
96
|
-
# terminal is told to reset, and finally we clear
|
97
|
-
# the prompt.
|
95
|
+
# Attempts to tidy up the screen just before the application
|
96
|
+
# terminates. The cursor is shown, colours are reset to terminal
|
97
|
+
# defaults, the terminal is told to reset, and finally we clear
|
98
|
+
# the last line ready for the prompt.
|
98
99
|
#
|
99
100
|
# @return [String]
|
100
101
|
def restore_screen
|
101
|
-
output(Esc.string('screen_exit'))
|
102
|
+
output(Vedeu::EscapeSequences::Esc.string('screen_exit'))
|
102
103
|
end
|
103
104
|
|
104
|
-
# Sets the cursor to be visible unless in raw mode, whereby it
|
105
|
-
# hidden.
|
105
|
+
# Sets the cursor to be visible unless in raw mode, whereby it
|
106
|
+
# will be left hidden.
|
106
107
|
#
|
107
108
|
# @return [String]
|
108
109
|
def set_cursor_mode
|
109
|
-
output(Esc.string('show_cursor')) unless raw_mode?
|
110
|
+
output(Vedeu::EscapeSequences::Esc.string('show_cursor')) unless raw_mode?
|
110
111
|
end
|
111
112
|
|
112
|
-
# Returns a coordinate tuple of the format [y, x], where `y` is
|
113
|
-
# and `x` is the column/character.
|
113
|
+
# Returns a coordinate tuple of the format [y, x], where `y` is
|
114
|
+
# the row/line and `x` is the column/character.
|
114
115
|
#
|
115
116
|
# @return [Array]
|
116
117
|
def centre
|
117
118
|
[(height / 2), (width / 2)]
|
118
119
|
end
|
119
120
|
|
120
|
-
# Returns the `y` (row/line) component of the coordinate tuple
|
121
|
-
# {Vedeu::Terminal.centre}
|
121
|
+
# Returns the `y` (row/line) component of the coordinate tuple
|
122
|
+
# provided by {Vedeu::Terminal.centre}
|
122
123
|
#
|
123
124
|
# @return [Fixnum]
|
124
125
|
def centre_y
|
125
126
|
centre[0]
|
126
127
|
end
|
127
128
|
|
128
|
-
# Returns the `x` (column/character) component of the coodinate
|
129
|
-
# provided by {Vedeu::Terminal.centre}
|
129
|
+
# Returns the `x` (column/character) component of the coodinate
|
130
|
+
# tuple provided by {Vedeu::Terminal.centre}
|
130
131
|
#
|
131
132
|
# @return [Fixnum]
|
132
133
|
def centre_x
|
133
134
|
centre[-1]
|
134
135
|
end
|
135
136
|
|
136
|
-
# Returns 1. This 1 is either the top-most or left-most coordinate
|
137
|
-
# terminal.
|
137
|
+
# Returns 1. This 1 is either the top-most or left-most coordinate
|
138
|
+
# of the terminal.
|
138
139
|
#
|
139
140
|
# @return [Fixnum]
|
140
141
|
def origin
|
@@ -145,8 +146,8 @@ module Vedeu
|
|
145
146
|
alias_method :tx, :origin
|
146
147
|
alias_method :ty, :origin
|
147
148
|
|
148
|
-
# Returns the total width (number of columns/characters) of the
|
149
|
-
# terminal.
|
149
|
+
# Returns the total width (number of columns/characters) of the
|
150
|
+
# current terminal.
|
150
151
|
#
|
151
152
|
# @example
|
152
153
|
# Vedeu.width # => provides the width via the Vedeu API.
|
@@ -160,7 +161,8 @@ module Vedeu
|
|
160
161
|
alias_method :xn, :width
|
161
162
|
alias_method :txn, :width
|
162
163
|
|
163
|
-
# Returns the total height (number of rows/lines) of the current
|
164
|
+
# Returns the total height (number of rows/lines) of the current
|
165
|
+
# terminal.
|
164
166
|
#
|
165
167
|
# @example
|
166
168
|
# Vedeu.height # => provides the height via the Vedeu API.
|
@@ -174,21 +176,23 @@ module Vedeu
|
|
174
176
|
alias_method :yn, :height
|
175
177
|
alias_method :tyn, :height
|
176
178
|
|
177
|
-
# Returns a tuple containing the height and width of the current
|
179
|
+
# Returns a tuple containing the height and width of the current
|
180
|
+
# terminal.
|
178
181
|
#
|
179
182
|
# @note
|
180
|
-
# If the terminal is a odd number of characters in height or
|
181
|
-
# 1 is deducted from the dimension to make it even.
|
182
|
-
# actual terminal is height: 37, width: 145,
|
183
|
-
# be 36, 144 respectively.
|
183
|
+
# If the terminal is a odd number of characters in height or
|
184
|
+
# width, then 1 is deducted from the dimension to make it even.
|
185
|
+
# For example; the actual terminal is height: 37, width: 145,
|
186
|
+
# then the reported size will be 36, 144 respectively.
|
184
187
|
#
|
185
|
-
# This is done to make it easier for client applications to
|
186
|
-
# terminal space up when defining interfaces or
|
187
|
-
# consistent rendering.
|
188
|
+
# This is done to make it easier for client applications to
|
189
|
+
# divide the terminal space up when defining interfaces or
|
190
|
+
# views, leading to more consistent rendering.
|
188
191
|
#
|
189
|
-
# If the client application is using the
|
190
|
-
# {Vedeu::Geometry::Grid#
|
191
|
-
#
|
192
|
+
# If the client application is using the
|
193
|
+
# {Vedeu::Geometry::Grid#rows} or
|
194
|
+
# {Vedeu::Geometry::Grid#columns} helpers, the dimensions are
|
195
|
+
# made more consistent using this approach.
|
192
196
|
#
|
193
197
|
# @return [Array]
|
194
198
|
def size
|
@@ -200,7 +204,8 @@ module Vedeu
|
|
200
204
|
[h, w]
|
201
205
|
end
|
202
206
|
|
203
|
-
# Provides our gateway into the wonderful rainbow-filled world of
|
207
|
+
# Provides our gateway into the wonderful rainbow-filled world of
|
208
|
+
# IO.
|
204
209
|
#
|
205
210
|
# @return [File]
|
206
211
|
def console
|
data/lib/vedeu/version.rb
CHANGED
@@ -75,7 +75,8 @@ module Vedeu
|
|
75
75
|
describe '#hide' do
|
76
76
|
let(:visible) { true }
|
77
77
|
let(:hide_cursor) {
|
78
|
-
Vedeu::Models::Escape
|
78
|
+
Vedeu::Models::Escape
|
79
|
+
.new(value: Vedeu::EscapeSequences::Esc.hide_cursor)
|
79
80
|
}
|
80
81
|
|
81
82
|
before do
|
@@ -201,7 +202,8 @@ module Vedeu
|
|
201
202
|
describe '#show' do
|
202
203
|
let(:visible) { false }
|
203
204
|
let(:show_cursor) {
|
204
|
-
Vedeu::Models::Escape
|
205
|
+
Vedeu::Models::Escape
|
206
|
+
.new(value: Vedeu::EscapeSequences::Esc.show_cursor)
|
205
207
|
}
|
206
208
|
|
207
209
|
before do
|
@@ -31,9 +31,6 @@ module Vedeu
|
|
31
31
|
|
32
32
|
describe '#initialize' do
|
33
33
|
it { instance.must_be_instance_of(described) }
|
34
|
-
it {
|
35
|
-
instance.instance_variable_get('@attributes').must_equal(attributes)
|
36
|
-
}
|
37
34
|
it { instance.instance_variable_get('@y').must_equal(y) }
|
38
35
|
it { instance.instance_variable_get('@x').must_equal(x) }
|
39
36
|
it { instance.instance_variable_get('@by').must_equal(by) }
|
@@ -2,75 +2,79 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module EscapeSequences
|
6
6
|
|
7
|
-
|
7
|
+
describe Esc do
|
8
8
|
|
9
|
-
|
10
|
-
let(:stream) { "\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l" }
|
9
|
+
let(:described) { Vedeu::EscapeSequences::Esc }
|
11
10
|
|
12
|
-
|
11
|
+
describe '.escape' do
|
12
|
+
let(:stream) { "\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l" }
|
13
13
|
|
14
|
-
|
14
|
+
subject { described.escape(stream) }
|
15
15
|
|
16
|
-
|
17
|
-
subject.must_equal('\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l')
|
18
|
-
end
|
16
|
+
it { subject.must_be_instance_of(String) }
|
19
17
|
|
20
|
-
|
21
|
-
|
18
|
+
it 'escapes the escape sequences' do
|
19
|
+
subject.must_equal('\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l')
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
22
|
+
context 'when a stream is not given' do
|
23
|
+
let(:stream) { '' }
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
it { described.border { 'b' }.must_equal("\e(0b\e(B") }
|
25
|
+
it { subject.must_equal('') }
|
26
|
+
end
|
30
27
|
end
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
describe '.border' do
|
30
|
+
context 'when the block is given' do
|
31
|
+
it { described.border { 'b' }.must_equal("\e(0b\e(B") }
|
32
|
+
end
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
context 'when the block is not given' do
|
35
|
+
it { described.border.must_equal('') }
|
36
|
+
end
|
40
37
|
end
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
39
|
+
describe '.string' do
|
40
|
+
context 'when the style is not provided' do
|
41
|
+
it { described.string.must_equal('') }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when the style is provided' do
|
45
|
+
it { described.string('bg_reset').must_equal("\e[49m") }
|
46
|
+
it { described.string('blink').must_equal("\e[5m") }
|
47
|
+
it { described.string('blink_off').must_equal("\e[25m") }
|
48
|
+
it { described.string('bold').must_equal("\e[1m") }
|
49
|
+
it { described.string('bold_off').must_equal("\e[22m") }
|
50
|
+
it { described.string('clear').must_equal("\e[39m\e[49m\e[2J") }
|
51
|
+
it { described.string('clear_line').must_equal("\e[39m\e[49m\e[2K") }
|
52
|
+
it { described.string('colour_reset').must_equal("\e[39m\e[49m") }
|
53
|
+
it { described.string('fg_reset').must_equal("\e[39m") }
|
54
|
+
it { described.string('hide_cursor').must_equal("\e[?25l") }
|
55
|
+
it { described.string('screen_init').
|
56
|
+
must_equal("\e[0m\e[39m\e[49m\e[2J\e[?25l") }
|
57
|
+
it { described.string('negative').must_equal("\e[7m") }
|
58
|
+
it { described.string('positive').must_equal("\e[27m") }
|
59
|
+
it { described.string('reset').must_equal("\e[0m") }
|
60
|
+
it { described.string('normal').must_equal("\e[24m\e[22m\e[27m") }
|
61
|
+
it { described.string('dim').must_equal("\e[2m") }
|
62
|
+
it { described.string('show_cursor').must_equal("\e[?25h") }
|
63
|
+
it { described.string('underline').must_equal("\e[4m") }
|
64
|
+
it { described.string('underline_off').must_equal("\e[24m") }
|
65
|
+
it { described.string('cursor_position').must_equal("\e[6n") }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'screen_exit' do
|
69
|
+
before { Vedeu::Terminal.stubs(:size).returns([80, 25]) }
|
70
|
+
|
71
|
+
it { described.string('screen_exit').
|
72
|
+
must_equal("\e[?25h\e[39m\e[49m\e[0m\e[80;25H\n") }
|
73
|
+
end
|
64
74
|
end
|
65
75
|
|
66
|
-
|
67
|
-
before { Vedeu::Terminal.stubs(:size).returns([80, 25]) }
|
68
|
-
|
69
|
-
it { described.string('screen_exit').
|
70
|
-
must_equal("\e[?25h\e[39m\e[49m\e[0m\e[80;25H\n") }
|
71
|
-
end
|
72
|
-
end
|
76
|
+
end # Esc
|
73
77
|
|
74
|
-
end #
|
78
|
+
end # EscapeSequences
|
75
79
|
|
76
80
|
end # Vedeu
|
@@ -9,7 +9,7 @@ module Vedeu
|
|
9
9
|
let(:described) { Vedeu::Events::Collection }
|
10
10
|
let(:instance) { described.new }
|
11
11
|
|
12
|
-
it { described.superclass.must_equal(Vedeu::Collection) }
|
12
|
+
it { described.superclass.must_equal(Vedeu::Repositories::Collection) }
|
13
13
|
|
14
14
|
describe '#initialize' do
|
15
15
|
it { instance.must_be_instance_of(described) }
|
@@ -9,7 +9,7 @@ module Vedeu
|
|
9
9
|
let(:described) { Vedeu::Input::Keys }
|
10
10
|
let(:instance) { described.new }
|
11
11
|
|
12
|
-
it { described.superclass.must_equal(Vedeu::Collection) }
|
12
|
+
it { described.superclass.must_equal(Vedeu::Repositories::Collection) }
|
13
13
|
|
14
14
|
describe '#initialize' do
|
15
15
|
it { instance.must_be_instance_of(described) }
|
@@ -23,7 +23,7 @@ module Vedeu
|
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'when the repository is provided' do
|
26
|
-
let(:repository) { Vedeu::Repository.new }
|
26
|
+
let(:repository) { Vedeu::Repositories::Repository.new }
|
27
27
|
|
28
28
|
it do
|
29
29
|
instance.instance_variable_get('@repository').must_equal(repository)
|
@@ -9,7 +9,7 @@ module Vedeu
|
|
9
9
|
let(:described) { Vedeu::Views::Chars }
|
10
10
|
let(:instance) { described.new }
|
11
11
|
|
12
|
-
it { described.superclass.must_equal(Vedeu::Collection) }
|
12
|
+
it { described.superclass.must_equal(Vedeu::Repositories::Collection) }
|
13
13
|
|
14
14
|
describe '#initialize' do
|
15
15
|
it { instance.must_be_instance_of(described) }
|
@@ -9,7 +9,7 @@ module Vedeu
|
|
9
9
|
let(:described) { Vedeu::Views::Lines }
|
10
10
|
let(:instance) { described.new }
|
11
11
|
|
12
|
-
it { described.superclass.must_equal(Vedeu::Collection) }
|
12
|
+
it { described.superclass.must_equal(Vedeu::Repositories::Collection) }
|
13
13
|
|
14
14
|
describe '#initialize' do
|
15
15
|
it { instance.must_be_instance_of(described) }
|
@@ -9,7 +9,7 @@ module Vedeu
|
|
9
9
|
let(:described) { Vedeu::Views::Streams }
|
10
10
|
let(:instance) { described.new }
|
11
11
|
|
12
|
-
it { described.superclass.must_equal(Vedeu::Collection) }
|
12
|
+
it { described.superclass.must_equal(Vedeu::Repositories::Collection) }
|
13
13
|
|
14
14
|
describe '#initialize' do
|
15
15
|
it { instance.must_be_instance_of(described) }
|
@@ -9,7 +9,7 @@ module Vedeu
|
|
9
9
|
let(:described) { Vedeu::Views::ViewCollection }
|
10
10
|
let(:instance) { described.new }
|
11
11
|
|
12
|
-
it { described.superclass.must_equal(Vedeu::Collection) }
|
12
|
+
it { described.superclass.must_equal(Vedeu::Repositories::Collection) }
|
13
13
|
|
14
14
|
describe '#initialize' do
|
15
15
|
it { instance.must_be_instance_of(described) }
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Output
|
6
|
+
|
7
|
+
describe RefreshGroup do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Output::RefreshGroup }
|
10
|
+
let(:instance) { described.new(_name) }
|
11
|
+
let(:_name) { 'Vedeu::Output::RefreshGroup' }
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(described) }
|
15
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.by_name' do
|
19
|
+
subject { described.by_name(_name) }
|
20
|
+
|
21
|
+
context 'when the name is not present' do
|
22
|
+
let(:_name) { '' }
|
23
|
+
|
24
|
+
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when the name is present' do
|
28
|
+
it {
|
29
|
+
Vedeu::Output::RefreshGroup.expects(:by_name).with(_name)
|
30
|
+
subject
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#by_name' do
|
36
|
+
it { instance.must_respond_to(:by_name) }
|
37
|
+
end
|
38
|
+
|
39
|
+
end # RefreshGroup
|
40
|
+
|
41
|
+
end # Output
|
42
|
+
|
43
|
+
end # Vedeu
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Output
|
6
|
+
|
7
|
+
describe Refresh do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Output::Refresh }
|
10
|
+
let(:instance) { described.new }
|
11
|
+
|
12
|
+
describe '.all' do
|
13
|
+
before { Vedeu.stubs(:trigger) }
|
14
|
+
|
15
|
+
subject { described.all }
|
16
|
+
|
17
|
+
it { subject.must_be_instance_of(Array) }
|
18
|
+
|
19
|
+
context 'when there are no registered interfaces' do
|
20
|
+
before { Vedeu.interfaces.reset }
|
21
|
+
|
22
|
+
it { subject.must_equal([]) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when there are registered interfaces' do
|
26
|
+
let(:interface) {
|
27
|
+
Vedeu::Models::Interface.new(name: 'Vedeu::Output::Refresh')
|
28
|
+
}
|
29
|
+
let(:interfaces) { [interface] }
|
30
|
+
|
31
|
+
before { Vedeu.interfaces.stubs(:zindexed).returns(interfaces) }
|
32
|
+
|
33
|
+
it {
|
34
|
+
Vedeu.expects(:trigger).with(:_refresh_, 'Vedeu::Output::Refresh')
|
35
|
+
subject
|
36
|
+
}
|
37
|
+
|
38
|
+
it { subject.must_equal([interface]) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#all' do
|
43
|
+
it { instance.must_respond_to(:all) }
|
44
|
+
end
|
45
|
+
|
46
|
+
end # Refresh
|
47
|
+
|
48
|
+
end # Output
|
49
|
+
|
50
|
+
end # Vedeu
|
@@ -2,11 +2,15 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Renderers
|
6
6
|
|
7
|
-
|
8
|
-
# it { skip }
|
7
|
+
describe RendererOptions do
|
9
8
|
|
10
|
-
|
9
|
+
# @todo Add more tests.
|
10
|
+
# it { skip }
|
11
|
+
|
12
|
+
end # RendererOptions
|
13
|
+
|
14
|
+
end # Renderers
|
11
15
|
|
12
16
|
end # Vedeu
|
@@ -73,7 +73,8 @@ module Vedeu
|
|
73
73
|
|
74
74
|
context 'when there is content' do
|
75
75
|
let(:output) {
|
76
|
-
Vedeu::Models::Escape
|
76
|
+
Vedeu::Models::Escape
|
77
|
+
.new(value: Vedeu::EscapeSequences::Esc.hide_cursor)
|
77
78
|
}
|
78
79
|
|
79
80
|
it { subject.must_be_instance_of(Vedeu::Models::Escape) }
|