vedeu 0.4.13 → 0.4.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -1
  3. data/.travis.yml +2 -1
  4. data/Guardfile +6 -5
  5. data/README.md +3 -30
  6. data/Rakefile +5 -5
  7. data/bin/vedeu_drb_client +1 -1
  8. data/bin/vedeu_drb_server +91 -89
  9. data/bin/vedeu_test +4 -0
  10. data/config/rubocop_enabled.yml +5 -10
  11. data/examples/borders_app.rb +2 -1
  12. data/examples/colours_app.rb +13 -8
  13. data/examples/configuration_app.rb +3 -2
  14. data/examples/cursor_app.rb +16 -11
  15. data/examples/drb_app.rb +88 -89
  16. data/examples/focus_app.rb +31 -32
  17. data/examples/geometry_app.rb +2 -1
  18. data/examples/hello_world.rb +2 -1
  19. data/examples/lines_app.rb +2 -1
  20. data/examples/material_colours_app.rb +126 -0
  21. data/examples/typed_commands/typed_commands_app.rb +5 -1
  22. data/examples/view_templates_app/view_templates_app.rb +6 -3
  23. data/lib/vedeu/all.rb +1 -1
  24. data/lib/vedeu/api.rb +18 -10
  25. data/lib/vedeu/application.rb +0 -1
  26. data/lib/vedeu/bindings.rb +77 -16
  27. data/lib/vedeu/buffers/all.rb +2 -5
  28. data/lib/vedeu/buffers/buffer.rb +69 -25
  29. data/lib/vedeu/buffers/display_buffer.rb +3 -7
  30. data/lib/vedeu/configuration/all.rb +3 -6
  31. data/lib/vedeu/configuration/api.rb +28 -4
  32. data/lib/vedeu/configuration/cli.rb +9 -9
  33. data/lib/vedeu/configuration/configuration.rb +11 -7
  34. data/lib/vedeu/cursor/all.rb +3 -6
  35. data/lib/vedeu/cursor/cursor.rb +22 -14
  36. data/lib/vedeu/cursor/move.rb +32 -22
  37. data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
  38. data/lib/vedeu/debug.rb +2 -1
  39. data/lib/vedeu/distributed/client.rb +1 -7
  40. data/lib/vedeu/distributed/server.rb +0 -4
  41. data/lib/vedeu/distributed/subprocess.rb +1 -1
  42. data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -1
  43. data/lib/vedeu/distributed/test_application.rb +3 -5
  44. data/lib/vedeu/distributed/uri.rb +2 -2
  45. data/lib/vedeu/dsl/all.rb +6 -6
  46. data/lib/vedeu/dsl/components/all.rb +0 -3
  47. data/lib/vedeu/dsl/components/border.rb +20 -12
  48. data/lib/vedeu/dsl/components/geometry.rb +68 -3
  49. data/lib/vedeu/dsl/components/keymap.rb +1 -2
  50. data/lib/vedeu/dsl/composition.rb +8 -1
  51. data/lib/vedeu/dsl/interface.rb +61 -11
  52. data/lib/vedeu/dsl/line.rb +12 -12
  53. data/lib/vedeu/dsl/shared/all.rb +4 -7
  54. data/lib/vedeu/dsl/shared/colour.rb +2 -2
  55. data/lib/vedeu/dsl/shared/text.rb +2 -35
  56. data/lib/vedeu/dsl/shared/use.rb +2 -2
  57. data/lib/vedeu/dsl/view.rb +4 -4
  58. data/lib/vedeu/events/all.rb +3 -5
  59. data/lib/vedeu/events/event.rb +5 -5
  60. data/lib/vedeu/geometry/all.rb +11 -16
  61. data/lib/vedeu/geometry/area.rb +2 -5
  62. data/lib/vedeu/geometry/canvas.rb +12 -16
  63. data/lib/vedeu/geometry/dimension.rb +20 -22
  64. data/lib/vedeu/geometry/geometry.rb +28 -30
  65. data/lib/vedeu/geometry/grid.rb +1 -1
  66. data/lib/vedeu/geometry/index_position.rb +7 -0
  67. data/lib/vedeu/geometry/null_geometry.rb +61 -0
  68. data/lib/vedeu/geometry/position.rb +0 -3
  69. data/lib/vedeu/geometry/position_index.rb +7 -0
  70. data/lib/vedeu/geometry/position_validator.rb +44 -33
  71. data/lib/vedeu/input/all.rb +5 -4
  72. data/lib/vedeu/input/keymap.rb +0 -1
  73. data/lib/vedeu/input/mapper.rb +1 -3
  74. data/lib/vedeu/launcher.rb +6 -7
  75. data/lib/vedeu/main_loop.rb +1 -2
  76. data/lib/vedeu/models/all.rb +1 -0
  77. data/lib/vedeu/models/cell.rb +5 -8
  78. data/lib/vedeu/models/char.rb +50 -15
  79. data/lib/vedeu/models/composition.rb +8 -1
  80. data/lib/vedeu/models/focus.rb +4 -4
  81. data/lib/vedeu/models/group.rb +3 -3
  82. data/lib/vedeu/models/interface.rb +62 -46
  83. data/lib/vedeu/models/line.rb +1 -1
  84. data/lib/vedeu/models/null.rb +48 -0
  85. data/lib/vedeu/models/stream.rb +5 -5
  86. data/lib/vedeu/output/all.rb +20 -30
  87. data/lib/vedeu/output/border.rb +93 -40
  88. data/lib/vedeu/output/clear.rb +100 -15
  89. data/lib/vedeu/output/colour.rb +56 -12
  90. data/lib/vedeu/output/compressor.rb +59 -0
  91. data/lib/vedeu/output/html_char.rb +4 -2
  92. data/lib/vedeu/output/null_border.rb +16 -4
  93. data/lib/vedeu/output/output.rb +13 -21
  94. data/lib/vedeu/output/presentation.rb +28 -23
  95. data/lib/vedeu/output/refresh.rb +2 -2
  96. data/lib/vedeu/output/renderers/all.rb +80 -3
  97. data/lib/vedeu/output/renderers/file_renderer.rb +38 -2
  98. data/lib/vedeu/output/renderers/html_renderer.rb +6 -4
  99. data/lib/vedeu/output/renderers/json_renderer.rb +52 -0
  100. data/lib/vedeu/output/renderers/null_renderer.rb +14 -0
  101. data/lib/vedeu/output/renderers/terminal_renderer.rb +2 -12
  102. data/lib/vedeu/output/style.rb +33 -3
  103. data/lib/vedeu/output/text.rb +98 -1
  104. data/lib/vedeu/output/translator.rb +30 -7
  105. data/lib/vedeu/output/viewport.rb +43 -79
  106. data/lib/vedeu/output/wordwrap.rb +4 -4
  107. data/lib/vedeu/repositories/all.rb +22 -179
  108. data/lib/vedeu/repositories/collection.rb +11 -13
  109. data/lib/vedeu/repositories/collections/all.rb +8 -0
  110. data/lib/vedeu/repositories/collections/chars.rb +9 -0
  111. data/lib/vedeu/repositories/collections/events.rb +9 -0
  112. data/lib/vedeu/repositories/collections/interfaces.rb +9 -0
  113. data/lib/vedeu/repositories/collections/keys.rb +9 -0
  114. data/lib/vedeu/repositories/collections/lines.rb +9 -0
  115. data/lib/vedeu/repositories/collections/streams.rb +9 -0
  116. data/lib/vedeu/repositories/model.rb +7 -2
  117. data/lib/vedeu/repositories/repositories/all.rb +14 -0
  118. data/lib/vedeu/repositories/repositories/background_colours.rb +14 -0
  119. data/lib/vedeu/repositories/repositories/borders.rb +38 -0
  120. data/lib/vedeu/repositories/repositories/buffers.rb +36 -0
  121. data/lib/vedeu/repositories/repositories/colours.rb +63 -0
  122. data/lib/vedeu/repositories/repositories/cursors.rb +29 -0
  123. data/lib/vedeu/repositories/repositories/events_repository.rb +24 -0
  124. data/lib/vedeu/repositories/repositories/foreground_colours.rb +14 -0
  125. data/lib/vedeu/repositories/repositories/geometries.rb +37 -0
  126. data/lib/vedeu/repositories/repositories/groups.rb +24 -0
  127. data/lib/vedeu/repositories/repositories/interfaces_repository.rb +24 -0
  128. data/lib/vedeu/repositories/repositories/keymaps.rb +24 -0
  129. data/lib/vedeu/repositories/repositories/menus.rb +24 -0
  130. data/lib/vedeu/repositories/repository.rb +29 -47
  131. data/lib/vedeu/storage/all.rb +6 -0
  132. data/lib/vedeu/storage/associative_store.rb +47 -0
  133. data/lib/vedeu/storage/conveyor_store.rb +69 -0
  134. data/lib/vedeu/storage/fifo_store.rb +37 -0
  135. data/lib/vedeu/storage/store.rb +58 -0
  136. data/lib/vedeu/support/all.rb +5 -10
  137. data/lib/vedeu/support/common.rb +0 -8
  138. data/lib/vedeu/support/log.rb +13 -24
  139. data/lib/vedeu/support/template.rb +4 -1
  140. data/lib/vedeu/support/terminal.rb +10 -10
  141. data/lib/vedeu/support/trace.rb +15 -88
  142. data/lib/vedeu/support/visibility.rb +73 -0
  143. data/lib/vedeu.rb +37 -0
  144. data/test/lib/vedeu/api_test.rb +7 -3
  145. data/test/lib/vedeu/application_test.rb +9 -3
  146. data/test/lib/vedeu/bindings_test.rb +21 -0
  147. data/test/lib/vedeu/buffers/buffer_test.rb +110 -134
  148. data/test/lib/vedeu/buffers/display_buffer_test.rb +8 -0
  149. data/test/lib/vedeu/configuration/api_test.rb +5 -1
  150. data/test/lib/vedeu/configuration/configuration_test.rb +4 -6
  151. data/test/lib/vedeu/cursor/cursor_test.rb +25 -17
  152. data/test/lib/vedeu/cursor/move_test.rb +7 -7
  153. data/test/lib/vedeu/distributed/client_test.rb +1 -1
  154. data/test/lib/vedeu/distributed/subprocess_test.rb +3 -1
  155. data/test/lib/vedeu/distributed/uri_test.rb +5 -5
  156. data/test/lib/vedeu/dsl/components/geometry_test.rb +43 -0
  157. data/test/lib/vedeu/dsl/components/keymap_test.rb +1 -1
  158. data/test/lib/vedeu/dsl/composition_test.rb +6 -5
  159. data/test/lib/vedeu/dsl/interface_test.rb +81 -16
  160. data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -4
  161. data/test/lib/vedeu/dsl/shared/text_test.rb +87 -9
  162. data/test/lib/vedeu/dsl/stream_test.rb +1 -1
  163. data/test/lib/vedeu/events/event_test.rb +3 -1
  164. data/test/lib/vedeu/events/trigger_test.rb +8 -4
  165. data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
  166. data/test/lib/vedeu/geometry/geometry_test.rb +5 -3
  167. data/test/lib/vedeu/geometry/index_position_test.rb +30 -7
  168. data/test/lib/vedeu/geometry/null_geometry_test.rb +57 -0
  169. data/test/lib/vedeu/geometry/position_index_test.rb +14 -0
  170. data/test/lib/vedeu/geometry/position_validator_test.rb +17 -3
  171. data/test/lib/vedeu/input/keymap_test.rb +3 -1
  172. data/test/lib/vedeu/input/mapper_test.rb +8 -4
  173. data/test/lib/vedeu/launcher_test.rb +1 -1
  174. data/test/lib/vedeu/models/cell_test.rb +10 -8
  175. data/test/lib/vedeu/models/char_test.rb +52 -28
  176. data/test/lib/vedeu/models/composition_test.rb +26 -4
  177. data/test/lib/vedeu/models/group_test.rb +11 -5
  178. data/test/lib/vedeu/models/interface_test.rb +32 -19
  179. data/test/lib/vedeu/models/line_test.rb +21 -25
  180. data/test/lib/vedeu/models/menu_test.rb +10 -6
  181. data/test/lib/vedeu/models/null_test.rb +66 -0
  182. data/test/lib/vedeu/models/stream_test.rb +13 -10
  183. data/test/lib/vedeu/output/border_test.rb +29 -8
  184. data/test/lib/vedeu/output/clear_test.rb +23 -4
  185. data/test/lib/vedeu/output/colour_test.rb +20 -4
  186. data/test/lib/vedeu/output/compressor_test.rb +43 -0
  187. data/test/lib/vedeu/output/html_char_test.rb +29 -17
  188. data/test/lib/vedeu/output/null_border_test.rb +2 -1
  189. data/test/lib/vedeu/output/output_test.rb +20 -30
  190. data/test/lib/vedeu/output/presentation_test.rb +39 -16
  191. data/test/lib/vedeu/output/refresh_test.rb +14 -10
  192. data/test/lib/vedeu/output/renderers/all_test.rb +96 -0
  193. data/test/lib/vedeu/output/renderers/file_renderer_test.rb +1 -1
  194. data/test/lib/vedeu/output/renderers/html_renderer_test.rb +13 -9
  195. data/test/lib/vedeu/output/renderers/json_renderer_test.rb +52 -0
  196. data/test/lib/vedeu/output/renderers/null_renderer_test.rb +19 -0
  197. data/test/lib/vedeu/output/style_test.rb +41 -1
  198. data/test/lib/vedeu/output/text_test.rb +61 -10
  199. data/test/lib/vedeu/output/translator_test.rb +14 -0
  200. data/test/lib/vedeu/output/viewport_test.rb +22 -3
  201. data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
  202. data/test/lib/vedeu/output/wordwrap_test.rb +58 -45
  203. data/test/lib/vedeu/repositories/collections/chars_test.rb +16 -0
  204. data/test/lib/vedeu/repositories/collections/events_test.rb +16 -0
  205. data/test/lib/vedeu/repositories/collections/interfaces_test.rb +16 -0
  206. data/test/lib/vedeu/repositories/collections/keys_test.rb +16 -0
  207. data/test/lib/vedeu/repositories/collections/lines_test.rb +16 -0
  208. data/test/lib/vedeu/repositories/collections/streams_test.rb +16 -0
  209. data/test/lib/vedeu/repositories/repositories/background_colours_test.rb +17 -0
  210. data/test/lib/vedeu/repositories/repositories/borders_test.rb +51 -0
  211. data/test/lib/vedeu/repositories/repositories/buffers_test.rb +52 -0
  212. data/test/lib/vedeu/repositories/repositories/colours_test.rb +16 -0
  213. data/test/lib/vedeu/repositories/repositories/cursors_test.rb +39 -0
  214. data/test/lib/vedeu/repositories/repositories/events_repository_test.rb +17 -0
  215. data/test/lib/vedeu/repositories/repositories/foreground_colours_test.rb +17 -0
  216. data/test/lib/vedeu/repositories/repositories/geometries_test.rb +42 -0
  217. data/test/lib/vedeu/repositories/repositories/groups_test.rb +17 -0
  218. data/test/lib/vedeu/repositories/repositories/interfaces_repositories_test.rb +17 -0
  219. data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +17 -0
  220. data/test/lib/vedeu/repositories/repositories/menus_test.rb +17 -0
  221. data/test/lib/vedeu/repositories/repository_test.rb +16 -36
  222. data/test/lib/vedeu/storage/associative_store_test.rb +69 -0
  223. data/test/lib/vedeu/storage/conveyor_store_test.rb +135 -0
  224. data/test/lib/vedeu/storage/fifo_store_test.rb +47 -0
  225. data/test/lib/vedeu/storage/store_test.rb +123 -0
  226. data/test/lib/vedeu/support/common_test.rb +0 -9
  227. data/test/lib/vedeu/support/terminal_test.rb +78 -55
  228. data/test/lib/vedeu/support/visibility_test.rb +80 -0
  229. data/test/test_helper.rb +13 -11
  230. data/vedeu.gemspec +4 -3
  231. metadata +92 -32
  232. data/lib/vedeu/cursor/toggle.rb +0 -55
  233. data/lib/vedeu/exceptions.rb +0 -37
  234. data/lib/vedeu/geometry/centre.rb +0 -85
  235. data/lib/vedeu/geometry/content.rb +0 -70
  236. data/lib/vedeu/geometry/limit.rb +0 -58
  237. data/lib/vedeu/output/compositor.rb +0 -62
  238. data/lib/vedeu/repositories/collections.rb +0 -41
  239. data/lib/vedeu/support/coercions.rb +0 -60
  240. data/lib/vedeu/support/sentence.rb +0 -91
  241. data/lib/vedeu/support/visible.rb +0 -90
  242. data/test/lib/vedeu/cursor/toggle_test.rb +0 -63
  243. data/test/lib/vedeu/geometry/centre_test.rb +0 -58
  244. data/test/lib/vedeu/geometry/content_test.rb +0 -98
  245. data/test/lib/vedeu/geometry/limit_test.rb +0 -30
  246. data/test/lib/vedeu/output/compositor_test.rb +0 -48
  247. data/test/lib/vedeu/repositories/all_test.rb +0 -135
  248. data/test/lib/vedeu/repositories/collections_test.rb +0 -71
  249. data/test/lib/vedeu/support/coercions_test.rb +0 -84
  250. data/test/lib/vedeu/support/sentence_test.rb +0 -56
  251. data/test/lib/vedeu/support/visible_test.rb +0 -161
