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
@@ -15,14 +15,6 @@ module Vedeu
15
15
  false
16
16
  end
17
17
 
18
- # Returns the array as a sentence.
19
- #
20
- # @param array [Array]
21
- # @return [String]
22
- def to_sentence(array)
23
- Vedeu::Sentence.construct(array)
24
- end
25
-
26
18
  end # Common
27
19
 
28
20
  end # Vedeu
@@ -10,23 +10,13 @@ module Vedeu
10
10
  #
11
11
  # @param logdev [String|IO] The filename (String) or IO object (typically
12
12
  # STDOUT, STDERR or an open file).
13
- # @param shift_age [] Number of old log files to keep, or frequency of
14
- # rotation (daily, weekly, monthly).
15
- # @param shift_size [] Maximum log file size (only applies when shift_age
16
- # is a number).
17
13
  #
18
- # @example
19
- # Logger.new(name, shift_age = 7, shift_size = 1048576)
20
- # Logger.new(name, shift_age = 'weekly')
21
- #
22
- def initialize(logdev, shift_age=nil, shift_size=nil)
14
+ def initialize(logdev)
23
15
  @level = DEBUG
24
16
  @default_formatter = Formatter.new
25
17
  @formatter = nil
26
18
  @logdev = nil
27
- if logdev
28
- @logdev = LocklessLogDevice.new(logdev)
29
- end
19
+ @logdev = LocklessLogDevice.new(logdev) if logdev
30
20
  end
31
21
 
32
22
  # Ensures we can always write to the log file by creating a lock-less
@@ -41,8 +31,6 @@ module Vedeu
41
31
  def initialize(log = nil)
42
32
  @dev = nil
43
33
  @filename = nil
44
- @shift_age = nil
45
- @shift_size = nil
46
34
 
47
35
  if log.respond_to?(:write) && log.respond_to?(:close)
48
36
  @dev = log
@@ -60,9 +48,8 @@ module Vedeu
60
48
  def write(message)
61
49
  @dev.write(message)
62
50
 
63
- rescue Exception => ignored
64
- warn("log writing failed. #{ignored}")
65
-
51
+ rescue StandardError => exception
52
+ warn("log writing failed. #{exception}")
66
53
  end
67
54
 
68
55
  # @return []
@@ -75,7 +62,7 @@ module Vedeu
75
62
  # @param filename []
76
63
  # @return []
77
64
  def open_logfile(filename)
78
- if (FileTest.exist?(filename))
65
+ if FileTest.exist?(filename)
79
66
  open(filename, (File::WRONLY | File::APPEND))
80
67
 
81
68
  else
@@ -98,16 +85,16 @@ module Vedeu
98
85
 
99
86
  # Write a message to the Vedeu log file.
100
87
  #
88
+ # @example
89
+ # Vedeu.log(message: 'A useful debugging message: Error!')
90
+ #
101
91
  # @param message [String] The message you wish to emit to the log file,
102
92
  # useful for debugging.
103
- # @param force [Boolean] When evaluates to true will attempt to write to
93
+ # @param force [Boolean] When evaluates to true will attempt to write to
104
94
  # the log file regardless of the Configuration setting.
105
- # @param type [Symbol] Colour code messages in the log file depending
95
+ # @param type [Symbol] Colour code messages in the log file depending
106
96
  # on their source.
107
97
  #
108
- # @example
109
- # Vedeu.log(message: 'A useful debugging message: Error!')
110
- #
111
98
  # @return [TrueClass]
112
99
  def log(message:, force: false, type: :info)
113
100
  logger.debug([message_type(type), message]) if enabled? || force
@@ -141,7 +128,9 @@ module Vedeu
141
128
 
142
129
  # @return [String]
143
130
  def message_type(type)
144
- Vedeu::Esc.send(message_types.fetch(type, :default)) { "[#{type}]".ljust(9) }
131
+ Vedeu::Esc.send(message_types.fetch(type, :default)) do
132
+ "[#{type}]".ljust(9)
133
+ end
145
134
  end
146
135
 
147
136
  # @return [Hash<Symbol => Symbol>]
@@ -43,7 +43,10 @@ module Vedeu
43
43
  # @return [String]
44
44
  def path
45
45
  fail MissingRequired, 'No path to template specified.' if @path.empty?
46
- fail MissingRequired, 'Template file cannot be found.' unless File.exist?(@path)
46
+
47
+ unless File.exist?(@path)
48
+ fail MissingRequired, 'Template file cannot be found.'
49
+ end
47
50
 
