vedeu 0.4.19 → 0.4.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,12 +38,16 @@ module Vedeu
38
38
  end
39
39
  alias_method :==, :eql?
40
40
 
41
+ # Returns the y coordinate.
42
+ #
41
43
  # @return [Fixnum]
42
44
  def y
43
45
  (iy <= 0) ? oy : (iy + oy)
44
46
  end
45
47
  alias_method :first, :y
46
48
 
49
+ # Returns the x coordinate.
50
+ #
47
51
  # @return [Fixnum]
48
52
  def x
49
53
  (ix <= 0) ? ox : (ix + ox)
@@ -29,6 +29,8 @@ module Vedeu
29
29
  end
30
30
  end
31
31
 
32
+ # Add a key to the keymap.
33
+ #
32
34
  # @param key [Key]
33
35
  # @return [void]
34
36
  def add(key)
@@ -37,11 +39,15 @@ module Vedeu
37
39
  @keys = keys.add(key)
38
40
  end
39
41
 
42
+ # Returns the collection of keys defined for this keymap.
43
+ #
40
44
  # @return [Vedeu::Keys]
41
45
  def keys
42
46
  collection.coerce(@keys, self)
43
47
  end
44
48
 
49
+ # Check whether the key is already defined for this keymap.
50
+ #
45
51
  # @param input [String|Symbol]
46
52
  # @return [Boolean] A boolean indicating the input provided is already in
47
53
  # use for this keymap.
@@ -98,6 +98,14 @@ module Vedeu
98
98
  alias_method :content?, :lines?
99
99
  alias_method :value?, :lines?
100
100
 
101
+ # Returns a boolean indicating whether the interface belongs to a
102
+ # group.
103
+ #
104
+ # @return [Boolean]
105
+ def group?
106
+ !group.nil? && !group.empty?
107
+ end
108
+
101
109
  # @return [Array<Array<Vedeu::Char>>]
102
110
  def render
103
111
  return [] unless visible?
@@ -6,32 +6,6 @@ module Vedeu
6
6
 
7
7
  private
8
8
 
9
- # Registers a HTML/CSS colour code and escape sequence to reduce processing.
10
- #
11
- # @param colour [String] A HTML/CSS colour code.
12
- # @param escape_sequence [String] The HTML/CSS colour code as an escape
13
- # sequence.
14
- # @return [String]
15
- def register(colour, escape_sequence)
16
- Vedeu.background_colours.register(colour, escape_sequence)
17
- end
18
-
19
- # Returns a boolean indicating the HTML/CSS colour code has been registered.
20
- #
21
- # @param colour [String]
22
- # @return [Boolean]
23
- def registered?(colour)
24
- Vedeu.background_colours.registered?(colour)
25
- end
26
-
27
- # Retrieves the escape sequence for the HTML/CSS colour code.
28
- #
29
- # @param colour [String]
30
- # @return [String]
31
- def retrieve(colour)
32
- Vedeu.background_colours.retrieve(colour)
33
- end
34
-
35
9
  # @return [String]
36
10
  def named_codes
37
11
  Vedeu::Esc.background_codes[colour]
@@ -42,6 +16,11 @@ module Vedeu
42
16
  "\e[48;5;"
43
17
  end
44
18
 
19
+ # @return [Vedeu::BackgroundColours]
20
+ def repository
21
+ Vedeu.background_colours
22
+ end
23
+
45
24
  # @return [String]
46
25
  def rgb_prefix
47
26
  "\e[48;2;%s;%s;%sm"
@@ -6,32 +6,6 @@ module Vedeu
6
6
 
7
7
  private
8
8
 
9
- # Registers a HTML/CSS colour code and escape sequence to reduce processing.
10
- #
11
- # @param colour [String] A HTML/CSS colour code.
12
- # @param escape_sequence [String] The HTML/CSS colour code as an escape
13
- # sequence.
14
- # @return [String]
15
- def register(colour, escape_sequence)
16
- Vedeu.foreground_colours.register(colour, escape_sequence)
17
- end
18
-
19
- # Returns a boolean indicating the HTML/CSS colour code has been registered.
20
- #
21
- # @param colour [String]
22
- # @return [Boolean]
23
- def registered?(colour)
24
- Vedeu.foreground_colours.registered?(colour)
25
- end
26
-
27
- # Retrieves the escape sequence for the HTML/CSS colour code.
28
- #
29
- # @param colour [String]
30
- # @return [String]
31
- def retrieve(colour)
32
- Vedeu.foreground_colours.retrieve(colour)
33
- end
34
-
35
9
  # @return [String]
36
10
  def named_codes
37
11
  Vedeu::Esc.foreground_codes[colour]
@@ -42,6 +16,11 @@ module Vedeu
42
16
  "\e[38;5;"
