vedeu 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/docs/api.md +1 -1
  3. data/docs/events.md +11 -8
  4. data/lib/vedeu/api/api.rb +19 -43
  5. data/lib/vedeu/api/composition.rb +13 -8
  6. data/lib/vedeu/api/defined.rb +14 -4
  7. data/lib/vedeu/api/helpers.rb +8 -5
  8. data/lib/vedeu/api/interface.rb +15 -21
  9. data/lib/vedeu/api/keymap.rb +11 -5
  10. data/lib/vedeu/api/line.rb +6 -7
  11. data/lib/vedeu/api/menu.rb +9 -17
  12. data/lib/vedeu/api/stream.rb +8 -6
  13. data/lib/vedeu/application.rb +14 -12
  14. data/lib/vedeu/configuration/api.rb +33 -3
  15. data/lib/vedeu/configuration/cli.rb +23 -3
  16. data/lib/vedeu/configuration/configuration.rb +3 -2
  17. data/lib/vedeu/input/input.rb +6 -2
  18. data/lib/vedeu/launcher.rb +5 -2
  19. data/lib/vedeu/models/attributes/background.rb +3 -2
  20. data/lib/vedeu/models/attributes/coercions.rb +3 -2
  21. data/lib/vedeu/models/attributes/colour_translator.rb +11 -4
  22. data/lib/vedeu/models/attributes/foreground.rb +3 -2
  23. data/lib/vedeu/models/attributes/presentation.rb +3 -2
  24. data/lib/vedeu/models/colour.rb +3 -2
  25. data/lib/vedeu/models/composition.rb +5 -2
  26. data/lib/vedeu/models/cursor.rb +3 -2
  27. data/lib/vedeu/models/geometry.rb +48 -6
  28. data/lib/vedeu/models/interface.rb +12 -2
  29. data/lib/vedeu/models/keymap.rb +4 -2
  30. data/lib/vedeu/models/line.rb +5 -2
  31. data/lib/vedeu/models/stream.rb +12 -2
  32. data/lib/vedeu/models/style.rb +3 -2
  33. data/lib/vedeu/output/clear.rb +5 -2
  34. data/lib/vedeu/output/compositor.rb +4 -2
  35. data/lib/vedeu/output/refresh.rb +4 -6
  36. data/lib/vedeu/output/render.rb +17 -14
  37. data/lib/vedeu/output/view.rb +5 -2
  38. data/lib/vedeu/repositories/buffers.rb +16 -47
  39. data/lib/vedeu/repositories/cursors.rb +26 -28
  40. data/lib/vedeu/repositories/events.rb +33 -48
  41. data/lib/vedeu/repositories/focus.rb +24 -20
  42. data/lib/vedeu/repositories/groups.rb +17 -52
  43. data/lib/vedeu/repositories/interfaces.rb +21 -42
  44. data/lib/vedeu/repositories/keymaps.rb +9 -57
  45. data/lib/vedeu/repositories/menus.rb +15 -55
  46. data/lib/vedeu/support/common.rb +2 -2
  47. data/lib/vedeu/support/esc.rb +35 -2
  48. data/lib/vedeu/support/event.rb +7 -8
  49. data/lib/vedeu/support/exceptions.rb +47 -0
  50. data/lib/vedeu/support/grid.rb +11 -4
  51. data/lib/vedeu/support/keymap_validator.rb +9 -14
  52. data/lib/vedeu/support/log.rb +13 -3
  53. data/lib/vedeu/support/menu.rb +3 -2
  54. data/lib/vedeu/support/position.rb +3 -2
  55. data/lib/vedeu/support/registrar.rb +2 -23
  56. data/lib/vedeu/support/repository.rb +77 -0
  57. data/lib/vedeu/support/terminal.rb +12 -2
  58. data/lib/vedeu/support/trace.rb +127 -20
  59. data/lib/vedeu.rb +11 -46
  60. data/test/lib/vedeu/api/api_test.rb +14 -18
  61. data/test/lib/vedeu/api/defined_test.rb +16 -6
  62. data/test/lib/vedeu/api/interface_test.rb +5 -20
  63. data/test/lib/vedeu/api/menu_test.rb +1 -1
  64. data/test/lib/vedeu/models/geometry_test.rb +41 -0
  65. data/test/lib/vedeu/models/interface_test.rb +14 -0
  66. data/test/lib/vedeu/repositories/buffers_test.rb +6 -32
  67. data/test/lib/vedeu/repositories/cursors_test.rb +14 -0
  68. data/test/lib/vedeu/repositories/events_test.rb +18 -47
  69. data/test/lib/vedeu/repositories/focus_test.rb +18 -5
  70. data/test/lib/vedeu/repositories/groups_test.rb +3 -62
  71. data/test/lib/vedeu/repositories/interfaces_test.rb +13 -49
  72. data/test/lib/vedeu/repositories/keymaps_test.rb +0 -23
  73. data/test/lib/vedeu/repositories/menus_test.rb +3 -62
  74. data/test/lib/vedeu/support/esc_test.rb +24 -0
  75. data/test/lib/vedeu/support/keymap_validator_test.rb +19 -38
  76. data/test/lib/vedeu/support/repository_test.rb +70 -0
  77. data/test/test_helper.rb +2 -0
  78. data/vedeu.gemspec +3 -3
  79. metadata +10 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c51db32c71781208264d0ea69bf433a5bde9bf75
