vedeu 0.4.18 → 0.4.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Rakefile +1 -0
  4. data/bin/vedeu_drb_server +0 -1
  5. data/bin/vedeu_test +0 -1
  6. data/config/rubocop_enabled.yml +1 -1
  7. data/examples/borders_app.rb +0 -1
  8. data/examples/colours_app.rb +0 -1
  9. data/examples/cursor_app.rb +0 -1
  10. data/examples/drb_app.rb +0 -1
  11. data/examples/geometry_app.rb +0 -1
  12. data/examples/hello_world.rb +0 -1
  13. data/examples/lines_app.rb +0 -1
  14. data/examples/material_colours_app.rb +0 -1
  15. data/examples/typed_commands/typed_commands_app.rb +0 -1
  16. data/examples/view_templates_app/view_templates_app.rb +0 -1
  17. data/lib/vedeu/api.rb +2 -1
  18. data/lib/vedeu/application.rb +3 -2
  19. data/lib/vedeu/bindings.rb +3 -5
  20. data/lib/vedeu/buffers/buffer.rb +8 -11
  21. data/lib/vedeu/buffers/display_buffer.rb +0 -2
  22. data/lib/vedeu/configuration/api.rb +1 -4
  23. data/lib/vedeu/configuration/cli.rb +153 -74
  24. data/lib/vedeu/configuration/configuration.rb +1 -2
  25. data/lib/vedeu/cursor/cursor.rb +0 -4
  26. data/lib/vedeu/cursor/move.rb +3 -6
  27. data/lib/vedeu/cursor/refresh_cursor.rb +12 -2
  28. data/lib/vedeu/distributed/client.rb +3 -2
  29. data/lib/vedeu/distributed/server.rb +4 -3
  30. data/lib/vedeu/distributed/subprocess.rb +3 -4
  31. data/lib/vedeu/distributed/test_application.rb +0 -1
  32. data/lib/vedeu/distributed/uri.rb +0 -1
  33. data/lib/vedeu/dsl/components/border.rb +3 -4
  34. data/lib/vedeu/dsl/components/geometry.rb +1 -5
  35. data/lib/vedeu/dsl/components/keymap.rb +1 -3
  36. data/lib/vedeu/dsl/components/menu.rb +1 -2
  37. data/lib/vedeu/dsl/composition.rb +3 -4
  38. data/lib/vedeu/dsl/group.rb +1 -4
  39. data/lib/vedeu/dsl/interface.rb +3 -10
  40. data/lib/vedeu/dsl/line.rb +3 -4
  41. data/lib/vedeu/dsl/shared/text.rb +0 -3
  42. data/lib/vedeu/dsl/stream.rb +3 -4
  43. data/lib/vedeu/dsl/view.rb +0 -3
  44. data/lib/vedeu/events/event.rb +3 -3
  45. data/lib/vedeu/events/trigger.rb +3 -2
  46. data/lib/vedeu/geometry/area.rb +0 -1
  47. data/lib/vedeu/geometry/canvas.rb +0 -1
  48. data/lib/vedeu/geometry/coordinate.rb +6 -7
  49. data/lib/vedeu/geometry/dimension.rb +3 -2
  50. data/lib/vedeu/geometry/geometry.rb +0 -6
  51. data/lib/vedeu/geometry/grid.rb +3 -2
  52. data/lib/vedeu/geometry/index_position.rb +0 -1
  53. data/lib/vedeu/geometry/position.rb +0 -1
  54. data/lib/vedeu/geometry/position_index.rb +0 -1
  55. data/lib/vedeu/geometry/position_validator.rb +6 -68
  56. data/lib/vedeu/input/all.rb +0 -2
  57. data/lib/vedeu/input/input.rb +3 -2
  58. data/lib/vedeu/input/key.rb +0 -1
  59. data/lib/vedeu/input/keymap.rb +4 -7
  60. data/lib/vedeu/input/mapper.rb +3 -2
  61. data/lib/vedeu/launcher.rb +3 -2
  62. data/lib/vedeu/main_loop.rb +1 -1
  63. data/lib/vedeu/models/cell.rb +0 -1
  64. data/lib/vedeu/models/char.rb +0 -1
  65. data/lib/vedeu/models/composition.rb +1 -7
  66. data/lib/vedeu/models/group.rb +0 -3
  67. data/lib/vedeu/models/interface.rb +0 -3
  68. data/lib/vedeu/models/line.rb +0 -4
  69. data/lib/vedeu/models/menu.rb +5 -8
  70. data/lib/vedeu/models/stream.rb +0 -4
  71. data/lib/vedeu/null/all.rb +11 -0
  72. data/lib/vedeu/null/border.rb +3 -1
  73. data/lib/vedeu/null/buffer.rb +0 -1
  74. data/lib/vedeu/null/generic.rb +4 -1
  75. data/lib/vedeu/null/geometry.rb +0 -1
  76. data/lib/vedeu/null/interface.rb +36 -7
  77. data/lib/vedeu/output/background.rb +0 -1
  78. data/lib/vedeu/output/border.rb +1 -6
  79. data/lib/vedeu/output/clear.rb +3 -2
  80. data/lib/vedeu/output/colour.rb +6 -18
  81. data/lib/vedeu/output/compressor.rb +5 -2
  82. data/lib/vedeu/output/esc.rb +4 -1
  83. data/lib/vedeu/output/foreground.rb +0 -5
  84. data/lib/vedeu/output/html_char.rb +3 -2
  85. data/lib/vedeu/output/output.rb +1 -5
  86. data/lib/vedeu/output/refresh.rb +1 -1
  87. data/lib/vedeu/output/renderers/all.rb +0 -1
  88. data/lib/vedeu/output/renderers/escape_sequence.rb +3 -2
  89. data/lib/vedeu/output/renderers/file.rb +85 -80
  90. data/lib/vedeu/output/renderers/html.rb +77 -72
  91. data/lib/vedeu/output/renderers/json.rb +45 -42
  92. data/lib/vedeu/output/renderers/null.rb +11 -8
  93. data/lib/vedeu/output/renderers/terminal.rb +41 -36
  94. data/lib/vedeu/output/renderers/text.rb +41 -36
  95. data/lib/vedeu/output/style.rb +0 -3
  96. data/lib/vedeu/output/text.rb +3 -2
  97. data/lib/vedeu/output/viewport.rb +3 -2
  98. data/lib/vedeu/output/virtual_terminal.rb +0 -1
  99. data/lib/vedeu/output/wordwrap.rb +3 -2
  100. data/lib/vedeu/repositories/all.rb +7 -6
  101. data/lib/vedeu/repositories/collection.rb +0 -1
  102. data/lib/vedeu/repositories/collections/chars.rb +0 -1
  103. data/lib/vedeu/repositories/collections/events.rb +0 -1
  104. data/lib/vedeu/repositories/collections/interfaces.rb +0 -1
  105. data/lib/vedeu/repositories/collections/keys.rb +0 -1
  106. data/lib/vedeu/repositories/collections/lines.rb +0 -1
  107. data/lib/vedeu/repositories/collections/streams.rb +0 -1
  108. data/lib/vedeu/repositories/model.rb +0 -1
  109. data/lib/vedeu/repositories/registerable.rb +29 -0
  110. data/lib/vedeu/repositories/repositories/background_colours.rb +0 -1
  111. data/lib/vedeu/repositories/repositories/borders.rb +2 -13
  112. data/lib/vedeu/repositories/repositories/buffers.rb +2 -13
  113. data/lib/vedeu/repositories/repositories/colours.rb +0 -1
  114. data/lib/vedeu/repositories/repositories/cursors.rb +1 -2
  115. data/lib/vedeu/repositories/repositories/events_repository.rb +0 -1
  116. data/lib/vedeu/repositories/repositories/foreground_colours.rb +0 -1
  117. data/lib/vedeu/repositories/repositories/geometries.rb +2 -13
  118. data/lib/vedeu/repositories/repositories/groups.rb +1 -2
  119. data/lib/vedeu/repositories/repositories/interfaces_repository.rb +2 -14
  120. data/lib/vedeu/repositories/repositories/keymaps.rb +1 -2
  121. data/lib/vedeu/repositories/repositories/menus.rb +1 -2
  122. data/lib/vedeu/repositories/repository.rb +14 -5
  123. data/lib/vedeu/storage/all.rb +0 -1
  124. data/lib/vedeu/storage/associative_store.rb +0 -1
  125. data/lib/vedeu/storage/conveyor_store.rb +0 -1
  126. data/lib/vedeu/storage/fifo_store.rb +0 -1
  127. data/lib/vedeu/support/log.rb +0 -3
  128. data/lib/vedeu/support/options.rb +3 -2
  129. data/lib/vedeu/support/template.rb +3 -4
  130. data/lib/vedeu/support/terminal.rb +0 -2
  131. data/lib/vedeu/support/trace.rb +6 -7
  132. data/lib/vedeu/support/visibility.rb +1 -2
  133. data/lib/vedeu.rb +3 -5
  134. data/test/lib/vedeu/buffers/buffer_test.rb +48 -13
  135. data/test/lib/vedeu/configuration/cli_test.rb +5 -4
  136. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +37 -15
  137. data/test/lib/vedeu/distributed/subprocess_test.rb +1 -0
  138. data/test/lib/vedeu/dsl/shared/use_test.rb +1 -6
  139. data/test/lib/vedeu/main_loop_test.rb +11 -0
  140. data/test/lib/vedeu/null/interface_test.rb +27 -0
  141. data/test/lib/vedeu/output/output_test.rb +17 -10
  142. data/test/lib/vedeu/output/presentation_test.rb +35 -7
  143. data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +50 -0
  144. data/test/lib/vedeu/output/renderers/file_test.rb +34 -30
  145. data/test/lib/vedeu/output/renderers/html_test.rb +61 -57
  146. data/test/lib/vedeu/output/renderers/json_test.rb +40 -36
  147. data/test/lib/vedeu/output/renderers/null_test.rb +12 -8
  148. data/test/lib/vedeu/output/renderers/terminal_test.rb +17 -13
  149. data/test/lib/vedeu/output/renderers/text_test.rb +17 -13
  150. data/test/lib/vedeu/repositories/model_test.rb +1 -1
  151. data/test/lib/vedeu/repositories/registerable_test.rb +28 -0
  152. data/test/lib/vedeu/storage/associative_store_test.rb +7 -0
  153. data/test/lib/vedeu/storage/conveyor_store_test.rb +7 -0
  154. data/test/lib/vedeu/storage/fifo_store_test.rb +7 -0
  155. data/test/support/helpers/model_test_class.rb +6 -2
  156. data/test/test_helper.rb +2 -0
  157. data/vedeu.gemspec +3 -2
  158. metadata +23 -6
  159. data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +0 -46
