vedeu 0.6.13 → 0.6.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/docs/configuration.md +0 -14
  3. data/lib/vedeu.rb +0 -1
  4. data/lib/vedeu/all.rb +13 -14
  5. data/lib/vedeu/api/internal.rb +2 -2
  6. data/lib/vedeu/bindings/focus.rb +2 -0
  7. data/lib/vedeu/bindings/refresh.rb +2 -0
  8. data/lib/vedeu/bindings/system.rb +2 -0
  9. data/lib/vedeu/configuration/api.rb +0 -2
  10. data/lib/vedeu/configuration/configuration.rb +9 -17
  11. data/lib/vedeu/dsl/dsl.rb +2 -0
  12. data/lib/vedeu/dsl/text.rb +6 -0
  13. data/lib/vedeu/editor/all.rb +1 -1
  14. data/lib/vedeu/editor/{documents.rb → repository.rb} +2 -2
  15. data/lib/vedeu/esc/actions.rb +0 -2
  16. data/lib/vedeu/esc/borders.rb +0 -2
  17. data/lib/vedeu/esc/colours.rb +0 -2
  18. data/lib/vedeu/input/mapper.rb +2 -2
  19. data/lib/vedeu/menus/all.rb +3 -0
  20. data/lib/vedeu/models/all.rb +2 -0
  21. data/lib/vedeu/models/views/all.rb +0 -4
  22. data/lib/vedeu/models/views/char.rb +7 -0
  23. data/lib/vedeu/models/views/line.rb +7 -0
  24. data/lib/vedeu/models/views/stream.rb +7 -0
  25. data/lib/vedeu/models/views/view.rb +7 -0
  26. data/lib/vedeu/null/all.rb +4 -1
  27. data/lib/vedeu/null/interface.rb +0 -2
  28. data/lib/vedeu/null/view.rb +0 -2
  29. data/lib/vedeu/output/output.rb +8 -2
  30. data/lib/vedeu/output/renderers/all.rb +95 -1
  31. data/lib/vedeu/runtime/all.rb +2 -0
  32. data/lib/vedeu/runtime/launcher.rb +1 -9
  33. data/lib/vedeu/version.rb +1 -1
  34. data/test/lib/vedeu/editor/{documents_test.rb → repository_test.rb} +3 -3
  35. data/test/lib/vedeu/models/views/char_test.rb +13 -0
  36. data/test/lib/vedeu/models/views/line_test.rb +16 -3
  37. data/test/lib/vedeu/models/views/stream_test.rb +13 -0
  38. data/test/lib/vedeu/models/views/view_test.rb +13 -0
  39. data/test/lib/vedeu/output/output_test.rb +32 -18
  40. data/test/lib/vedeu/output/{renderers_test.rb → renderers/all_test.rb} +0 -0
  41. data/test/lib/vedeu/output/renderers/file_test.rb +2 -2
  42. metadata +6 -27
  43. data/lib/vedeu/configuration/cli.rb +0 -290
  44. data/lib/vedeu/models/views/collections/chars.rb +0 -14
  45. data/lib/vedeu/models/views/collections/lines.rb +0 -14
  46. data/lib/vedeu/models/views/collections/streams.rb +0 -14
  47. data/lib/vedeu/models/views/collections/view_collection.rb +0 -14
  48. data/lib/vedeu/null/null.rb +0 -11
  49. data/lib/vedeu/output/renderers.rb +0 -92
  50. data/test/lib/vedeu/configuration/cli_test.rb +0 -157
  51. data/test/lib/vedeu/models/views/collections/chars_test.rb +0 -22
  52. data/test/lib/vedeu/models/views/collections/lines_test.rb +0 -22
  53. data/test/lib/vedeu/models/views/collections/streams_test.rb +0 -22
  54. data/test/lib/vedeu/models/views/collections/view_collection_test.rb +0 -22
  55. data/test/lib/vedeu/null/null_test.rb +0 -8
  56. data/test/support/examples/configuration_app.rb +0 -63