4
- data.tar.gz: bb5067249adad44b4788b4abcb0471c513d0ec9b
3
+ metadata.gz: 53b812fdf424dda850a0a008b824cb388a2329cb
4
+ data.tar.gz: 85d3208b47291886ed7dad1913fe29bb7806b2b8
5
5
  SHA512:
6
- metadata.gz: 16bbad5b4ffb6b0748dbef756d4b5db9ef0abb562c842246a66aee21cbd3c3f1bcf7d0aeb43cf44171b958be9f8c821e199b61eea0439b571536238894341545
7
- data.tar.gz: a29d38fd26002e43980502708196e9d3434a7a92f7b952feafc571e74dce7b27664c962bb0674a2607284824af145b6554f85616c256d48528b31c0288e986c3
6
+ metadata.gz: 6d2e44aebbefa2314e55ba466f262d9417ed6380872746d23f2b9e9fe940c70f9fbbc741ec756e1069211c54498d8da09de57702076814bf014f717bdb7908a5
7
+ data.tar.gz: 4cc8fd2986658da91d8d4b10d48da4514e9eaf588c11dc4941b2173471e85ccaf1adea8e5d19453f1f65532c5395e6234f5ffcca656743b7a9609e86dfb35adb
data/docs/api.md CHANGED
@@ -59,7 +59,7 @@ Note: Nesting indicates where an API method is allowed/supposed to be used.
59
59
  #### Interfaces
60
60
 
61
61
  - interface
62
- - centred
62
+ - centred (or centred!)
63
63
  - colour
64
64
  - delay
65
65
  - group
data/docs/events.md CHANGED
@@ -15,10 +15,6 @@ Events described in this document assume that you have included Vedeu in your cl
15
15
 
16
16
  System events generally control the internal state of Vedeu with respects to your application. They are soft-namespaced using underscores.
17
17
 
18
- ### `:_cleanup_`
19
-
20
- This event is fired by Vedeu when `:_exit_` is triggered. You can hook into this to perform a special action before the application terminates. Saving the user's work, session or preferences might be popular here.
21
-
22
18
  ### `:_clear_`
23
19
 
24
20
  Clears the whole terminal space.
@@ -67,10 +63,6 @@ When triggered will focus the next interface and restore the cursor position and
67
63
 
68
64
  When triggered will focus the previous interface and restore the cursor position and visibility.
69
65
 
70
- ### `:_initialize_`
71
-
72
- Special event which Vedeu triggers when it is ready to enter the main loop. Client applications can listen for this event and perform some action(s), like render the first screen, interface or make a sound.
73
-
74
66
  ### `:_keypress_`
