vedeu 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +2 -0
  3. data/README.md +116 -98
  4. data/lib/vedeu.rb +24 -11
  5. data/lib/vedeu/api/api.rb +174 -33
  6. data/lib/vedeu/api/composition.rb +2 -13
  7. data/lib/vedeu/api/helpers.rb +41 -0
  8. data/lib/vedeu/api/interface.rb +147 -34
  9. data/lib/vedeu/api/line.rb +47 -0
  10. data/lib/vedeu/api/stream.rb +41 -0
  11. data/lib/vedeu/application.rb +9 -2
  12. data/lib/vedeu/configuration.rb +66 -8
  13. data/lib/vedeu/launcher.rb +11 -0
  14. data/lib/vedeu/models/attributes/background.rb +29 -0
  15. data/lib/vedeu/models/attributes/coercions.rb +30 -0
  16. data/lib/vedeu/models/attributes/colour_translator.rb +106 -16
  17. data/lib/vedeu/models/attributes/foreground.rb +29 -0
  18. data/lib/vedeu/models/attributes/presentation.rb +15 -0
  19. data/lib/vedeu/models/colour.rb +12 -7
  20. data/lib/vedeu/models/composition.rb +23 -5
  21. data/lib/vedeu/models/geometry.rb +101 -16
  22. data/lib/vedeu/models/interface.rb +36 -28
  23. data/lib/vedeu/models/line.rb +16 -14
  24. data/lib/vedeu/models/stream.rb +17 -25
  25. data/lib/vedeu/models/style.rb +29 -0
  26. data/lib/vedeu/support/buffer.rb +36 -21
  27. data/lib/vedeu/support/buffers.rb +88 -0
  28. data/lib/vedeu/{output → support}/clear.rb +9 -2
  29. data/lib/vedeu/support/esc.rb +16 -2
  30. data/lib/vedeu/support/event.rb +104 -0
  31. data/lib/vedeu/support/events.rb +61 -0
  32. data/lib/vedeu/support/focus.rb +69 -0
  33. data/lib/vedeu/{api → support}/grid.rb +29 -25
  34. data/lib/vedeu/support/groups.rb +51 -0
  35. data/lib/vedeu/support/input.rb +5 -0
  36. data/lib/vedeu/support/log.rb +105 -0
  37. data/lib/vedeu/support/menu.rb +19 -0
  38. data/lib/vedeu/support/position.rb +7 -0
  39. data/lib/vedeu/{output → support}/render.rb +12 -6
  40. data/lib/vedeu/support/terminal.rb +21 -0
  41. data/lib/vedeu/support/trace.rb +54 -0
  42. data/lib/vedeu/{output → support}/view.rb +15 -10
  43. data/test/lib/vedeu/api/api_test.rb +55 -29
  44. data/test/lib/vedeu/api/interface_test.rb +3 -49
  45. data/test/lib/vedeu/api/line_test.rb +71 -0
  46. data/test/lib/vedeu/api/stream_test.rb +25 -0
  47. data/test/lib/vedeu/models/attributes/background_test.rb +83 -0
  48. data/test/lib/vedeu/models/attributes/coercer_test.rb +52 -0
  49. data/test/lib/vedeu/models/attributes/foreground_test.rb +83 -0
  50. data/test/lib/vedeu/models/attributes/presentation_test.rb +30 -0
  51. data/test/lib/vedeu/models/composition_test.rb +6 -6
  52. data/test/lib/vedeu/models/geometry_test.rb +34 -0
  53. data/test/lib/vedeu/models/interface_test.rb +0 -12
  54. data/test/lib/vedeu/models/line_test.rb +1 -13
  55. data/test/lib/vedeu/models/stream_test.rb +4 -50
  56. data/test/lib/vedeu/models/style_test.rb +39 -0
  57. data/test/lib/vedeu/support/buffer_test.rb +7 -3
  58. data/test/lib/vedeu/support/buffers_test.rb +15 -0
  59. data/test/lib/vedeu/{output → support}/clear_test.rb +8 -1
  60. data/test/lib/vedeu/support/esc_test.rb +2 -2
  61. data/test/lib/vedeu/support/event_test.rb +41 -0
  62. data/test/lib/vedeu/support/events_test.rb +70 -0
  63. data/test/lib/vedeu/support/focus_test.rb +114 -0
  64. data/test/lib/vedeu/support/grid_test.rb +31 -0
  65. data/test/lib/vedeu/support/groups_test.rb +65 -0
  66. data/test/lib/vedeu/{output → support}/render_test.rb +8 -1
  67. data/test/lib/vedeu/{output → support}/view_test.rb +1 -1
  68. data/test/test_helper.rb +3 -1
  69. data/vedeu.gemspec +3 -2
  70. metadata +67 -31
  71. data/lib/vedeu/api/events.rb +0 -46
  72. data/lib/vedeu/api/log.rb +0 -84
  73. data/lib/vedeu/models/attributes/attributes.rb +0 -25
  74. data/lib/vedeu/models/store.rb +0 -29
  75. data/lib/vedeu/output/buffers.rb +0 -65
  76. data/test/lib/vedeu/api/events_test.rb +0 -36
  77. data/test/lib/vedeu/api/grid_test.rb +0 -33
  78. data/test/lib/vedeu/models/attributes/attributes_test.rb +0 -39
  79. data/test/lib/vedeu/models/attributes/colour_translator_test.rb +0 -78
  80. data/test/lib/vedeu/models/store_test.rb +0 -57
  81. data/test/lib/vedeu/output/buffers_test.rb +0 -35
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
  class ViewTest < View
