vedeu 0.5.11 → 0.5.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +1 -0
  4. data/docs/configuration.md +94 -0
  5. data/lib/vedeu/application/application_view.rb +4 -0
  6. data/lib/vedeu/bindings/system.rb +1 -0
  7. data/lib/vedeu/configuration/api.rb +17 -32
  8. data/lib/vedeu/configuration/cli.rb +61 -1
  9. data/lib/vedeu/configuration/configuration.rb +1 -1
  10. data/lib/vedeu/dsl/view.rb +2 -2
  11. data/lib/vedeu/events/event.rb +4 -1
  12. data/lib/vedeu/log/log.rb +5 -1
  13. data/lib/vedeu/runtime/bootstrap.rb +19 -17
  14. data/lib/vedeu/runtime/router.rb +2 -2
  15. data/lib/vedeu/version.rb +1 -1
  16. data/test/lib/vedeu/application/application_view_test.rb +24 -0
  17. data/test/lib/vedeu/bindings/application_test.rb +2 -2
  18. data/test/lib/vedeu/bindings_test.rb +2 -2
  19. data/test/lib/vedeu/configuration/api_test.rb +17 -17
  20. data/test/lib/vedeu/cursor/move_test.rb +30 -11
  21. data/test/lib/vedeu/dsl/interface_test.rb +8 -2
  22. data/test/lib/vedeu/esc/actions_test.rb +2 -2
  23. data/test/lib/vedeu/esc/borders_test.rb +2 -2
  24. data/test/lib/vedeu/events/event_aliases_test.rb +2 -2
  25. data/test/lib/vedeu/events/event_collection_test.rb +1 -1
  26. data/test/lib/vedeu/internal_api_test.rb +2 -2
  27. data/test/lib/vedeu/models/views/collections/chars_test.rb +1 -1
  28. data/test/lib/vedeu/models/views/collections/view_collection_test.rb +2 -2
  29. data/test/lib/vedeu/models/views/view_test.rb +2 -2
  30. data/test/lib/vedeu/null/menu_test.rb +2 -2
  31. data/test/lib/vedeu/null/view_test.rb +2 -2
  32. data/test/lib/vedeu/plugins/plugin_test.rb +2 -2
  33. data/test/lib/vedeu/plugins_test.rb +2 -2
  34. data/test/lib/vedeu/repositories_test.rb +2 -2
  35. data/test/lib/vedeu/runtime/bootstrap_test.rb +7 -16
  36. data/test/lib/vedeu/runtime/flags_test.rb +2 -2
  37. data/test/lib/vedeu/runtime/main_loop_test.rb +4 -1
  38. data/test/lib/vedeu/runtime/router_test.rb +2 -2
  39. data/test/lib/vedeu/runtime/traps_test.rb +2 -2
  40. data/test/lib/vedeu/templating/decoder_test.rb +2 -2
  41. data/test/lib/vedeu/templating/encoder_test.rb +2 -2
  42. data/test/lib/vedeu/templating/view_template_test.rb +2 -2
  43. data/test/lib/vedeu/terminal_mode_test.rb +2 -2
  44. data/vedeu.gemspec +1 -1
  45. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edd33e8e10532a87dc3e6ea6c7aa2142227e70f7
4
- data.tar.gz: 29b39513afa32eac1564900988eb5d28d386a17a
3
+ metadata.gz: 31e9c17f2fcd8a9e852e9e8ebed87d34f1d7b5aa
4
+ data.tar.gz: 43767a98407c836ddb20a6782f7828ab7ec7ce2e
5
5
  SHA512:
6
- metadata.gz: 6d1cd9b457457e795e9779b9d1265b6db9e8669d29f03ab62079250b08ecd65f1091c046351e9ae849f3b7843313828652984e1bc4561eef43e972ec600c0a18
7
- data.tar.gz: 679201d647f7663cbe6a3789d2967206232efef7636642150ad53bfbc92ccbd18ad55cf0dcd2e0488edaa454405bec7332b8d003825c35de353edf58223483d5
6
+ metadata.gz: 69e4146a2fa2ef01d4508344ec02b4557e4e4794e1f16ee43a7b691d58132d03f0494d9e76f7ce0adcdf5553d87f66420764460cd28fe7d61dd86be8764930a7
7
+ data.tar.gz: f2996b4ca485971f2468367dc7448f0d1b06d94df945c0e64a178bb517c56ae19cce0cc69527839da2152a9564e557392744cabd64d24fc86de6630695152cdb
data/.yardopts CHANGED
@@ -3,6 +3,7 @@
3
3
  --embed-mixin ClassMethods
