vedeu 0.6.24 → 0.6.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/borders/refresh.rb +1 -1
- data/lib/vedeu/buffers/buffer.rb +2 -2
- data/lib/vedeu/configuration/api.rb +6 -2
- data/lib/vedeu/cursors/cursor.rb +3 -1
- data/lib/vedeu/cursors/refresh.rb +0 -2
- data/lib/vedeu/editor/document.rb +52 -11
- data/lib/vedeu/editor/editor.rb +2 -1
- data/lib/vedeu/editor/line.rb +1 -1
- data/lib/vedeu/editor/lines.rb +15 -13
- data/lib/vedeu/esc/esc.rb +1 -1
- data/lib/vedeu/groups/group.rb +1 -1
- data/lib/vedeu/input/store.rb +2 -2
- data/lib/vedeu/logging/log.rb +1 -0
- data/lib/vedeu/models/views/view.rb +0 -5
- data/lib/vedeu/output/clear/interface.rb +1 -1
- data/lib/vedeu/output/output.rb +12 -3
- data/lib/vedeu/output/viewport.rb +3 -3
- data/lib/vedeu/terminal/terminal.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/refresh_test.rb +1 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +1 -1
- data/test/lib/vedeu/configuration/api_test.rb +5 -0
- data/test/lib/vedeu/cursors/cursor_test.rb +2 -4
- data/test/lib/vedeu/editor/document_test.rb +20 -72
- data/test/lib/vedeu/editor/lines_test.rb +33 -44
- data/test/lib/vedeu/groups/group_test.rb +11 -3
- data/test/lib/vedeu/models/views/view_test.rb +0 -13
- data/test/lib/vedeu/output/clear/interface_test.rb +2 -2
- data/test/lib/vedeu/output/output_test.rb +4 -4
- data/test/lib/vedeu/output/viewport_test.rb +2 -2
- data/test/lib/vedeu_test.rb +1 -0
- data/test/support/examples/editor_app.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 815df61c875e913607ccedbc8d9851c4888b4a5b
|
4
|
+
data.tar.gz: 31b4afe5a7789f707d7e17ae05127c8e66b34684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf4133bd63868341598ed14ca0b0086f45f8604f40bebe8013365ba36976fed7502755e93c09a968810db61cc07ae410089bfcb0b3f266c9ce27f9b38ec509a8
|
7
|
+
data.tar.gz: 88c0bee0f579b4a8d75c693e78c3cd99d263f7f867601c3c69fd0d081ff387024f138a6dd1b7e97cc82379a8a88b1a7f4dd6229956dd27b7bd22ee019bd95b07
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -299,14 +299,18 @@ module Vedeu
|
|
299
299
|
#
|
300
300
|
# Vedeu.configure do
|
301
301
|
# log_only :debug, :event
|
302
|
+
#
|
303
|
+
# # or
|
304
|
+
# log_only [:debug, :info]
|
305
|
+
#
|
302
306
|
# # ...
|
303
307
|
# end
|
304
308
|
#
|
305
309
|
# @param types [Array<Symbol>] The message types which should be
|
306
|
-
#
|
310
|
+
# logged.
|
307
311
|
# @return [Array<Symbol>]
|
308
312
|
def log_only(*types)
|
309
|
-
options[:log_only] = types
|
313
|
+
options[:log_only] = types.flatten
|
310
314
|
end
|
311
315
|
|
312
316
|
# Sets boolean to enable/disable profiling. Vedeu's default
|
data/lib/vedeu/cursors/cursor.rb
CHANGED
@@ -132,7 +132,9 @@ module Vedeu
|
|
132
132
|
#
|
133
133
|
# @return [Array<Vedeu::Models::Escape>]
|
134
134
|
def render
|
135
|
-
Vedeu
|
135
|
+
Vedeu.log(type: :info, message: "Refreshing cursor: '#{name}'")
|
136
|
+
|
137
|
+
Vedeu.render_output(escape_sequence)
|
136
138
|
end
|
137
139
|
|
138
140
|
# Arbitrarily move the cursor to a given position.
|
@@ -46,9 +46,17 @@ module Vedeu
|
|
46
46
|
#
|
47
47
|
# @return [Vedeu::Editor::Document]
|
48
48
|
def delete_character
|
49
|
-
|
49
|
+
if x - 1 < 0 && y == 0
|
50
|
+
bol
|
50
51
|
|
51
|
-
|
52
|
+
elsif x - 1 < 0 && y > 0
|
53
|
+
delete_line
|
54
|
+
|
55
|
+
else
|
56
|
+
@lines = lines.delete_character(y, x - 1)
|
57
|
+
|
58
|
+
left
|
59
|
+
end
|
52
60
|
end
|
53
61
|
|
54
62
|
# Delete a line.
|
@@ -58,6 +66,8 @@ module Vedeu
|
|
58
66
|
@lines = lines.delete_line(y)
|
59
67
|
|
60
68
|
up
|
69
|
+
|
70
|
+
eol
|
61
71
|
end
|
62
72
|
|
63
73
|
# Returns the document as a string with line breaks if there is
|
@@ -93,9 +103,9 @@ module Vedeu
|
|
93
103
|
#
|
94
104
|
# @return [Vedeu::Editor::Document]
|
95
105
|
def insert_line
|
96
|
-
|
106
|
+
@lines = lines.insert_line(y + 1)
|
97
107
|
|
98
|
-
|
108
|
+
down
|
99
109
|
|
100
110
|
bol
|
101
111
|
end
|
@@ -103,8 +113,8 @@ module Vedeu
|
|
103
113
|
# Returns the current line from the collection of lines.
|
104
114
|
#
|
105
115
|
# @return [Array<String|void>]
|
106
|
-
def line
|
107
|
-
lines.line(
|
116
|
+
def line(index = y)
|
117
|
+
lines.line(index)
|
108
118
|
end
|
109
119
|
|
110
120
|
# Returns the collection of lines which constitutes the document
|
@@ -135,7 +145,7 @@ module Vedeu
|
|
135
145
|
|
136
146
|
Vedeu.trigger(:_clear_view_content_, name)
|
137
147
|
|
138
|
-
Vedeu
|
148
|
+
Vedeu.render_output(output)
|
139
149
|
|
140
150
|
cursor.refresh
|
141
151
|
|
@@ -146,6 +156,8 @@ module Vedeu
|
|
146
156
|
#
|
147
157
|
# @return [Vedeu::Editor::Document]
|
148
158
|
def left
|
159
|
+
return self if x - 1 < 0
|
160
|
+
|
149
161
|
cursor.left
|
150
162
|
|
151
163
|
refresh
|
@@ -155,6 +167,8 @@ module Vedeu
|
|
155
167
|
#
|
156
168
|
# @return [Vedeu::Editor::Document]
|
157
169
|
def right
|
170
|
+
return self if x + 1 > line.size
|
171
|
+
|
158
172
|
cursor.right
|
159
173
|
|
160
174
|
refresh
|
@@ -164,18 +178,36 @@ module Vedeu
|
|
164
178
|
#
|
165
179
|
# @return [Vedeu::Editor::Document]
|
166
180
|
def up
|
167
|
-
|
181
|
+
if x > line(y - 1).size
|
182
|
+
cursor.up
|
168
183
|
|
169
|
-
|
184
|
+
eol
|
185
|
+
|
186
|
+
else
|
187
|
+
cursor.up
|
188
|
+
|
189
|
+
refresh
|
190
|
+
|
191
|
+
end
|
170
192
|
end
|
171
193
|
|
172
194
|
# Move the virtual cursor down.
|
173
195
|
#
|
174
196
|
# @return [Vedeu::Editor::Document]
|
175
197
|
def down
|
176
|
-
|
198
|
+
return self if y + 1 >= lines.size
|
177
199
|
|
178
|
-
|
200
|
+
if x > line(y + 1).size
|
201
|
+
cursor.down
|
202
|
+
|
203
|
+
eol
|
204
|
+
|
205
|
+
else
|
206
|
+
cursor.down
|
207
|
+
|
208
|
+
refresh
|
209
|
+
|
210
|
+
end
|
179
211
|
end
|
180
212
|
|
181
213
|
# Move the virtual cursor to the beginning of the line.
|
@@ -187,6 +219,15 @@ module Vedeu
|
|
187
219
|
refresh
|
188
220
|
end
|
189
221
|
|
222
|
+
# Move the virtual cursor to the end of the line.
|
223
|
+
#
|
224
|
+
# @return [Vedeu::Editor::Document]
|
225
|
+
def eol
|
226
|
+
cursor.x = line.size
|
227
|
+
|
228
|
+
refresh
|
229
|
+
end
|
230
|
+
|
190
231
|
private
|
191
232
|
|
192
233
|
# Returns the default options/attributes for this class.
|
data/lib/vedeu/editor/editor.rb
CHANGED
@@ -13,6 +13,7 @@ module Vedeu
|
|
13
13
|
def_delegators :document,
|
14
14
|
:clear,
|
15
15
|
:delete_character,
|
16
|
+
:delete_line,
|
16
17
|
:down,
|
17
18
|
:insert_character,
|
18
19
|
:insert_line,
|
@@ -49,6 +50,7 @@ module Vedeu
|
|
49
50
|
|
50
51
|
case input
|
51
52
|
when :backspace then delete_character
|
53
|
+
when :delete then delete_line
|
52
54
|
when :ctrl_c then Vedeu.trigger(:_exit_)
|
53
55
|
when :down then down
|
54
56
|
when :enter then insert_line
|
@@ -57,7 +59,6 @@ module Vedeu
|
|
57
59
|
when :right then right
|
58
60
|
when :tab then execute
|
59
61
|
when :up then up
|
60
|
-
# when '' then delete_line
|
61
62
|
else
|
62
63
|
insert_character(input)
|
63
64
|
end
|
data/lib/vedeu/editor/line.rb
CHANGED
@@ -66,7 +66,7 @@ module Vedeu
|
|
66
66
|
# @param index [Fixnum|NilClass]
|
67
67
|
# @return [String]
|
68
68
|
def delete_character(index = nil)
|
69
|
-
return self if line.empty? || (index && index
|
69
|
+
return self if line.empty? || (index && index < 0)
|
70
70
|
|
71
71
|
new_line = if index && index <= size
|
72
72
|
line.dup.tap { |line| line.slice!(index) }
|
data/lib/vedeu/editor/lines.rb
CHANGED
@@ -61,7 +61,8 @@ module Vedeu
|
|
61
61
|
# @param x [Fixnum]
|
62
62
|
# @return [Vedeu::Editor::Lines]
|
63
63
|
def delete_character(y, x)
|
64
|
-
lines[y] = line(y).delete_character(x)
|
64
|
+
lines[y] = line(y).delete_character(x) unless line(y).empty?
|
65
|
+
|
65
66
|
Vedeu::Editor::Lines.coerce(lines)
|
66
67
|
end
|
67
68
|
|
@@ -70,7 +71,7 @@ module Vedeu
|
|
70
71
|
# @param index [Fixnum|NilClass]
|
71
72
|
# @return [String]
|
72
73
|
def delete_line(index = nil)
|
73
|
-
return self if lines.empty? || (index && index
|
74
|
+
return self if lines.empty? || (index && index < 0)
|
74
75
|
|
75
76
|
new_lines = if index && index <= size
|
76
77
|
lines.dup.tap { |lines| lines.slice!(index) }
|
@@ -95,7 +96,7 @@ module Vedeu
|
|
95
96
|
#
|
96
97
|
# @return [Boolean]
|
97
98
|
def empty?
|
98
|
-
|
99
|
+
lines.empty?
|
99
100
|
end
|
100
101
|
|
101
102
|
# An object is equal when its values are the same.
|
@@ -115,19 +116,20 @@ module Vedeu
|
|
115
116
|
# @return [Vedeu::Editor::Lines]
|
116
117
|
def insert_character(character, y, x)
|
117
118
|
lines[y] = line(y).insert_character(character, x)
|
119
|
+
|
118
120
|
Vedeu::Editor::Lines.coerce(lines)
|
119
121
|
end
|
120
122
|
|
121
123
|
# Insert the line on the line below the given index.
|
122
124
|
#
|
123
|
-
# @param line [String]
|
124
125
|
# @param index [Fixnum|NilClass]
|
125
126
|
# @return [Vedeu::Editor::Lines]
|
126
|
-
def insert_line(
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
127
|
+
def insert_line(index = nil)
|
128
|
+
Vedeu::Editor::Lines.coerce(
|
129
|
+
Vedeu::Editor::Insert.into(lines,
|
130
|
+
Vedeu::Editor::Line.new,
|
131
|
+
index,
|
132
|
+
size))
|
131
133
|
end
|
132
134
|
|
133
135
|
# Returns the line at the given index.
|
@@ -135,17 +137,17 @@ module Vedeu
|
|
135
137
|
# @param index [Fixnum|NilClass]
|
136
138
|
# @return [Vedeu::Editor::Line]
|
137
139
|
def line(index = nil)
|
138
|
-
return Vedeu::Editor::Line.new
|
139
|
-
return Vedeu::Editor::Line.coerce(lines
|
140
|
+
return Vedeu::Editor::Line.new unless lines
|
141
|
+
return Vedeu::Editor::Line.coerce(lines[-1]) unless index
|
140
142
|
|
141
143
|
indexed = if index <= 0
|
142
|
-
lines
|
144
|
+
lines[0]
|
143
145
|
|
144
146
|
elsif index && index <= size
|
145
147
|
lines[index]
|
146
148
|
|
147
149
|
else
|
148
|
-
lines
|
150
|
+
lines[-1]
|
149
151
|
|
150
152
|
end
|
151
153
|
|
data/lib/vedeu/esc/esc.rb
CHANGED
data/lib/vedeu/groups/group.rb
CHANGED
data/lib/vedeu/input/store.rb
CHANGED
@@ -36,12 +36,12 @@ module Vedeu
|
|
36
36
|
|
37
37
|
# @return [NilClass|Symbol|String]
|
38
38
|
def last_command
|
39
|
-
all_commands
|
39
|
+
all_commands[-1]
|
40
40
|
end
|
41
41
|
|
42
42
|
# @return [NilClass|Symbol|String]
|
43
43
|
def last_keypress
|
44
|
-
all_keypresses
|
44
|
+
all_keypresses[-1]
|
45
45
|
end
|
46
46
|
|
47
47
|
# @return [Hash<Symbol => Array<Symbol|String>>]
|
data/lib/vedeu/logging/log.rb
CHANGED
@@ -76,11 +76,6 @@ module Vedeu
|
|
76
76
|
end
|
77
77
|
alias_method :lines, :value
|
78
78
|
|
79
|
-
# @return [Array<Array<Vedeu::Views::Char>>]
|
80
|
-
def render
|
81
|
-
Vedeu::Output::Viewport.render(self)
|
82
|
-
end
|
83
|
-
|
84
79
|
# Store the view and immediately refresh it; causing to be
|
85
80
|
# pushed to the Terminal. Called by {Vedeu::DSL::View.renders}.
|
86
81
|
#
|
data/lib/vedeu/output/output.rb
CHANGED
@@ -13,8 +13,8 @@ module Vedeu
|
|
13
13
|
#
|
14
14
|
# @return [Array|String]
|
15
15
|
# @see #initialize
|
16
|
-
def self.
|
17
|
-
new(output).
|
16
|
+
def self.render_output(output)
|
17
|
+
new(output).render_output
|
18
18
|
end
|
19
19
|
|
20
20
|
# Return a new instance of Vedeu::Output::Output.
|
@@ -33,7 +33,7 @@ module Vedeu
|
|
33
33
|
# not other renderers.
|
34
34
|
#
|
35
35
|
# @return [Array|NilClass]
|
36
|
-
def
|
36
|
+
def render_output
|
37
37
|
return nil if output.nil?
|
38
38
|
return render_terminal_buffer unless output.is_a?(Vedeu::Models::Escape)
|
39
39
|
|
@@ -55,4 +55,13 @@ module Vedeu
|
|
55
55
|
|
56
56
|
end # Output
|
57
57
|
|
58
|
+
# Write the given output to the configured or default renderers.
|
59
|
+
#
|
60
|
+
# @example
|
61
|
+
# Vedeu.render_output(output)
|
62
|
+
#
|
63
|
+
# @!method render_output
|
64
|
+
# @return [Array|NilClass]
|
65
|
+
def_delegators Vedeu::Output::Output, :render_output
|
66
|
+
|
58
67
|
end # Vedeu
|
@@ -26,8 +26,8 @@ module Vedeu
|
|
26
26
|
:ox,
|
27
27
|
:oy
|
28
28
|
|
29
|
-
# @param
|
30
|
-
# @return
|
29
|
+
# @param (see #initialize)
|
30
|
+
# @return (see #render)
|
31
31
|
def self.render(view)
|
32
32
|
new(view).render
|
33
33
|
end
|
@@ -44,7 +44,7 @@ module Vedeu
|
|
44
44
|
#
|
45
45
|
# @return [Array<Array<String>>|NilClass]
|
46
46
|
def render
|
47
|
-
Vedeu
|
47
|
+
Vedeu.render_output(output) if visible?
|
48
48
|
end
|
49
49
|
|
50
50
|
# Returns a string representation of the viewport.
|
@@ -173,7 +173,7 @@ module Vedeu
|
|
173
173
|
return Vedeu::Configuration.drb_height if Vedeu::Configuration.drb?
|
174
174
|
return Vedeu::Configuration.height if Vedeu::Configuration.height
|
175
175
|
|
176
|
-
size
|
176
|
+
size[0]
|
177
177
|
end
|
178
178
|
alias_method :yn, :height
|
179
179
|
alias_method :tyn, :height
|
data/lib/vedeu/version.rb
CHANGED
@@ -246,6 +246,11 @@ module Vedeu
|
|
246
246
|
configuration = Vedeu.configure { log_only :debug, :store }
|
247
247
|
configuration.log_only.must_equal([:debug, :store])
|
248
248
|
end
|
249
|
+
|
250
|
+
it 'sets the options to the desired value' do
|
251
|
+
configuration = Vedeu.configure { log_only [:debug, :info] }
|
252
|
+
configuration.log_only.must_equal([:debug, :info])
|
253
|
+
end
|
249
254
|
end
|
250
255
|
|
251
256
|
describe '#renderer' do
|
@@ -102,8 +102,7 @@ module Vedeu
|
|
102
102
|
}
|
103
103
|
|
104
104
|
before do
|
105
|
-
Vedeu
|
106
|
-
with(hide_cursor).returns(hide_cursor)
|
105
|
+
Vedeu.stubs(:render_output).with(hide_cursor).returns(hide_cursor)
|
107
106
|
end
|
108
107
|
|
109
108
|
subject { instance.hide }
|
@@ -229,8 +228,7 @@ module Vedeu
|
|
229
228
|
}
|
230
229
|
|
231
230
|
before do
|
232
|
-
Vedeu
|
233
|
-
with(show_cursor).returns(show_cursor)
|
231
|
+
Vedeu.stubs(:render_output).with(show_cursor).returns(show_cursor)
|
234
232
|
end
|
235
233
|
|
236
234
|
subject { instance.show }
|
@@ -35,7 +35,7 @@ module Vedeu
|
|
35
35
|
Vedeu.geometries.stubs(:by_name).with(_name).returns(geometry)
|
36
36
|
Vedeu.interfaces.stubs(:by_name).with(_name).returns(interface)
|
37
37
|
|
38
|
-
Vedeu
|
38
|
+
Vedeu.stubs(:render_output)
|
39
39
|
}
|
40
40
|
|
41
41
|
describe '#initialize' do
|
@@ -59,31 +59,15 @@ module Vedeu
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#delete_character' do
|
62
|
-
|
63
|
-
let(:x) { 0 }
|
64
|
-
|
65
|
-
subject { instance.delete_character }
|
66
|
-
|
67
|
-
it { subject.must_be_instance_of(described) }
|
68
|
-
|
69
|
-
# it { skip }
|
62
|
+
it { instance.must_respond_to(:delete_character) }
|
70
63
|
end
|
71
64
|
|
72
65
|
describe '#delete_line' do
|
73
|
-
|
74
|
-
|
75
|
-
subject { instance.delete_line }
|
76
|
-
|
77
|
-
it { subject.must_be_instance_of(described) }
|
78
|
-
|
79
|
-
# it { skip }
|
66
|
+
it { instance.must_respond_to(:delete_line) }
|
80
67
|
end
|
81
68
|
|
82
69
|
describe '#down' do
|
83
|
-
|
84
|
-
|
85
|
-
it { subject.must_be_instance_of(described) }
|
86
|
-
# it { skip }
|
70
|
+
it { instance.must_respond_to(:down) }
|
87
71
|
end
|
88
72
|
|
89
73
|
describe '#execute' do
|
@@ -95,36 +79,23 @@ module Vedeu
|
|
95
79
|
end
|
96
80
|
|
97
81
|
describe '#insert_character' do
|
98
|
-
|
99
|
-
|
100
|
-
subject { instance.insert_character(character) }
|
101
|
-
|
102
|
-
it { subject.must_be_instance_of(described) }
|
103
|
-
|
104
|
-
# it { skip }
|
82
|
+
it { instance.must_respond_to(:insert_character) }
|
105
83
|
|
106
84
|
context 'when the character is a Symbol' do
|
107
85
|
let(:character) { :a }
|
108
86
|
|
87
|
+
subject { instance.insert_character(character) }
|
88
|
+
|
109
89
|
it { subject.must_equal(instance) }
|
110
90
|
end
|
111
91
|
end
|
112
92
|
|
113
93
|
describe '#insert_line' do
|
114
|
-
|
115
|
-
|
116
|
-
subject { instance.insert_line }
|
117
|
-
|
118
|
-
it { subject.must_be_instance_of(described) }
|
119
|
-
|
120
|
-
# it { skip }
|
94
|
+
it { instance.must_respond_to(:insert_line) }
|
121
95
|
end
|
122
96
|
|
123
97
|
describe '#left' do
|
124
|
-
|
125
|
-
|
126
|
-
it { subject.must_be_instance_of(described) }
|
127
|
-
# it { skip }
|
98
|
+
it { instance.must_respond_to(:left) }
|
128
99
|
end
|
129
100
|
|
130
101
|
describe '#line' do
|
@@ -139,12 +110,6 @@ module Vedeu
|
|
139
110
|
context 'when the line is not empty' do
|
140
111
|
it { subject.must_equal(Vedeu::Editor::Line.new('Hydrogen')) }
|
141
112
|
end
|
142
|
-
|
143
|
-
# context 'when y is set' do
|
144
|
-
# let(:y) { 2 }
|
145
|
-
|
146
|
-
# it { subject.must_equal(Vedeu::Editor::Line.new('Lithium')) }
|
147
|
-
# end
|
148
113
|
end
|
149
114
|
|
150
115
|
describe '#lines' do
|
@@ -162,44 +127,27 @@ module Vedeu
|
|
162
127
|
end
|
163
128
|
|
164
129
|
describe '#reset!' do
|
165
|
-
|
166
|
-
|
167
|
-
it { subject.must_be_instance_of(described) }
|
130
|
+
it { instance.must_respond_to(:reset!) }
|
168
131
|
end
|
169
132
|
|
170
133
|
describe '#refresh' do
|
171
|
-
|
172
|
-
Vedeu.stubs(:trigger)
|
173
|
-
Vedeu::Output::Output.stubs(:render)
|
174
|
-
end
|
175
|
-
|
176
|
-
subject { instance.refresh }
|
177
|
-
|
178
|
-
it { subject.must_be_instance_of(described) }
|
179
|
-
|
180
|
-
it {
|
181
|
-
Vedeu.expects(:trigger).with(:_clear_view_content_, _name)
|
182
|
-
subject
|
183
|
-
}
|
184
|
-
|
185
|
-
it {
|
186
|
-
Vedeu::Output::Output.expects(:render)
|
187
|
-
subject
|
188
|
-
}
|
134
|
+
it { instance.must_respond_to(:refresh) }
|
189
135
|
end
|
190
136
|
|
191
137
|
describe '#right' do
|
192
|
-
|
193
|
-
|
194
|
-
it { subject.must_be_instance_of(described) }
|
195
|
-
# it { skip }
|
138
|
+
it { instance.must_respond_to(:right) }
|
196
139
|
end
|
197
140
|
|
198
141
|
describe '#up' do
|
199
|
-
|
142
|
+
it { instance.must_respond_to(:up) }
|
143
|
+
end
|
144
|
+
|
145
|
+
describe '#bol' do
|
146
|
+
it { instance.must_respond_to(:bol) }
|
147
|
+
end
|
200
148
|
|
201
|
-
|
202
|
-
|
149
|
+
describe '#eol' do
|
150
|
+
it { instance.must_respond_to(:eol) }
|
203
151
|
end
|
204
152
|
|
205
153
|
end # Editor
|
@@ -140,7 +140,7 @@ module Vedeu
|
|
140
140
|
context 'and x is the first character of the line' do
|
141
141
|
let(:x) { 0 }
|
142
142
|
let(:expected) {
|
143
|
-
Vedeu::Editor::Lines.new([Vedeu::Editor::Line.new('
|
143
|
+
Vedeu::Editor::Lines.new([Vedeu::Editor::Line.new('ydrogen')])
|
144
144
|
}
|
145
145
|
|
146
146
|
it { subject.must_equal(expected) }
|
@@ -180,7 +180,7 @@ module Vedeu
|
|
180
180
|
let(:expected) {
|
181
181
|
Vedeu::Editor::Lines.new([
|
182
182
|
Vedeu::Editor::Line.new('Hydrogen'),
|
183
|
-
Vedeu::Editor::Line.new('
|
183
|
+
Vedeu::Editor::Line.new('elium'),
|
184
184
|
Vedeu::Editor::Line.new('Lithium'),
|
185
185
|
])
|
186
186
|
}
|
@@ -411,67 +411,56 @@ module Vedeu
|
|
411
411
|
end
|
412
412
|
|
413
413
|
describe '#insert_line' do
|
414
|
-
let(:line) { "Many text..." }
|
415
414
|
let(:index) { 1 }
|
416
415
|
|
417
|
-
subject { instance.insert_line(
|
416
|
+
subject { instance.insert_line(index) }
|
418
417
|
|
419
418
|
it { subject.must_be_instance_of(described) }
|
420
419
|
|
421
|
-
context '
|
422
|
-
let(:
|
420
|
+
context 'and an index is not given' do
|
421
|
+
let(:index) {}
|
423
422
|
let(:expected) {
|
424
|
-
Vedeu::Editor::Lines.coerce(['Some text...', 'More text...', 'Other text...'])
|
423
|
+
Vedeu::Editor::Lines.coerce(['Some text...', 'More text...', 'Other text...', ''])
|
425
424
|
}
|
426
425
|
|
427
426
|
it { subject.must_equal(expected) }
|
428
427
|
end
|
429
428
|
|
430
|
-
context '
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
}
|
436
|
-
|
437
|
-
it { subject.must_equal(expected) }
|
438
|
-
end
|
439
|
-
|
440
|
-
context 'and a negative index is given' do
|
441
|
-
let(:index) { -4 }
|
442
|
-
let(:expected) {
|
443
|
-
Vedeu::Editor::Lines.coerce(['Many text...', 'Some text...', 'More text...', 'Other text...'])
|
444
|
-
}
|
429
|
+
context 'and a negative index is given' do
|
430
|
+
let(:index) { -4 }
|
431
|
+
let(:expected) {
|
432
|
+
Vedeu::Editor::Lines.coerce(['', 'Some text...', 'More text...', 'Other text...'])
|
433
|
+
}
|
445
434
|
|
446
|
-
|
447
|
-
|
435
|
+
it { subject.must_equal(expected) }
|
436
|
+
end
|
448
437
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
438
|
+
context 'and an index is given' do
|
439
|
+
let(:expected) {
|
440
|
+
Vedeu::Editor::Lines.coerce(['Some text...', '', 'More text...', 'Other text...'])
|
441
|
+
}
|
453
442
|
|
454
|
-
|
455
|
-
|
443
|
+
it { subject.must_equal(expected) }
|
444
|
+
end
|
456
445
|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
446
|
+
context 'and an index of the last line is given' do
|
447
|
+
let(:index) { 5 }
|
448
|
+
let(:expected) {
|
449
|
+
Vedeu::Editor::Lines.coerce(['Some text...', 'More text...', 'Other text...', ''])
|
450
|
+
}
|
462
451
|
|
463
|
-
|
464
|
-
|
452
|
+
it { subject.must_equal(expected) }
|
453
|
+
end
|
465
454
|
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
455
|
+
context 'and an index greater than the number of lines is given' do
|
456
|
+
let(:index) { 10 }
|
457
|
+
let(:expected) {
|
458
|
+
Vedeu::Editor::Lines.coerce(['Some text...', 'More text...', 'Other text...', ''])
|
459
|
+
}
|
471
460
|
|
472
|
-
|
473
|
-
end
|
461
|
+
it { subject.must_equal(expected) }
|
474
462
|
end
|
463
|
+
|
475
464
|
end
|
476
465
|
|
477
466
|
describe '#line' do
|
@@ -70,12 +70,20 @@ module Vedeu
|
|
70
70
|
end
|
71
71
|
|
72
72
|
describe '#by_zindex' do
|
73
|
+
let(:interfaces) {
|
74
|
+
[
|
75
|
+
Vedeu::Models::Interface.new(zindex: 3, name: 'c'),
|
76
|
+
Vedeu::Models::Interface.new(zindex: 1, name: 'a'),
|
77
|
+
Vedeu::Models::Interface.new(zindex: 2, name: 'b'),
|
78
|
+
]
|
79
|
+
}
|
80
|
+
|
81
|
+
before { instance.stubs(:interfaces).returns(interfaces) }
|
82
|
+
|
73
83
|
subject { instance.by_zindex }
|
74
84
|
|
75
85
|
it { subject.must_be_instance_of(Array) }
|
76
|
-
|
77
|
-
# @todo Add more tests.
|
78
|
-
# it { skip }
|
86
|
+
it { subject.must_equal(['a', 'b', 'c']) }
|
79
87
|
end
|
80
88
|
|
81
89
|
describe '#hide' do
|
@@ -59,19 +59,6 @@ module Vedeu
|
|
59
59
|
# it { skip }
|
60
60
|
end
|
61
61
|
|
62
|
-
describe '#render' do
|
63
|
-
before do
|
64
|
-
Vedeu::Output::Viewport.stubs(:render).with(instance)
|
65
|
-
end
|
66
|
-
|
67
|
-
subject { instance.render }
|
68
|
-
|
69
|
-
it {
|
70
|
-
Vedeu::Output::Viewport.expects(:render).with(instance)
|
71
|
-
subject
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
62
|
describe '#store_immediate' do
|
76
63
|
before { Vedeu.stubs(:trigger) }
|
77
64
|
|
@@ -52,14 +52,14 @@ module Vedeu
|
|
52
52
|
before do
|
53
53
|
Vedeu.interfaces.stubs(:by_name).returns(interface)
|
54
54
|
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
55
|
-
Vedeu
|
55
|
+
Vedeu.stubs(:render_output).returns(output)
|
56
56
|
end
|
57
57
|
|
58
58
|
subject { instance.render }
|
59
59
|
|
60
60
|
it { subject.must_be_instance_of(Array) }
|
61
61
|
it {
|
62
|
-
Vedeu
|
62
|
+
Vedeu.expects(:render_output).with(output)
|
63
63
|
subject
|
64
64
|
}
|
65
65
|
it { subject.must_equal(output) }
|
@@ -16,8 +16,8 @@ module Vedeu
|
|
16
16
|
it { instance.instance_variable_get('@output').must_equal(output) }
|
17
17
|
end
|
18
18
|
|
19
|
-
describe '.
|
20
|
-
subject { described.
|
19
|
+
describe '.render_output' do
|
20
|
+
subject { described.render_output(output) }
|
21
21
|
|
22
22
|
context 'when the output is empty' do
|
23
23
|
it { subject.must_be_instance_of(NilClass) }
|
@@ -51,8 +51,8 @@ module Vedeu
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe '#
|
55
|
-
it { instance.must_respond_to(:
|
54
|
+
describe '#render_output' do
|
55
|
+
it { instance.must_respond_to(:render_output) }
|
56
56
|
end
|
57
57
|
|
58
58
|
end # Output
|
@@ -40,7 +40,7 @@ module Vedeu
|
|
40
40
|
|
41
41
|
describe '.render' do
|
42
42
|
before do
|
43
|
-
Vedeu
|
43
|
+
Vedeu.stubs(:render_output)
|
44
44
|
Vedeu.stubs(:ready?).returns(ready)
|
45
45
|
end
|
46
46
|
|
@@ -49,7 +49,7 @@ module Vedeu
|
|
49
49
|
context 'when the interface is visible' do
|
50
50
|
context 'and Vedeu is ready' do
|
51
51
|
it {
|
52
|
-
Vedeu
|
52
|
+
Vedeu.expects(:render_output)
|
53
53
|
subject
|
54
54
|
}
|
55
55
|
end
|
data/test/lib/vedeu_test.rb
CHANGED
@@ -60,6 +60,7 @@ describe Vedeu do
|
|
60
60
|
it { Vedeu.must_respond_to(:ready!) }
|
61
61
|
it { Vedeu.must_respond_to(:ready?) }
|
62
62
|
it { Vedeu.must_respond_to(:render) }
|
63
|
+
it { Vedeu.must_respond_to(:render_output) }
|
63
64
|
it { Vedeu.must_respond_to(:renders) }
|
64
65
|
it { Vedeu.must_respond_to(:renderer) }
|
65
66
|
it { Vedeu.must_respond_to(:renderers) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|