@@ -1,11 +1,8 @@
1
- require 'vedeu/repositories/all'
2
- require 'vedeu/dsl/components/all'
3
- require 'vedeu/input/key'
1
+ require 'vedeu/dsl/components/keymap'
4
2
 
5
3
  module Vedeu
6
4
 
7
5
  # A container class for keys associated with a particular interface.
8
- #
9
6
  class Keymap
10
7
 
11
8
  include Vedeu::Model
@@ -27,9 +24,9 @@ module Vedeu
27
24
  def initialize(attributes = {})
28
25
  @attributes = defaults.merge!(attributes)
29
26
 
30
- @name = @attributes[:name]
31
- @keys = @attributes[:keys]
32
- @repository = @attributes[:repository]
27
+ @attributes.each do |key, value|
28
+ instance_variable_set("@#{key}", value)
29
+ end
33
30
  end
34
31
 
35
32
  # @param key [Key]
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # Maps keys to keymaps.
4
- #
5
4
  class Mapper
6
5
 
7
6
  # Takes a key as a keypress and sends it to registered keymaps. If found,
@@ -65,7 +64,7 @@ module Vedeu
65
64
  true
66
65
  end
67
66
 
68
- private
67
+ protected
69
68
 
70
69
  # @!attribute [r] key
71
70
  # @return [String|Symbol]
