vedeu 0.1.18 → 0.1.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +5 -0
  3. data/Dockerfile +40 -0
  4. data/README.md +7 -30
  5. data/docs/api.md +79 -0
  6. data/docs/events.md +121 -0
  7. data/lib/vedeu.rb +61 -18
  8. data/lib/vedeu/api/api.rb +73 -53
  9. data/lib/vedeu/api/composition.rb +4 -1
  10. data/lib/vedeu/api/defined.rb +35 -0
  11. data/lib/vedeu/api/helpers.rb +20 -15
  12. data/lib/vedeu/api/interface.rb +17 -12
  13. data/lib/vedeu/api/line.rb +20 -12
  14. data/lib/vedeu/api/stream.rb +3 -0
  15. data/lib/vedeu/application.rb +34 -1
  16. data/lib/vedeu/configuration.rb +15 -3
  17. data/lib/vedeu/input/input.rb +77 -0
  18. data/lib/vedeu/launcher.rb +7 -0
  19. data/lib/vedeu/models/attributes/background.rb +15 -2
  20. data/lib/vedeu/models/attributes/coercions.rb +18 -3
  21. data/lib/vedeu/models/attributes/colour_translator.rb +23 -17
  22. data/lib/vedeu/models/attributes/foreground.rb +10 -2
  23. data/lib/vedeu/models/attributes/presentation.rb +62 -0
  24. data/lib/vedeu/models/colour.rb +7 -3
  25. data/lib/vedeu/models/composition.rb +17 -19
  26. data/lib/vedeu/models/geometry.rb +13 -5
  27. data/lib/vedeu/models/interface.rb +35 -19
  28. data/lib/vedeu/models/line.rb +24 -8
  29. data/lib/vedeu/models/stream.rb +13 -7
  30. data/lib/vedeu/models/style.rb +17 -7
  31. data/lib/vedeu/{support → output}/clear.rb +14 -0
  32. data/lib/vedeu/output/compositor.rb +77 -0
  33. data/lib/vedeu/output/refresh.rb +129 -0
  34. data/lib/vedeu/{support → output}/render.rb +49 -13
  35. data/lib/vedeu/{support → output}/view.rb +15 -8
  36. data/lib/vedeu/repositories/buffers.rb +181 -0
  37. data/lib/vedeu/{support → repositories}/events.rb +16 -6
  38. data/lib/vedeu/repositories/focus.rb +109 -0
  39. data/lib/vedeu/repositories/groups.rb +76 -0
  40. data/lib/vedeu/repositories/interfaces.rb +74 -0
  41. data/lib/vedeu/support/common.rb +20 -0
  42. data/lib/vedeu/support/cursor.rb +77 -0
  43. data/lib/vedeu/support/esc.rb +181 -46
  44. data/lib/vedeu/support/event.rb +22 -4
  45. data/lib/vedeu/support/grid.rb +10 -3
  46. data/lib/vedeu/support/log.rb +14 -1
  47. data/lib/vedeu/support/menu.rb +51 -12
  48. data/lib/vedeu/support/position.rb +9 -0
  49. data/lib/vedeu/support/terminal.rb +49 -15
  50. data/lib/vedeu/support/trace.rb +11 -4
  51. data/test/integration/defining_interfaces_test.rb +27 -0
  52. data/test/integration/views/basic_view_test.rb +767 -0
  53. data/test/lib/vedeu/api/api_test.rb +32 -37
  54. data/test/lib/vedeu/api/composition_test.rb +23 -61
  55. data/test/lib/vedeu/api/defined_test.rb +49 -0
  56. data/test/lib/vedeu/api/helpers_test.rb +91 -0
  57. data/test/lib/vedeu/api/interface_test.rb +136 -688
  58. data/test/lib/vedeu/api/line_test.rb +28 -32
  59. data/test/lib/vedeu/application_test.rb +6 -0
  60. data/test/lib/vedeu/configuration_test.rb +8 -4
  61. data/test/lib/vedeu/{support → input}/input_test.rb +9 -0
  62. data/test/lib/vedeu/launcher_test.rb +6 -0
  63. data/test/lib/vedeu/models/attributes/{coercer_test.rb → coercions_test.rb} +11 -10
  64. data/test/lib/vedeu/models/attributes/colour_translator_test.rb +13 -0
  65. data/test/lib/vedeu/models/attributes/presentation_test.rb +30 -0
  66. data/test/lib/vedeu/models/colour_test.rb +8 -0
  67. data/test/lib/vedeu/models/composition_test.rb +208 -200
  68. data/test/lib/vedeu/models/geometry_test.rb +39 -0
  69. data/test/lib/vedeu/models/interface_test.rb +11 -1
  70. data/test/lib/vedeu/models/line_test.rb +8 -1
  71. data/test/lib/vedeu/models/stream_test.rb +35 -0
  72. data/test/lib/vedeu/models/style_test.rb +8 -0
  73. data/test/lib/vedeu/{support → output}/clear_test.rb +1 -1
  74. data/test/lib/vedeu/output/compositor_test.rb +64 -0
  75. data/test/lib/vedeu/output/refresh_test.rb +48 -0
  76. data/test/lib/vedeu/{support → output}/render_test.rb +36 -0
  77. data/test/lib/vedeu/{support → output}/view_test.rb +0 -0
  78. data/test/lib/vedeu/repositories/buffers_test.rb +48 -0
  79. data/test/lib/vedeu/{support → repositories}/events_test.rb +0 -0
  80. data/test/lib/vedeu/repositories/focus_test.rb +74 -0
  81. data/test/lib/vedeu/repositories/groups_test.rb +66 -0
  82. data/test/lib/vedeu/repositories/interfaces_test.rb +6 -0
  83. data/test/lib/vedeu/support/common_test.rb +6 -0
  84. data/test/lib/vedeu/support/cursor_test.rb +79 -0
  85. data/test/lib/vedeu/support/log_test.rb +6 -0
  86. data/test/lib/vedeu/support/terminal_test.rb +6 -28
  87. data/test/lib/vedeu/support/trace_test.rb +6 -0
  88. data/test/test_helper.rb +37 -0
  89. data/vedeu.gemspec +1 -1
  90. metadata +65 -33
  91. data/bin/log +0 -13
  92. data/lib/vedeu/support/buffer.rb +0 -69
  93. data/lib/vedeu/support/buffers.rb +0 -106
  94. data/lib/vedeu/support/focus.rb +0 -83
  95. data/lib/vedeu/support/groups.rb +0 -61
  96. data/lib/vedeu/support/input.rb +0 -67
  97. data/test/lib/vedeu/support/buffer_test.rb +0 -83
  98. data/test/lib/vedeu/support/buffers_test.rb +0 -15
  99. data/test/lib/vedeu/support/focus_test.rb +0 -114
  100. data/test/lib/vedeu/support/groups_test.rb +0 -65