@@ -1,290 +0,0 @@
1
- module Vedeu
2
-
3
- module Config
4
-
5
- # The Configuration::CLI class parses command-line arguments using
6
- # OptionParser into options used by Vedeu to affect certain
7
- # behaviours.
8
- #
9
- class CLI
10
-
11
- # @param (see #initialize)
12
- def self.configure(args = [])
13
- new(args).configuration
14
- end
15
-
16
- # Returns a new instance of Vedeu::Config::CLI.
17
- #
18
- # Configure Vedeu via command-line arguments. Options set here
19
- # via arguments override the client application configuration
20
- # set via {Vedeu::API::External#configure}.
21
- #
22
- # @param args [Array]
23
- # @return [Vedeu::Configuration::CLI]
24
- def initialize(args = [])
25
- @args = args
26
- @options = {}
27
- end
28
-
29
- # Returns the configuration options set up by parsing the
30
- # command-line arguments passed to the client application.
31
- #
32
- # @return [Hash]
33
- def configuration
34
- setup!
35
-
36
- parser.parse!(args)
37
-
38
- Vedeu::Config.log(Vedeu::EscapeSequences::Esc.blue { '[cli]' }, options)
39
- end
40
-
41
- protected
42
-
43
- # @!attribute [r] args
44
- # @return [Array<String>]
45
- attr_reader :args
46
-
47
- # @!attribute [r] options
48
- # @return [Hash]
49
- attr_reader :options
50
-
51
- private
52
-
53
- # Setup Vedeu using CLI configuration options for the client
54
- # application.
55
- #
56
- # @return [void]
57
- def setup!
58
- ([:banner] + allowed_options).each { |opt| send(opt) }
59
- end
60
-
61
- # @return [OptionParser]
62
- def parser
63
- @parser ||= OptionParser.new
64
- end
65
-
66
- # @return [Array<Symbol>]
67
- def allowed_options
68
- [
69
- :colour_mode,
70
- :cooked,
71
- :debug,
72
- :drb,
73
- :drb_height,
74
- :drb_host,
75
- :drb_port,
76
- :drb_width,
77
- :fake,
78
- :interactive,
79
- :log,
80
- :raw,
81
- :run_many,
82
- :run_once,
83
- :root,
84
- :standalone,
85
- ]
86
- end
87
-
88
- # @return [String]
89
- def banner
90
- parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
91
- end
92
-
93
- # CLI arguments:
94
- #
95
- # -C, --colour-mode
96
- #
97
- # @return [OptionParser]
98
- def colour_mode
99
- parser.on('-C', '--colour-mode [COLOURS]', Integer,
100
- 'Run application in either `8`, `16`, `256` or `16777216` ' \
101
- 'colour mode.') do |colours|
102
- if [8, 16, 256, 16_777_216].include?(colours)
103
- options[:colour_mode] = colours
104
-
105
- else
106
- options[:colour_mode] = 8
107
-
108
- end
109
- end
110
- end
111
-
112
- # CLI arguments:
113
- #
114
- # -c, --cooked
115
- #
116
- # @return [OptionParser]
117
- def cooked
118
- parser.on('-c', '--cooked', 'Run application in cooked mode.') do
119
- options[:terminal_mode] = :cooked
120
- end
121
- end
122
-
123
- # CLI arguments:
124
- #
125
- # -d, --debug
126
- #
127
- # @return [OptionParser]
128
- def debug
129
- parser.on('-d', '--debug', 'Run application with debugging on.') do
130
- options[:debug] = true
131
- end
132
- end
133
-
134
- # CLI arguments:
135
- #
136
- # --drb
137
- #
138
- # @return [OptionParser]
139
- def drb
140
- parser.on('--drb', 'Run application with DRb on.') do
141
- options[:drb] = true
142
- end
143
- end
144
-
145
- # CLI arguments:
146
- #
147
- # --drb-height
148
- #
149
- # @return [OptionParser]
150
- def drb_height
151
- parser.on('--drb-height',
152
- 'Set the height for fake terminal.') do |height|
153
- options[:drb] = true
154
- options[:drb_height] = height
155
- end
156
- end
157
-
158
- # CLI arguments:
159
- #
160
- # --drb-host
161
- #
162
- # @return [OptionParser]
163
- def drb_host
164
- parser.on('--drb-host',
165
- 'Set the hostname/IP for the DRb server.') do |hostname|
166
- options[:drb] = true
167
- options[:drb_host] = hostname
168
- end
169
- end
170
-
171
- # CLI arguments:
172
- #
173
- # --drb-port
174
- #
175
- # @return [OptionParser]
176
- def drb_port
177
- parser.on('--drb-port', 'Set the port for the DRb server.') do |port|
178
- options[:drb] = true
179
- options[:drb_port] = port
180
- end
181
- end
182
-
183
- # CLI arguments:
184
- #
185
- # --drb-width
186
- #
187
- # @return [OptionParser]
188
- def drb_width
189
- parser.on('--drb-width',
190
- 'Set the width for fake terminal.') do |width|
191
- options[:drb] = true
192
- options[:drb_width] = width
193
- end
194
- end
195
-
196
- # CLI arguments:
197
- #
198
- # -i, --interactive
199
- #
200
- # @return [OptionParser]
201
- def fake
202
- parser.on('-f', '--fake', 'Run application in fake mode.') do
203
- options[:terminal_mode] = :fake
204
- end
205
- end
206
-
207
- # @return [OptionParser]
208
- def interactive
209
- parser.on('-i', '--interactive',
210
- 'Run the application in interactive mode (default).') do
211
- options[:interactive] = true
212
- end
213
- end
214
-
215
- # CLI arguments:
216
- #
217
- # -l, --log
218
- #
219
- # @return [OptionParser]
220
- def log
221
- parser.on('-l', '--log [FILENAME]', String,
222
- 'Specify the path for the log file.') do |filename|
223
- options[:log] = filename
224
- end
225
- end
226
-
227
- # CLI arguments:
228
- #
229
- # -r, --raw
230
- #
231
- # @return [OptionParser]
232
- def raw
233
- parser.on('-r', '--raw', 'Run application in raw mode (default).') do
234
- options[:terminal_mode] = :raw
235
- end
236
- end
237
-
238
- # CLI arguments:
239
- #
240
- # -s, --root
241
- #
242
- # @return [OptionParser]
243
- def root
244
- parser.on('-s', '--root []', String,
245
- 'Start the application from the specified controller.') do |c|
246
- options[:root] = c
247
- end
248
- end
249
-
250
- # CLI arguments:
251
- #
252
- # -n, --run-many
253
- #
254
- # @return [OptionParser]
255
- def run_many
256
- parser.on('-n', '--run-many',
257
- 'Run the application loop continuously (default).') do
258
- options[:once] = false
259
- end
260
- end
261
-
262
- # CLI arguments:
263
- #
264
- # -1, --run-once
265
- #
266
- # @return [OptionParser]
267
- def run_once
268
- parser.on('-1', '--run-once', 'Run the application loop once.') do
269
- options[:once] = true
270
- end
271
- end
272
-
273
- # CLI arguments:
274
- #
275
- # -I, --noninteractive, --standalone
276
- #
277
- # @return [OptionParser]
278
- def standalone
279
- parser.on('-I', '--noninteractive', '--standalone',
280
- 'Run the application non-interactively; ' \
281
- 'i.e. not requiring intervention from the user.') do
282
- options[:interactive] = false
283
- end
284
- end
285
-
286
- end # CLI
287
-
288
- end # Config
289
-
290
- end # Vedeu
@@ -1,14 +0,0 @@
1
- module Vedeu
2
-
3
- module Views
4
-
5
- # A collection of {Vedeu::Views::Char} instances.
6
- #
7
- # @api private
8
- class Chars < Vedeu::Repositories::Collection
9
-
10
- end # Chars
11
-
12
- end # Views
13
-
14
- end # Vedeu
@@ -1,14 +0,0 @@
1
- module Vedeu
2
-
3
- module Views
4
-
5
- # A collection of {Vedeu::Views::Line} instances.
6
- #
7
- # @api private
8
- class Lines < Vedeu::Repositories::Collection
9
-
10
- end # Lines
11
-
12
- end # Views
13
-
14
- end # Vedeu
@@ -1,14 +0,0 @@
1
- module Vedeu
2
-
3
- module Views
4
-
5
- # A collection of {Vedeu::Views::Stream} instances.
6
- #
7
- # @api private
8
- class Streams < Vedeu::Repositories::Collection
9
-
10
- end # Streams
11
-
12
- end # Views
13
-
14
- end # Vedeu
@@ -1,14 +0,0 @@
1
- module Vedeu
2
-
3
- module Views
4
-
5
- # A collection of {Vedeu::Views::View} instances.
6
- #
7
- # @api private
8
- class ViewCollection < Vedeu::Repositories::Collection
9
-
10
- end # ViewCollection
11
-
12
- end # Views
13
-
14
- end # Vedeu
@@ -1,11 +0,0 @@
1
- module Vedeu
2
-
3
- # A group of objects that serve to intercept messages destined for their
4
- # real counterpart. In most cases the call is muted or returns a generic
5
- # value that does not halt processing.
6
- #
7
- module Null
8
-
9
- end # Null
10
-
11
- end # Vedeu
@@ -1,92 +0,0 @@
1
- module Vedeu
2
-
3
- # Provides a single interface to all registered renderers.
4
- #
5
- module Renderers
6
-
7
- extend Enumerable
8
- extend self
9
-
10
- def clear
11
- threads = storage.map do |renderer|
12
- Thread.new(renderer) do
13
- mutex.synchronize do
14
- renderer.clear
15
- end
16
- end
17
- end
18
- threads.each(&:join)
19
-
20
- ''
21
- end
22
-
23
- # Provides access to the list of renderers.
24
- #
25
- # @example
26
- # Vedeu.renderers
27
- #
28
- # @return [Module]
29
- def renderers
30
- self
31
- end
32
-
33
- # @example
34
- # Vedeu.renderers.render(output)
35
- #
36
- # @param output [void]
37
- # @return [Array<void>]
38
- def render(output)
39
- threads = storage.map do |renderer|
40
- Thread.new(renderer) do
41
- mutex.synchronize do
42
- Vedeu.log(type: :output,
43
- message: "Renderer: '#{renderer.class.name}'")
44
-
45
- renderer.render(output)
46
- end
47
- end
48
- end
49
- threads.each(&:join)
50
-
51
- output
52
- end
53
-
54
- # Adds the given renderer class(es) to the list of renderers.
55
- #
56
- # @example
57
- # Vedeu.renderer SomeRenderer
58
- #
59
- # @note
60
- # A renderer class must respond to the '.render' class method.
61
- #
62
- # @param renderers [Class]
63
- # @return [Set]
64
- def renderer(*renderers)
65
- renderers.each { |renderer| storage.add(renderer) unless renderer.nil? }
66
-
67
- storage
68
- end
69
-
70
- # @example
71
- # Vedeu.renderers.reset
72
- #
73
- # @return [Set]
74
- def reset
75
- @storage = Set.new
76
- end
77
-
78
- private
79
-
80
- # @return [Set]
81
- def storage
82
- @storage ||= reset
83
- end
84
-
85
- # @return [Mutex]
86
- def mutex
87
- @mutex ||= Mutex.new
88
- end
89
-
90
- end # Renderers
91
-
92
- end # Vedeu