vedeu 0.4.56 → 0.4.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/examples/borders_app.rb +22 -24
  3. data/examples/colours_app.rb +4 -6
  4. data/examples/configuration_app.rb +5 -7
  5. data/examples/drb_app.rb +1 -1
  6. data/examples/focus_app.rb +1 -1
  7. data/examples/geometry_app.rb +8 -10
  8. data/examples/hello_world.rb +4 -6
  9. data/examples/material_colours_app.rb +19 -9
  10. data/examples/material_colours_app_20150721.svg +2285 -0
  11. data/examples/panel_app.rb +6 -8
  12. data/examples/typed_commands/typed_commands_app.rb +15 -17
  13. data/examples/view_templates_app/view_templates_app.rb +1 -1
  14. data/lib/vedeu/all.rb +82 -10
  15. data/lib/vedeu/api.rb +34 -14
  16. data/lib/vedeu/application.rb +0 -1
  17. data/lib/vedeu/application/application_controller.rb +0 -1
  18. data/lib/vedeu/application/application_helper.rb +0 -1
  19. data/lib/vedeu/application/application_view.rb +0 -1
  20. data/lib/vedeu/application/controller.rb +0 -1
  21. data/lib/vedeu/application/helper.rb +0 -1
  22. data/lib/vedeu/application/view.rb +0 -1
  23. data/lib/vedeu/bindings/all.rb +0 -1
  24. data/lib/vedeu/bindings/visibility.rb +2 -19
  25. data/lib/vedeu/buffers/buffer.rb +0 -1
  26. data/lib/vedeu/buffers/display_buffer.rb +0 -1
  27. data/lib/vedeu/cli/generator/application.rb +0 -1
  28. data/lib/vedeu/cli/generator/helpers.rb +0 -1
  29. data/lib/vedeu/cli/generator/view.rb +0 -1
  30. data/lib/vedeu/colours/background.rb +0 -1
  31. data/lib/vedeu/colours/colour.rb +0 -1
  32. data/lib/vedeu/colours/colour_translator.rb +0 -1
  33. data/lib/vedeu/colours/foreground.rb +0 -1
  34. data/lib/vedeu/common.rb +0 -1
  35. data/lib/vedeu/configuration/configuration.rb +0 -1
  36. data/lib/vedeu/cursor/cursor.rb +0 -1
  37. data/lib/vedeu/cursor/move.rb +0 -1
  38. data/lib/vedeu/cursor/refresh_cursor.rb +0 -1
  39. data/lib/vedeu/cursor/reposition.rb +0 -1
  40. data/lib/vedeu/distributed/client.rb +2 -0
  41. data/lib/vedeu/distributed/server.rb +2 -0
  42. data/lib/vedeu/distributed/uri.rb +2 -1
  43. data/lib/vedeu/exceptions.rb +0 -7
  44. data/lib/vedeu/geometry/area.rb +0 -1
  45. data/lib/vedeu/geometry/coordinate.rb +0 -1
  46. data/lib/vedeu/geometry/dimension.rb +14 -1
  47. data/lib/vedeu/geometry/geometry.rb +0 -1
  48. data/lib/vedeu/geometry/index_position.rb +0 -1
  49. data/lib/vedeu/geometry/position.rb +0 -1
  50. data/lib/vedeu/geometry/position_index.rb +0 -1
  51. data/lib/vedeu/geometry/position_validator.rb +0 -1
  52. data/lib/vedeu/input/input.rb +0 -1
  53. data/lib/vedeu/input/key.rb +0 -1
  54. data/lib/vedeu/input/keymap.rb +0 -1
  55. data/lib/vedeu/input/mapper.rb +0 -1
  56. data/lib/vedeu/log.rb +0 -1
  57. data/lib/vedeu/main_loop.rb +0 -1
  58. data/lib/vedeu/models/cell.rb +0 -1
  59. data/lib/vedeu/models/char.rb +0 -1
  60. data/lib/vedeu/models/composition.rb +0 -1
  61. data/lib/vedeu/models/escape.rb +0 -1
  62. data/lib/vedeu/models/focus.rb +0 -1
  63. data/lib/vedeu/models/group.rb +37 -15
  64. data/lib/vedeu/models/interface.rb +1 -2
  65. data/lib/vedeu/models/line.rb +0 -1
  66. data/lib/vedeu/models/menu.rb +0 -1
  67. data/lib/vedeu/models/stream.rb +0 -1
  68. data/lib/vedeu/models/toggleable.rb +21 -11
  69. data/lib/vedeu/null/all.rb +0 -1
  70. data/lib/vedeu/null/border.rb +0 -1
  71. data/lib/vedeu/null/buffer.rb +0 -1
  72. data/lib/vedeu/null/generic.rb +0 -1
  73. data/lib/vedeu/null/geometry.rb +0 -1
  74. data/lib/vedeu/null/interface.rb +0 -1
  75. data/lib/vedeu/output/border.rb +0 -1
  76. data/lib/vedeu/output/clear/named_group.rb +3 -2
  77. data/lib/vedeu/output/clear/named_interface.rb +2 -1
  78. data/lib/vedeu/output/compressor.rb +0 -1
  79. data/lib/vedeu/output/html_char.rb +0 -1
  80. data/lib/vedeu/output/output.rb +0 -1
  81. data/lib/vedeu/output/presentation.rb +0 -1
  82. data/lib/vedeu/output/refresh_group.rb +0 -1
  83. data/lib/vedeu/output/render_border.rb +0 -1
  84. data/lib/vedeu/output/renderers/all.rb +0 -1
  85. data/lib/vedeu/output/renderers/escape_sequence.rb +0 -1
  86. data/lib/vedeu/output/renderers/file.rb +0 -1
  87. data/lib/vedeu/output/renderers/html.rb +0 -1
  88. data/lib/vedeu/output/renderers/json.rb +0 -1
  89. data/lib/vedeu/output/renderers/null.rb +0 -1
  90. data/lib/vedeu/output/renderers/renderer_options.rb +0 -1
  91. data/lib/vedeu/output/renderers/terminal.rb +0 -1
  92. data/lib/vedeu/output/renderers/text.rb +0 -1
  93. data/lib/vedeu/output/style.rb +0 -1
  94. data/lib/vedeu/output/text.rb +0 -1
  95. data/lib/vedeu/output/viewport.rb +0 -1
  96. data/lib/vedeu/output/virtual_terminal.rb +0 -1
  97. data/lib/vedeu/output/wordwrap.rb +0 -1
  98. data/lib/vedeu/repositories/collection.rb +0 -7
  99. data/lib/vedeu/repositories/model.rb +0 -1
  100. data/lib/vedeu/repositories/registerable.rb +0 -1
  101. data/lib/vedeu/repositories/repository.rb +0 -1
  102. data/lib/vedeu/repositories/store.rb +0 -1
  103. data/lib/vedeu/templating/directive.rb +1 -1
  104. data/lib/vedeu/templating/helpers.rb +1 -1
  105. data/lib/vedeu/templating/preprocessor.rb +1 -1
  106. data/lib/vedeu/templating/template.rb +1 -1
  107. data/lib/vedeu/traps.rb +0 -1
  108. data/lib/vedeu/version.rb +1 -1
  109. data/test/lib/vedeu/application/controller_test.rb +8 -1
  110. data/test/lib/vedeu/buffers/buffer_test.rb +5 -0
  111. data/test/lib/vedeu/cursor/reposition_test.rb +5 -5
  112. data/test/lib/vedeu/models/group_test.rb +4 -3
  113. data/test/lib/vedeu/models/interface_test.rb +15 -1
  114. data/test/lib/vedeu/null/interface_test.rb +7 -21
  115. data/test/lib/vedeu/output/esc_test.rb +105 -109
  116. metadata +3 -15
  117. data/lib/vedeu/application/all.rb +0 -6
  118. data/lib/vedeu/buffers/all.rb +0 -3
  119. data/lib/vedeu/cli/all.rb +0 -1
  120. data/lib/vedeu/colours/all.rb +0 -7
  121. data/lib/vedeu/configuration/all.rb +0 -3
  122. data/lib/vedeu/cursor/all.rb +0 -7
  123. data/lib/vedeu/distributed/all.rb +0 -15
  124. data/lib/vedeu/events/all.rb +0 -5
  125. data/lib/vedeu/geometry/all.rb +0 -14
  126. data/lib/vedeu/models/all.rb +0 -16
  127. data/lib/vedeu/output/all.rb +0 -21
  128. data/lib/vedeu/output/clear/all.rb +0 -13
  129. data/lib/vedeu/templating/all.rb +0 -13
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # Interfaces can be associated with one another by being members of the same
6
6
  # Group. A Group is a collection of interface names.