@@ -75,6 +74,8 @@ module Vedeu
75
74
  # @return [Vedeu::Repository]
76
75
  attr_reader :repository
77
76
 
77
+ private
78
+
78
79
  # Is the key a global key?
79
80
  #
80
81
  # @return [Boolean]
@@ -6,7 +6,6 @@ module Vedeu
6
6
  # finally the exiting of the application with the correct exit code.
7
7
  #
8
8
  # @api public
9
- #
10
9
  class Launcher
11
10
 
12
11
  # @!attribute [r] exit_code
@@ -70,12 +69,14 @@ module Vedeu
70
69
  puts uncaught_exception.backtrace.join("\n") if configuration.debug?
71
70
  end
72
71
 
73
- private
72
+ protected
74
73
 
75
74
  # @!attribute [r] argv
76
75
  # @return [Array<String>] The command line arguments provided.
77
76
  attr_reader :argv
78
77
 
78
+ private
79
+
79
80
  # Terminates the application after resetting $stdin, $stdout and $stderr.
80
81
  #
81
82
  # @return [void]
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # Each time Vedeu starts one cycle in the application loop, it triggers the
6
6
  # `:tick` event. A completion of that cycle will trigger `:tock`. This can be
7
7
  # used by the client application for timing amongst other things.
8
- #
9
8
  class MainLoop
