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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31ffcc8349f9218094f5a70a9aad877413bd7190
4
- data.tar.gz: c2cba91b9c9c55055ca68aff099fb974005b6c03
3
+ metadata.gz: 815df61c875e913607ccedbc8d9851c4888b4a5b
4
+ data.tar.gz: 31b4afe5a7789f707d7e17ae05127c8e66b34684
5
5
  SHA512:
6
- metadata.gz: e70bd67f435d4db9713ffdc8cb729463e7a7189bfd5ce4d4aa3a4d1d22c699ad3c43647d5410492632497450e51786f1a2cab57345e3b3bc7407783820c857df
7
- data.tar.gz: d3cbb5f04bc6eb6f12d452e51c0711254f2203d82b2c929c97157a0e7c98d9d922e5443d3323bf7a69cfa92d90cf568d3ae2a461bc9759e0ebadd0551131ba42
6
+ metadata.gz: cf4133bd63868341598ed14ca0b0086f45f8604f40bebe8013365ba36976fed7502755e93c09a968810db61cc07ae410089bfcb0b3f266c9ce27f9b38ec509a8
7
+ data.tar.gz: 88c0bee0f579b4a8d75c693e78c3cd99d263f7f867601c3c69fd0d081ff387024f138a6dd1b7e97cc82379a8a88b1a7f4dd6229956dd27b7bd22ee019bd95b07
@@ -57,7 +57,7 @@ module Vedeu
57
57
 
58
58
  # @return [Array<Array<Vedeu::Views::Char>>]
59
59
  def render
60
- Vedeu::Output::Output.render(output) if enabled?
60
+ Vedeu.render_output(output) if enabled?
61
61
  end
62
62
 
63
63
  protected
@@ -112,10 +112,10 @@ module Vedeu
112
112
  swap if back?
113
113
 
114
114
  if front?
115
- front.render
115
+ Vedeu::Output::Viewport.render(front)
116
116
 
117
117
  elsif previous?
118
- previous.render
118
+ Vedeu::Output::Viewport.render(previous)
119
119
 
120
120
  end
121
121
  end
@@ -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
- # slogged.
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
@@ -132,7 +132,9 @@ module Vedeu
132
132
  #
133
133
  # @return [Array<Vedeu::Models::Escape>]
134
134
  def render
135
- Vedeu::Output::Output.render(escape_sequence)
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.
@@ -37,8 +37,6 @@ module Vedeu
37
37
  #
38
38
  # @return [Array]
39
39
  def by_name
40
- Vedeu.log(type: :info, message: "Refreshing cursor: '#{name}'")
41
-
42
40
  Vedeu.trigger(:_refresh_view_content_, name) if refresh_view?
43
41
 
44
42
  cursor.render
@@ -46,9 +46,17 @@ module Vedeu
46
46
  #
47
47
  # @return [Vedeu::Editor::Document]
48
48
  def delete_character
49
- @lines = lines.delete_character(y, x - 1)
49
+ if x - 1 < 0 && y == 0
50
+ bol
50
51
 
51
- left
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
- down
106
+ @lines = lines.insert_line(y + 1)
97
107
 
98
- @lines = lines.insert_line(Vedeu::Editor::Line.new, y)
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(y)
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::Output::Output.render(output)
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
- cursor.up
181
+ if x > line(y - 1).size
182
+ cursor.up
168
183
 
169
- refresh
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
- cursor.down
198
+ return self if y + 1 >= lines.size
177
199
 
178
- refresh
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.
@@ -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
@@ -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 <= 0)
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) }
@@ -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 <= 0)
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
- size == 0
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(line, index = nil)
127
- return self unless line
128
-
129
- Vedeu::Editor::Lines.coerce(Vedeu::Editor::Insert
130
- .into(lines, line, index, size))
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 unless lines
139
- return Vedeu::Editor::Line.coerce(lines.last) unless index
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.first
144
+ lines[0]
143
145
 
144
146
  elsif index && index <= size
145
147
  lines[index]
146
148
 
147
149
  else
148
- lines.last
150
+ lines[-1]
149
151
 
150
152
  end
151
153
 
data/lib/vedeu/esc/esc.rb CHANGED
@@ -40,7 +40,7 @@ module Vedeu
40
40
  def string(value = '')
41
41
  return '' if value.empty?
42
42
 
43
- send(value.to_sym)
43
+ send(value)
44
44
  rescue NoMethodError
45
45
  ''
46
46
  end
@@ -69,7 +69,7 @@ module Vedeu
69
69
  #
70
70
  # @return [Array<String>]
71
71
  def by_zindex
72
- interfaces.sort { |a, b| a.zindex <=> b.zindex }.map(&:name)
72
+ interfaces.sort_by(&:zindex).map(&:name)
73
73
  end
74
74
 
75
75
  # An object is equal when its values are the same.
@@ -36,12 +36,12 @@ module Vedeu
36
36
 
37
37
  # @return [NilClass|Symbol|String]
38
38
  def last_command
39
- all_commands.last
39
+ all_commands[-1]
40
40
  end
41
41
 