@@ -17,13 +17,53 @@ module Vedeu
17
17
  it { instance.instance_variable_get('@value').must_equal('bold') }
18
18
  end
19
19
 
20
+ describe '.coerce' do
21
+ let(:value) { 'bold' }
22
+
23
+ subject { described.coerce(value) }
24
+
25
+ it { subject.must_be_instance_of(described) }
26
+
27
+ context 'when the value is nil' do
28
+ let(:value) { nil }
29
+
30
+ it { subject.must_be_instance_of(described) }
31
+ end
32
+
33
+ context 'when the value is a Style already' do
34
+ let(:value) { Vedeu::Style.new('bold') }
35
+
36
+ it { subject.must_equal(value) }
37
+ end
38
+
39
+ context 'when the value is an Array' do
40
+ let(:value) { [:bold, :blink] }
41
+
42
+ it { subject.value.must_equal([:bold, :blink]) }
43
+ end
44
+ end
45
+
20
46
  describe '#attributes' do
21
47
  subject { instance.attributes }
22
48
 
23
49
  it { subject.must_be_instance_of(Hash) }
24
50
 
25
51
  it 'returns an attributes hash for this instance' do
26
- subject.must_equal({ style: 'bold' })
52
+ subject.must_equal(style: 'bold')
53
+ end
54
+ end
55
+
56
+ describe '#eql?' do
57
+ let(:other) { instance }
58
+
59
+ subject { instance.eql?(other) }
60
+
61
+ it { subject.must_equal(true) }
62
+
63
+ context 'when different to other' do
64
+ let(:other) { described.new('underline') }
65
+
66
+ it { subject.must_equal(false) }
27
67
  end
