vedeu 0.4.58 → 0.4.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -558
  3. data/README.md +2 -0
  4. data/docs/dsl.md +66 -54
  5. data/lib/vedeu/all.rb +44 -16
  6. data/lib/vedeu/api.rb +0 -2
  7. data/lib/vedeu/bindings/drb.rb +0 -1
  8. data/lib/vedeu/bindings/menus.rb +0 -1
  9. data/lib/vedeu/bindings/movement.rb +0 -1
  10. data/lib/vedeu/bindings/system.rb +0 -1
  11. data/lib/vedeu/bindings/visibility.rb +0 -1
  12. data/lib/vedeu/bootstrap.rb +2 -2
  13. data/lib/vedeu/buffers/buffers.rb +0 -4
  14. data/lib/vedeu/cli/generator/all.rb +0 -4
  15. data/lib/vedeu/cli/generator/helpers.rb +0 -2
  16. data/lib/vedeu/cli/generator/templates/application/application.erb +8 -5
  17. data/lib/vedeu/cli/generator/view.rb +4 -2
  18. data/lib/vedeu/cli/main.rb +0 -2
  19. data/lib/vedeu/colours/backgrounds.rb +0 -1
  20. data/lib/vedeu/colours/colours.rb +0 -1
  21. data/lib/vedeu/colours/foregrounds.rb +0 -1
  22. data/lib/vedeu/configuration/api.rb +19 -6
  23. data/lib/vedeu/configuration/cli.rb +9 -1
  24. data/lib/vedeu/configuration/configuration.rb +9 -0
  25. data/lib/vedeu/cursor/cursor.rb +0 -2
  26. data/lib/vedeu/cursor/cursors.rb +0 -3
  27. data/lib/vedeu/debug.rb +0 -1
  28. data/lib/vedeu/dsl.rb +0 -1
  29. data/lib/vedeu/dsl/border.rb +69 -106
  30. data/lib/vedeu/dsl/composition.rb +1 -2
  31. data/lib/vedeu/dsl/geometry.rb +102 -67
  32. data/lib/vedeu/dsl/group.rb +21 -9
  33. data/lib/vedeu/dsl/interface.rb +0 -1
  34. data/lib/vedeu/dsl/keymap.rb +26 -36
  35. data/lib/vedeu/dsl/line.rb +5 -10
  36. data/lib/vedeu/dsl/menu.rb +7 -13
  37. data/lib/vedeu/dsl/presentation.rb +0 -1
  38. data/lib/vedeu/dsl/stream.rb +0 -1
  39. data/lib/vedeu/dsl/text.rb +0 -1
  40. data/lib/vedeu/dsl/use.rb +0 -1
  41. data/lib/vedeu/dsl/view.rb +28 -31
  42. data/lib/vedeu/events/event.rb +0 -3
  43. data/lib/vedeu/events/events.rb +0 -1
  44. data/lib/vedeu/events/trigger.rb +0 -1
  45. data/lib/vedeu/geometry/geometries.rb +0 -4
  46. data/lib/vedeu/geometry/geometry.rb +0 -2
  47. data/lib/vedeu/geometry/grid.rb +2 -25
  48. data/lib/vedeu/input/keymap.rb +0 -3
  49. data/lib/vedeu/input/keymaps.rb +0 -3
  50. data/lib/vedeu/launcher.rb +0 -1
  51. data/lib/vedeu/log.rb +0 -1
  52. data/lib/vedeu/models/char.rb +0 -5
  53. data/lib/vedeu/models/group.rb +0 -2
  54. data/lib/vedeu/models/groups.rb +0 -3
  55. data/lib/vedeu/models/interface.rb +0 -19
  56. data/lib/vedeu/models/interfaces.rb +0 -4
  57. data/lib/vedeu/models/menus.rb +0 -3
  58. data/lib/vedeu/null/interface.rb +6 -7
  59. data/lib/vedeu/output/border.rb +0 -2
  60. data/lib/vedeu/output/borders.rb +0 -4
  61. data/lib/vedeu/output/esc.rb +0 -1
  62. data/lib/vedeu/output/html_char.rb +0 -2
  63. data/lib/vedeu/output/refresh.rb +0 -3
  64. data/lib/vedeu/output/refresh_group.rb +0 -2
  65. data/lib/vedeu/output/renderers.rb +0 -13
  66. data/lib/vedeu/repositories.rb +2 -15
  67. data/lib/vedeu/repositories/model.rb +0 -2
  68. data/lib/vedeu/repositories/repository.rb +0 -2
  69. data/lib/vedeu/templating/template.rb +0 -2
  70. data/lib/vedeu/terminal.rb +0 -3
  71. data/lib/vedeu/timer.rb +0 -1
  72. data/lib/vedeu/version.rb +1 -1
  73. data/test/lib/vedeu/bootstrap_test.rb +8 -1
  74. data/test/lib/vedeu/configuration/api_test.rb +14 -0
  75. data/test/lib/vedeu/configuration/cli_test.rb +15 -0
  76. data/test/lib/vedeu/cursor/cursor_test.rb +0 -1
  77. data/test/lib/vedeu/models/interface_test.rb +12 -4
  78. data/test/lib/vedeu/null/interface_test.rb +3 -12
  79. data/test/support/helpers/model_test_class.rb +0 -3
  80. data/test/test_helper.rb +0 -2
  81. data/vedeu.gemspec +1 -1
  82. metadata +4 -4