7
7
  #
8
- # @api private
9
8
  class Group
10
9
 
11
10
  include Vedeu::Model
@@ -17,20 +16,22 @@ module Vedeu
17
16
 
18
17
  # Return a new instance of Vedeu::Group.
19
18
  #
19
+ # @note
20
+ # A group being visible or not may not necessarily mean the members are of
21
+ # the same state.
22
+ #
20
23
  # @param attributes [Hash]
21
- # @option attributes members [Array] A collection of names of interfaces
24
+ # @option attributes members [Set] A collection of names of interfaces
22
25
  # belonging to this group.
23
26
  # @option attributes name [String] The name of the group.
24
27
  # @option attributes repository [Vedeu::Repository] The storage for all
25
28
  # Group models.
29
+ # @option attributes visible [Boolean] Whether the group is visible or not.
26
30
  # @return [Vedeu::Group]
27
31
  def initialize(attributes = {})
28
32
  @attributes = defaults.merge!(attributes)
29
33
 
30
- @members = Array(@attributes[:members])
31
- @name = @attributes[:name]
32
- @repository = @attributes[:repository]
33
- @visible = @attributes[:visible]
34
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
34
35
  end
35
36
 
36
37
  # Add a member to the group by name.
@@ -38,15 +39,33 @@ module Vedeu
38
39
  # @param member [String]