10
9
 
11
10
  trap('SIGTERM') { stop! }
@@ -27,6 +26,7 @@ module Vedeu
27
26
  safe_exit_point!
28
27
  end
29
28
  rescue VedeuInterrupt
29
+ Vedeu.log(type: :debug, message: 'Vedeu execution interrupted, exiting.')
30
30
  end
31
31
  # :nocov:
32
32
 
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # A Cell represents a single square of the terminal.
4
- #
5
4
  class Cell
6
5
 
7
6
  # @!attribute [r] colour
@@ -10,7 +10,6 @@ module Vedeu
10
10
  #
11
11
  # Though a multi-character String can be passed as a value, only the first
12
12
  # character is returned in the escape sequence.
13
- #
14
13
  class Char
15
14
 
16
15
  include Vedeu::Presentation
@@ -1,12 +1,6 @@
1
- require 'vedeu/dsl/composition'
2
- require 'vedeu/repositories/all'
3
- require 'vedeu/output/presentation'
4
- require 'vedeu/support/common'
5
-
6
1
  module Vedeu
7
2
 
8
3
  # A composition is a collection of interfaces.
9
- #
10
4
  class Composition
11
5
 
12
6
  include Vedeu::Model
@@ -30,7 +24,6 @@ module Vedeu
30
24
  @attributes = defaults.merge!(attributes)
31
25
 
32
26
  @interfaces = @attributes[:interfaces]
33
- @repository = Vedeu.interfaces
34
27
  end
35
28
 
36
29
  # @param child [Vedeu::Interface]
@@ -62,6 +55,7 @@ module Vedeu
62
55
  client: nil,
63
56
  colour: nil,
64
57
  interfaces: [],
58
+ repository: Vedeu.interfaces,
65
59
  style: nil,
66
60
  }
67
61
  end
@@ -1,10 +1,7 @@
1
- require 'vedeu/repositories/model'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # Interfaces can be associated with one another by being members of the same
6
4
  # Group. A Group is a collection of interface names.
7
- #
8
5
  class Group
9
6
 
10
7
  include Vedeu::Model
@@ -1,5 +1,3 @@
1
- require 'vedeu/models/all'
2
- require 'vedeu/output/presentation'
3
1
  require 'vedeu/buffers/display_buffer'
4
2
 
5
3
  module Vedeu
@@ -7,7 +5,6 @@ module Vedeu
7
5
  # An Interface represents a portion of the terminal defined by
8
6
  # {Vedeu::Geometry}. It is a container for {Vedeu::Line} and {Vedeu::Stream}
9
7
  # objects.
10
- #
11
8
  class Interface
12
9
 
13
10
  extend Forwardable
@@ -1,12 +1,8 @@
1
- require 'vedeu/output/presentation'
2
- require 'vedeu/models/all'
3
-
4
1
  module Vedeu
5
2
 
6
3
  # A Line represents a single row of the terminal. It is a container for
7
4
  # {Vedeu::Stream} objects. A line's width is determined by the
8
5
  # {Vedeu::Interface} it belongs to.
9
- #
10
6
  class Line
11
7
 
12
8
  include Vedeu::Model
@@ -1,10 +1,7 @@
1
- require 'vedeu/repositories/model'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # Converts the collection passed into a list of menu items which can be
6
4
  # navigated using the instance methods or events provided.
7
- #
8
5
  class Menu
9
6
 
10
7
  include Vedeu::Model
@@ -67,11 +64,10 @@ module Vedeu
67
64
  # @return [Menu]
68
65
  def initialize(attributes = {})
69
66
  @attributes = defaults.merge!(attributes)
70
- @collection = @attributes[:collection]
71
- @current = @attributes[:current]
72
- @name = @attributes[:name]
73
- @repository = Vedeu.menus
74
- @selected = @attributes[:selected]
67
+
68
+ @attributes.each do |key, value|
69
+ instance_variable_set("@#{key}", value)
70
+ end
75
71
  end