75
67
 
76
68
  Triggering this event will cause the triggering of the `:key` event; which you should define to 'do things'. If the `escape` key is pressed, then `key` is triggered with the argument `:escape`, also an internal event `_mode_switch_` is triggered.
@@ -153,6 +145,17 @@ System events can be handled or triggered by your application also, but overridi
153
145
 
154
146
  User events allow you to orchestrate behaviour within your application, ie. the user presses a specific key, you trigger an event to make something happen. Eg. pressing 'p' instructs the player to play.
155
147
 
148
+ ## Pre-defined User Events
149
+
150
+ Vedeu pre-defines a few user events, which client applications can listen for, or trigger themselves.
151
+
152
+ ### `:_cleanup_`
153
+
154
+ Vedeu triggers this event when `:_exit_` is triggered. You can hook into this to perform a special action before the application terminates. Saving the user's work, session or preferences might be popular here.
155
+
156
+ ### `:_initialize_`
157
+
158
+ Vedeu triggers this event when it is ready to enter the main loop. Client applications can listen for this event and perform some action(s), like render the first screen, interface or make a sound.
156
159
 
157
160
  #### How to define user events
158
161
 
data/lib/vedeu/api/api.rb CHANGED
@@ -1,16 +1,17 @@
1
1
  module Vedeu
2
2
 
3
- # Vedeu::Trace.call({ trace: true })
4
-
5
3
  # Provides the API to Vedeu. Methods therein, and classes belonging to this
6
4
  # module expose Vedeu's core functionality.
5
+ #
6
+ # @api public
7
7
  module API
8
8
 
9
9
  # Configure Vedeu using a simple configuration DSL.
10
10
  #
11
- # @api public
11
+ # @param block [Proc]
12
+ # @raise [InvalidSyntax] When the required block is not given.
13
+ # @return [Hash]
12
14
  # @see Vedeu::Configuration
13
- # @return []
14
15
  def configure(&block)
15
16
  fail InvalidSyntax, '`configure` requires a block.' unless block_given?
16
17
 
@@ -20,9 +21,8 @@ module Vedeu
20
21
  # Returns information about various registered subsystems when used with
21
22
  # a defined method within {Vedeu::API::Defined}.
22
23
  #
23
- # @api public
24
- # @see Vedeu::API::Defined
25
24
  # @return [Vedeu::API::Defined]
25
+ # @see Vedeu::API::Defined
26
26
  def defined
27
27
  Vedeu::API::Defined
28
28
  end
@@ -30,7 +30,6 @@ module Vedeu
30
30
  # Register an event by name with optional delay (throttling) which when
31
31
  # triggered will execute the code contained within the passed block.
32
32
  #
33
- # @api public
34
33
  # @param name [Symbol] The name of the event which will be triggered later.
35
34
  # @param [Hash] opts The options to register the event with.
36
35
  # @option opts :delay [Fixnum|Float] Limits the execution of the
@@ -72,38 +71,21 @@ module Vedeu
72
71
  #
73
72
  # @return [Hash]
74
73
  def event(name, opts = {}, &block)
75
- Vedeu.events.event(name, opts, &block)
76
- end
77
-
78
- # Initially accessed by Vedeu itself, this sets up some basic events needed
79
- # by Vedeu to run. Afterwards, it is simply a gateway to the Events class
80
- # used by other API methods.
81
- #
82
- # @api private
83
- # @return [Events]
84
- def events
85
- @events ||= Vedeu::Events.new do
86
- event(:_clear_) { Terminal.clear_screen }
87
- event(:_exit_) { Vedeu::Application.stop }
88
- event(:_keypress_) { |key| Vedeu.keypress(key) }
89
- event(:_log_) { |msg| Vedeu.log(msg) }
90
- event(:_mode_switch_) { fail ModeSwitch }
91
- event(:_resize_, { delay: 0.25 }) { Vedeu.resize }
92
- end
74
+ Events.add(name, opts, &block)
93
75
  end