28
68
  end
29
69
 
@@ -4,25 +4,32 @@ module Vedeu
4
4
 
5
5
  describe Text do
6
6
 
7
- let(:value) { 'Testing the Text class with various options' }
8
- let(:options) {
7
+ let(:described) { Vedeu::Text }
8
+ let(:value) { 'Testing the Text class with various options' }
9
+ let(:options) {
9
10
  {
10
11
  anchor: anchor,
12
+ colour: colour,
13
+ model: model,
11
14
  pad: pad,
12
15
  width: width,
13
16
  }
14
17
  }
15
18
  let(:anchor) { :left }
19
+ let(:colour) { nil }
20
+ let(:model) { nil }
16
21
  let(:pad) { ' ' }
17
22
  let(:width) { nil }
18
23
 
19
24
  describe '.with' do
25
+ subject { described.with(value, options) }
26
+
20
27
  context 'when a width is provided' do
21
28
  context 'when value longer than the width' do
22
29
  let(:width) { 23 }
23
30
 
24
31
  it 'returns the value truncated' do
25
- Text.with(value, options).must_equal('Testing the Text class ')
32
+ subject.must_equal('Testing the Text class ')
26
33
  end
27
34
  end
28
35
 
@@ -31,14 +38,14 @@ module Vedeu
31
38
 
32
39
  context 'and an anchor is not set' do
33
40
  it 'returns the value left aligned' do
34
- Text.with(value, options)
41
+ subject
35
42
  .must_equal('Testing the Text class with various options ')
36
43
  end
37
44
  end
38
45
 
39
46
  context 'and the anchor is set to :left' do
40
47
  it 'returns the value left aligned' do
41
- Text.with(value, options)
48
+ subject
42
49
  .must_equal('Testing the Text class with various options ')
43
50
  end
44
51
  end
@@ -47,7 +54,7 @@ module Vedeu
47
54
  let(:anchor) { :align }
48
55
 
49
56
  it 'returns the value left aligned' do
50
- Text.with(value, options)
57
+ subject
51
58
  .must_equal('Testing the Text class with various options ')
52
59
  end
53
60
  end
@@ -56,7 +63,7 @@ module Vedeu
56
63
  let(:anchor) { :centre }
57
64
 
58
65
  it 'returns the value centre aligned' do
59
- Text.with(value, options)
66
+ subject
60
67
  .must_equal(' Testing the Text class with various options ')
61
68
  end
62
69
  end
@@ -65,7 +72,7 @@ module Vedeu
65
72
  let(:anchor) { :right }
66
73
 
67
74
  it 'returns the value right aligned' do
68
- Text.with(value, options)
75
+ subject
69
76
  .must_equal(' Testing the Text class with various options')
70
77
  end
71
78
  end
@@ -74,7 +81,7 @@ module Vedeu
74
81
  let(:anchor) { :invalid }
75
82
 
76
83
  it 'returns the value left aligned' do
77
- Text.with(value, options)
84
+ subject
78
85
  .must_equal('Testing the Text class with various options ')
79
86
  end
80
87
  end
@@ -82,12 +89,56 @@ module Vedeu
82
89
  end
83
90
 
84
91
  context 'when a width is not provided' do
92
+ let(:width) {}
93
+ let(:value) { 'some value' }
94
+
85
95
  it 'returns the value as a string' do
86
- Text.with(:some_value).must_equal('some_value')
96
+ subject.must_equal('some value')
87
97
  end
88
98
  end
89
99
  end
90
100
 
101
+ describe '.add' do
102
+ subject { described.add(value, options) }
103
+
104
+ context 'when the model is a Vedeu::Interface' do
105
+ let(:model) { Vedeu::Interface.new }
106
+
107
+ it { subject.must_be_instance_of(Vedeu::Lines) }
108
+ end
109
+
110
+ context 'when the model is a Vedeu::Line' do
111
+ let(:model) { Vedeu::Line.new }
112
+
113
+ it { subject.must_be_instance_of(Vedeu::Streams) }
114
+ end
115
+
116
+ context 'when the model is a Vedeu::Stream' do
117
+ let(:parent) { Vedeu::Line.new }
118
+ let(:model) { Vedeu::Stream.new(parent: parent) }
119
+
120
+ it { subject.must_be_instance_of(Vedeu::Streams) }
121
+ end
122
+
123
+ context 'when the model is not given' do
124
+ let(:model) {}
125
+
126
+ it { subject.must_be_instance_of(NilClass) }
127
+ end
128
+
129
+ context 'when the colour option is given' do
130
+ let(:colour) {}
131
+ end
132
+
133
+ context 'when the background and/or foreground options are given' do
134
+ let(:background) { '#111111' }
135
+ let(:foreground) { '#aadd00' }
136
+
137
+
138
+ end
139
+
140
+ end
141
+
91
142
  end # Text
92
143
 
93
144
  end # Vedeu
@@ -17,6 +17,20 @@ module Vedeu
17
17
  it { instance.instance_variable_get('@colour').must_equal(colour) }
18
18
  end
19
19
 
20
+ describe '#eql?' do
21
+ let(:other) { instance }
22
+
23
+ subject { instance.eql?(other) }
24
+
25
+ it { subject.must_equal(true) }
26
+
27
+ context 'when different to other' do
28
+ let(:other) { described.new('#ff00ff') }
29
+
30
+ it { subject.must_equal(false) }
31
+ end
32
+ end
33
+
20
34
  describe '#escape_sequence' do
21
35
  subject { instance.escape_sequence }
22
36
 
@@ -20,18 +20,36 @@ module Vedeu
20
20
  line 'nickel'
21
21
  line 'osmium'
22
22
  end
23
+ visible(visibility)
23
24
  end
24
25
  }
26
+ let(:visibility) { true }
25
27
 
26
28
  describe '#initialize' do
27
29
  it { instance.must_be_instance_of(Viewport) }
28
30
  it { instance.instance_variable_get('@interface').must_equal(interface) }
29
31
  end
30
32
 
33
+ describe '.render' do
34
+ subject { described.render(interface) }
35
+
36
+ context 'when the interface is visible' do
37
+
38
+ end
39
+
40
+ context 'when the interface is not visible' do
41
+ let(:visibility) { false }
42
+
43
+ it { subject.must_be_instance_of(Array) }
44
+
45
+ it { subject.must_equal([]) }
46
+ end
47
+ end
48
+
31
49
  describe '#render' do
32
50
  let(:cursor) { Cursor.new(cursor_attributes) }
33
51
  let(:cursor_attributes) {
34
- { name: 'lithium', ox: ox, oy: oy, state: true, x: x, y: y }
52
+ { name: 'lithium', ox: ox, oy: oy, visible: true, x: x, y: y }
35
53
  }
36
54
  let(:lines) { [] }
37
55
  let(:ox) { 0 }
@@ -57,7 +75,7 @@ module Vedeu
57
75
  # describe '#to_s' do
58
76
  # let(:cursor) { Cursor.new(cursor_attributes) }
59
77
  # let(:cursor_attributes) {
60
- # { name: 'lithium', ox: ox, oy: oy, state: true, x: x, y: y }
78
+ # { name: 'lithium', ox: ox, oy: oy, visible: true, x: x, y: y }
61
79
  # }
62
80
  # let(:lines) { [] }
63
81
  # let(:ox) { 0 }
@@ -80,7 +98,8 @@ module Vedeu
80
98
  # end
81
99
 
82
100
  # context 'when there is content' do
83
- # context "when the cursor's y position is outside the viewable area - negative" do
101
+ # context "when the cursor's y position is outside the viewable " \
102
+ # "area - negative" do
84
103
  # let(:ox) { -4 }
85
104
  # let(:oy) { -4 }
86
105
 
@@ -16,7 +16,7 @@ module Vedeu
16
16
  it { instance.must_be_instance_of(Vedeu::VirtualTerminal) }
17
17
  it { instance.instance_variable_get('@height').must_equal(3) }
18
18
  it { instance.instance_variable_get('@width').must_equal(3) }
19
- it { instance.instance_variable_get('@renderer').must_equal(Vedeu::HTMLRenderer) }
19
+ it { instance.instance_variable_get('@renderer').must_equal(renderer) }
20
20
  end
21
21
 
22
22
  describe 'attr_accessor' do
@@ -26,7 +26,7 @@ module Vedeu
26
26
  it { subject.must_equal(Vedeu::HTMLRenderer) }
27
27
  end
28
28
  context '#renderer=' do
29
- subject { instance.renderer=(Vedeu::FakeRenderer) }
29
+ subject { instance.renderer = (Vedeu::FakeRenderer) }
30
30
 
31
31
  it { subject.must_equal(Vedeu::FakeRenderer) }
32
32
  end
@@ -103,7 +103,7 @@ module Vedeu
103
103
  end
104
104
 
105
105
  describe '#write' do
106
- let(:data) { Vedeu::Char.new({ value: 'a' }) }
106
+ let(:data) { Vedeu::Char.new(value: 'a') }
107
107
 
108
108
  subject { instance.write(y, x, data) }
109
109
 
@@ -22,8 +22,8 @@ module Vedeu
22
22
  }
23
23
  let(:text_block) {
24
24
  "Krypton (from Greek: κρυπτός kryptos 'the hidden one') is a chemical " \
25
- "element with symbol Kr and atomic number 36. It is a member of group " \
26
- "18 (noble gases) elements."
25
+ 'element with symbol Kr and atomic number 36. It is a member of group ' \
26
+ '18 (noble gases) elements.'
27
27
  }
28
28
  let(:text_newlines) {
29
29
  "Krypton is a colorless, odorless, tasteless noble gas.\n" \
@@ -35,14 +35,27 @@ module Vedeu
35
35
  "Krypton (from Greek: κρυπτός kryptos 'the hidden one').\n\n" \
36
36
  "It is a chemical element with symbol Kr and atomic number 36.\n" \
37
37
  "It is a member of group 18 (noble gases) elements.\n\n" \
38
- "-- Wikipedia"
38
+ '-- Wikipedia'
39
39
  }
40
40
  let(:text_line_objects) {
41
41
  [
42
- Vedeu::Line.new({ streams: [Vedeu::Stream.new({ value: "Krypton is a colorless, odorless, tasteless noble gas." })] }),
43
- Vedeu::Line.new({ streams: [Vedeu::Stream.new({ value: "It occurs in trace amounts in the atmosphere." })] }),
44
- Vedeu::Line.new({ streams: [Vedeu::Stream.new({ value: "It is isolated by fractionally distilling liquefied air." })] }),
45
- Vedeu::Line.new({ streams: [Vedeu::Stream.new({ value: "Krypton is often used with other rare gases in fluorescent lamps." })] })
42
+ Vedeu::Line.new(streams: [
43
+ Vedeu::Stream.new(
44
+ value: 'Krypton is a colorless, odorless, tasteless noble gas.'
45
+ )]),
46
+ Vedeu::Line.new(streams: [
47
+ Vedeu::Stream.new(
48
+ value: 'It occurs in trace amounts in the atmosphere.'
49
+ )]),
50
+ Vedeu::Line.new(streams: [
51
+ Vedeu::Stream.new(
52
+ value: 'It is isolated by fractionally distilling liquefied air.'
53
+ )]),
54
+ Vedeu::Line.new(streams: [
55
+ Vedeu::Stream.new(
56
+ value: 'Krypton is often used with other rare gases in ' \
57
+ 'fluorescent lamps.'
58
+ )])
46
59
  ]
47
60
  }
48
61
 
@@ -69,23 +82,23 @@ module Vedeu
69
82
 
70
83
  context 'when the text is > the pruning width' do
71
84
  context 'with a single line of text' do
72
- it { subject.must_equal("Krypton (from Greek: κρυπτός...") }
85
+ it { subject.must_equal('Krypton (from Greek: κρυπτός...') }
73
86
  end
74
87
 
75
88
  context 'with a text block' do
76
89
  let(:text) { text_block }
77
90
 
78
- it { subject.must_equal("Krypton (from Greek: κρυπτός...") }
91
+ it { subject.must_equal('Krypton (from Greek: κρυπτός...') }
79
92
  end
80
93
 
81
94
  context 'with a text block containing newlines' do
82
95
  let(:text) { text_newlines }
83
96
 
84
97
  it { subject.must_equal([
85
- "Krypton is a colorless, odor...",
86
- "It occurs in trace amounts i...",
87
- "It is isolated by fractional...",
88
- "Krypton is often used with o..."
98
+ 'Krypton is a colorless, odor...',
99
+ 'It occurs in trace amounts i...',
100
+ 'It is isolated by fractional...',
101
+ 'Krypton is often used with o...'
89
102
  ])
90
103
  }
91
104
  end
@@ -94,12 +107,12 @@ module Vedeu
94
107
  let(:text) { text_blanklines }
95
108
 
96
109
  it { subject.must_equal([
97
- "Krypton (from Greek: κρυπτός...",
98
- "",
99
- "It is a chemical element wit...",
100
- "It is a member of group 18 (...",
101
- "",
102
- "-- Wikipedia..."
110
+ 'Krypton (from Greek: κρυπτός...',
111
+ '',
112
+ 'It is a chemical element wit...',
113
+ 'It is a member of group 18 (...',
114
+ '',
115
+ '-- Wikipedia...'
103
116
  ])
104
117
  }
105
118
  end
@@ -113,7 +126,7 @@ module Vedeu
113
126
  let(:text) { text_line }
114
127
 
115
128
  it { subject.must_equal([
116
- "Krypton (from Greek: κρυπτός",
129
+ 'Krypton (from Greek: κρυπτός',
117
130
  "kryptos 'the hidden one')."
118
131
  ])
119
132
  }
@@ -123,12 +136,12 @@ module Vedeu
123
136
  let(:text) { text_block }
124
137
 
125
138
  it { subject.must_equal([
126
- "Krypton (from Greek: κρυπτός",
139
+ 'Krypton (from Greek: κρυπτός',
127
140
  "kryptos 'the hidden one') is",
128
- "a chemical element with",
129
- "symbol Kr and atomic number",
130
- "36. It is a member of group",
131
- "18 (noble gases) elements."
141
+ 'a chemical element with',
142
+ 'symbol Kr and atomic number',
143
+ '36. It is a member of group',
144
+ '18 (noble gases) elements.'
132
145
  ])
133
146
  }
134
147
  end
@@ -137,17 +150,17 @@ module Vedeu
137
150
  let(:text) { text_newlines }
138
151
 
139
152
  it { subject.must_equal([
140
- "Krypton is a colorless,",
141
- "odorless, tasteless noble",
142
- "gas.",
143
- "It occurs in trace amounts",
144
- "in the atmosphere.",
145
- "It is isolated by",
146
- "fractionally distilling",
147
- "liquefied air.",
148
- "Krypton is often used with",
149
- "other rare gases in",
150
- "fluorescent lamps."
153
+ 'Krypton is a colorless,',
154
+ 'odorless, tasteless noble',
155
+ 'gas.',
156
+ 'It occurs in trace amounts',
157
+ 'in the atmosphere.',
158
+ 'It is isolated by',
159
+ 'fractionally distilling',
160
+ 'liquefied air.',
161
+ 'Krypton is often used with',
162
+ 'other rare gases in',
163
+ 'fluorescent lamps.'
151
164
  ])
152
165
  }
153
166
  end
@@ -156,16 +169,16 @@ module Vedeu
156
169
  let(:text) { text_blanklines }
157
170
 
158
171
  it { subject.must_equal([
159
- "Krypton (from Greek: κρυπτός",
172
+ 'Krypton (from Greek: κρυπτός',
160
173
  "kryptos 'the hidden one').",
161
- "",
162
- "It is a chemical element",
163
- "with symbol Kr and atomic",
164
- "number 36.",
165
- "It is a member of group 18",
166
- "(noble gases) elements.",
167
- "",
168
- "-- Wikipedia"
174
+ '',
175
+ 'It is a chemical element',
176
+ 'with symbol Kr and atomic',
177
+ 'number 36.',
178
+ 'It is a member of group 18',
179
+ '(noble gases) elements.',
180
+ '',
181
+ '-- Wikipedia'
169
182
  ])
170
183
  }
171
184
  end
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Chars do
6
+
7
+ let(:described) { Vedeu::Chars }
8
+ let(:instance) { described.new }
9
+
10
+ describe '#initialize' do
11
+ it { instance.must_be_instance_of(Vedeu::Chars) }
12
+ end
13
+
14
+ end # Chars
15
+
16
+ end # Vedeu
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Events do
6
+
7
+ let(:described) { Vedeu::Events }
8
+ let(:instance) { described.new }
9
+
10
+ describe '#initialize' do
11
+ it { instance.must_be_instance_of(Vedeu::Events) }
12
+ end
13
+
14
+ end # Events
15
+
16
+ end # Vedeu
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Interfaces do
6
+
7
+ let(:described) { Vedeu::Interfaces }
8
+ let(:instance) { described.new }
9
+
10
+ describe '#initialize' do
11
+ it { instance.must_be_instance_of(Vedeu::Interfaces) }
12
+ end
13
+
14
+ end # Interfaces
15
+
16
+ end # Vedeu
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Keys do
6
+
7
+ let(:described) { Vedeu::Keys }
8
+ let(:instance) { described.new }
9
+
10
+ describe '#initialize' do
11
+ it { instance.must_be_instance_of(Vedeu::Keys) }
12
+ end
13
+
14
+ end # Keys
15
+
16
+ end # Vedeu
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Lines do
6
+
7
+ let(:described) { Vedeu::Lines }
8
+ let(:instance) { described.new }
9
+
10
+ describe '#initialize' do
11
+ it { instance.must_be_instance_of(Vedeu::Lines) }
12
+ end
13
+
14
+ end # Lines
15
+
16
+ end # Vedeu
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Streams do
6
+
7
+ let(:described) { Vedeu::Streams }
8
+ let(:instance) { described.new }
9
+
10
+ describe '#initialize' do
11
+ it { instance.must_be_instance_of(Vedeu::Streams) }
12
+ end
13
+
14
+ end # Streams
15
+
16
+ end # Vedeu
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe BackgroundColours do
6
+
7
+ let(:described) { Vedeu::BackgroundColours }
8
+
9
+ describe '.background_colours' do
10
+ subject { described.background_colours }
11
+
12
+ it { subject.must_be_instance_of(described) }
13
+ end
14
+
15
+ end # BackgroundColours
16
+
17
+ end # Vedeu
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Borders do
6
+
7
+ let(:described) { Vedeu::Borders }
8
+
9
+ describe '.borders' do
10
+ subject { described.borders }
11
+
12
+ it { subject.must_be_instance_of(described) }
13
+ end
14
+
15
+ describe '#by_name' do
16
+ let(:_name) { 'carbon' }
17
+
18
+ subject { described.borders.by_name(_name) }
19
+
20
+ context 'when the border exists' do
21
+ before do
22
+ Vedeu.border 'carbon' do
23
+ end
24
+ end
25
+ after { Vedeu.borders.reset }
26
+
27
+ it { subject.must_be_instance_of(Vedeu::Border) }
28
+ end
29
+
30
+ context 'when the border does not exist' do
31
+ let(:_name) { 'nitrogen' }
32
+
33
+ context 'and an interface with this name exists' do
34
+ before do
35
+ Vedeu.interface 'nitrogen' do
36
+ end
37
+ end
38
+ after { Vedeu.interfaces.reset }
39
+
40
+ it { subject.must_be_instance_of(Vedeu::NullBorder) }
41
+ end
42
+
43
+ context 'and an interface with this name does not exist' do
44
+ it { subject.must_be_instance_of(NilClass) }
45
+ end
46
+ end
47
+ end
48
+
49
+ end # Borders
50
+
51
+ end # Vedeu