76
72
 
77
73
  # Returns the item from the collection which shares the same index as the
@@ -210,6 +206,7 @@ module Vedeu
210
206
  collection: [],
211
207
  current: 0,
212
208
  name: '',
209
+ repository: Vedeu.menus,
213
210
  selected: nil,
214
211
  }
215
212
  end
@@ -1,12 +1,8 @@
1
- require 'vedeu/output/presentation'
2
- require 'vedeu/models/all'
3
-
4
1
  module Vedeu
5
2
 
6
3
  # A Stream can represent a character or collection of characters as part of a
7
4
  # {Vedeu::Line} which you wish to colour and style independently of the other
8
5
  # characters in that line.
9
- #
10
6
  class Stream
11
7
 
12
8
  include Vedeu::Model
@@ -1,3 +1,14 @@
1
+ module Vedeu
2
+
3
+ # A group of objects that serve to intercept messages destined for their
4
+ # real counterpart. In most cases the call is muted or returns a generic
5
+ # value that does not halt processing.
6
+ module Null
7
+
8
+ end
9
+
10
+ end
11
+
1
12
  require_relative 'border'
2
13
  require_relative 'buffer'
3
14
  require_relative 'generic'
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # Provides a non-existent Vedeu::Border that acts like the real thing, but
6
6
  # does nothing.
7
- #
8
7
  class Border
9
8
 
10
9
  # @!attribute [r] name
@@ -43,6 +42,9 @@ module Vedeu
43
42
  end
44
43
  alias_method :yn, :byn
45
44
 
45
+ # The null border should not be enabled, so that named geometry
46
+ # or null geometry is used.
47
+ #
46
48
  # @return [FalseClass]
47
49
  def enabled?
48
50
  false
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # Provides a non-existent Vedeu::Buffer that acts like the real thing, but
6
6
  # does nothing.
7
- #
8
7
  class Buffer
9
8
 
10
9
  # @!attribute [r] name
@@ -3,9 +3,10 @@ module Vedeu
3
3
  module Null
4
4
 
5
5
  # Provides a non-existent model to swallow messages.
6
- #
7
6
  class Generic
8
7
 
8
+ # Returns an instance of the Vedeu::Null::Generic class.
9
+ #
9
10
  # @return [Vedeu::Null::Generic]
10
11
  def initialize; end
11
12
 
@@ -34,6 +35,8 @@ module Vedeu
34
35
  nil
35
36
  end
36
37
 
38
+ # The generic null should not be visible.
39
+ #
37
40
  # @return [FalseClass]
38
41
  def visible?
39
42
  false
@@ -3,7 +3,6 @@ module Vedeu
3
3
  module Null
4
4
 
5
5
  # Provides a non-existent model to swallow messages.
6
- #
7
6
  class Geometry
8
7
 
9
8
  extend Forwardable
@@ -3,19 +3,48 @@ module Vedeu
3
3
  module Null
4
4
 
5
5
  # Provides a non-existent model to swallow messages.
6
- #
7
6
  class Interface
8
7
 
9
- # @!attribute [r] attributes
10
- # @return [Hash]
11
- attr_reader :attributes
8
+ # @param name [String]
9
+ # @return [Vedeu::Null::Interface]
10
+ def initialize(name = nil)
11
+ @name = name
12
+ end
12
13
 
13
- # @param attributes [Hash]
14
+ # @return [Hash<Symbol => String>]
15
+ def attributes
16
+ {
17
+ name: name,
18
+ }
19
+ end
20
+
21
+ # Pretend to store this model in the repository.
22
+ #
14
23
  # @return [Vedeu::Null::Interface]
15
- def initialize(attributes = {})
16
- @attributes = attributes
24
+ def store
25
+ self
26
+ end
27
+
28
+ # The null interface should not be visible.
29
+ #
30
+ # @return [FalseClass]
31
+ def visible?
32
+ false
33
+ end
34
+
35
+ # Override the visible= setter usually found on a Vedeu::Interface.
36
+ #
37
+ # @return [FalseClass]
38
+ def visible=(*)
39
+ false
17
40
  end
18
41
 
42
+ protected
43
+
44
+ # @!attribute [r] name
45
+ # @return [String]
46
+ attr_reader :name
47
+
19
48
  end # Interface