5
- def output
5
+ def render
6
6
  { interfaces: [] }
7
7
  end
8
8
  end
@@ -13,6 +13,8 @@ require 'mocha/setup'
13
13
 
14
14
  GC.disable
15
15
 
16
+ ENV['VEDEUTERM'] = 'xterm-truecolor'
17
+
16
18
  require 'vedeu'
17
19
 
18
20
  # commented out by default (makes tests slower)
@@ -23,5 +25,5 @@ require 'vedeu'
23
25
  # )
24
26
 
25
27
  # trace method execution with (optionally) local variables
26
- # require 'vedeu/api/log'
28
+ # require 'vedeu/support/log'
27
29
  # Vedeu::Log::Trace.call({ watched: 'call', klass: /^Vedeu/ })
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'vedeu'
7
- spec.version = '0.1.15'
7
+ spec.version = '0.1.16'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
@@ -20,11 +20,12 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency 'bundler', '~> 1.6'
21
21
  spec.add_development_dependency 'guard', '2.6.1'
22
22
  spec.add_development_dependency 'guard-bundler', '2.0.0'
23
- spec.add_development_dependency 'guard-minitest', '2.3.1'
23
+ spec.add_development_dependency 'guard-minitest', '2.3.2'
24
24
  spec.add_development_dependency 'minitest', '5.4.0'
25
25
  spec.add_development_dependency 'minitest-reporters', '1.0.5'
26
26
  spec.add_development_dependency 'mocha', '1.1.0'
27
27
  spec.add_development_dependency 'pry', '0.10.0'
28
28
  spec.add_development_dependency 'rake', '10.3.2'
29
29
  spec.add_development_dependency 'simplecov', '0.9.0'
30
+ spec.add_development_dependency 'yard', '0.8.7.4'
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2014-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 2.3.1
61
+ version: 2.3.2
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 2.3.1
68
+ version: 2.3.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.9.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 0.8.7.4
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 0.8.7.4
153
167
  description: A GUI framework for terminal/console applications.
154
168
  email:
155
169
  - gavinlaking@gmail.com
@@ -172,61 +186,75 @@ files:
172
186
  - lib/vedeu.rb
173
187
  - lib/vedeu/api/api.rb
174
188
  - lib/vedeu/api/composition.rb
175
- - lib/vedeu/api/events.rb
176
- - lib/vedeu/api/grid.rb
177
189
  - lib/vedeu/api/helpers.rb
178
190
  - lib/vedeu/api/interface.rb
179
191
  - lib/vedeu/api/line.rb
180
- - lib/vedeu/api/log.rb
181
192
  - lib/vedeu/api/stream.rb
182
193
  - lib/vedeu/application.rb
183
194
  - lib/vedeu/configuration.rb
184
195
  - lib/vedeu/launcher.rb
185
- - lib/vedeu/models/attributes/attributes.rb
196
+ - lib/vedeu/models/attributes/background.rb
197
+ - lib/vedeu/models/attributes/coercions.rb
186
198
  - lib/vedeu/models/attributes/colour_translator.rb
199
+ - lib/vedeu/models/attributes/foreground.rb
200
+ - lib/vedeu/models/attributes/presentation.rb
187
201
  - lib/vedeu/models/colour.rb
188
202
  - lib/vedeu/models/composition.rb
189
203
  - lib/vedeu/models/geometry.rb
190
204
  - lib/vedeu/models/interface.rb
191
205
  - lib/vedeu/models/line.rb