94
76
 
95
77
  # Used after defining an interface or interfaces to set the initially
96
78
  # focussed interface.
97
79
  #
98
80
  # @param name [String] The interface to focus; must be defined.
99
- # @return []
81
+ # @return [String] The name of the interface now in focus.
82
+ # @raise [InterfaceNotFound] When the interface cannot be found.
100
83
  def focus(name)
101
- Vedeu.trigger(:_focus_by_name, name)
84
+ Vedeu.trigger(:_focus_by_name_, name)
102
85
  end
103
86
 
104
87
  # Find out how many lines the current terminal is able to display.
105
88
  #
106
- # @api public
107
89
  # @example
108
90
  # Vedeu.height
109
91
  #
@@ -117,7 +99,6 @@ module Vedeu
117
99
  # views without their content.
118
100
  #
119
101
  # @todo More documentation required.
120
- # @api public
121
102
  # @param name [String] The name of the interface. Used to reference the
122
103
  # interface throughout your application's execution lifetime.
123
104
  # @param block [Proc] A set of attributes which define the features of the
@@ -136,7 +117,7 @@ module Vedeu
136
117
  API::Interface.define({ name: name }, &block)
137
118
  end
138
119
 
139
- # @api public
120
+ # Simulate a keypress.
140
121
  #
141
122
  # @example
142
123
  # Vedeu.keypress('s')
@@ -170,6 +151,7 @@ module Vedeu
170
151
  # interface 'my_interface' # => will only function when 'my_interface'
171
152
  # ... # is in focus
172
153
  #
154
+ # @raise [InvalidSyntax] When the required block is not given.
173
155
  # @return [API::Keymap]
174
156
  def keys(*name_or_names, &block)
175
157
  fail InvalidSyntax, '`keys` requires a block.' unless block_given?
@@ -179,7 +161,6 @@ module Vedeu
179
161
 
180
162
  # Write a message to the Vedeu log file located at `$HOME/.vedeu/vedeu.log`
181
163
  #
182
- # @api public
183
164
  # @param message [String] The message you wish to emit to the log
184
165
  # file, useful for debugging.
185
166
  # @param force [Boolean] When evaluates to true will
@@ -196,7 +177,6 @@ module Vedeu
196
177
  # Register a menu by name which will display a collection of items for your
197
178
  # users to select; and provide interactivity within your application.
198
179
  #
199
- # @api public
200
180
  # @param name [String] The name of the menu. Used to reference the
201
181
  # menu throughout your application's execution lifetime.
202
182
  # @param block [Proc] A set of attributes which define the features of the
@@ -212,6 +192,7 @@ module Vedeu
212
192
  # items Track.all_my_favourites
213
193
  # ...
214
194
  #
195
+ # @raise [InvalidSyntax] When the required block is not given.
215
196
  # @return [API::Menu]
216
197
  def menu(name = '', &block)
217
198
  fail InvalidSyntax, '`menu` requires a block.' unless block_given?
@@ -223,7 +204,6 @@ module Vedeu
223
204
  # that the refresh event does not need to be triggered after creating the
224
205
  # view or views, though can be later triggered if needed.
225
206
  #
226
- # @api public
227
207
  # @param block [Proc] The directives you wish to send to render. Must
228
208
  # include `view` or `views` with associated sub-
229
209
  # directives.
@@ -260,7 +240,6 @@ module Vedeu
260
240
  # Trigger a registered or system event by name with arguments. If the
261
241
  # event stored returns a value, that is returned.
262
242
  #
263
- # @api public
264
243
  # @param name [Symbol] The name of the event you wish to trigger.
265
244
  # The event does not have to exist.
266
245
  # @param args [Array] Any arguments the event needs to execute correctly.
@@ -270,23 +249,21 @@ module Vedeu
270
249
  #
271
250
  # @return [Array|undefined]
272
251
  def trigger(name, *args)
273
- Vedeu.events.trigger(name, *args)
252
+ Events.use(name, *args)
274
253
  end