20
49
 
21
50
  end # Null
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # The class represents one half (the other, can be found at
4
4
  # {Vedeu::Foreground}) of a terminal colour escape sequence.
5
- #
6
5
  class Background < Vedeu::Translator
7
6
 
8
7
  private
@@ -1,6 +1,3 @@
1
- require 'vedeu/repositories/all'
2
- require 'vedeu/dsl/components/all'
3
-
4
1
  module Vedeu
5
2
 
6
3
  # Provides the mechanism to decorate an interface with a border on all edges,
@@ -10,7 +7,6 @@ module Vedeu
10
7
  #
11
8
  # @note Refer to UTF-8 U+2500 to U+257F for border characters. More details
12
9
  # can be found at: http://en.wikipedia.org/wiki/Box-drawing_character
13
- #
14
10
  class Border
15
11
 
16
12
  extend Forwardable
@@ -241,9 +237,8 @@ module Vedeu
241
237
  # @param position [Symbol] Either :top_horizontal, or :bottom_horizontal.
242
238
  # @return [Array<Vedeu::Char>]
243
239
  def horizontal_border(position)
244
- width.times.inject([]) do |a, ix|
240
+ width.times.each_with_object([]) do |ix, a|
245
241
  a << border(horizontal, position, nil, ix)
246
- a
247
242
  end
248
243
  end
249
244
 
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # Clears the area defined by an interface.
4
- #
5
4
  class Clear
6
5
 
7
6
  extend Forwardable
@@ -84,12 +83,14 @@ module Vedeu
84
83
  Vedeu::Output.render(rendered)
85
84
  end
86
85
 
87
- private
86
+ protected
88
87
 
89
88
  # @!attribute [r] interface
90
89
  # @return [Interface]
91
90
  attr_reader :interface
92
91
 
92
+ private
93
+
93
94
  # @return (see Vedeu::Borders#by_name)
94
95
  def border
95
96
  @border ||= Vedeu.borders.by_name(name)
@@ -30,7 +30,6 @@ module Vedeu
30
30
  # area needs more work in Vedeu.
31
31
  #
32
32
  # @todo Fix colours in all terminals. (GL: 2015-04-13)
33
- #
34
33
  class Colour
35
34
 
36
35
  # @!attribute [r] attributes
@@ -42,21 +41,12 @@ module Vedeu
42
41
  def self.coerce(value)
43
42
  return value if value.is_a?(self)
44
43
  return new unless value.is_a?(Hash)
45
- return new unless value[:colour] ||
46
- value[:background] ||
47
- value[:foreground]
48
44
 
49
45
  if value[:colour]
50
46
  return value[:colour] if value[:colour].is_a?(self)
51
-
52
- if value[:colour].is_a?(Hash) && (value[:colour][:background] ||
53
- value[:colour][:foreground])
54
- new(value[:colour])
55
-
56
- else
57
- new
58
-
59
- end
47
+ return new unless value[:colour].is_a?(Hash)
48
+ return new(value[:colour]) if value[:colour][:background] ||
49
+ value[:colour][:foreground]
60
50
 
61
51
  elsif value[:background] || value[:foreground]
62
52
  new(value)
@@ -72,7 +62,7 @@ module Vedeu
72
62
  # @param attributes [Hash]
73
63
  # @option attributes background [String]
74
64
  # @option attributes foreground [String]
75
- # @return [Colour]
65
+ # @return [Vedeu::Colour]
76
66
  def initialize(attributes = {})
77
67
  @attributes = defaults.merge!(attributes)
78
68
  end
@@ -89,8 +79,7 @@ module Vedeu
89
79
  # @param value [String]
90
80
  # @return [String]
91
81
  def background=(value)
92
- @attributes[:background] = value
93
- @background = Vedeu::Background.coerce(value)
82
+ @background = @attributes[:background] = Vedeu::Background.coerce(value)
94
83
  end
95
84
 
96
85
  # @param other [Vedeu::Char]
@@ -113,8 +102,7 @@ module Vedeu
113
102
  # @param value [String]
114
103
  # @return [String]
115
104
  def foreground=(value)
116
- @attributes[:foreground] = value
117
- @foreground = Vedeu::Foreground.coerce(value)
105
+ @foreground = @attributes[:foreground] = Vedeu::Foreground.coerce(value)
118
106
  end