48
51
  @path
49
52
  end
@@ -33,7 +33,6 @@ module Vedeu
33
33
  end
34
34
  ensure
35
35
  restore_screen
36
-
37
36
  end
38
37
 
39
38
  # Takes input from the user via the keyboard. Accepts special keys like
@@ -42,17 +41,18 @@ module Vedeu
42
41
  # @return [String]
43
42
  def input
44
43
  keys_or_cmd = if raw_mode?
45
- keys = console.getch
46
- if keys.ord == 27
47
- keys << console.read_nonblock(3) rescue nil
48
- keys << console.read_nonblock(2) rescue nil
49
- end
50
- keys
44
+ keys = console.getch
51
45
 
52
- else
53
- console.gets.chomp
46
+ if keys.ord == 27
47
+ keys << console.read_nonblock(3) rescue nil
48
+ keys << console.read_nonblock(2) rescue nil
49
+ end
50
+ keys
54
51
 
55
- end
52
+ else
53
+ console.gets.chomp
54
+
55
+ end
56
56
 
57
57
  Vedeu.trigger(:tick, Time.now.to_f)
58
58
 
@@ -18,7 +18,9 @@ module Vedeu
18
18
  # def self.trace
19
19
  # trace = TracePoint.new(:call) do |tp|
20
20
  # if tp.defined_class.to_s.match(/Troo/)
21
- # Vedeu.log(type: :debug, message: [tp.defined_class.to_s, tp.method_id.to_s].join(' '))
21
+ # Vedeu.log(type: :debug,
22
+ # message: [tp.defined_class.to_s,
23
+ # tp.method_id.to_s].join(' '))
22
24
  # end
23
25
  # end
24
26
  # trace.enable
@@ -50,17 +52,15 @@ module Vedeu
50
52
  #
51
53
  # @return [NilClass|String]
52
54
  def trace