39
40
  # @return [Vedeu::Group]
40
41
  def add(member)
41
- @members = members.add(member)
42
+ attrs = attributes.merge!(members: members.add(member))
42
43
 
43
- Vedeu::Group.new(name: name, members: @members, visible: visible).store
44
+ Vedeu::Group.new(attrs).store
45
+ end
46
+
47
+ # Returns the attributes of the group.
48
+ #
49
+ # @return [Hash<Symbol => void>]
50
+ def attributes
51
+ {
52
+ name: name,
53
+ members: members,
54
+ repository: repository,
55
+ visible: visible,
56
+ }
44
57
  end
45
58
 
46
59
  # Hide the named group of interfaces, or without a name, the group of the
47
- # currently focussed interface.
60
+ # currently focussed interface. Useful for hiding part of that which is
61
+ # currently displaying in the terminal.
62
+ #
63
+ # @note
64
+ # The action of showing a group will effectively clear the terminal and
65
+ # show the new group, therefore hiding the group may not be necessary.
48
66
  #
49
67
  # @example
68
+ # Vedeu.trigger(:_hide_group_, name)
50
69
  # Vedeu.hide_group(name)
51
70
  #
52
71
  # @return [Vedeu::Group]
@@ -58,11 +77,11 @@ module Vedeu
58
77
  self
59
78
  end
60
79
 
61
- # Return the members as a Set.
80
+ # Return the members of the group.
62
81
  #
63
82
  # @return [Set]
64
83
  def members
65
- @members.to_set
84
+ @_members ||= Set.new(@members)
66
85
  end
67
86
 
68
87
  # Remove a member from the group by name.
@@ -70,22 +89,25 @@ module Vedeu
70
89
  # @param member [String]
71
90
  # @return [Vedeu::Group]
72
91
  def remove(member)
73
- @members = members.delete(member)
92
+ attrs = attributes.merge!(members: members.delete(member))
74
93
 
75
- Vedeu::Group.new(name: name, members: @members, visible: visible).store
94
+ Vedeu::Group.new(attrs).store
76
95
  end
77
96
 
78
97
  # Remove all members from the group.
79
98
  #
80
99
  # @return [Vedeu::Group]
81
100
  def reset
82
- Vedeu::Group.new(defaults.merge!(name: name)).store
101
+ attrs = defaults.merge!(name: name)
102
+
103
+ Vedeu::Group.new(attrs).store
83
104
  end
84
105
 
85
106
  # Show the named group of interfaces, or without a name, the group of the
86
107
  # currently focussed interface.
87
108
  #
88
109
  # @example
110
+ # Vedeu.trigger(:_show_group_, name)
89
111
  # Vedeu.show_group(name)
90
112
  #
91
113
  # @return [Vedeu::Group]
@@ -104,7 +126,7 @@ module Vedeu
104
126
  # @return [Hash]
105
127
  def defaults