4
4
  -
5
5
  docs/api.md
6
+ docs/configuration.md
6
7
  docs/dsl.md
7
8
  docs/events.md
8
9
  docs/getting_started.md
data/README.md CHANGED
@@ -49,6 +49,7 @@ documentation shortly. In the meantime, please browse the
49
49
  - [Getting Started](http://rubydoc.info/gems/vedeu/file/docs/getting_started.md)
50
50
  - [The Vedeu DSL](http://rubydoc.info/gems/vedeu/file/docs/dsl.md)
51
51
  - [The Vedeu API](http://rubydoc.info/gems/vedeu/file/docs/api.md)
52
+ - [Vedeu Configuration](http://rubydoc.info/gems/vedeu/file/docs/configuration.md)
52
53
  - [Vedeu Events](http://rubydoc.info/gems/vedeu/file/docs/events.md)
53
54
  - [Object Graphs](http://rubydoc.info/gems/vedeu/file/docs/object_graph.md)
54
55
 
@@ -0,0 +1,94 @@
1
+ # @title Vedeu Configuration
2
+ # Vedeu Configuration
3
+
4
+ Vedeu provides a simple DSL for configuration.
5
+
6
+ ```ruby
7
+ Vedeu.configure do
8
+
9
+ # add configuration options here...
10
+
11
+ end
12
+ ```
13
+
14
+ ## Configuration Options
15
+
16
+ ### base_path
17
+ {include:Vedeu::Config::API#base_path}
18
+
19
+ ### colour_mode
20
+ {include:Vedeu::Config::API#colour_mode}
21
+ {include:Vedeu::Config::CLI#colour_mode}
22
+
23
+ ### compression / compression!
24
+ {include:Vedeu::Config::API#compression}
25
+
26
+ ### cooked / cooked!
27
+ {include:Vedeu::Config::API#cooked}
28
+ {include:Vedeu::Config::CLI#cooked}
29
+
30
+ ### debug / debug!
31
+ {include:Vedeu::Config::API#debug}
32
+ {include:Vedeu::Config::CLI#debug}
33
+
34
+ ### drb / drb!
35
+ {include:Vedeu::Config::API#drb}
36
+ {include:Vedeu::Config::CLI#drb}
37
+
38
+ ### drb_host
39
+ {include:Vedeu::Config::API#drb_host}
40
+ {include:Vedeu::Config::CLI#drb_host}
41
+
42
+ ### drb_port
43
+ {include:Vedeu::Config::API#drb_port}
44
+ {include:Vedeu::Config::CLI#drb_port}
45
+
46
+ ### drb_height
47
+ {include:Vedeu::Config::API#drb_height}
48
+ {include:Vedeu::Config::CLI#drb_height}
49
+
50
+ ### drb_width
51
+ {include:Vedeu::Config::API#drb_width}
52
+ {include:Vedeu::Config::CLI#drb_width}
53
+
54
+ ### interactive / interactive!
55
+ {include:Vedeu::Config::API#interactive}
56
+ {include:Vedeu::Config::CLI#interactive}
57
+
58
+ ### log
59
+ {include:Vedeu::Config::API#log}
60
+ {include:Vedeu::Config::CLI#log}
61
+
62
+ ### log_only
63
+ {include:Vedeu::Config::API#log_only}
64
+
65
+ ### raw / raw!
66
+ {include:Vedeu::Config::API#raw}
67
+ {include:Vedeu::Config::CLI#raw}
68
+
69
+ ### renderer / renderers
70
+ {include:Vedeu::Config::API#renderer}
71
+
72
+ ### root
73
+ {include:Vedeu::Config::API#root}
74
+ {include:Vedeu::Config::CLI#root}
75
+
76
+ ### run_once / run_once!
77
+ {include:Vedeu::Config::API#run_once}
78
+ {include:Vedeu::Config::CLI#run_once}
79
+
80
+ ### standalone / standalone!
81
+ {include:Vedeu::Config::API#standalone}
82
+ {include:Vedeu::Config::CLI#standalone}
83
+
84
+ ### stderr
85
+ {include:Vedeu::Config::API#stderr}
86
+
87
+ ### stdin
88
+ {include:Vedeu::Config::API#stdin}
89
+
90
+ ### stdout
91
+ {include:Vedeu::Config::API#stdout}
92
+
93
+ ### terminal_mode
94
+ {include:Vedeu::Config::API#terminal_mode}
@@ -21,6 +21,10 @@ module Vedeu
21
21
  # @return [Vedeu::ApplicationView]
22
22
  def initialize(**params)
23
23
  @params = params
24
+
25
+ @params.each do |key, value|
26
+ self.class.send(:define_method, key) { value } unless respond_to?(key)
27
+ end
24
28
  end
25
29
 
26
30
  # @raise [Vedeu::NotImplemented] Subclasses of this class must implement
@@ -140,6 +140,7 @@ module Vedeu
140
140
  def initialize!
141
141
  Vedeu.bind(:_initialize_) do
142
142
  Vedeu.ready!
143
+ Vedeu.trigger(:_refresh_)
143
144
  end
144
145
  end
145
146
 
@@ -20,7 +20,6 @@ module Vedeu
20
20
  # override the default Vedeu configuration set in
21
21
  # {Vedeu::Configuration#defaults}.
22
22
  #
23
- # @example
24
23
  # Vedeu.configure do
25
24
  # # ...
26
25
  # end
@@ -41,7 +40,6 @@ module Vedeu
41
40
  # Sets boolean to allow user input. The default behaviour of Vedeu is to
42
41
  # be interactive.
43
42
  #
44
- # @example
45
43
  # Vedeu.configure do
46
44
  # interactive! # => same as `interactive true` or `standalone false`
47
45
  # # ...
@@ -67,7 +65,6 @@ module Vedeu
67
65
  # Sets boolean to prevent user intervention. This is the same as setting
68
66
  # {#interactive!} to false.
69
67
  #
70
- # @example
71
68
  # Vedeu.configure do
72
69
  # standalone! # => same as `standalone true` or `interactive false`
73
70
  # # ...
@@ -94,7 +91,6 @@ module Vedeu
94
91
  # using `run_once!` or setting `run_once` to true will allow Vedeu to
95
92
  # initialize, run any client application code, cleanup, then terminate.
96
93
  #
97
- # @example
98
94
  # Vedeu.configure do
99
95
  # run_once!
100
96
  # # ...
@@ -109,7 +105,6 @@ module Vedeu
109
105
 
110
106
  # Sets boolean to run a DRb server.
111
107
  #
112
- # @example
113
108
  # Vedeu.configure do
114
109
  # drb!
115
110
  # # ...
@@ -124,7 +119,6 @@ module Vedeu
124
119
 
125
120
  # Sets the hostname or IP address of the DRb server.
126
121
  #
127
- # @example
128
122
  # Vedeu.configure do
129
123
  # drb_host 'localhost'
130
124
  # # ...
@@ -138,7 +132,6 @@ module Vedeu
138
132
 
139
133
  # Sets the port of the DRb server.
140
134
  #
141
- # @example
142
135
  # Vedeu.configure do
143
136
  # drb_port 12345
144
137
  # # ...
@@ -152,7 +145,6 @@ module Vedeu
152
145
 
153
146
  # Sets the height of the fake terminal in the DRb server.
154
147
  #
155
- # @example
156
148
  # Vedeu.configure do
157
149
  # drb_height 25
158
150
  # # ...
@@ -166,7 +158,6 @@ module Vedeu
166
158
 
167
159
  # Sets the width of the fake terminal in the DRb server.
168
160
  #
169
- # @example
170
161
  # Vedeu.configure do
171
162
  # drb_width 80
172
163
  # # ...
@@ -179,8 +170,8 @@ module Vedeu
179
170
  end
180
171
 
181
172
  # Sets the terminal mode to `cooked`. Default terminal mode is `raw`.
173
+ # Also, see {Vedeu::Config::API#raw!}
182
174
  #
183
- # @example
184
175
  # Vedeu.configure do
185
176
  # cooked!
186
177
  # # ...
@@ -193,8 +184,8 @@ module Vedeu
193
184
  alias_method :cooked, :cooked!
194
185
 
195
186
  # Sets the terminal mode to `raw`. Default terminal mode is `raw`.
187
+ # Also, see {Vedeu::Config::API#cooked!}
196
188
  #
197
- # @example
198
189
  # Vedeu.configure do
199
190
  # raw!
200
191
  # # ...
@@ -214,7 +205,6 @@ module Vedeu
214
205
  # Be aware that running an application with debugging enabled will
215
206
  # affect performance.
216
207
  #
217
- # @example
218
208
  # Vedeu.configure do
219
209
  # debug!
220
210
  # # ...
@@ -234,7 +224,6 @@ module Vedeu
234
224
 
235
225
  # Sets the colour mode of the terminal.
236
226
  #
237
- # @example
238
227
  # Vedeu.configure do
239
228
  # colour_mode 256
240
229
  # # ...
@@ -258,7 +247,6 @@ module Vedeu
258
247
 
259
248
  # Sets the location of the log file.
260
249
  #
261
- # @example
262
250
  # Vedeu.configure do
263
251
  # log '/var/log/vedeu.log'
264
252
  # # ...
@@ -270,6 +258,9 @@ module Vedeu
270
258
  options[:log] = filename
271
259
  end
272
260
 
261
+ # Only log specific message types. A complete list of message types can
262
+ # be found at {Vedeu::Log.message_types}.
263
+ #
273
264
  # @param types [Array<Symbol>] The message types which should be logged.
274
265
  # @return [Array<Symbol>]
275
266
  def log_only(*types)
@@ -279,7 +270,6 @@ module Vedeu
279
270
  # Sets the renderers for Vedeu. Each renderer added must have the class
280
271
  # method '.render' defined as this will be called when rendering content.
281
272
  #
282
- # @example
283
273
  # Vedeu.configure do
284
274
  # renderer MyRenderer
285
275
  # # ...
@@ -308,22 +298,21 @@ module Vedeu
308
298
  end
309
299
 
310
300
  # Sets the root of the client application. Vedeu will execute this
311
- # controller first.
301
+ # controller with action and optional arguments first.
312
302
  #
313
- # @example
314
303
  # Vedeu.configure do
315
- # root YourApp::SomeController.new
316
- # ...
304
+ # root :controller, :action, args
305
+ # # ...
306
+ # end
317
307
  #
318
- # @param controller [Class]
308
+ # @param args [Array<Symbol|void>]
319
309
  # @return [Class]
320
- def root(controller)
321
- options[:root] = controller
310
+ def root(*args)
311
+ options[:root] = args
322
312
  end
323
313
 
324
314
  # Sets the value of STDIN.
325
315
  #
326
- # @example
327
316
  # Vedeu.configure do
328
317
  # stdin IO.console
329
318
  # # ...
@@ -337,7 +326,6 @@ module Vedeu
337
326
 
338
327
  # Sets the value of STDOUT.
339
328
  #
340
- # @example
341
329
  # Vedeu.configure do
342
330
  # stdout IO.console
343
331
  # # ...
@@ -351,7 +339,6 @@ module Vedeu
351
339
 
352
340
  # Sets the value of STDERR.
353
341
  #
354
- # @example
355
342
  # Vedeu.configure do
356
343
  # stderr IO.console
357
344
  # # ...
@@ -371,12 +358,6 @@ module Vedeu
371
358
  # for compression to be enabled. Setting `compression` to false will
372
359
  # disable compression.
373
360
  #
374
- # @note
375
- # - Be aware that running an application without compression will
376
- # affect performance.
377
- # - Compression cannot yet be configured using a CLI option flag.
378
- #
379
- # @example
380
361
  # Vedeu.configure do
381
362
  # compression! # enabled (default)
382
363
  # # ...
@@ -387,6 +368,11 @@ module Vedeu
387
368
  # # ...
388
369
  # end
389
370
  #
371
+ # @note
372
+ # - Be aware that running an application without compression will
373
+ # affect performance.
374
+ # - Compression cannot yet be configured using a CLI option flag.
375
+ #
390
376
  # @param value [Boolean]
391
377
  # @return [Boolean]
392
378
  def compression(value = true)
@@ -396,7 +382,6 @@ module Vedeu
396
382
 
397
383
  # Sets the terminal mode. Valid values can be either ':raw' or ':cooked'.
398
384
  #
399
- # @example
400
385
  # Vedeu.configure do
401
386
  # terminal_mode :raw
402
387
  # # ...
@@ -87,6 +87,10 @@ module Vedeu
87
87
  parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
88
88
  end
89
89
 
90
+ # CLI arguments:
91
+ #
92
+ # -C, --colour-mode
93
+ #
90
94
  # @return [OptionParser]
91
95
  def colour_mode
92
96
  parser.on('-C', '--colour-mode [COLOURS]', Integer,
@@ -102,6 +106,10 @@ module Vedeu
102
106
  end
103
107
  end
104
108
 
109
+ # CLI arguments:
110
+ #
111
+ # -c, --cooked
112
+ #
105
113
  # @return [OptionParser]
106
114
  def cooked
107
115
  parser.on('-c', '--cooked', 'Run application in cooked mode.') do
@@ -109,6 +117,10 @@ module Vedeu
109
117
  end
110
118
  end
111
119
 
120
+ # CLI arguments:
121
+ #
122
+ # -d, --debug
123
+ #
112
124
  # @return [OptionParser]
113
125
  def debug
114
126
  parser.on('-d', '--debug', 'Run application with debugging on.') do
@@ -116,6 +128,10 @@ module Vedeu
116
128
  end
117
129
  end
118
130
 
131
+ # CLI arguments:
132
+ #
133
+ # --drb
134
+ #
119
135
  # @return [OptionParser]
120
136
  def drb
121
137
  parser.on('--drb', 'Run application with DRb on.') do
@@ -123,6 +139,10 @@ module Vedeu
123
139
  end
124
140
  end
125
141
 
142
+ # CLI arguments:
143
+ #
144
+ # --drb-height
145
+ #
126
146
  # @return [OptionParser]
127
147
  def drb_height
128
148
  parser.on('--drb-height',
@@ -132,6 +152,10 @@ module Vedeu
132
152
  end
133
153
  end
134
154
 
155
+ # CLI arguments:
156
+ #
157
+ # --drb-host
158
+ #
135
159
  # @return [OptionParser]
136
160
  def drb_host
137
161
  parser.on('--drb-host',
@@ -141,6 +165,10 @@ module Vedeu
141
165
  end
142
166
  end
143
167
 
168
+ # CLI arguments:
169
+ #
170
+ # --drb-port
171
+ #
144
172
  # @return [OptionParser]
145
173
  def drb_port
146
174
  parser.on('--drb-port', 'Set the port for the DRb server.') do |port|
@@ -149,6 +177,10 @@ module Vedeu
149
177
  end
150
178
  end
151
179
 
180
+ # CLI arguments:
181
+ #
182
+ # --drb-width
183
+ #
152
184
  # @return [OptionParser]
153
185
  def drb_width
154
186
  parser.on('--drb-width',
@@ -158,6 +190,10 @@ module Vedeu
158
190
  end
159
191
  end
160
192
 
193
+ # CLI arguments:
194
+ #
195
+ # -i, --interactive
196
+ #
161
197
  # @return [OptionParser]
162
198
  def interactive
163
199
  parser.on('-i', '--interactive',
@@ -166,6 +202,10 @@ module Vedeu
166
202
  end
167
203
  end
168
204
 
205
+ # CLI arguments:
206
+ #
207
+ # -l, --log
208
+ #
169
209
  # @return [OptionParser]
170
210
  def log
171
211
  parser.on('-l', '--log [FILENAME]', String,
@@ -174,6 +214,10 @@ module Vedeu
174
214
  end
175
215
  end
176
216
 
217
+ # CLI arguments:
218
+ #
219
+ # -r, --raw
220
+ #
177
221
  # @return [OptionParser]
178
222
  def raw
179
223
  parser.on('-r', '--raw', 'Run application in raw mode (default).') do
@@ -181,7 +225,11 @@ module Vedeu
181
225
  end
182
226
  end
183
227
 
184
- # # @return [OptionParser]
228
+ # CLI arguments:
229
+ #
230
+ # -s, --root
231
+ #
232
+ # @return [OptionParser]
185
233
  def root
186
234
  parser.on('-s', '--root []', String,
187
235
  'Start the application from the specified controller.') do |c|
@@ -189,6 +237,10 @@ module Vedeu
189
237
  end
190
238
  end
191
239
 
240
+ # CLI arguments:
241
+ #
242
+ # -n, --run-many
243
+ #
192
244
  # @return [OptionParser]
193
245
  def run_many
194
246
  parser.on('-n', '--run-many',
@@ -197,6 +249,10 @@ module Vedeu
197
249
  end
198
250
  end
199
251
 
252
+ # CLI arguments:
253
+ #
254
+ # -1, --run-once
255
+ #
200
256
  # @return [OptionParser]
201
257
  def run_once
202
258
  parser.on('-1', '--run-once', 'Run the application loop once.') do
@@ -204,6 +260,10 @@ module Vedeu
204
260
  end
205
261
  end
206
262
 
263
+ # CLI arguments:
264
+ #
265
+ # -I, --noninteractive, --standalone
266
+ #
207
267
  # @return [OptionParser]
208
268
  def standalone
209
269
  parser.on('-I', '--noninteractive', '--standalone',