119
107
 
120
108
  # Returns both or either of the converted attributes into a single escape
@@ -3,7 +3,6 @@ module Vedeu
3
3
  # During the conversion of a Vedeu::Char object into a string of escape
4
4
  # sequences, this class removes multiple occurences of the same escape
5
5
  # sequence, resulting in a smaller payload being sent to the renderer.
6
- #
7
6
  class Compressor
8
7
 
9
8
  # @param output [Array<Array<Vedeu::Char>>]
@@ -32,10 +31,14 @@ module Vedeu
32
31
  end.join
33
32
  end
34
33
 
35
- private
34
+ protected
36
35
 
36
+ # @!attribute [r] output
37
+ # @return [Array<Array<Vedeu::Char>>]
37
38
  attr_reader :output
38
39
 
40
+ private
41
+
39
42
  # @param char [Vedeu::Char]
40
43
  # @return [String]
41
44
  def colour_for(char)
@@ -121,7 +121,10 @@ module Vedeu
121
121
 
122
122
  return '' if name.empty?
123
123
 
124
- send(name) rescue ''
124
+ send(name)
125
+
126
+ rescue NoMethodError
127
+ ''
125
128
  end
126
129
 
127
130
  # Return the escape sequence to render a border character.
@@ -1,12 +1,7 @@
1
- require 'vedeu/configuration/configuration'
2
- require 'vedeu/output/translator'
3
- require 'vedeu/output/esc'
4
-
5
1
  module Vedeu
6
2
 
7
3
  # The class represents one half (the other, can be found at
8
4
  # {Vedeu::Background}) of a terminal colour escape sequence.
9
- #
10
5
  class Foreground < Vedeu::Translator
11
6
 
12
7
  private
@@ -3,7 +3,6 @@ require 'vedeu/support/common'
3
3
  module Vedeu
4
4
 
5
5
  # Represents a {Vedeu::Char} as a HTML table cell.
6
- #
7
6
  class HTMLChar
8
7
 
9
8
  include Vedeu::Common
@@ -27,12 +26,14 @@ module Vedeu
27
26
  "<td#{td_style}>#{td_value}</td>"
28
27
  end
29
28
 
30
- private
29
+ protected
31
30
 
32
31
  # @!attribute [r] char
33
32
  # @return [Vedeu::Char]
34
33
  attr_reader :char
35
34
 
35
+ private
36
+
36
37
  # @return [String]
37
38
  def td_style
38
39
  return '' unless border || defined_value?(value)
@@ -1,10 +1,6 @@
1
- require 'vedeu/output/renderers/all'
2
- require 'vedeu/output/virtual_buffer'
3
-
4
1
  module Vedeu
5
2
 
6
3
  # Sends the content to the renderers.
7
- #
8
4
  class Output
9
5
 
10
6
  # Writes content to the defined renderers.
@@ -36,7 +32,7 @@ module Vedeu
36
32
  Vedeu.renderers.render(content)
37
33
  end
38
34
 
39
- private
35
+ protected
40
36
 
41
37
  # @!attribute [r] content
42
38
  # @return [Array<Array<Vedeu::Char>>]
@@ -4,7 +4,7 @@ module Vedeu
4
4
  #
5
5
  module Refresh
6
6
 
7
- extend self
7
+ module_function
8
8
 
9
9
  # Refresh all registered interfaces.
10
10
  #
@@ -9,7 +9,6 @@ require_relative 'text'
9
9
  module Vedeu
10
10
 
11
11
  # Provides a single interface to all registered renderers.
12
- #
13
12
  module Renderers
14
13
 
15
14
  extend Enumerable
@@ -3,7 +3,6 @@ module Vedeu
3
3
  module Renderers
4
4
 
5
5
  # A renderer which returns the escape sequence for each character.
6
- #
7
6
  class EscapeSequence
8
7
 
9
8
  # @param output [Array<Array<Vedeu::Char>>]
@@ -25,12 +24,14 @@ module Vedeu
25
24
  parsed
26
25
  end
27
26
 
28
- private
27
+ protected
29
28
 
30
29
  # @!attribute [r] output
31
30
  # @return [Array<Array<Vedeu::Char>>]
32
31
  attr_reader :output
33
32
 
33
+ private
34
+
34
35
  # Escapes the escape sequences.
35
36
  #
36
37
  # @return [String]