275
254
 
276
255
  # Unregisters the event by name, effectively deleting the associated events
277
256
  # bound with it also.
278
257
  #
279
- # @api public
280
258
  # @param name [Symbol]
281
259
  # @return [Hash]
282
260
  def unevent(name)
283
- Vedeu.events.unevent(name)
261
+ Events.remove(name)
284
262
  end
285
263
 
286
264
  # Use attributes of another interface whilst defining one.
287
265
  #
288
266
  # @todo More documentation required.
289
- # @api public
290
267
  # @param name [String] The name of the interface you wish to use. Typically
291
268
  # used when defining interfaces to share geometry.
292
269
  #
@@ -304,7 +281,6 @@ module Vedeu
304
281
  # Define a view (content) for an interface.
305
282
  #
306
283
  # @todo More documentation required.
307
- # @api public
308
284
  # @param name [String] The name of the interface you are targetting for this
309
285
  # view.
310
286
  # @param block [Proc] The directives you wish to send to this interface.
@@ -320,7 +296,6 @@ module Vedeu
320
296
 
321
297
  # Instruct Vedeu to treat contents of block as a single composition.
322
298
  #
323
- # @api public
324
299
  # @param block [Proc] Instructs Vedeu to treat all of the 'view' directives
325
300
  # therein as one instruction. Useful for redrawing multiple interfaces at
326
301
  # once.
@@ -340,6 +315,7 @@ module Vedeu
340
315
  # ...
341
316
  # ...
342
317
  #
318
+ # @raise [InvalidSyntax] When the required block is not given.
343
319
  # @return [Hash]
344
320
  def views(&block)
345
321
  fail InvalidSyntax, '`views` requires a block.' unless block_given?
@@ -350,7 +326,6 @@ module Vedeu
350
326
 
351
327
  # Find out how many columns the current terminal is able to display.
352
328
  #
353
- # @api public
354
329
  # @example
355
330
  # Vedeu.width
356
331
  #
@@ -359,9 +334,10 @@ module Vedeu
359
334
  Terminal.width
360
335
  end
361
336
 
362
- end
337
+ end # API
363
338
 
364
339
  extend API
365
340
 
366
341
  trap('SIGWINCH') { Vedeu.trigger(:_resize_) }
367
- end
342
+
343
+ end # Vedeu
@@ -1,4 +1,5 @@
1
1
  module Vedeu
2
+
2
3
  module API
3
4
 
4
5
  # @see Vedeu::Composition
@@ -8,11 +9,11 @@ module Vedeu
8
9
 
9
10
  # Directly write a view buffer to the terminal.
10
11
  #
11
- # @api public
12
12
  # @param block [Proc]
13
+ # @raise [InvalidSyntax] When the required block is not given.
13
14
  # @return [Array] A collection of strings, each defining containing the
14
- # escape sequences and content. This data has already
15
- # been sent to the terminal to be output.
15
+ # escape sequences and content. This data has already been sent to the
16
+ # terminal to be output.
16
17
  def self.render(&block)
17
18
  fail InvalidSyntax, '`render` requires a block.' unless block_given?
18
19
 
@@ -22,16 +23,20 @@ module Vedeu
22
23
  Buffers.add(interface.attributes)
23
24
 
24
25
  interface.name
25
- end.map { |name| Compositor.render(name) }
26
+ end.map { |name| Vedeu::Refresh.by_name(name) }
26
27
  end
27
28
 
28
- # @api public
29
+ # @param name [String]
30
+ # @param block [Proc]
31
+ # @return []
29
32
  # @see Vedeu::API#view
30
33
  def view(name, &block)
31
34
  attributes[:interfaces] << API::Interface
32
35
  .build({ name: name, parent: self.view_attributes }, &block)
33
36
  end
34
37
 
35
- end
36
- end
37
- end
38
+ end # Composition
39
+
40
+ end # API
41
+
42
+ end # Vedeu
@@ -1,4 +1,5 @@
1
1
  module Vedeu