53
- set_trace_func proc { |event, _file, _line, id, binding, classname|
54
- if event == watched && id != :log && classes.include?(classname.to_s)
55
+ set_trace_func proc { |event, _file, _line, id, binding, name|
56
+ if event == watched && id != :log && classes.include?(name.to_s)
55
57
  vars = variables(binding)
56
58
 
57
59
  if vars.empty?
58
- log_this(sprintf("%s %-25s #%-20s",
59
- class_count, classname, id))
60
+ log_this(format('%s %-25s #%-20s', count, name, id))
60
61
 
61
62
  else
62
- log_this(sprintf("%s %-25s #%-20s\n%s\n",
63
- class_count, classname, id, vars))
63
+ log_this(format("%s %-25s #%-20s\n%s\n", count, name, id, vars))
64
64
 
65
65
  end
66
66
  end
@@ -86,21 +86,15 @@ module Vedeu
86
86
  # @param binding [Class]
87
87
  # @return [String]
88
88
  def variables(binding)
89
- entries = []
90
89
  binding.eval('local_variables').each do |var|
91
- variable = var.to_s
90
+ variable = Vedeu::Esc.green { var.to_s }
92
91
  value = binding.local_variable_get(var)
93
- valclass = value.class.to_s
92
+ klass = Vedeu::Esc.magenta { value.class.to_s }
94
93
  output = (value.is_a?(Proc)) ? '#<Proc:...' : value.inspect
94
+ content = colour(value.class.to_s, output)
95
95
 
96
- content = Vedeu::Esc.send(class_colour.fetch(valclass, :white)) { output }
97
-
98
- entries << sprintf("%33s %-10s = %s %s", " ",
99
- Vedeu::Esc.green { variable },
100
- Vedeu::Esc.magenta { valclass },
101
- content)
102
- end
103
- entries.join("\n")
96
+ format('%33s %-10s = %s %s', ' ', variable, klass, content)
97
+ end.join("\n")
104
98
  end
105
99
 
106
100
  # @return [String]
@@ -129,7 +123,7 @@ module Vedeu
129
123
  end
130
124
 
131
125
  # @return [Hash]
132
- def class_colour
126
+ def colour(klass, output)
133
127
  {
134
128
  'Array' => :yellow,
135
129
  'Fixnum' => :cyan,
@@ -137,13 +131,13 @@ module Vedeu
137
131
  'NilClass' => :red,
138
132
  'String' => :green,
139
133
  'Symbol' => :magenta,
140
- }
134
+ }.fetch(klass, :white) { |colour| Vedeu::Esc.send(colour) { output } }
141
135
  end
142
136
 
143
137
  # Returns the number of Vedeu classes/modules. (Useful for debugging.)
144
138
  #
145
139
  # @return [String]
146
- def class_count
140
+ def count
147
141
  @count ||= "(#{classes.size}/#{vedeu_classes.size})"
148
142
  end
149
143
 
@@ -179,89 +173,22 @@ module Vedeu
179
173
  # @return [Set]
180
174
  def ignored_classes
181
175
  Set.new [
182
- # 'Vedeu::API',
183
- # 'Vedeu::Application',
184
- # 'Vedeu::Background',
185
- # 'Vedeu::Bindings',
186
- # 'Vedeu::Border',
187
- # 'Vedeu::BoundingArea',
188
- # 'Vedeu::Buffer',
189
- # 'Vedeu::Char',
190
- # 'Vedeu::Chars',
191
176
  'Vedeu::Coercions',
192
177
  'Vedeu::Colour',
193
178
  'Vedeu::Common',
194
- # 'Vedeu::Composition',
195
- # 'Vedeu::Compositor',
196
- # 'Vedeu::Config::API',
197
- # 'Vedeu::Config::CLI',
198
179
  'Vedeu::Configuration',
199
- # 'Vedeu::Console',
200
- # 'Vedeu::Content',
201
- # 'Vedeu::Coordinate',
202
- # 'Vedeu::Cursor',
203
- # 'Vedeu::DisplayBuffer',
204
- # 'Vedeu::DSL::Border',
205
- # 'Vedeu::DSL::Colour',
206
- # 'Vedeu::DSL::Composition',
207
- # 'Vedeu::DSL::Geometry',
208
- # 'Vedeu::DSL::Interface',
209
- # 'Vedeu::DSL::Keymap',
210
- # 'Vedeu::DSL::Line',
211
- # 'Vedeu::DSL::Menu',
212
- # 'Vedeu::DSL::Stream',
213
- # 'Vedeu::DSL::Style',
214
- # 'Vedeu::DSL::Text',
215
- # 'Vedeu::DSL::Use',
216
- # 'Vedeu::DSL::View',
217
180
  'Vedeu::Esc',
218
181
  'Vedeu::Event',
219
- # 'Vedeu::Focus',
220
- # 'Vedeu::Foreground',
221
182
  'Vedeu::Geometry',
222
- # 'Vedeu::Grid',
223
- # 'Vedeu::Group',
224
- # 'Vedeu::Input',
225
- # 'Vedeu::Interface',
226
- # 'Vedeu::Interfaces',
227
- # 'Vedeu::Keymap',
228
- # 'Vedeu::Keys',
229
- # 'Vedeu::Key',
230
- # 'Vedeu::Launcher',
231
- # 'Vedeu::Line',
232
- # 'Vedeu::Lines',
233
183
  'Vedeu::Log',
234
- # 'Vedeu::Mapper',
235
- # 'Vedeu::Menu',
236
- # 'Vedeu::Menus',
237
- # 'Vedeu::Model',
238
- # 'Vedeu::Collection',
239
- # 'Vedeu::Move',
240
- # 'Vedeu::Node',
241
- # 'Vedeu::Output',
242
184
  'Vedeu::Position',
243
- # 'Vedeu::PositionValidator',
244
185
  'Vedeu::Presentation',
245
- # 'Vedeu::Read',
246
- # 'Vedeu::Refresh',
247
- # 'Vedeu::Render',
248
186
  'Vedeu::Repository',
249
- # 'Vedeu::Sentence',
250
187
  'Vedeu::Stream',
251
- # 'Vedeu::Streams',
252
188
  'Vedeu::Style',
253
189
  'Vedeu::Terminal',
254
- # 'Vedeu::Text',
255
- # 'Vedeu::Toggle',
256
190
  'Vedeu::Trace',
257
191
  'Vedeu::Translator',
258
- # 'Vedeu::Traps',
259
- # 'Vedeu::Trigger',
260
- # 'Vedeu::View',
261
- # 'Vedeu::Viewport',
262
- # 'Vedeu::Visible',
263
- # 'Vedeu::Write',
264
- # 'Vedeu::Writer',
265
192
  ]
266
193
  end
267
194
 
@@ -0,0 +1,73 @@
1
+ module Vedeu
2
+
3
+ # Change the visibility of the given model.
4
+ #
5
+ class Visibility
6
+
7
+ # @param model [void]
8
+ # @return [void]
9
+ def self.show(model)
10
+ new(model).show
11
+ end
12
+
13
+ # @param model [void]
14
+ # @return [void]
15
+ def self.hide(model)
16
+ new(model).hide
17
+ end
18
+
19
+ # @param model [void]
20
+ # @return [void]
21
+ def self.toggle(model)
22
+ new(model).toggle
23
+ end
24
+
25
+ # @param model [void]
26
+ # @return [Vedeu::Visibility]
27
+ def initialize(model)
28
+ @model = model
29
+ end
30
+
31
+ # @return [void]
32
+ def show
33
+ model.visible = true
34
+ model.store
35
+ end
36
+
37
+ # @return [Symbol]
38
+ def state
39
+ if model.visible?
40
+ :visible
41
+
42
+ else
43
+ :invisible
44
+
45
+ end
46
+ end
47
+
48
+ # @return [void]
49
+ def hide
50
+ model.visible = false
51
+ model.store
52
+ end
53
+
54
+ # @return [void]
55
+ def toggle
56
+ if model.visible?
57
+ hide
58
+
59
+ else
60
+ show
61
+
62
+ end
63
+ end
64
+
65
+ private
66
+
67
+ # @!attribute [r] model
68
+ # @return [void]
69
+ attr_reader :model
70
+
71
+ end # Visibility
72
+
73
+ end # Vedeu
data/lib/vedeu.rb CHANGED
@@ -2,12 +2,15 @@ $LIB_DIR = File.dirname(__FILE__) + '/../lib'
2
2
  $LOAD_PATH.unshift($LIB_DIR) unless $LOAD_PATH.include?($LIB_DIR)
3
3
 
4
4
  require 'date'
5
+ require 'drb'
5
6
  require 'forwardable'
6
7
  require 'io/console'
8
+ require 'json'
7
9
  require 'logger'
8
10
  require 'optparse'
9
11
  require 'set'
10
12
  require 'singleton'
13
+ require 'thread'
11
14
  require 'time'
12
15
 
13
16
  require 'vedeu/support/log'
@@ -41,6 +44,40 @@ module Vedeu
41
44
  receiver.extend(API)
42
45
  end
43
46
 
47
+ # ModelNotFound: Raised with Vedeu attempts to access a named model that does
48
+ # not exist.
49
+ #
50
+ # InvalidSyntax: Raised when Vedeu attempts to parse a {Vedeu.view} or
51
+ # {Vedeu.interface} and encounters a problem.
52
+ #
53
+ # MissingRequired: Raised when a name is not provided for a model when
54
+ # attempting to store it in a repository.
55
+ #
56
+ # ModeSwitch: Raised intentionally when the client application wishes to
57
+ # switch between cooked and raw (or vice versa) terminal modes. Vedeu is
58
+ # hard-wired to use the `Escape` key to trigger this change for the time
59
+ # being.
60
+ #
61
+ # NotImplemented: Raised to remind me (or client application developers) that
62
+ # the subclass implements the functionality sought.
63
+ #
64
+ # OutOfRange: Raised when trying to access an interface column less than 1 or
65
+ # greater than 12. Vedeu is hard-wired to a 12-column layout for the time
66
+ # being.
67
+ #
68
+ # VedeuInterrupt: Raised when Vedeu wishes to exit.
69
+ #
70
+ Exceptions = %w(
71
+ ModelNotFound
72
+ InvalidSyntax
73
+ MissingRequired
74
+ ModeSwitch
75
+ NotImplemented
76
+ OutOfRange
77
+ VedeuInterrupt
78
+ )
79
+ Exceptions.each { |e| const_set(e, Class.new(StandardError)) }
80
+
44
81
  private
45
82
 
46
83
  end # Vedeu
@@ -7,20 +7,24 @@ module Vedeu
7
7
  describe '.log' do
8
8
  it 'writes the message to the log file when debugging is enabled' do
9
9
  Configuration.stub(:debug?, true) do
10
- Vedeu.log(type: :test, message: 'Testing debugging to log').must_equal(true)
10
+ Vedeu.log(type: :test,
11
+ message: 'Testing debugging to log').must_equal(true)
11
12
  end
12
13
  end
13
14
 
14
15
  it 'returns nil when debugging is disabled' do
15
16
  Configuration.stub(:debug?, false) do
16
- Vedeu.log(type: :test, message: 'some message not logged...').must_equal(nil)
17
+ Vedeu.log(type: :test,
18
+ message: 'some message not logged...').must_equal(nil)
17
19
  end
18
20
  end
19
21
 
20
22
  it 'write the message to the log file when the `force` argument ' \
21
23
  'evaluates to true' do
22
24
  Configuration.stub(:debug?, false) do
23
- Vedeu.log(type: :test, message: 'Testing forced debugging to log', force: true).must_equal(true)
25
+ Vedeu.log(type: :test,
26
+ message: 'Testing forced debugging to log',
27
+ force: true).must_equal(true)
24
28
  end
25
29
  end
26
30
  end
@@ -6,7 +6,7 @@ module Vedeu
6
6
 
7
7
  let(:described) { Vedeu::Application }
8
8
  let(:instance) { described.new(configuration) }
9
- let(:configuration) { test_configuration }
9
+ let(:configuration) { Vedeu.configuration }
10
10
 
11
11
  before do
12
12
  configuration.stubs(:drb?).returns(false)
@@ -14,8 +14,13 @@ module Vedeu
14
14
  end
15
15
 
16
16
  describe '#initialize' do
17
- it { instance.must_be_instance_of(described) }
18
- it { instance.instance_variable_get('@configuration').must_equal(configuration) }
17
+ subject { instance }
18
+
19
+ it { subject.must_be_instance_of(described) }
20
+ it do
21
+ subject.instance_variable_get('@configuration').
22
+ must_equal(configuration)
23
+ end
19
24
  end
20
25
 
21
26
  describe '.start' do
@@ -29,6 +34,7 @@ module Vedeu
29
34
  describe '.stop' do
30
35
  subject { described.stop }
31
36
 
37
+ it { subject.must_equal(false) }
32
38
  end
33
39
 
34
40
  describe '#start' do
@@ -6,12 +6,22 @@ module Vedeu
6
6
 
7
7
  context 'the system events needed by Vedeu to run are defined' do
8
8
  it { Vedeu.events.registered?(:_clear_).must_equal(true) }
9
+ it { Vedeu.events.registered?(:_clear_group_).must_equal(true) }
10
+ it { Vedeu.events.registered?(:_cleanup_).must_equal(true) }
11
+ it { Vedeu.events.registered?(:_command_).must_equal(true) }
9
12
  it { Vedeu.events.registered?(:_exit_).must_equal(true) }
13
+ it { Vedeu.events.registered?(:_hide_group_).must_equal(true) }
10
14
  it { Vedeu.events.registered?(:_initialize_).must_equal(true) }
11
15
  it { Vedeu.events.registered?(:_keypress_).must_equal(true) }
12
16
  it { Vedeu.events.registered?(:_log_).must_equal(true) }
13
17
  it { Vedeu.events.registered?(:_mode_switch_).must_equal(true) }
18
+ it { Vedeu.events.registered?(:_refresh_).must_equal(true) }
19
+ it { Vedeu.events.registered?(:_refresh_cursor_).must_equal(true) }
20
+ it { Vedeu.events.registered?(:_refresh_group_).must_equal(true) }
14
21
  it { Vedeu.events.registered?(:_resize_).must_equal(true) }
22
+ it { Vedeu.events.registered?(:_show_group_).must_equal(true) }
23
+ it { Vedeu.events.registered?(:tick).must_equal(true) }
24
+ it { Vedeu.events.registered?(:tock).must_equal(true) }
15
25
  end
16
26
 
17
27
  context 'the cursor specific events are defined' do
@@ -22,6 +32,17 @@ module Vedeu
22
32
  it { Vedeu.events.registered?(:_cursor_right_).must_equal(true) }
23
33
  it { Vedeu.events.registered?(:_cursor_up_).must_equal(true) }
24
34
  it { Vedeu.events.registered?(:_cursor_origin_).must_equal(true) }
35
+ it { Vedeu.events.registered?(:_cursor_reset_).must_equal(true) }
36
+ end
37
+
38
+ context 'the drb specific events are defined' do
39
+ it { Vedeu.events.registered?(:_drb_input_).must_equal(true) }
40
+ it { Vedeu.events.registered?(:_drb_retrieve_output_).must_equal(true) }
41
+ it { Vedeu.events.registered?(:_drb_store_output_).must_equal(true) }
42
+ it { Vedeu.events.registered?(:_drb_restart_).must_equal(true) }
43
+ it { Vedeu.events.registered?(:_drb_start_).must_equal(true) }
44
+ it { Vedeu.events.registered?(:_drb_status_).must_equal(true) }
45
+ it { Vedeu.events.registered?(:_drb_stop_).must_equal(true) }
25
46
  end
26
47
 
27
48
  context 'the focus specific events are defined' do