43
17
  end
44
18
 
19
+ # @return [Vedeu::ForegroundColours]
20
+ def repository
21
+ Vedeu.foreground_colours
22
+ end
23
+
45
24
  # @return [String]
46
25
  def rgb_prefix
47
26
  "\e[38;2;%s;%s;%sm"
@@ -105,18 +105,30 @@ module Vedeu
105
105
 
106
106
  private
107
107
 
108
- # Subclasses implement this method.
108
+ # Retrieves the escape sequence for the HTML/CSS colour code.
109
109
  #
110
+ # @param colour [String]
110
111
  # @return [String]
111
- def retrieve(*)
112
- ''
112
+ def retrieve(colour)
113
+ repository.retrieve(colour)
113
114
  end
114
115
 
115
- # Subclasses implement this method.
116
+ # Registers a HTML/CSS colour code and escape sequence to reduce processing.
116
117
  #
117
- # @return [FalseClass]
118
- def registered?(*)
119
- false
118
+ # @param colour [String] A HTML/CSS colour code.
119
+ # @param escape_sequence [String] The HTML/CSS colour code as an escape
120
+ # sequence.
121
+ # @return [String]
122
+ def register(colour, escape_sequence)
123
+ repository.register(colour, escape_sequence)
124
+ end
125
+
126
+ # Returns a boolean indicating the HTML/CSS colour code has been registered.
127
+ #
128
+ # @param colour [String]
129
+ # @return [Boolean]
130
+ def registered?(colour)
131
+ repository.registered?(colour)
120
132
  end
121
133
 
122
134
  # @return [Boolean]
@@ -243,26 +255,16 @@ module Vedeu
243
255
  (css_to_rgb[2] / 51) * 1
244
256
  end
245
257
 
246
- # @raise [NotImplemented] Subclasses of this class must implement this
247
- # method.
248
- # @return [Exception]
249
- def named_codes
250
- fail NotImplemented, 'Subclasses implement this.'
251
- end
252
-
253
- # @raise [NotImplemented] Subclasses of this class must implement this
254
- # method.
255
- # @return [NotImplemented]
256
- def numbered_prefix
257
- fail NotImplemented, 'Subclasses implement this.'
258
- end
259
-
260
258
  # @raise [NotImplemented] Subclasses of this class must implement this
261
259
  # method.
262
260
  # @return [NotImplemented]
263
- def rgb_prefix
261
+ def not_implemented
264
262
  fail NotImplemented, 'Subclasses implement this.'
265
263
  end
264
+ alias_method :named_codes, :not_implemented
265
+ alias_method :numbered_prefix, :not_implemented
266
+ alias_method :repository, :not_implemented
267
+ alias_method :rgb_prefix, :not_implemented
266
268
 
267
269
  end # Translator
268
270
 
@@ -4,61 +4,310 @@ module Vedeu
4
4
 
5
5
  describe API do
6
6
 
7
- describe '.log' do
8
- it 'writes the message to the log file when debugging is enabled' do
9
- Configuration.stub(:debug?, true) do
10
- Vedeu.log(type: :test,
11
- message: 'Testing debugging to log').must_equal(true)
7
+ describe 'Forwardable' do
8
+
9
+ describe 'Vedeu::BackgroundColours' do
10
+ describe '.background_colours' do
11
+ subject { Vedeu.background_colours }
12
+
13
+ # it { subject.must_be_instance_of(Vedeu::BackgroundColours) }
12
14
  end
13
15
  end
14
16
 
15
- it 'returns nil when debugging is disabled' do
16
- Configuration.stub(:debug?, false) do
17
- Vedeu.log(type: :test,
18
- message: 'some message not logged...').must_equal(nil)
17
+ describe 'Vedeu::Borders' do
18
+ describe '.borders' do
19
+ subject { Vedeu.borders }
20
+
21
+ # it { subject.must_be_instance_of(Vedeu::Borders) }
19
22
  end
20
23
  end
21
24
 
22
- it 'write the message to the log file when the `force` argument ' \
23
- 'evaluates to true' do
24
- Configuration.stub(:debug?, false) do
25
- Vedeu.log(type: :test,
26
- message: 'Testing forced debugging to log',
27
- force: true).must_equal(true)
25
+ describe 'Vedeu::Buffers' do
26
+ describe '.buffers' do
27
+ subject { Vedeu.buffers }
28
+
29
+ # it { subject.must_be_instance_of(Vedeu::Buffers) }
28
30
  end
29
31
  end
30
- end
31
32
 