2
+
2
3
  module API
3
4
 
4
5
  # Provides a set of helpful API methods to return information about various
@@ -13,7 +14,7 @@ module Vedeu
13
14
  #
14
15
  # @return [Array]
15
16
  def events
16
- Vedeu.events.registered
17
+ Vedeu::Events.registered
17
18
  end
18
19
 
19
20
  # Returns all groups currently registered with Vedeu.
@@ -30,6 +31,13 @@ module Vedeu
30
31
  Vedeu::Interfaces.registered
31
32
  end
32
33
 
34
+ # Returns the names of all keymaps currently registered with Vedeu.
35
+ #
36
+ # @return [Array]
37
+ def keymaps
38
+ Vedeu::Keymaps.registered
39
+ end
40
+
33
41
  # Returns all menus currently registered with Vedeu.
34
42
  #
35
43
  # @return [Array]
@@ -37,6 +45,8 @@ module Vedeu
37
45
  Vedeu::Menus.registered
38
46
  end
39
47
 
40
- end
41
- end
42
- end
48
+ end # Defined
49
+
50
+ end # API
51
+
52
+ end # Vedeu
@@ -1,4 +1,5 @@
1
1
  module Vedeu
2
+
2
3
  module API
3
4
 
4
5
  # Provides colour and style helpers for use in the {API::Interface},
@@ -10,7 +11,6 @@ module Vedeu
10
11
  # Define either or both foreground and background colours for an
11
12
  # interface, line or a stream.
12
13
  #
13
- # @api public
14
14
  # @param values [Hash]
15
15
  #
16
16
  # @example
@@ -26,6 +26,8 @@ module Vedeu
26
26
  # colour background: '#000000', foreground: '#ffffff'
27
27
  # ...
28
28
  #
29
+ # @raise [InvalidSyntax] When the values parameter does not contain
30
+ # required keys.
29
31
  # @return [Hash]
30
32
  def colour(values)
31
33
  unless values.key?(:foreground) || values.key?(:background)
@@ -38,7 +40,6 @@ module Vedeu
38
40
 
39
41
  # Define a style or styles for an interface, line or a stream.
40
42
  #
41
- # @api public
42
43
  # @param values [Array|String]
43
44
  # @param block [Proc]
44
45
  #
@@ -67,6 +68,8 @@ module Vedeu
67
68
  end
68
69
  end
69
70
 
70
- end
71
- end
72
- end
71
+ end # Helpers
72
+
73
+ end # API
74
+
75
+ end # Vedeu
@@ -1,4 +1,5 @@
1
1
  module Vedeu
2
+
2
3
  module API
3
4
 
4
5
  # Provides methods to be used to define interfaces or views.
@@ -11,28 +12,27 @@ module Vedeu
11
12
  # Instructs Vedeu to calculate x and y geometry automatically based on the
12
13
  # centre character of the terminal, the width and the height.
13
14
  #
14
- # @api public
15
- # @param value [Boolean]
15
+ # @param value [Boolean] Any value other than nil or false will evaluate
16
+ # to true.
16
17
  #
17
18
  # @example
18
19
  # interface 'my_interface' do
19
- # centred true
20
+ # centred!
21
+ #
22
+ # interface 'my_interface' do
23
+ # centred false
20
24
  # ...
21
25
  #
22
26
  # @return [API::Interface]
23
- def centred(value)
24
- unless value.is_a?(TrueClass) || value.is_a?(FalseClass)
25
- fail InvalidSyntax, 'Argument must be `true` or `false` for centred.'
26
- end
27
-
28
- attributes[:geometry][:centred] = value
27
+ def centred(value = true)
28
+ attributes[:geometry][:centred] = !!(value)
29
29
  end
30
+ alias_method :centred!, :centred
30
31
 
31
32
  # To maintain performance interfaces can be delayed from refreshing too
32
33
  # often, the reduces artefacts particularly when resizing the terminal
33
34
  # screen.
34
35
  #