106
128
  {
107
- members: [],
129
+ members: Set.new,
108
130
  name: '',
109
131
  repository: Vedeu.groups,
110
132
  visible: true,
@@ -10,7 +10,6 @@ module Vedeu
10
10
  # {Vedeu::Geometry}. It is a container for {Vedeu::Line} and {Vedeu::Stream}
11
11
  # objects.
12
12
  #
13
- # @api private
14
13
  class Interface
15
14
 
16
15
  include Vedeu::Model
@@ -134,8 +133,8 @@ module Vedeu
134
133
 
135
134
  output = [
136
135
  Vedeu::Clear::NamedInterface.render(name),
137
- Vedeu.borders.by_name(name).render,
138
136
  Vedeu::Viewport.render(self),
137
+ Vedeu.borders.by_name(name).render,
139
138
  ]
140
139
 
141
140
  Vedeu.trigger(:_show_cursor_, name)
@@ -4,7 +4,6 @@ module Vedeu
4
4
  # {Vedeu::Stream} objects. A line's width is determined by the
5
5
  # {Vedeu::Interface} it belongs to.
6
6
  #
7
- # @api private
8
7
  class Line
9
8
 
10
9
  include Vedeu::Model
@@ -3,7 +3,6 @@ module Vedeu
3
3
  # Converts the collection passed into a list of menu items which can be
4
4
  # navigated using the instance methods or events provided.
5
5
  #
6
- # @api private
7
6
  class Menu
8
7
 
9
8
  include Vedeu::Model
@@ -4,7 +4,6 @@ module Vedeu
4
4
  # {Vedeu::Line} which you wish to colour and style independently of the other
5
5
  # characters in that line.
6
6
  #
7
- # @api private
8
7
  class Stream
9
8
 
10
9
  include Vedeu::Model
@@ -1,8 +1,11 @@
1
1
  module Vedeu
2
2
 
3
- # Toggleable instance methods for certain models.
3
+ # This module provides behaviour for certain classes which can be toggled
4
+ # between being shown and hidden.
5
+ #
6
+ # Currently using this are: {Vedeu::Cursor}, {Vedeu::Group} and
7
+ # {Vedeu::Interface}.
4
8
  #
5
- # @api private
6
9
  module Toggleable
7
10
 
8
11
  # @!attribute [rw] visible
@@ -10,6 +13,8 @@ module Vedeu
10
13
  attr_accessor :visible
11
14
  alias_method :visible?, :visible
12
15
 
16
+ # Set the visible state to false and store the model.
17
+ #
13
18
  # @return [FalseClass]
14
19
  def hide
15
20
  @visible = false
@@ -17,6 +22,8 @@ module Vedeu
17
22
  store
18
23
  end
19
24
 
25
+ # Set the visible state to true and store the model.
26
+ #
20
27
  # @return [TrueClass]
21
28
  def show
22
29
  @visible = true
@@ -24,6 +31,8 @@ module Vedeu
24
31
  store
25
32
  end
26
33
 
34
+ # Toggle the visible state and store the model.
35
+ #
27
36
  # @return [FalseClass|TrueClass]
28
37
  def toggle
29
38
  if visible?
@@ -35,11 +44,12 @@ module Vedeu
35
44
  end
36
45
  end
37
46
 
38
- # Toggleable class methods for models.
47
+ # Provide class methods to models to allow the visibility to be changed.
39
48
  #
40
- # @api private
41
49
  module ClassMethods
42
50
 
51
+ # Hides the model.
52
+ #
43
53
  # @param name [String]
44
54
  # @return [void]
45
55
  def hide(name = nil)
@@ -49,6 +59,8 @@ module Vedeu
49
59
  alias_method :hide_group, :hide
50
60
  alias_method :hide_interface, :hide
51
61
 
62
+ # Shows the model.
63
+ #
52
64
  # @param name [String]
53
65
  # @return [void]
54
66
  def show(name = nil)
@@ -58,6 +70,8 @@ module Vedeu
58
70
  alias_method :show_group, :show
59
71
  alias_method :show_interface, :show
60
72
 
73
+ # Toggles the visibility of the model.
74
+ #
61
75
  # @param name [String]
62
76
  # @return [void]
63
77
  def toggle(name = nil)
@@ -69,17 +83,13 @@ module Vedeu
69
83
 
70
84
  private
71
85
 
86
+ # Fetch the model by name.
87
+ #
72
88
  # @param name [String]
73
89
  # @param klass [void] The repository of the model.
74
90
  # @return [void]
75
91
  def model_by_name(name = nil, klass)
76
- klass.by_name(model_name(name))
77
- end
78
-
79
- # @param name [String]
80
- # @return [void]
81
- def model_name(name = nil)
82
- name || Vedeu.focus
92
+ klass.by_name(name || Vedeu.focus)
83
93
  end
84
94
 
85
95
  end # ClassMethods
@@ -4,7 +4,6 @@ module Vedeu
4
4
  # real counterpart. In most cases the call is muted or returns a generic
5
5
  # value that does not halt processing.
6
6
  #
7
- # @api private
8
7
  module Null
9
8
 
10
9
  end
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # Provides a non-existent Vedeu::Border that acts like the real thing, but
6
6
  # does nothing.
7
7
  #
8
- # @api private
9
8
  class Border
10
9
 
11
10
  # @!attribute [r] name
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # Provides a non-existent Vedeu::Buffer that acts like the real thing, but
6
6
  # does nothing.
7
7
  #
8
- # @api private
9
8
  class Buffer
10
9
 
11
10
  # @!attribute [r] name
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # Provides a non-existent model to swallow messages.
6
6
  #
7
- # @api private
8
7
  class Generic
9
8
 
10
9
  # Returns an instance of the Vedeu::Null::Generic class.
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # Provides a non-existent model to swallow messages.
6
6
  #
7
- # @api private
8
7
  class Geometry
9
8
 
10
9
  extend Forwardable
@@ -6,7 +6,6 @@ module Vedeu
6
6
 
7
7
  # Provides a non-existent model to swallow messages.
8
8
  #
9
- # @api private
10
9
  class Interface
11
10
 
12
11
  include Vedeu::Presentation
@@ -10,7 +10,6 @@ module Vedeu
10
10
  # @note Refer to UTF-8 U+2500 to U+257F for border characters. More details
11
11
  # can be found at: http://en.wikipedia.org/wiki/Box-drawing_character
12
12
  #
13
- # @api private
14
13
  class Border
15
14
 
16
15
  extend Forwardable
@@ -1,10 +1,11 @@
1
1
  module Vedeu
2
2
 
3
+ # Provides the mechanisms to clear an interface or group of interfaces.
4
+ #
3
5
  module Clear
4
6
 
5
- # Clear the named group.
7
+ # Clear the interfaces belonging to the named group.
6
8
  #
7
- # @api private
8
9
  class NamedGroup
9
10
 
10
11
  class << self
@@ -1,10 +1,11 @@
1
1
  module Vedeu
2
2
 
3
+ # Provides the mechanisms to clear an interface or group of interfaces.
4
+ #
3
5
  module Clear
4
6
 
5
7
  # Clear the named interface.
6
8
  #
7
- # @api private
8
9
  class NamedInterface
9
10
 
10
11
  class << self
@@ -4,7 +4,6 @@ module Vedeu
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
6
  #
7
- # @api private
8
7
  class Compressor
9
8
 
10
9
  # @param output [Array<Array<Vedeu::Char>>]
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # Represents a {Vedeu::Char} as a HTML tag with value. By default, a table
6
6
  # cell is used.
7
7
  #
8
- # @api private
9
8
  class HTMLChar
10
9
 
11
10
  include Vedeu::Common
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Sends the output to the renderers.
4
4
  #
5
- # @api private
6
5
  class Output
7
6
 
8
7
  # Writes output to the defined renderers.
@@ -3,7 +3,6 @@ module Vedeu
3
3
  # This module allows the sharing of presentation concerns between the models:
4
4
  # Interface, Line and Stream.
5
5
  #
6
- # @api private
7
6
  module Presentation
8
7
 
9
8
  # Returns the background colour for the model, or if it does not exist,
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # Refreshes the given named group of interfaces.
6
6
  #
7
- # @api private
8
7
  class RefreshGroup
9
8
 
10
9
  include Vedeu::Common
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Renders the provided border.
4
4
  #
5
- # @api private
6
5
  class RenderBorder
7
6
 
8
7
  extend Forwardable
@@ -11,7 +11,6 @@ module Vedeu
11
11
 
12
12
  # Provides a single interface to all registered renderers.
13
13
  #
14
- # @api private
15
14
  module Renderers
16
15
 
17
16
  extend Enumerable
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # A renderer which returns the escape sequence for each character.
6
6
  #
7
- # @api private
8
7
  class EscapeSequence
9
8
 
10
9
  include Vedeu::RendererOptions
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # Writes the given output to a file.
6
6
  #
7
- # @api private
8
7
  class File
9
8
 
10
9
  # Returns a new instance of Vedeu::Renderers::File.
@@ -5,7 +5,6 @@ module Vedeu
5
5
  # Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML snippet;
6
6
  # a table by default.
7
7
  #
8
- # @api private
9
8
  class HTML < Vedeu::Renderers::File
10
9
 
11
10
  # Returns a new instance of Vedeu::Renderers::HTML.