32
- describe '.menu' do
33
- it 'creates and stores a new menu' do
34
- Vedeu.menu('Vedeu.menu') do
35
- # ...
36
- end.must_be_instance_of(Vedeu::Menu)
33
+ describe 'Vedeu::Canvas' do
34
+ describe '.canvas' do
35
+ subject { Vedeu.canvas }
36
+
37
+ # it { subject.must_be_instance_of(Vedeu::Canvas) }
38
+ end
37
39
  end
38
- end
39
40
 
40
- describe '.menus' do
41
- it 'accesses the menus repository' do
42
- Vedeu.menus.must_be_instance_of(Vedeu::Menus)
41
+ describe 'Vedeu::Configuration' do
42
+ describe '.configure' do
43
+ subject { Vedeu.configure }
44
+
45
+ # it { subject.must_be_instance_of(NilClass) }
46
+ end
47
+
48
+ describe '.configuration' do
49
+ subject { Vedeu.configuration }
50
+
51
+ # it { subject.must_be_instance_of(Vedeu::Configuration) }
52
+ end
43
53
  end
44
- end
45
54
 
46
- describe '.resize' do
47
- before do
48
- Vedeu.interfaces.reset
49
- Terminal.console.stubs(:print)
55
+ describe 'Vedeu::Cursors' do
56
+ describe '.cursor' do
57
+ subject { Vedeu.cursor }
58
+
59
+ # when all tests run
60
+ # it { subject.must_be_instance_of(Vedeu::Cursor) }
61
+
62
+ # when just this test runs
63
+ # it { subject.must_be_instance_of(NilClass) }
64
+ end
65
+
66
+ describe '.cursors' do
67
+ subject { Vedeu.cursors }
68
+
69
+ # it { subject.must_be_instance_of(Vedeu::Cursors) }
70
+ end
50
71
  end
51
72
 
52
- it 'returns a TrueClass' do
53
- Vedeu.resize.must_be_instance_of(TrueClass)
73
+ describe 'Vedeu::DSL::Border' do
74
+ describe '.border' do
75
+ let(:arg) {}
76
+
77
+ subject { Vedeu.border(arg) {} }
78
+
79
+ # it { subject.must_be_instance_of(NilClass) }
80
+ end
54
81
  end
55
- end
56
82
 
57
- describe '.trigger' do
58
- it 'triggers the specifed event and returns the collection of events' \
59
- ' which this trigger triggers' do
60
- Vedeu.trigger(:vedeu_trigger_event, :event_arguments).must_equal([])
83
+ describe 'Vedeu::DSL::Geometry' do
84
+ describe '.geometry' do
85
+ let(:arg) {}
86
+
87
+ subject { Vedeu.geometry(arg) { } }
88
+
89
+ # it { subject.must_be_instance_of(NilClass) }
90
+ end
61
91
  end