35
- # @api public
36
36
  # @param value [Fixnum|Float]
37
37
  #
38
38
  # @return [API::Interface]
@@ -44,7 +44,6 @@ module Vedeu
44
44
  # targetted together; for example you may want to refresh multiple
45
45
  # interfaces at once.
46
46
  #
47
- # @api public
48
47
  # @param value [String]
49
48
  #
50
49
  # @example
@@ -59,7 +58,6 @@ module Vedeu
59
58
 
60
59
  # Define the number of characters/rows/lines tall the interface will be.
61
60
  #
62
- # @api public
63
61
  # @param value [Fixnum]
64
62
  #
65
63
  # @example
@@ -76,7 +74,6 @@ module Vedeu
76
74
 
77
75
  # Define a single line in a view.
78
76
  #
79
- # @api public
80
77
  # @param value [String]
81
78
  # @param block [Proc]
82
79
  #
@@ -108,7 +105,6 @@ module Vedeu
108
105
  # The name of the interface. Used to reference the interface throughout
109
106
  # your application's execution lifetime.
110
107
  #
111
- # @api public
112
108
  # @param value [String]
113
109
  #
114
110
  # @example
@@ -124,7 +120,6 @@ module Vedeu
124
120
  # Use the specified interface; useful for sharing attributes with other
125
121
  # interfaces.
126
122
  #
127
- # @api public
128
123
  # @param value [String]
129
124
  # @see Vedeu::API#use
130
125
  def use(value)
@@ -133,7 +128,6 @@ module Vedeu
133
128
 
134
129
  # Define the number of characters/columns wide the interface will be.
135
130
  #
136
- # @api public
137
131
  # @param value [Fixnum]
138
132
  #
139
133
  # @example
@@ -150,7 +144,6 @@ module Vedeu
150
144
 
151
145
  # Define the starting x position (column) of the interface.
152
146
  #
153
- # @api public
154
147
  # @param value [Fixnum]
155
148
  # @param block [Proc]
156
149
  #
@@ -174,7 +167,6 @@ module Vedeu
174
167
 
175
168
  # Define the starting y position (row/line) of the interface.
176
169
  #
177
- # @api public
178
170
  # @param value [Fixnum]
179
171
  # @param block [Proc]
180
172
  #
@@ -225,6 +217,8 @@ module Vedeu
225
217
  value < 1 || value > Terminal.width
226
218
  end
227
219
 
228
- end
229
- end
230
- end
220
+ end # Interface
221
+
222
+ end # API
223
+
224
+ end # Vedeu
@@ -1,4 +1,5 @@
1
1
  module Vedeu
2
+
2
3
  module API
3
4
 
4
5
  # Provides methods to be used to define keypress mapped to actions.
@@ -21,6 +22,9 @@ module Vedeu
21
22
  # key('j', :down) { trigger(:down) }
22
23
  # ...
23
24
  #
25
+ # @raise [InvalidSyntax] When the required block is not given, the
26
+ # value_or_values parameter is undefined, or when processing the
27
+ # collection, a member is undefined.
24
28
  # @return [Array] A collection containing the keypress(es).
25
29
  def key(*value_or_values, &block)
26
30
  fail InvalidSyntax,
@@ -29,8 +33,9 @@ module Vedeu
29
33
  defined_value?(value_or_values)
30
34
 
31
35
  value_or_values.each do |value|
32
- fail InvalidSyntax, 'Key cannot be empty.' unless
33
- defined_value?(value)
36
+ fail InvalidSyntax,
37
+ 'An invalid value for `key` was encountered.' unless
38
+ defined_value?(value)
34
39
 
35
40
  attributes[:keys] << { key: value, action: block }
36
41
  end
@@ -58,7 +63,8 @@ module Vedeu
58
63
  attributes[:interfaces] = name_or_names
59
64
  end
60
65
 
61
- end
66
+ end # Keymap
67
+
68
+ end # API
62
69
 
63
- end
64
- end
70
+ end # Vedeu
@@ -1,4 +1,5 @@
1
1
  module Vedeu