@@ -3,7 +3,6 @@ module Vedeu
3
3
  # Allows the storing of HTML/CSS colours and their respective escape
4
4
  # sequences.
5
5
  #
6
- # @api public
7
6
  class Colours
8
7
 
9
8
  # @!attribute [r] storage
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Store foreground colour escape sequences by HTML/CSS code.
4
4
  #
5
- # @api public
6
5
  class Foregrounds < Colours
7
6
 
8
7
  # @return [Vedeu::Foregrounds]
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # The Configuration::API class parses client application configuration into
6
6
  # options used by Vedeu to affect certain behaviours.
7
7
  #
8
- # @api public
9
8
  class API
10
9
 
11
10
  include Vedeu::Common
@@ -302,6 +301,20 @@ module Vedeu
302
301
  options[:base_path] = path
303
302
  end
304
303
 
304
+ # Sets the root of the client application. Vedeu will execute this
305
+ # controller first.
306
+ #
307
+ # @example
308
+ # Vedeu.configure do
309
+ # root YourApp::SomeController.new
310
+ # ...
311
+ #
312
+ # @param controller [Class]
313
+ # @return [Class]
314
+ def root(controller)
315
+ options[:root] = controller
316
+ end
317
+
305
318
  # Sets the value of STDIN.
306
319
  #
307
320
  # @example
@@ -393,13 +406,13 @@ module Vedeu
393
406
  # @return [Symbol]
394
407
  # @see Vedeu::Config::API#raw!
395
408
  # @see Vedeu::Config::API#cooked!
396
- def terminal_mode(value)
397
- if value == :raw || value == :cooked
398
- options[:terminal_mode] = value
409
+ def terminal_mode(mode)
410
+ if mode == :raw || mode == :cooked
411
+ options[:terminal_mode] = mode
399
412
 
400
413
  else
401
- fail Vedeu::InvalidSyntax, 'Terminal mode can be set to either :raw or ' \
402
- ':cooked'
414
+ fail Vedeu::InvalidSyntax,
415
+ 'Terminal mode can be set to either :raw or :cooked'
403
416
 
404
417
  end
405
418
  end
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # The Configuration::CLI class parses command-line arguments using
6
6
  # OptionParser into options used by Vedeu to affect certain behaviours.
7
7
  #
8
- # @api public
9
8
  class CLI
10
9
 
11
10
  # @param (see #initialize)
@@ -78,6 +77,7 @@ module Vedeu
78
77
  :raw,
79
78
  :run_many,
80
79
  :run_once,
80
+ :root,
81
81
  :standalone,
82
82
  ]
83
83
  end