92
+
93
+ describe 'Vedeu::DSL::Group' do
94
+ describe '.group' do
95
+ let(:arg) {}
96
+
97
+ subject { Vedeu.group(arg) { } }
98
+
99
+ # it { subject.must_be_instance_of(NilClass) }
100
+ end
101
+ end
102
+
103
+ describe 'Vedeu::DSL::Keymap' do
104
+ describe '.keymap' do
105
+ let(:arg) {}
106
+
107
+ subject { Vedeu.keymap(arg) }
108
+
109
+ # it { subject.must_be_instance_of(NilClass) }
110
+ end
111
+ end
112
+
113
+ describe 'Vedeu::DSL::View' do
114
+ describe '.interface' do
115
+ subject { Vedeu.interface { } }
116
+
117
+ # it { subject.must_be_instance_of(NilClass) }
118
+ end
119
+
120
+ describe '.renders' do
121
+ subject { Vedeu.renders { } }
122
+
123
+ # it { subject.must_be_instance_of(Array) }
124
+ end
125
+
126
+ describe '.views' do
127
+ subject { Vedeu.views { } }
128
+
129
+ # it { subject.must_be_instance_of(Array) }
130
+ end
131
+ end
132
+
133
+ describe 'Vedeu::Event' do
134
+ describe '.bind' do
135
+ let(:args) {}
136
+
137
+ subject { Vedeu.bind(args) }
138
+
139
+ # it { subject.must_be_instance_of(NilClass) }
140
+ end
141
+
142
+ describe '.unbind' do
143
+ let(:args) {}
144
+
145
+ subject { Vedeu.unbind(args) }
146
+
147
+ # it { subject.must_be_instance_of(FalseClass) }
148
+ end
149
+ end
150
+
151
+ describe 'Vedeu::EventsRepository' do
152
+ describe '.events' do
153
+ subject { Vedeu.events }
154
+
155
+ # it { subject.must_be_instance_of(Vedeu::EventsRepository) }
156
+ end
157
+ end
158
+
159
+ describe 'Vedeu::Focus' do
160
+ describe '.focus' do
161
+ subject { Vedeu.focus }
162
+
163
+ # it { subject.must_be_instance_of(NilClass) }
164
+ end
165
+
166
+ describe '.focus_by_name' do
167
+ let(:_name) {}
168
+
169
+ subject { Vedeu.focus_by_name(_name) }
170
+
171
+ # it { subject.must_be_instance_of(NilClass) }
172
+ end
173
+
174
+ describe '.focussed?' do
175
+ let(:arg) {}
176
+
177
+ subject { Vedeu.focussed?(arg) }
178
+
179
+ # it { subject.must_be_instance_of(TrueClass) }
180
+ end
181
+
182
+ describe '.focus_next' do
183
+ subject { Vedeu.focus_next }
184
+
185
+ # it { subject.must_be_instance_of(FalseClass) }
186
+ end
187
+
188
+ describe '.focus_previous' do
189
+ subject { Vedeu.focus_previous }
190
+
191
+ # it { subject.must_be_instance_of(FalseClass) }
192
+ end
193
+ end
194
+
195
+ describe 'Vedeu::ForegroundColours' do
196
+ describe '.foreground_colours' do
197
+ subject { Vedeu.foreground_colours }
198
+
199
+ # it { subject.must_be_instance_of(Vedeu::ForegroundColours) }
200
+ end
201
+ end
202
+
203
+ describe 'Vedeu::Geometries' do
204
+ describe '.geometries' do
205
+ subject { Vedeu.geometries }
206
+
207
+ # it { subject.must_be_instance_of(Vedeu::Geometries) }
208
+ end
209
+ end
210
+
211
+ describe 'Vedeu::Groups' do
212
+ describe '.groups' do
213
+ subject { Vedeu.groups }
214
+
215
+ # it { subject.must_be_instance_of(Vedeu::Groups) }
216
+ end
217
+ end
218
+
219
+ describe 'Vedeu::InterfacesRepository' do
220
+ describe '.interfaces' do
221
+ subject { Vedeu.interfaces }
222
+
223
+ # it { subject.must_be_instance_of(Vedeu::InterfacesRepository) }
224
+ end
225
+ end
226
+
227
+ describe 'Vedeu::Keymaps' do
228
+ describe '.keymaps' do
229
+ subject { Vedeu.keymaps }
230
+
231
+ # it { subject.must_be_instance_of(Vedeu::Keymaps) }
232
+ end
233
+ end
234
+
235
+ describe 'Vedeu::Log' do
236
+ describe '.log' do
237
+ subject { Vedeu.log(message: '') }
238
+
239
+ # it { subject.must_be_instance_of(NilClass) }
240
+ end
241
+ end
242
+
243
+ describe 'Vedeu::Mapper' do
244
+ describe '.keypress' do
245
+ subject { Vedeu.keypress }
246
+
247
+ # it { subject.must_be_instance_of(FalseClass) }
248
+ end
249
+ end
250
+
251
+ describe 'Vedeu::Menu' do
252
+ describe '.menu' do
253
+ subject { Vedeu.menu { } }
254
+
255
+ # it { subject.must_be_instance_of(NilClass) }
256
+ end
257
+ end
258
+
259
+ describe 'Vedeu::Menus' do
260
+ describe '.menus' do
261
+ subject { Vedeu.menus }
262
+
263
+ # it { subject.must_be_instance_of(Vedeu::Menus) }
264
+ end
265
+ end
266
+
267
+ describe 'Vedeu::Renderers' do
268
+ describe '.renderer' do
269
+ subject { Vedeu.renderer }
270
+
271
+ # it { subject.must_be_instance_of(Set) }
272
+ end
273
+
274
+ describe '.renderers' do
275
+ subject { Vedeu.renderers }
276
+
277
+ # it { subject.must_be_instance_of(Module) }
278
+ end
279
+ end
280
+
281
+ describe 'Vedeu::Terminal' do
282
+ describe '.height' do
283
+ subject { Vedeu.height }
284
+
285
+ # it { subject.must_be_instance_of(Fixnum) }
286
+ end
287
+
288
+ describe '.width' do
289
+ subject { Vedeu.width }
290
+
291
+ # it { subject.must_be_instance_of(Fixnum) }
292
+ end
293
+
294
+ describe '.resize' do
295
+ subject { Vedeu.resize }
296
+
297
+ # it { subject.must_be_instance_of(TrueClass) }
298
+ end
299
+ end
300
+
301
+ describe 'Vedeu::Trigger' do
302
+ describe '.trigger' do
303
+ let(:args) {}
304
+
305
+ subject { Vedeu.trigger(args) }
306
+
307
+ # it { subject.must_be_instance_of(Array) }
308
+ end
309
+ end
310
+
62
311
  end
63
312
 
64
313
  end # API