2
+
2
3
  module API
3
4
 
4
5
  # Provides methods to be used to define views.
@@ -10,7 +11,6 @@ module Vedeu
10
11
 
11
12
  # Define a stream (a subset of a line).
12
13
  #
13
- # @api public
14
14
  # @param block [Proc] Block contains directives relating to API::Stream.
15
15
  #
16
16
  # @example
@@ -19,6 +19,7 @@ module Vedeu
19
19
  # stream do
20
20
  # ...
21
21
  #
22
+ # @raise [InvalidSyntax] When the required block is not given.
22
23
  # @return [Array]
23
24
  def stream(&block)
24
25
  fail InvalidSyntax, '`stream` requires a block.' unless block_given?
@@ -31,7 +32,6 @@ module Vedeu
31
32
  # attributes for this line but is useful for adding lines straight into
32
33
  # the interface.
33
34
  #
34
- # @api public
35
35
  # @param value [String]
36
36
  #
37
37
  # @example
@@ -48,7 +48,6 @@ module Vedeu
48
48
  attributes[:streams] << { text: value }
49
49
  end
50
50
 
51
- # @api public
52
51
  # @param value [String]
53
52
  # @param block [Proc]
54
53
  #
@@ -66,7 +65,6 @@ module Vedeu
66
65
  attributes[:streams] << stream
67
66
  end
68
67
 
69
- # @api public
70
68
  # @param value [String]
71
69
  # @param block [Proc]
72
70
  #
@@ -84,7 +82,8 @@ module Vedeu
84
82
  attributes[:streams] << stream
85
83
  end
86
84
 
87
- end
85
+ end # Line
86
+
87
+ end # API
88
88
 
89
- end
90
- end
89
+ end # Vedeu
@@ -1,4 +1,5 @@
1
1
  module Vedeu
2
+
2
3
  module API
3
4
 
4
5
  # Provides the mechanism to create menus within client applications and use
@@ -27,6 +28,7 @@ module Vedeu
27
28
  end
28
29
 
29
30
  # @param block [Proc]
31
+ # @raise [InvalidSyntax] When the required block is not given.
30
32
  # @return [API::Menu]
31
33
  def define(&block)
32
34
  fail InvalidSyntax, '`menu` requires a block.' unless block_given?
@@ -35,8 +37,6 @@ module Vedeu
35
37
 
36
38
  instance_eval(&block)
37
39
 
38
- validate_attributes!
39
-
40
40
  Vedeu::Menus.add(attributes)
41
41
 
42
42
  self
@@ -48,7 +48,6 @@ module Vedeu
48
48
  # In the 'my_playlist' example below, your `Track` model may return a
49
49
  # collection of tracks to populate the menu.
50
50
  #
51
- # @api public
52
51
  # @param collection [Array]
53
52
  #
54
53
  # @example
@@ -68,7 +67,6 @@ module Vedeu
68
67
  # The name of the menu. Used to reference the menu throughout your
69
68
  # application's execution lifetime.
70
69
  #
71
- # @api public
72
70
  # @param value [String]
73
71
  #
74
72
  # @example
@@ -94,22 +92,16 @@ module Vedeu
94
92
  }
95
93
  end
96
94
 
97
- # At present, validates that a menu has a name attribute.
98
- #
99
- # @api private
100
- # @return [Boolean]
101
- def validate_attributes!
102
- unless defined_value?(attributes[:name])
103
- fail InvalidSyntax, 'Menus must have a `name`.'
104
- end
105
- end
106
-
107
95
  # @api private
108
96
  # @return []
109
97
  def method_missing(method, *args, &block)
98
+ Vedeu.log("API::Menu#method_missing '#{method.to_s}' (args: #{args.inspect})")
99
+
110
100
  @self_before_instance_eval.send(method, *args, &block)
111
101
  end
112
102
 
113
- end
114
- end
115
- end
103
+ end # Menu
104
+
105
+ end # API
106
+
107
+ end # Vedeu