192
- - lib/vedeu/models/store.rb
193
206
  - lib/vedeu/models/stream.rb
194
- - lib/vedeu/output/buffers.rb
195
- - lib/vedeu/output/clear.rb
196
- - lib/vedeu/output/render.rb
197
- - lib/vedeu/output/view.rb
207
+ - lib/vedeu/models/style.rb
198
208
  - lib/vedeu/support/buffer.rb
209
+ - lib/vedeu/support/buffers.rb
210
+ - lib/vedeu/support/clear.rb
199
211
  - lib/vedeu/support/esc.rb
212
+ - lib/vedeu/support/event.rb
213
+ - lib/vedeu/support/events.rb
214
+ - lib/vedeu/support/focus.rb
215
+ - lib/vedeu/support/grid.rb
216
+ - lib/vedeu/support/groups.rb
200
217
  - lib/vedeu/support/input.rb
218
+ - lib/vedeu/support/log.rb
201
219
  - lib/vedeu/support/menu.rb
202
220
  - lib/vedeu/support/position.rb
221
+ - lib/vedeu/support/render.rb
203
222
  - lib/vedeu/support/terminal.rb
223
+ - lib/vedeu/support/trace.rb
224
+ - lib/vedeu/support/view.rb
204
225
  - logs/.gitkeep
205
226
  - test/lib/vedeu/api/api_test.rb
206
227
  - test/lib/vedeu/api/composition_test.rb
207
- - test/lib/vedeu/api/events_test.rb
208
- - test/lib/vedeu/api/grid_test.rb
209
228
  - test/lib/vedeu/api/interface_test.rb
229
+ - test/lib/vedeu/api/line_test.rb
230
+ - test/lib/vedeu/api/stream_test.rb
210
231
  - test/lib/vedeu/configuration_test.rb
211
- - test/lib/vedeu/models/attributes/attributes_test.rb
212
- - test/lib/vedeu/models/attributes/colour_translator_test.rb
232
+ - test/lib/vedeu/models/attributes/background_test.rb
233
+ - test/lib/vedeu/models/attributes/coercer_test.rb
234
+ - test/lib/vedeu/models/attributes/foreground_test.rb
235
+ - test/lib/vedeu/models/attributes/presentation_test.rb
213
236
  - test/lib/vedeu/models/colour_test.rb
214
237
  - test/lib/vedeu/models/composition_test.rb
215
238
  - test/lib/vedeu/models/geometry_test.rb
216
239
  - test/lib/vedeu/models/interface_test.rb
217
240
  - test/lib/vedeu/models/line_test.rb
218
- - test/lib/vedeu/models/store_test.rb
219
241
  - test/lib/vedeu/models/stream_test.rb
220
- - test/lib/vedeu/output/buffers_test.rb
221
- - test/lib/vedeu/output/clear_test.rb
222
- - test/lib/vedeu/output/render_test.rb
223
- - test/lib/vedeu/output/view_test.rb
242
+ - test/lib/vedeu/models/style_test.rb
224
243
  - test/lib/vedeu/support/buffer_test.rb
244
+ - test/lib/vedeu/support/buffers_test.rb
245
+ - test/lib/vedeu/support/clear_test.rb
225
246
  - test/lib/vedeu/support/esc_test.rb
247
+ - test/lib/vedeu/support/event_test.rb
248
+ - test/lib/vedeu/support/events_test.rb
249
+ - test/lib/vedeu/support/focus_test.rb
250
+ - test/lib/vedeu/support/grid_test.rb
251
+ - test/lib/vedeu/support/groups_test.rb
226
252
  - test/lib/vedeu/support/input_test.rb
227
253
  - test/lib/vedeu/support/menu_test.rb
228
254
  - test/lib/vedeu/support/position_test.rb
255
+ - test/lib/vedeu/support/render_test.rb
229
256
  - test/lib/vedeu/support/terminal_test.rb
257
+ - test/lib/vedeu/support/view_test.rb
230
258
  - test/support/colour_test.sh
231
259
  - test/support/model_test_data.json
232
260
  - test/support/stats.sh
@@ -259,30 +287,38 @@ summary: A terminal case of wonderland.
259
287
  test_files:
260
288
  - test/lib/vedeu/api/api_test.rb
261
289
  - test/lib/vedeu/api/composition_test.rb
262
- - test/lib/vedeu/api/events_test.rb
263
- - test/lib/vedeu/api/grid_test.rb
264
290
  - test/lib/vedeu/api/interface_test.rb