42
42
  # @return [NilClass|Symbol|String]
43
43
  def last_keypress
44
- all_keypresses.last
44
+ all_keypresses[-1]
45
45
  end
46
46
 
47
47
  # @return [Hash<Symbol => Array<Symbol|String>>]
@@ -142,6 +142,7 @@ module Vedeu
142
142
  create: [:light_green, :green],
143
143
  debug: [:light_red, :red],
144
144
  error: [:light_red, :red],
145
+ editor: [:light_blue, :blue],
145
146
  drb: [:light_blue, :blue],
146
147
  event: [:light_magenta, :magenta],
147
148
  info: [:white, :default],
@@ -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
  #
@@ -51,7 +51,7 @@ module Vedeu
51
51
 
52
52
  # @return [Array<Array<Vedeu::Views::Char>>]
53
53
  def render
54
- Vedeu::Output::Output.render(output)
54
+ Vedeu.render_output(output)
55
55
  end
56
56
 
57
57
  protected
@@ -13,8 +13,8 @@ module Vedeu
13
13
  #
14
14
  # @return [Array|String]
15
15
  # @see #initialize
16
- def self.render(output)
17
- new(output).render
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 render
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 view [Vedeu::Views::View]
30
- # @return [Array<Array<Vedeu::Views::Char>>]
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::Output::Output.render(output) if visible?
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.first
176
+ size[0]
177
177
  end
178
178
  alias_method :yn, :height
179
179
  alias_method :tyn, :height
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.24'
4
+ VERSION = '0.6.25'
5
5
 
6
6
  end
@@ -56,7 +56,7 @@ module Vedeu
56
56
  let(:enabled) { true }
57
57
 
58
58
  it {
59
- Vedeu::Output::Output.expects(:render)
59
+ Vedeu.expects(:render_output)
60
60
  subject
61
61
  }
62
62
  end
@@ -106,7 +106,7 @@ module Vedeu
106
106
  describe '#render' do
107
107
  before {
108
108
  Vedeu.stubs(:log)
109
- Vedeu::Output::Output.stubs(:render)
109
+ Vedeu.stubs(:render_output)
110
110
  }
111
111
 
112
112
  subject { instance.render }
@@ -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::Output::Output.stubs(:render).
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::Output::Output.stubs(:render).
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::Output::Output.stubs(:render)
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
- let(:y) { 0 }
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
- let(:y) { 0 }
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
- subject { instance.down }
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
- let(:character) { 'a' }
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
- let(:y) { 2 }
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
- subject { instance.left }
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
- subject { instance.reset! }
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
- before do
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
- subject { instance.right }
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
- subject { instance.up }
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
- it { subject.must_be_instance_of(described) }
202
- # it { skip }
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('Hydrogen')])
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('Helium'),
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(line, index) }
416
+ subject { instance.insert_line(index) }
418
417
 
419
418
  it { subject.must_be_instance_of(described) }
420
419
 
421
- context 'when a line is not given' do
422
- let(:line) {}
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 'when a line is given' do
431
- context 'and an index is not given' do
432
- let(:index) {}
433
- let(:expected) {
434
- Vedeu::Editor::Lines.coerce(['Some text...', 'More text...', 'Other text...', 'Many text...'])
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
- it { subject.must_equal(expected) }
447
- end
435
+ it { subject.must_equal(expected) }
436
+ end
448
437
 
449
- context 'and an index is given' do
450
- let(:expected) {
451
- Vedeu::Editor::Lines.coerce(['Some text...', 'Many text...', 'More text...', 'Other text...'])
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
- it { subject.must_equal(expected) }
455
- end
443
+ it { subject.must_equal(expected) }
444
+ end
456
445
 
457
- context 'and an index of the last line is given' do
458
- let(:index) { 5 }
459
- let(:expected) {
460
- Vedeu::Editor::Lines.coerce(['Some text...', 'More text...', 'Other text...', 'Many text...'])
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
- it { subject.must_equal(expected) }
464
- end
452
+ it { subject.must_equal(expected) }
453
+ end
465
454
 
466
- context 'and an index greater than the number of lines is given' do
467
- let(:index) { 10 }
468
- let(:expected) {
469
- Vedeu::Editor::Lines.coerce(['Some text...', 'More text...', 'Other text...', 'Many text...'])
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
- it { subject.must_equal(expected) }
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::Output::Output.stubs(:render).returns(output)
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::Output::Output.expects(:render).with(output)
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 '.render' do
20
- subject { described.render(output) }
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 '#render' do
55
- it { instance.must_respond_to(:render) }
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::Output::Output.stubs(:render)
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::Output::Output.expects(:render)
52
+ Vedeu.expects(:render_output)
53
53
  subject
54
54
  }
55
55
  end
@@ -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) }
@@ -36,7 +36,7 @@ class VedeuEditorApp
36
36
  x columns(1)
37
37
  xn columns(11)
38
38
  y rows(1)
39
- yn rows(1) + 4
39
+ yn rows(1) + 10
40
40
  end
41
41
  zindex 1
42
42
  end
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.24
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-02 00:00:00.000000000 Z
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard