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
@@ -1,41 +0,0 @@
1
- require 'vedeu/repositories/collection'
2
-
3
- module Vedeu
4
-
5
- # A collection of {Vedeu::Char} instances.
6
- #
7
- class Chars < Vedeu::Collection
8
-
9
- end # Chars
10
-
11
- # A collection of {Vedeu::Event} instances.
12
- #
13
- class Events < Vedeu::Collection
14
-
15
- end # Events
16
-
17
- # A collection of {Vedeu::Interface} instances.
18
- #
19
- class Interfaces < Vedeu::Collection
20
-
21
- end # Interfaces
22
-
23
- # A collection of {Vedeu::Key} instances.
24
- #
25
- class Keys < Vedeu::Collection
26
-
27
- end # Keys
28
-
29
- # A collection of {Vedeu::Line} instances.
30
- #
31
- class Lines < Vedeu::Collection
32
-
33
- end # Lines
34
-
35
- # A collection of {Vedeu::Stream} instances.
36
- #
37
- class Streams < Vedeu::Collection
38
-
39
- end # Streams
40
-
41
- end # Vedeu
@@ -1,60 +0,0 @@
1
- require 'vedeu/support/common'
2
-
3
- module Vedeu
4
-
5
- # Provides means to convert attributes into the correct model.
6
- #
7
- module Coercions
8
-
9
- include Vedeu::Common
10
-
11
- # Produces new objects of the correct class from the value, ignores objects
12
- # that have already been coerced.
13
- #
14
- # @param value [Object|NilClass]
15
- # @return [Object]
16
- def coerce(value)
17
- if value.nil?
18
- new
19
-
20
- elsif value.is_a?(self)
21
- value
22
-
23
- else
24
- new(value)
25
-
26
- end
27
- end
28
-
29
- # Produces new objects of the correct class from attributes hashes,
30
- # ignores objects that have already been coerced.
31
- #
32
- # @param values [Array|Hash]
33
- # @return [Array]
34
- def coercer(values)
35
- return [] unless defined_value?(values)
36
-
37
- [values].flatten.map do |value|
38
- if value.is_a?(self)
39
- value
40
-
41
- else
42
- new(value)
43
-
44
- end
45
- end
46
- end
47
-
48
- # Whenever this module {Vedeu::Coercions} is included in another class or
49
- # module, make its methods into class methods, so they may be called
50
- # directly.
51
- #
52
- # @param receiver [Class] The class in which this module is included.
53
- # @return [void]
54
- def self.included(receiver)
55
- receiver.extend(self)
56
- end
57
-
58
- end # Coercions
59
-
60
- end # Vedeu
@@ -1,91 +0,0 @@
1
- module Vedeu
2
-
3
- # Take a collection of words (elements) and form a sentence from them.
4
- #
5
- # @example
6
- # elements = ['Hydrogen', 'Helium', 'Lithium']
7
- # Vedeu::Sentence.construct(elements) # => 'Hydrogen, Helium and Lithium'
8
- #
9
- class Sentence
10
-
11
- # @param elements [Array]
12
- # @param label [String]
13
- # @return [String]
14
- def self.construct(elements, label = 'elements')
15
- new(elements, label).construct
16
- end
17
-
18
- # Returns a new instance of Vedeu::Sentence.
19
- #
20
- # @param elements [Array]
21
- # @param label [String]
22
- # @return [Vedeu::Sentence]
23
- def initialize(elements, label)
24
- @elements, @label = elements, label
25
- end
26
-
27
- # @return [String]
28
- def construct
29
- if one?
30
- first
31
-
32
- elsif two?
33
- elements.join(' and ')
34
-
35
- elsif many?
36
- [but_last, last].join(' and ')
37
-
38
- else
39
- "No #{label} have been assigned."
40
-
41
- end
42
- end
43
-
44
- private
45
-
46
- # @!attribute [r] elements
47
- # @return [Array]
48
- attr_reader :elements
49
-
50
- # @!attribute [r] label
51
- # @return [String]
52
- attr_reader :label
53
-
54
- # @return [Boolean]
55
- def one?
56
- count == 1
57
- end
58
-
59
- # @return [Boolean]
60
- def two?
61
- count == 2
62
- end
63
-
64
- # @return [Boolean]
65
- def many?
66
- count > 2
67
- end
68
-
69
- # @return [String]
70
- def but_last
71
- elements[0...-1].join(', ')
72
- end
73
-
74
- # @return [String]
75
- def first
76
- elements.first
77
- end
78
-
79
- # @return [String]
80
- def last
81
- elements[-1]
82
- end
83
-
84
- # @return [Fixnum]
85
- def count
86
- elements.size
87
- end
88
-
89
- end # Sentence
90
-
91
- end # Vedeu
@@ -1,90 +0,0 @@
1
- require 'vedeu/output/esc'
2
-
3
- module Vedeu
4
-
5
- # Represents the concept of a visible or invisible attribute.
6
- #
7
- class Visible
8
-
9
- # @param value [Boolean|Symbol]
10
- # @return [Visible]
11
- def self.coerce(value)
12
- if value.is_a?(self)
13
- value
14
-
15
- else
16
- new(value)
17
-
18
- end
19
- end
20
-
21
- # Returns a new instance of Vedeu::Visible
22
- #
23
- # @param visible [Boolean|Symbol]
24
- # @return [Visible]
25
- def initialize(visible = nil)
26
- @visible = visible
27
- end
28
-
29
- # @return [String]
30
- def to_s
31
- visible? ? 'visible' : 'invisible'
32
- end
33
-
34
- # @return [String]
35
- def cursor
36
- if visible?
37
- Vedeu::Esc.string('show_cursor')
38
-
39
- else
40
- Vedeu::Esc.string('hide_cursor')
41
-
42
- end
43
- end
44
-
45
- # Returns a boolean indicating whether the instance is visible.
46
- #
47
- # @return [Boolean]
48
- def visible?
49
- visible
50
- end
51
-
52
- # Returns a boolean indicating whether the instance is invisible.
53
- #
54
- # @return [Boolean]
55
- def invisible?
56
- !visible
57
- end
58
-
59
- # @return [Visible]
60
- def hide
61
- Vedeu::Visible.new(false)
62
- end
63
-
64
- # @return [Visible]
65
- def show
66
- Vedeu::Visible.new(true)
67
- end
68
-
69
- # @return [Visible]
70
- def toggle
71
- visible? ? hide : show
72
- end
73
-
74
- # @return [Boolean]
75
- def visible
76
- if @visible == :hide || @visible == false
77
- false
78
-
79
- elsif @visible == :show || @visible == true
80
- true
81
-
82
- else
83
- !!@visible
84
-
85
- end
86
- end
87
-
88
- end # Visible
89
-
90
- end # Vedeu
@@ -1,63 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Toggle do
6
-
7
- let(:described) { Toggle.new(cursor) }
8
- let(:cursor) { Cursor.new({ name: 'vanadium',
9
- ox: 1,
10
- oy: 1,
11
- state: state,
12
- x: 1,
13
- y: 1 }) }
14
- let(:state) { true }
15
-
16
- describe '#initialize' do
17
- it { described.must_be_instance_of(Toggle) }
18
- it { described.instance_variable_get('@cursor').must_equal(cursor) }
19
- end
20
-
21
- describe '.hide' do
22
- subject { Toggle.hide(cursor) }
23
-
24
- it { subject.must_be_instance_of(Cursor) }
25
-
26
- context 'when the cursor is visible' do
27
- it 'returns a new cursor' do
28
- subject.wont_equal(cursor)
29
- end
30
- end
31
-
32
- context 'when the cursor is invisible' do
33
- let(:state) { false }
34
-
35
- it 'returns the cursor' do
36
- subject.must_equal(cursor)
37
- end
38
- end
39
- end
40
-
41
- describe '.show' do
42
- subject { Toggle.show(cursor) }
43
-
44
- it { subject.must_be_instance_of(Cursor) }
45
-
46
- context 'when the cursor is visible' do
47
- it 'returns the cursor' do
48
- subject.must_equal(cursor)
49
- end
50
- end
51
-
52
- context 'when the cursor is invisible' do
53
- let(:state) { false }
54
-
55
- it 'returns a new cursor' do
56
- subject.wont_equal(cursor)
57
- end
58
- end
59
- end
60
-
61
- end # Toggle
62
-
63
- end # Vedeu
@@ -1,58 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Centre do
6
-
7
- let(:described) { Vedeu::Centre }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
10
- {
11
- v: v,
12
- vn: vn,
13
- value: value,
14
- }
15
- }
16
- let(:v) { 2 }
17
- let(:vn) { 47 }
18
- let(:value) { 30 }
19
-
20
- describe '#initialize' do
21
- it { instance.must_be_instance_of(Vedeu::Centre) }
22
- it { instance.instance_variable_get('@v').must_equal(v) }
23
- it { instance.instance_variable_get('@vn').must_equal(vn) }
24
- it { instance.instance_variable_get('@value').must_equal(value) }
25
- end
26
-
27
- describe '#centre' do
28
- subject { instance.centre }
29
-
30
- it { subject.must_be_instance_of(Fixnum) }
31
-
32
- context 'when the value is given' do
33
- it { subject.must_equal(15) }
34
- end
35
-
36
- context 'when the value is not given' do
37
- let(:value) {}
38
-
39
- it { subject.must_equal(24) }
40
-
41
- context 'when either v or vn is missing' do
42
- let(:vn) {}
43
-
44
- it { proc { subject }.must_raise(InvalidSyntax) }
45
- end
46
-
47
- context 'when vn < v' do
48
- let(:vn) { 15 }
49
- let(:v) { 32 }
50
-
51
- it { proc { subject }.must_raise(InvalidSyntax) }
52
- end
53
- end
54
- end
55
-
56
- end # Centre
57
-
58
- end # Vedeu
@@ -1,98 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Content do
6
-
7
- let(:described) { Vedeu::Content }
8
- let(:instance) { described.new(interface) }
9
- let(:interface) {
10
- Vedeu.interface 'content_geometry' do
11
- geometry do
12
- height 3
13
- width 5
14
- end
15
- end
16
- }
17
- let(:lines) { [] }
18
-
19
- before do
20
- Vedeu.interfaces.reset
21
- interface.stubs(:lines).returns(lines)
22
- end
23
-
24
- describe '#initialize' do
25
- it { instance.must_be_instance_of(described) }
26
- it { instance.instance_variable_get('@interface').must_equal(interface) }
27
- end
28
-
29
- describe '#yn' do
30
- subject { instance.yn }
31
-
32
- it { subject.must_be_instance_of(Fixnum) }
33
-
34
- context 'when the interface has content' do
35
- context 'when there is more lines than height' do
36
- let(:lines) {
37
- [
38
- [:line_1],
39
- [:line_2],
40
- [:line_3],
41
- [:line_4]
42
- ]
43
- }
44
-
45
- it { subject.must_equal(4) }
46
- end
47
-
48
- context 'when there is less lines than height' do
49
- it { subject.must_equal(3) }
50
- end
51
- end
52
-
53
- context 'when the interface does not have content' do
54
- it { subject.must_equal(3) }
55
- end
56
- end
57
-
58
- describe '#xn' do
59
- subject { instance.xn }
60
-
61
- it { subject.must_be_instance_of(Fixnum) }
62
-
63
- context 'when the interface has content' do
64
- context 'when there are more characters than width' do
65
- let(:lines) {
66
- [
67
- ['S', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't', '.'],
68
- ['S', 'o', 'm', 'e'],
69
- ['S', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't', '.', '.', '.'],
70
- ['S', 'o', 'm', 'e', ' ', 't', 'e'],
71
- ]
72
- }
73
-
74
- it { subject.must_equal(12) }
75
- end
76
-
77
- context 'when there are less characters than width' do
78
- let(:lines) {
79
- [
80
- ['S', 'o', 'm', 'e'],
81
- ['S', 'o', 'm', 'e'],
82
- ['S', 'o', 'm', 'e'],
83
- ['S', 'o', 'm', 'e'],
84
- ]
85
- }
86
-
87
- it { subject.must_equal(5) }
88
- end
89
- end
90
-
91
- context 'when the interface does not have content' do
92
- it { subject.must_equal(5) }
93
- end
94
- end
95
-
96
- end # Content
97
-
98
- end # Vedeu
@@ -1,30 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Limit do
6
-
7
- let(:described) { Vedeu::Limit }
8
- let(:instance) { described.new(v, vn, max, min) }
9
- let(:v) {}
10
- let(:vn) {}
11
- let(:max) {}
12
- let(:min) { 2 }
13
-
14
- describe '#initialize' do
15
- it { instance.must_be_instance_of(Vedeu::Limit) }
16
- it { instance.instance_variable_get('@v').must_equal(v) }
17
- it { instance.instance_variable_get('@vn').must_equal(vn) }
18
- it { instance.instance_variable_get('@max').must_equal(max) }
19
- it { instance.instance_variable_get('@min').must_equal(min) }
20
-
21
- context 'when min is nil' do
22
- let(:min) {}
23
-
24
- it { instance.instance_variable_get('@min').must_equal(1) }
25
- end
26
- end
27
-
28
- end # Limit
29
-
30
- end # Vedeu
@@ -1,48 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- # TODO: Leak detected. (GL 2015-01-28)
6
-
7
- describe Compositor do
8
-
9
- let(:described) { Vedeu::Compositor }
10
- let(:instance) { described.new(_name) }
11
- let(:_name) { 'compositor' }
12
- let(:buffer) { Buffer.new(_name, interface) }
13
- let(:interface) {
14
- Vedeu.interface(_name) do
15
- border!
16
- geometry do
17
- height 5
18
- width 10
19
- end
20
- lines do
21
- line 'Some text.'
22
- end
23
- end
24
- }
25
-
26
- before do
27
- IO.console.stubs(:print)
28
-
29
- Vedeu.buffers.reset
30
- Vedeu.interfaces.reset
31
- Buffer.new(_name, interface).store
32
- end
33
-
34
- describe '#initialize' do
35
- it { instance.must_be_instance_of(described) }
36
- it { instance.instance_variable_get('@name').must_equal(_name) }
37
- end
38
-
39
- describe '.compose' do
40
- subject { described.compose(_name) }
41
-
42
- it { subject.must_be_instance_of(Array) }
43
- it { subject.first.must_be_instance_of(Vedeu::Interface) }
44
- end
45
-
46
- end # Compositor
47
-
48
- end # Vedeu
@@ -1,135 +0,0 @@
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
- end # Borders
16
-
17
- describe Buffers do
18
-
19
- let(:described) { Vedeu::Buffers }
20
-
21
- describe '.buffers' do
22
- subject { described.buffers }
23
-
24
- it { subject.must_be_instance_of(described) }
25
- end
26
-
27
- end # Buffers
28
-
29
- describe Cursors do
30
-
31
- let(:described) { Vedeu::Cursors }
32
-
33
- describe '.cursors' do
34
- subject { described.cursors }
35
-
36
- it { subject.must_be_instance_of(described) }
37
- end
38
-
39
- describe '.cursor' do
40
- subject { Vedeu.cursor }
41
-
42
- context 'when there are cursors are defined' do
43
- before do
44
- Vedeu::Focus.add('Vedeu.cursor')
45
- Vedeu::Cursor.new({ name: 'Vedeu.cursor' }).store
46
- end
47
-
48
- it { subject.must_be_instance_of(Vedeu::Cursor) }
49
- end
50
-
51
- context 'when there are no cursors defined' do
52
- before do
53
- Vedeu::Focus.reset
54
- Vedeu.cursors.reset
55
- end
56
-
57
- it { subject.must_be_instance_of(NilClass) }
58
- end
59
- end
60
-
61
- end # Cursors
62
-
63
- describe EventsRepository do
64
-
65
- let(:described) { Vedeu::EventsRepository }
66
-
67
- describe '.events' do
68
- subject { described.events }
69
-
70
- it { subject.must_be_instance_of(described) }
71
- end
72
-
73
- end # EventsRepository
74
-
75
- describe Geometries do
76
-
77
- let(:described) { Vedeu::Geometries }
78
-
79
- describe '.geometries' do
80
- subject { described.geometries }
81
-
82
- it { subject.must_be_instance_of(described) }
83
- end
84
-
85
- end # Geometries
86
-
87
- describe Groups do
88
-
89
- let(:described) { Vedeu::Groups }
90
-
91
- describe '.groups' do
92
- subject { described.groups }
93
-
94
- it { subject.must_be_instance_of(described) }
95
- end
96
-
97
- end # Groups
98
-
99
- describe InterfacesRepository do
100
-
101
- let(:described) { Vedeu::InterfacesRepository }
102
-
103
- describe '.interfaces' do
104
- subject { described.interfaces }
105
-
106
- it { subject.must_be_instance_of(described) }
107
- end
108
-
109
- end # InterfacesRepository
110
-
111
- describe Keymaps do
112
-
113
- let(:described) { Vedeu::Keymaps }
114
-
115
- describe '.keymaps' do
116
- subject { described.keymaps }
117
-
118
- it { subject.must_be_instance_of(described) }
119
- end
120
-
121
- end # Keymaps
122
-
123
- describe Menus do
124
-
125
- let(:described) { Vedeu::Menus }
126
-
127
- describe '.menus' do
128
- subject { described.menus }
129
-
130
- it { subject.must_be_instance_of(described) }
131
- end
132
-
133
- end # Menus
134
-
135
- end # Vedeu