@@ -181,6 +181,14 @@ module Vedeu
181
181
  end
182
182
  end
183
183
 
184
+ # # @return [OptionParser]
185
+ def root
186
+ parser.on('-s', '--root []', String,
187
+ 'Start the application from the specified controller.') do |c|
188
+ options[:root] = c
189
+ end
190
+ end
191
+
184
192
  # @return [OptionParser]
185
193
  def run_many
186
194
  parser.on('-n', '--run-many',
@@ -174,6 +174,14 @@ module Vedeu
174
174
  instance.options[:renderers]
175
175
  end
176
176
 
177
+ # Returns the root of the client application. Vedeu will execute this
178
+ # controller first.
179
+ #
180
+ # @return [Class]
181
+ def root
182
+ instance.options[:root]
183
+ end
184
+
177
185
  # Returns the redefined setting for STDIN.
178
186
  #
179
187
  # @return [File|IO]
@@ -274,6 +282,7 @@ module Vedeu
274
282
  log: nil,
275
283
  once: false,
276
284
  renderers: [Vedeu::Renderers::Terminal.new],
285
+ root: nil,
277
286
  stdin: nil,
278
287
  stdout: nil,
279
288
  stderr: nil,
@@ -1,5 +1,3 @@
1
- require 'vedeu/models/toggleable'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # Each interface has its own Cursor which maintains the position and
@@ -1,10 +1,7 @@
1
- require 'vedeu/cursor/cursor'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # Allows the storing of each interface's cursor.
6
4
  #
7
- # @api public
8
5
  class Cursors < Vedeu::Repository
9
6
 
10
7
  class << self
data/lib/vedeu/debug.rb CHANGED
@@ -4,7 +4,6 @@ module Vedeu
4
4
  # Helps to debug a running application by providing a stack trace of its
5
5
  # execution upon exiting.
6
6
  #
7
- # @api public
8
7
  # @param filename [String]
9
8
  # @return [void]
10
9
  # @yieldreturn [void] The section of the application to debug.
data/lib/vedeu/dsl.rb CHANGED
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Provides a mechanism to help configure and use Vedeu.
4
4
  #
5
- # @api public
6
5
  module DSL
7
6
 
8
7
  private
@@ -2,11 +2,10 @@ module Vedeu
2
2
 
3
3
  module DSL
4
4
 
5
- # DSL for creating borders for interfaces.
6
- #
7
- # Allows customisation for the border's sides and corners; a custom
8
- # foreground and background, style, and whether a particular side should be
9
- # drawn or not.
5
+ # Borders are defined by name for each of the client application's
6
+ # interfaces or views. They can be enabled or disabled (which controls
7
+ # whether they are rendered or not), they have their own colours and styles,
8
+ # and each aspect of the border can be controlled.
10
9
  #
11
10
  # @example
12
11
  # # Borders can be defined when defining your interface...
@@ -27,7 +26,6 @@ module Vedeu
27
26
  # # ...
28
27
  # end
29
28
  #
30
- # @api public
31
29
  class Border
32
30
 
33
31
  include Vedeu::DSL
@@ -36,7 +34,6 @@ module Vedeu
36
34
 
37
35
  # Specify the border of an interface or view with a simple DSL.
38
36
  #
39
- # @example
40
37
  # Vedeu.border 'some_interface' do
41
38
  # # ...
42
39
  # end
@@ -65,14 +62,9 @@ module Vedeu
65
62
  # Set the character to be used to draw the bottom left corner of the
66
63
  # border.
67
64
  #
68
- # @example
69
- # Vedeu.renders do
70
- # view 'border_demo' do
71
- # border do
72
- # bottom_left '+'
73
- # # ...
74
- # end
75
- # end
65
+ # Vedeu.border 'border_demo' do
66
+ # bottom_left '+'
67
+ # # ... some code
76
68
  # end
77
69
  #
78
70
  # @param char [String] Character to be used as the bottom left border
@@ -85,14 +77,9 @@ module Vedeu
85
77
  # Set the character to be used to draw the bottom right corner of the
86
78
  # border.
87
79
  #
88
- # @example
89
- # Vedeu.renders do
90
- # view 'border_demo' do
91
- # border do
92
- # bottom_right '+'
93
- # # ...
94
- # end
95
- # end
80
+ # Vedeu.border 'border_demo' do
81
+ # bottom_right '+'
82
+ # # ... some code
96
83
  # end
97
84
  #
98
85
  # @param char [String] Character to be used as the bottom right border
@@ -102,7 +89,12 @@ module Vedeu
102
89
  model.bottom_right = char
103
90
  end
104
91
 
105
- # Disable this border.
92
+ # Disable the border:
93
+ #
94
+ # Vedeu.border 'border_demo' do
95
+ # disable!
96
+ # # ... some other code (will be ignored)
97
+ # end
106
98
  #
107
99
  # @return [Boolean]
108
100
  def disable!
@@ -112,11 +104,18 @@ module Vedeu
112
104
  hide_left!
113
105
  hide_right!
114
106
  hide_top!
107
+
108
+ model.enabled
115
109
  end
116
110
 
117
- # Enable this border.
111
+ # Enable the border:
118
112
  # (Borders are enabled by default if defined for an interface).
119
113
  #
114
+ # Vedeu.border 'border_demo' do
115
+ # enable!
116
+ # # ... some code
117
+ # end
118
+ #
120
119
  # @return [Boolean]
121
120
  def enable!
122
121
  model.enabled = true
@@ -125,18 +124,15 @@ module Vedeu
125
124
  show_left!
126
125
  show_right!
127
126
  show_top!
127
+
128
+ model.enabled
128
129
  end
129
130
 
130
131
  # Set the character to be used to draw a horizontal part of the border.
131
132
  #
132
- # @example
133
- # Vedeu.renders do
134
- # view 'border_demo' do
135
- # border do
136
- # horizontal '-'
137
- # # ...
138
- # end
139
- # end
133
+ # Vedeu.border 'border_demo' do
134
+ # horizontal '-'
135
+ # # ... some code
140
136
  # end
141
137
  #
142
138
  # @param char [String] Character to be used as the horizontal border
@@ -148,17 +144,12 @@ module Vedeu
148
144
 
149
145
  # Enable/disable the bottom border.
150
146
  #
151
- # @example
152
- # Vedeu.renders do
153
- # view 'border_demo' do
154
- # border do
155
- # bottom false
156
- # # ... or
157
- # hide_bottom!
158
- # # ... or
159
- # show_bottom!
160
- # end
161
- # end
147
+ # Vedeu.border 'border_demo' do
148
+ # bottom true # or...
149
+ # bottom false # or...
150
+ # hide_bottom! # or...
151
+ # show_bottom!
152
+ # # ... some code
162
153
  # end
163
154
  #
164
155
  # @param value [Boolean] All values evaluate as true except nil and
@@ -187,17 +178,12 @@ module Vedeu
187
178
 
188
179
  # Enable/disable the left border.
189
180
  #
190
- # @example
191
- # Vedeu.renders do
192
- # view 'border_demo' do
193
- # border do
194
- # left false
195
- # # ... or
196
- # hide_left!
197
- # # ... or
198
- # show_left!
199
- # end
200
- # end
181
+ # Vedeu.border 'border_demo' do
182
+ # left true # or...
183
+ # left false # or...
184
+ # hide_left! # or...
185
+ # show_left!
186
+ # # ... some code
201
187
  # end
202
188
  #
203
189
  # @param value [Boolean] All values evaluate as true except nil and
@@ -226,17 +212,12 @@ module Vedeu
226
212
 
227
213
  # Enable/disable the right border.
228
214
  #
229
- # @example
230
- # Vedeu.renders do
231
- # view 'border_demo' do
232
- # border do
233
- # right false
234
- # # ... or
235
- # hide_right!
236
- # # ... or
237
- # show_right!
238
- # end
239
- # end
215
+ # Vedeu.border 'border_demo' do
216
+ # right true # or...
217
+ # right false # or...
218
+ # hide_right! # or...
219
+ # show_right!
220
+ # # ... some code
240
221
  # end
241
222
  #
242
223
  # @param value [Boolean] All values evaluate as true except nil and
@@ -265,17 +246,13 @@ module Vedeu
265
246
 
266
247
  # If you have you are showing a top border, you could add a title.
267
248
  #
268
- # @example
269
- # Vedeu.renders do
270
- # view 'border_demo' do
271
- # geometry { width: 50 }
272
- # border do
273
- # title 'My Cool Title'
274
- # # ...
275
- # end
276
- # end
249
+ # Vedeu.border 'border_demo' do
250
+ # title 'My Cool Title'
251
+ # # ... some code
277
252
  # end
278
253
  #
254
+ # produces, depending on other customisations:
255
+ #
279
256
  # +- My Cool Title --------------------------------+
280
257
  #
281
258
  # @param value [String] The title.
@@ -286,17 +263,12 @@ module Vedeu
286
263
 
287
264
  # Enable/disable the top border.
288
265
  #
289
- # @example
290
- # Vedeu.renders do
291
- # view 'border_demo' do
292
- # border do
293
- # top false
294
- # # ... or
295
- # hide_top!
296
- # # ... or
297
- # show_top!
298
- # end
299
- # end
266
+ # Vedeu.border 'border_demo' do
267
+ # top true # or...
268
+ # top false # or...
269
+ # hide_top! # or...
270
+ # show_top!
271
+ # # ... some code
300
272
  # end
301
273
  #
302
274
  # @param value [Boolean] All values evaluate as true except nil and
@@ -325,14 +297,9 @@ module Vedeu
325
297
 
326
298
  # Set the character to be used to draw the top left corner of the border.
327
299
  #
328
- # @example
329
- # Vedeu.renders do
330
- # view 'border_demo' do
331
- # border do
332
- # top_left '+'
333
- # # ...
334
- # end
335
- # end
300
+ # Vedeu.border 'border_demo' do
301
+ # top_left '+'
302
+ # # ... some code
336
303
  # end
337
304
  #
338
305
  # @param char [String] Character to be used as the top left border
@@ -344,12 +311,10 @@ module Vedeu
344
311
 
345
312
  # Set the character to be used to draw the top right corner of the border.
346
313
  #
347
- # @example
348
- # Vedeu.renders do
349
- # view 'border_demo' do
350
- # border do
351
- # top_right '+'
352
- # # ...
314
+ # Vedeu.border 'border_demo' do
315
+ # top_right '+'
316
+ # # ... some code
317
+ # end
353
318
  #
354
319
  # @param char [String] Character to be used as the top right border
355
320
  # character.
@@ -360,12 +325,10 @@ module Vedeu
360
325
 
361
326
  # Set the character to be used to draw a vertical part of the border.
362
327
  #
363
- # @example
364
- # Vedeu.renders do
365
- # view 'border_demo' do
366
- # border do
367
- # vertical '|'
368
- # # ...
328
+ # Vedeu.border 'border_demo' do
329
+ # vertical '|'
330
+ # # ... some code
331
+ # end
369
332
  #
370
333
  # @param char [String] Character to be used as the vertical border
371
334
  # character.
@@ -36,7 +36,6 @@ module Vedeu
36
36
  # - Colours are defined in CSS-style values, i.e. `#ff0000` would be red.
37
37
  # - Styles are named. See the table below for supported styles.
38
38
  #
39
- # @api public
40
39
  class Composition
41
40
 
42
41
  include Vedeu::DSL
@@ -103,7 +102,7 @@ module Vedeu
103
102
  fail Vedeu::MissingRequired,
104
103
  'Cannot render template without the name of the view.' unless name
105
104
  fail Vedeu::MissingRequired,
106
- "Cannot render template without a filename." unless filename
105
+ 'Cannot render template without a filename.' unless filename
107
106
 
108
107
  content = Vedeu::Templating::Template.parse(object, filename)
109
108
  lines = Vedeu::Wordwrap.for(content, options)