291
+ - test/lib/vedeu/api/line_test.rb
292
+ - test/lib/vedeu/api/stream_test.rb
265
293
  - test/lib/vedeu/configuration_test.rb
266
- - test/lib/vedeu/models/attributes/attributes_test.rb
267
- - test/lib/vedeu/models/attributes/colour_translator_test.rb
294
+ - test/lib/vedeu/models/attributes/background_test.rb
295
+ - test/lib/vedeu/models/attributes/coercer_test.rb
296
+ - test/lib/vedeu/models/attributes/foreground_test.rb
297
+ - test/lib/vedeu/models/attributes/presentation_test.rb
268
298
  - test/lib/vedeu/models/colour_test.rb
269
299
  - test/lib/vedeu/models/composition_test.rb
270
300
  - test/lib/vedeu/models/geometry_test.rb
271
301
  - test/lib/vedeu/models/interface_test.rb
272
302
  - test/lib/vedeu/models/line_test.rb
273
- - test/lib/vedeu/models/store_test.rb
274
303
  - test/lib/vedeu/models/stream_test.rb
275
- - test/lib/vedeu/output/buffers_test.rb
276
- - test/lib/vedeu/output/clear_test.rb
277
- - test/lib/vedeu/output/render_test.rb
278
- - test/lib/vedeu/output/view_test.rb
304
+ - test/lib/vedeu/models/style_test.rb
279
305
  - test/lib/vedeu/support/buffer_test.rb
306
+ - test/lib/vedeu/support/buffers_test.rb
307
+ - test/lib/vedeu/support/clear_test.rb
280
308
  - test/lib/vedeu/support/esc_test.rb
309
+ - test/lib/vedeu/support/event_test.rb
310
+ - test/lib/vedeu/support/events_test.rb
311
+ - test/lib/vedeu/support/focus_test.rb
312
+ - test/lib/vedeu/support/grid_test.rb
313
+ - test/lib/vedeu/support/groups_test.rb
281
314
  - test/lib/vedeu/support/input_test.rb
282
315
  - test/lib/vedeu/support/menu_test.rb
283
316
  - test/lib/vedeu/support/position_test.rb
317
+ - test/lib/vedeu/support/render_test.rb
284
318
  - test/lib/vedeu/support/terminal_test.rb
319
+ - test/lib/vedeu/support/view_test.rb
285
320
  - test/support/colour_test.sh
286
321
  - test/support/model_test_data.json
287
322
  - test/support/stats.sh
288
323
  - test/test_helper.rb