@@ -1,15 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
- describe Buffers do
5
- before { Buffers.reset }
6
-
7
- describe '.enqueue' do
8
- it 'raises an exception if the interface cannot be found by name' do
9
- name = 'unknown'
10
- view = '...'
11
- proc { Buffers.enqueue(name, view) }.must_raise(EntityNotFound)
12
- end
13
- end
14
- end
15
- end
@@ -1,114 +0,0 @@
1
- require 'test_helper'
2
-
3
- # [['thallium', false], ['lead', false], ['bismuth', false]]
4
-
5
- module Vedeu
6
- describe Focus do
7
- before do
8
- Vedeu.unevent(:_focus_next_)
9
- Vedeu.unevent(:_focus_prev_)
10
- Vedeu.unevent(:_focus_by_name_)
11
- end
12
-
13
- describe '#add' do
14
- it 'adds an interface to storage unfocussed' do
15
- focus = Focus.new
16
- focus.add('thallium').must_equal(['thallium'])
17
- end
18
-
19
- it 'does not add it again if already exists' do
20
- focus = Focus.new
21
- focus.add('thallium')
22
- focus.add('thallium').must_equal(['thallium'])
23
- end
24
- end
25
-
26
- describe '#by_name' do
27
- it 'the named interface is focussed when the method is called' do
28
- focus = Focus.new
29
- focus.add('thallium')
30
- focus.add('lead')
31
- focus.add('bismuth')
32
- focus.by_name('bismuth').must_equal('bismuth')
33
- end
34
-
35
- it 'the named interface is focussed when the event is triggered' do
36
- focus = Focus.new
37
- focus.add('thallium')
38
- focus.add('lead')
39
- focus.add('bismuth')
40
-
41
- Vedeu.trigger(:_focus_by_name_, 'lead')
42
-
43
- focus.current.must_equal('lead')
44
- end
45
-
46
- it 'raises an exception if the interface does not exist' do
47
- focus = Focus.new
48
- proc { Vedeu.trigger(:_focus_by_name_, 'not_found') }.must_raise(InterfaceNotFound)
49
- end
50
-
51
- it 'raises an exception if the interface does not exist' do
52
- focus = Focus.new
53
- proc { focus.by_name('not_found') }.must_raise(InterfaceNotFound)
54
- end
55
- end
56
-
57
- describe '#current' do
58
- it 'returns the name of the interface currently in focus' do
59
- focus = Focus.new
60
- focus.add('thallium')
61
- focus.add('lead')
62
- focus.add('bismuth')
63
- focus.current.must_equal('thallium')
64
- end
65
-
66
- it 'raises an exception if there are no interfaces defined' do
67
- focus = Focus.new
68
- proc { focus.current }.must_raise(NoInterfacesDefined)
69
- end
70
- end
71
-
72
- describe '#next_item' do
73
- it 'the next interface is focussed when the method is called' do
74
- focus = Focus.new
75
- focus.add('thallium')
76
- focus.add('lead')
77
- focus.add('bismuth')
78
- focus.next_item.must_equal('lead')
79
- end
80
-
81
- it 'the next interface is focussed when the event is triggered' do
82
- focus = Focus.new
83
- focus.add('thallium')
84
- focus.add('lead')
85
- focus.add('bismuth')
86
-
87
- Vedeu.trigger(:_focus_next_)
88
-
89
- focus.current.must_equal('lead')
90
- end
91
- end
92
-
93
- describe '#prev_item' do
94
- it 'the previous interface is focussed when the method is called' do
95
- focus = Focus.new
96
- focus.add('thallium')
97
- focus.add('lead')
98
- focus.add('bismuth')
99
- focus.prev_item.must_equal('bismuth')
100
- end
101
-
102
- it 'the previous interface is focussed when the event is triggered' do
103
- focus = Focus.new
104
- focus.add('thallium')
105
- focus.add('lead')
106
- focus.add('bismuth')
107
-
108
- Vedeu.trigger(:_focus_prev_)
109
-
110
- focus.current.must_equal('bismuth')
111
- end
112
- end
113
- end
114
- end
@@ -1,65 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
- describe Groups do
5
- let(:groups) { Groups.new }
6
-
7
- describe '#all' do
8
- before do
9
- groups.add('elements', 'cobalt', 0.0)
10
- groups.add('elements', 'nickel', 0.0)
11
- groups.add('elements', 'copper', 0.0)
12
- end
13
-
14
- it 'returns all the groups from storage' do
15
- groups.all.must_equal({
16
- "elements" => Set["cobalt", "nickel", "copper"]
17
- })
18
- end
19
- end
20
-
21
- describe '#find' do
22
- before { groups.add('elements', 'zinc', 0.0) }
23
-
24
- it 'raises an exception if the group cannot be found' do
25
- proc { groups.find('not_found') }.must_raise(GroupNotFound)
26
- end
27
-
28
- it 'returns a collection of interface names belonging to the group' do
29
- groups.find('elements').must_equal(Set['zinc'])
30
- end
31
- end
32
-
33
- describe '#add' do
34
- it 'returns false if the group name is empty' do
35
- groups.add('', 'gallium', 0.0).must_equal(false)
36
- end
37
-
38
- it 'adds the interface name to the group in storage' do
39
- groups.add('elements', 'germanium', 0.0)
40
- groups.all.must_equal({
41
- "elements" => Set['germanium']
42
- })
43
- end
44
-
45
- it 'registers a refresh event for the group' do
46
- groups.add('elements', 'arsenic', 0.0)
47
- Vedeu.events.registered.must_include(:_refresh_group_elements_)
48
- end
49
-
50
- it 'returns the object instance' do
51
- groups.add('elements', 'selenium', 0.0).must_be_instance_of(Groups)
52
- end
53
- end
54
-
55
- describe '#reset' do
56
- it 'removes all known groups from the storage' do
57
- groups.add('elements', 'bromine', 0.0)
58
- groups.all.must_equal({
59
- "elements" => Set['bromine']
60
- })
61
- groups.reset.must_be_empty
62
- end
63
- end
64
- end
65
- end