324
+ has_rdoc:
@@ -1,46 +0,0 @@
1
- module Vedeu
2
- module API
3
- class Events
4
- def initialize(&block)
5
- @handlers = Hash.new do |hash, key|
6
- hash[key] = {
7
- delay: 0,
8
- events: [],
9
- last_exec: 0,
10
- }
11
- end
12
- instance_eval(&block) if block_given?
13
- end
14
-
15
- def add(object, &block)
16
- @self_before_instance_eval = eval('self', block.binding)
17
-
18
- instance_eval(&block)
19
- end
20
-
21
- def event(event, delay = 0, &block)
22
- handlers[event][:events] << block
23
- handlers[event][:delay] = delay
24
- handlers[event]
25
- end
26
-
27
- def trigger(event, *args)
28
- elapsed = Time.now.to_f - handlers[event][:last_exec]
29
-
30
- if elapsed > handlers[event][:delay]
31
- handlers[event][:last_exec] = Time.now.to_f
32
-
33
- handlers[event][:events].each { |handler| handler.call(*args) }
34
- end
35
- end
36
-
37
- private
38
-
39
- attr_reader :handlers
40
-
41
- def method_missing(method, *args, &block)
42
- @self_before_instance_eval.send(method, *args, &block)
43
- end
44
- end
45
- end
46
- end
@@ -1,84 +0,0 @@
1
- require 'fileutils'
2
- require 'time'
3
-
4
- module Vedeu
5
- module API
6
- class Log
7
- def self.logger
8
- @logger ||= Logger.new(filename).tap do |log|
9
- log.formatter = proc do |_, time, _, message|
10
- time.utc.iso8601 + ": " + message + "\n"
11
- end
12
- end
13
- end
14
-
15
- def self.error(exception)
16
- backtrace = exception.backtrace.join("\n")
17
- message = exception.message + "\n" + backtrace
18
-
19
- logger.debug(message)
20
- end
21
-
22
- private
23
-
24
- def self.filename
25
- @_filename ||= directory + '/vedeu.log'
26
- end
27
-
28
- def self.directory
29
- FileUtils.mkdir_p(path) unless File.directory?(path)
30
-
31
- path
32
- end
33
-
34
- def self.path
35
- Dir.home + '/.vedeu'
36
- end
37
- end
38
-
39
- class Trace
40
- def self.call(options = {})
41
- new(options).trace
42
- end
43
-
44
- def initialize(options = {})
45
- @options = options
46
- end
47
-
48
- def trace
49
- set_trace_func proc { |event, file, line, id, binding, classname|
50
- if event == watched && classname.to_s.match(klass)
51
- Vedeu.log(sprintf(" %s %-35s #%s", event, classname, id))
52
- # binding.eval('local_variables').each do |var|
53
- # print("#{var.to_s} = #{binding.local_variable_get(var).inspect}\n")
54
- # end
55
- end
56
- }
57
- end
58
-
59
- private
60
-
61
- def watched
62
- options[:event]
63
- end
64
-
65
- def klass
66
- options[:klass]
67
- end
68
-
69
- def options
70
- defaults.merge!(@options)
71
- end
72
-
73
- def defaults
74
- {
75
- event: 'call',
76
- klass: /^Vedeu::(?!.*Log|Interface|Line|Stream|Style|Colour|Geometry|Terminal|Esc|ColourTranslator).*/
77
- }
78
- end
79
-
80
- # everything except Interface, Geometry and Terminal
81
- # klass: /^Vedeu::(?!.*Interface|Geometry|Terminal).*/
82
- end
83
- end
84
- end
@@ -1,25 +0,0 @@
1
- module Vedeu
2
- module Attributes
3
- extend self
4
-
5
- def coercer(values, model, key)
6
- return [] if values.nil? || values.empty?
7
-
8
- [values].flatten.map do |value|
9
- if value.is_a?(model)
10
- value
11
-
12
- else
13
- model.new(value)
14
-
15
- end
16
- end
17
- end
18
-
19
- def coerce_styles(values)
20
- return '' if values.nil? || values.empty?
21
-
22
- Array(values).flatten.map { |value| Esc.string(value) }.join
23
- end
24
- end
25
- end
@@ -1,29 +0,0 @@
1
- module Vedeu
2
- EntityNotFound = Class.new(StandardError)
3
-
4
- module Store
5
- extend self
6
-
7
- def create(attributes)
8
- storage.store(attributes[:name], attributes)
9
-
10
- Buffers.create(Interface.new(attributes))
11
-
12
- storage
13
- end
14
-
15
- def query(name)
16
- storage.fetch(name) { fail EntityNotFound, 'Interface was not found.' }
17
- end
18
-
19
- def reset
20
- @storage = {}
21
- end
22
-
23
- private
24
-
25
- def storage
26
- @storage ||= {}
27
- end
28
- end
29
- end
@@ -1,65 +0,0 @@
1
- module Vedeu
2
- RefreshFailed = Class.new(StandardError)
3
-
4
- module Buffers
5
- extend self
6
-
7
- def create(interface)
8
- store(interface.name, Buffer.new({
9
- name: interface.name,
10
- clear: Clear.call(interface),
11
- current: '',
12
- group: interface.group,
13
- next: ''
14
- }))
15
-
16
- create_events(interface.name, interface.group, interface.delay)
17
- end
18
-
19
- def enqueue(name, sequence)
20
- store(name, query(name).enqueue(sequence))
21
- end
22
-
23
- def refresh_all
24
- buffers.keys.map { |name| refresh(name) }
25
- end
26
-
27
- def reset
28
- @buffers = {}
29
- end
30
-
31
- private
32
-
33
- def create_events(name, group, delay)
34
- Vedeu.event("_refresh_#{name}_".to_sym, delay) { refresh(name) }
35
-
36
- Vedeu.event("_refresh_group_#{group}_".to_sym, delay) do
37
- refresh_group(group)
38
- end unless group.nil? || group.empty?
39
- end
40
-
41
- def query(name)
42
- buffers.fetch(name) {
43
- fail RefreshFailed, 'Cannot refresh non-existent interface.'
44
- }
45
- end
46
-
47
- def refresh(name)
48
- store(name, query(name).refresh)
49
- end
50
-
51
- def refresh_group(group)
52
- buffers.select.map do |name, buffer|
53
- name if buffer.group == group
54
- end.compact.map { |name| refresh(name) }
55
- end
56
-
57
- def store(name, buffer)
58
- buffers.store(name, buffer)
59
- end
60
-
61
- def buffers
62
- @buffers ||= {}
63
- end
64
- end
65
- end