vedeu 0.4.55 → 0.4.56

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu.rb +1 -1
  3. data/lib/vedeu/application.rb +2 -2
  4. data/lib/vedeu/buffers/buffer.rb +3 -3
  5. data/lib/vedeu/buffers/buffers.rb +1 -1
  6. data/lib/vedeu/buffers/display_buffer.rb +3 -3
  7. data/lib/vedeu/colours/colour.rb +1 -1
  8. data/lib/vedeu/colours/colour_translator.rb +4 -4
  9. data/lib/vedeu/configuration/api.rb +4 -4
  10. data/lib/vedeu/configuration/cli.rb +1 -1
  11. data/lib/vedeu/configuration/configuration.rb +2 -2
  12. data/lib/vedeu/cursor/cursor.rb +5 -5
  13. data/lib/vedeu/cursor/cursors.rb +1 -1
  14. data/lib/vedeu/cursor/move.rb +8 -8
  15. data/lib/vedeu/cursor/reposition.rb +2 -2
  16. data/lib/vedeu/distributed/client.rb +1 -1
  17. data/lib/vedeu/distributed/server.rb +1 -1
  18. data/lib/vedeu/distributed/test_application.rb +1 -1
  19. data/lib/vedeu/distributed/uri.rb +1 -1
  20. data/lib/vedeu/dsl/border.rb +3 -3
  21. data/lib/vedeu/dsl/composition.rb +4 -4
  22. data/lib/vedeu/dsl/geometry.rb +4 -4
  23. data/lib/vedeu/dsl/group.rb +4 -4
  24. data/lib/vedeu/dsl/interface.rb +9 -9
  25. data/lib/vedeu/dsl/keymap.rb +10 -8
  26. data/lib/vedeu/dsl/line.rb +5 -5
  27. data/lib/vedeu/dsl/stream.rb +2 -2
  28. data/lib/vedeu/dsl/use.rb +2 -2
  29. data/lib/vedeu/dsl/view.rb +7 -7
  30. data/lib/vedeu/events/event.rb +1 -1
  31. data/lib/vedeu/events/events.rb +1 -1
  32. data/lib/vedeu/geometry/geometries.rb +1 -1
  33. data/lib/vedeu/geometry/grid.rb +8 -8
  34. data/lib/vedeu/geometry/position_validator.rb +1 -1
  35. data/lib/vedeu/input/input.rb +1 -1
  36. data/lib/vedeu/input/key.rb +2 -2
  37. data/lib/vedeu/input/keymap.rb +1 -1
  38. data/lib/vedeu/input/keymaps.rb +1 -1
  39. data/lib/vedeu/input/mapper.rb +3 -3
  40. data/lib/vedeu/launcher.rb +1 -1
  41. data/lib/vedeu/log.rb +7 -7
  42. data/lib/vedeu/models/all.rb +1 -2
  43. data/lib/vedeu/models/char.rb +1 -1
  44. data/lib/vedeu/models/composition.rb +2 -2
  45. data/lib/vedeu/models/{escape_char.rb → escape.rb} +5 -5
  46. data/lib/vedeu/models/focus.rb +5 -3
  47. data/lib/vedeu/models/groups.rb +1 -1
  48. data/lib/vedeu/models/interface.rb +1 -1
  49. data/lib/vedeu/models/interfaces.rb +1 -1
  50. data/lib/vedeu/models/line.rb +2 -2
  51. data/lib/vedeu/models/menu.rb +3 -3
  52. data/lib/vedeu/models/menus.rb +1 -1
  53. data/lib/vedeu/models/stream.rb +1 -1
  54. data/lib/vedeu/output/border.rb +2 -2
  55. data/lib/vedeu/output/borders.rb +1 -1
  56. data/lib/vedeu/output/html_char.rb +42 -21
  57. data/lib/vedeu/output/refresh.rb +4 -4
  58. data/lib/vedeu/output/renderers/html.rb +22 -5
  59. data/lib/vedeu/output/renderers/renderer_options.rb +4 -0
  60. data/lib/vedeu/output/style.rb +1 -1
  61. data/lib/vedeu/output/text.rb +1 -1
  62. data/lib/vedeu/output/viewport.rb +1 -1
  63. data/lib/vedeu/output/virtual_terminal.rb +2 -1
  64. data/lib/vedeu/repositories/collection.rb +1 -1
  65. data/lib/vedeu/repositories/repository.rb +9 -5
  66. data/lib/vedeu/templating/helpers.rb +4 -4
  67. data/lib/vedeu/templating/template.rb +6 -4
  68. data/lib/vedeu/terminal.rb +2 -2
  69. data/lib/vedeu/version.rb +1 -1
  70. data/test/lib/vedeu/cursor/cursor_test.rb +2 -2
  71. data/test/lib/vedeu/models/{escape_char_test.rb → escape_test.rb} +4 -4
  72. data/test/lib/vedeu/models/group_test.rb +12 -0
  73. data/test/lib/vedeu/output/compressor_test.rb +2 -2
  74. data/test/lib/vedeu/output/html_char_test.rb +9 -2
  75. data/test/lib/vedeu/repositories/all_test.rb +21 -0
  76. data/test/lib/vedeu/repositories/repository_test.rb +2 -2
  77. metadata +6 -4
@@ -50,11 +50,13 @@ module Vedeu
50
50
  # Vedeu.focus_by_name('name')
51
51
  #
52
52
  # @param name [String] The interface to focus; must be defined.
53
- # @raise [ModelNotFound] When the interface cannot be found.
53
+ # @raise [Vedeu::ModelNotFound] When the interface cannot be found.
54
54
  # @return [String] The name of the interface now in focus.
55
55
  def by_name(name)
56
- fail ModelNotFound, "Cannot focus '#{name}' as this interface has not " \
57
- 'been registered.' unless registered?(name)
56
+ unless registered?(name)
57
+ fail Vedeu::ModelNotFound, "Cannot focus '#{name}' as this interface " \
58
+ 'has not been registered.'
59
+ end
58
60
 
59
61
  storage.rotate!(storage.index(name))
60
62
 
@@ -5,7 +5,7 @@ module Vedeu
5
5
  # Allows the storing of view groups.
6
6
  #
7
7
  # @api public
8
- class Groups < Repository
8
+ class Groups < Vedeu::Repository
9
9
 
10
10
  class << self
11
11
 
@@ -156,7 +156,7 @@ module Vedeu
156
156
  Vedeu.buffers.by_name(name).show
157
157
  end
158
158
 
159
- # @return [Interface]
159
+ # @return [Vedeu::Interface]
160
160
  def store
161
161
  super
162
162
 
@@ -6,7 +6,7 @@ module Vedeu
6
6
  # Allows the storing of interfaces and views.
7
7
  #
8
8
  # @api public
9
- class Interfaces < Repository
9
+ class Interfaces < Vedeu::Repository
10
10
 
11
11
  class << self
12
12
 
@@ -14,7 +14,7 @@ module Vedeu
14
14
  member Vedeu::Stream
15
15
 
16
16
  # @!attribute [rw] parent
17
- # @return [Interface]
17
+ # @return [Vedeu::Interface]
18
18
  attr_accessor :parent
19
19
 
20
20
  # @!attribute [r] attributes
@@ -35,7 +35,7 @@ module Vedeu
35
35
  @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
36
36
  end
37
37
 
38
- # @param child []
38
+ # @param child [void]
39
39
  # @return [void]
40
40
  def add(child)
41
41
  @_streams = @streams = collection.coerce(streams, self).add(child)
@@ -50,10 +50,10 @@ module Vedeu
50
50
  # # ...
51
51
  # end
52
52
  #
53
- # @raise [InvalidSyntax] The required block was not given.
53
+ # @raise [Vedeu::InvalidSyntax] The required block was not given.
54
54
  # @return [API::Menu]
55
55
  def self.menu(name = '', &block)
56
- fail InvalidSyntax, 'block not given' unless block_given?
56
+ fail Vedeu::InvalidSyntax, 'block not given' unless block_given?
57
57
 
58
58
  build({ name: name }, &block).store
59
59
  end
@@ -65,7 +65,7 @@ module Vedeu
65
65
  # @option attributes name [String]
66
66
  # @option attributes current [Fixnum]
67
67
  # @option attributes selected [Fixnum|NilClass]
68
- # @return [Menu]
68
+ # @return [Vedeu::Menu]
69
69
  def initialize(attributes = {})
70
70
  @attributes = defaults.merge!(attributes)
71
71
 
@@ -5,7 +5,7 @@ module Vedeu
5
5
  # Allows the storing of menus by name.
6
6
  #
7
7
  # @api public
8
- class Menus < Repository
8
+ class Menus < Vedeu::Repository
9
9
 
10
10
  class << self
11
11
 
@@ -14,7 +14,7 @@ module Vedeu
14
14
  member Vedeu::Char
15
15
 
16
16
  # @!attribute [rw] parent
17
- # @return [Line]
17
+ # @return [Vedeu::Line]
18
18
  attr_accessor :parent
19
19
 
20
20
  # @!attribute [rw] value
@@ -99,7 +99,7 @@ module Vedeu
99
99
  # @option attributes horizontal [String] The horizontal border character.
100
100
  # @option attributes name [String] The name of the interface to which this
101
101
  # border relates.
102
- # @option attributes style []
102
+ # @option attributes style [Vedeu::Style]
103
103
  # @option attributes show_bottom [Boolean] Indicate whether the bottom
104
104
  # border is to be shown.
105
105
  # @option attributes show_left [Boolean] Indicate whether the left border
@@ -113,7 +113,7 @@ module Vedeu
113
113
  # @option attributes top_left [String] The top left border character.
114
114
  # @option attributes top_right [String] The top right border character.
115
115
  # @option attributes vertical [String] The vertical border character.
116
- # @return [Border]
116
+ # @return [Vedeu::Border]
117
117
  def initialize(attributes = {})
118
118
  @attributes = defaults.merge!(attributes)
119
119
 
@@ -7,7 +7,7 @@ module Vedeu
7
7
  # instance.
8
8
  #
9
9
  # @api public
10
- class Borders < Repository
10
+ class Borders < Vedeu::Repository
11
11
 
12
12
  class << self
13
13
 
@@ -2,7 +2,8 @@ require 'vedeu/common'
2
2
 
3
3
  module Vedeu
4
4
 
5
- # Represents a {Vedeu::Char} as a HTML table cell.
5
+ # Represents a {Vedeu::Char} as a HTML tag with value. By default, a table
6
+ # cell is used.
6
7
  #
7
8
  # @api private
8
9
  class HTMLChar
@@ -10,22 +11,29 @@ module Vedeu
10
11
  include Vedeu::Common
11
12
 
12
13
  # @param char [Vedeu::Char]
14
+ # @param options [Hash<Symbol => String>]
15
+ # @option options start_tag [String]
16
+ # @option options end_tag [String]
13
17
  # @return [String]
14
- def self.render(char)
15
- new(char).render
18
+ def self.render(char, options = {})
19
+ new(char, options).render
16
20
  end
17
21
 
18
22
  # Returns a new instance of Vedeu::HTMLChar.
19
23
  #
20
24
  # @param char [Vedeu::Char]
25
+ # @param options [Hash<Symbol => String>]
26
+ # @option options start_tag [String]
27
+ # @option options end_tag [String]
21
28
  # @return [Vedeu::HTMLChar]
22
- def initialize(char)
23
- @char = char
29
+ def initialize(char, options = {})
30
+ @char = char
31
+ @options = options
24
32
  end
25
33
 
26
34
  # @return [String]
27
35
  def render
28
- "<td#{td_style}>#{td_value}</td>"
36
+ [start_tag, tag_style, '>', tag_value, end_tag].join
29
37
  end
30
38
 
31
39
  protected
@@ -37,7 +45,7 @@ module Vedeu
37
45
  private
38
46
 
39
47
  # @return [String]
40
- def td_style
48
+ def tag_style
41
49
  return '' unless border || present?(value)
42
50
 
43
51
  " style='" \
@@ -48,7 +56,7 @@ module Vedeu
48
56
  end
49
57
 
50
58
  # @return [String]
51
- def td_value
59
+ def tag_value
52
60
  return '&nbsp;' if border || !present?(value)
53
61
 
54
62
  value
@@ -77,25 +85,15 @@ module Vedeu
77
85
 
78
86
  # @return [String]
79
87
  def fg
80
- @fg ||= colour_fg
88
+ @fg ||= colour(char, 'foreground', '#222')
81
89
  end
82
90
 
83
91
  # @return [String]
84
92
  def bg
85
- @bg ||= colour_bg
93
+ @bg ||= colour(char, 'background', '#000')
86
94
  end
87
95
 
88
- # @return [String]
89
- def colour_bg
90
- colour(char, 'background', '#000')
91
- end
92
-
93
- # @return [String]
94
- def colour_fg
95
- colour(char, 'foreground', '#222')
96
- end
97
-
98
- # @param char []
96
+ # @param char [Vedeu::Char]
99
97
  # @param type [String]
100
98
  # @param default [String]
101
99
  # @return [String]
@@ -126,6 +124,29 @@ module Vedeu
126
124
  char.value
127
125
  end
128
126
 
127
+ # @return [String]
128
+ def start_tag
129
+ options[:start_tag]
130
+ end
131
+
132
+ # @return [String]
133
+ def end_tag
134
+ options[:end_tag]
135
+ end
136
+
137
+ # @return [Hash<Symbol => String>]
138
+ def options
139
+ defaults.merge!(@options)
140
+ end
141
+
142
+ # @return [Hash<Symbol => String>]
143
+ def defaults
144
+ {
145
+ start_tag: '<td',
146
+ end_tag: '</td>',
147
+ }
148
+ end
149
+
129
150
  end # HTMLChar
130
151
 
131
152
  end # Vedeu
@@ -30,7 +30,7 @@ module Vedeu
30
30
 
31
31
  # Refresh the interface which is currently focussed.
32
32
  #
33
- # @return [Array|ModelNotFound|NilClass]
33
+ # @return [Array|Vedeu::ModelNotFound|NilClass]
34
34
  def by_focus
35
35
  by_name(Vedeu.focus) if Vedeu.focus
36
36
  end
@@ -43,8 +43,8 @@ module Vedeu
43
43
  # Vedeu::Refresh.by_group(group_name)
44
44
  #
45
45
  # @param group_name [String] The name of the group to be refreshed.
46
- # @return [Array|ModelNotFound] A collection of the names of interfaces
47
- # refreshed, or an exception if the group was not found.
46
+ # @return [Array|Vedeu::ModelNotFound] A collection of the names of
47
+ # interfaces refreshed, or an exception if the group was not found.
48
48
  def by_group(group_name)
49
49
  Vedeu.timer("Refresh Group: '#{group_name}'") do
50
50
  Vedeu::RefreshGroup.by_name(group_name)
@@ -60,7 +60,7 @@ module Vedeu
60
60
  #
61
61
  # @param name [String] The name of the interface to be refreshed using the
62
62
  # named buffer.
63
- # @return [Array|ModelNotFound]
63
+ # @return [Array|Vedeu::ModelNotFound]
64
64
  def by_name(name)
65
65
  Vedeu.timer("Refresh Interface: '#{name}'") do
66
66
  Vedeu.buffers.by_name(name).render
@@ -2,7 +2,8 @@ module Vedeu
2
2
 
3
3
  module Renderers
4
4
 
5
- # Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML table.
5
+ # Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML snippet;
6
+ # a table by default.
6
7
  #
7
8
  # @api private
8
9
  class HTML < Vedeu::Renderers::File
@@ -10,6 +11,10 @@ module Vedeu
10
11
  # Returns a new instance of Vedeu::Renderers::HTML.
11
12
  #
12
13
  # @param options [Hash]
14
+ # @option options content [String]
15
+ # @option options end_row_tag [String]
16
+ # @option options start_row_tag [String]
17
+ # @option options template [String]
13
18
  # @return [Vedeu::Renderers::HTML]
14
19
  def initialize(options = {})
15
20
  @options = options || {}
@@ -33,14 +38,14 @@ module Vedeu
33
38
  def html_body
34
39
  out = ''
35
40
  Array(content).each do |line|
36
- out << "<tr>\n"
41
+ out << "#{start_row_tag}\n"
37
42
  line.each do |char|
38
43
  if char.is_a?(Vedeu::Char)
39
44
  out << char.to_html
40
45
  out << "\n"
41
46
  end
42
47
  end
43
- out << "</tr>\n"
48
+ out << "#{end_row_tag}\n"
44
49
  end
45
50
  out
46
51
  end
@@ -52,6 +57,16 @@ module Vedeu
52
57
  options[:content]
53
58
  end
54
59
 
60
+ # @return [String]
61
+ def end_row_tag
62
+ options[:end_row_tag]
63
+ end
64
+
65
+ # @return [String]
66
+ def start_row_tag
67
+ options[:start_row_tag]
68
+ end
69
+
55
70
  # @return [String]
56
71
  def template
57
72
  options[:template]
@@ -69,8 +84,10 @@ module Vedeu
69
84
  # @return [Hash<Symbol => void>]
70
85
  def defaults
71
86
  {
72
- content: '',
73
- template: default_template,
87
+ content: '',
88
+ end_row_tag: '</tr>',
89
+ start_row_tag: '<tr>',
90
+ template: default_template,
74
91
  }
75
92
  end
76
93
 
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # @api private
6
6
  module RendererOptions
7
7
 
8
+ # :nocov:
9
+
8
10
  private
9
11
 
10
12
  # Combines the options provided at instantiation with the default values.
@@ -21,6 +23,8 @@ module Vedeu
21
23
  {}
22
24
  end
23
25
 
26
+ # :nocov
27
+
24
28
  end # RendererOptions
25
29
 
26
30
  end # Vedeu
@@ -40,7 +40,7 @@ module Vedeu
40
40
  #
41
41
  # @param value [Array<String|Symbol>|String|Symbol]
42
42
  # The style value or a collection of values.
43
- # @return [Style]
43
+ # @return [Vedeu::Style]
44
44
  def initialize(value = nil)
45
45
  @value = value
46
46
  end
@@ -26,7 +26,7 @@ module Vedeu
26
26
  # @option options model [Vedeu::Interface|Vedeu::Line|Vedeu::Stream]
27
27
  # @option options pad [String]
28
28
  # @option options width [Integer]
29
- # @return [Text]
29
+ # @return [Vedeu::Text]
30
30
  def initialize(value = '', options = {})
31
31
  @value = value
32
32
  @options = defaults.merge!(options)
@@ -39,7 +39,7 @@ module Vedeu
39
39
 
40
40
  # Returns an instance of Vedeu::Viewport.
41
41
  #
42
- # @param interface [Interface] An instance of interface.
42
+ # @param interface [Vedeu::Interface] An instance of interface.
43
43
  # @return [Viewport]
44
44
  def initialize(interface)
45
45
  @interface = interface
@@ -21,7 +21,8 @@ module Vedeu
21
21
  #
22
22
  # @param height [Fixnum]
23
23
  # @param width [Fixnum]
24
- # @param renderer [Object|Renderers::HTML] An object responding to .render.
24
+ # @param renderer [Object|Vedeu::Renderers::HTML] An object responding to
25
+ # .render.
25
26
  # @return [Vedeu::VirtualTerminal]
26
27
  def initialize(height, width, renderer = Vedeu::Renderers::HTML.new)
27
28
  @height = height
@@ -37,7 +37,7 @@ module Vedeu
37
37
 
38
38
  # Returns a new instance of Vedeu::Collection.
39
39
  #
40
- # @param collection []
40
+ # @param collection [void]
41
41
  # @param parent [void]
42
42
  # @param name [String|NilClass]
43
43
  # @return [Vedeu::Collection]
@@ -92,10 +92,12 @@ module Vedeu
92
92
  # be found.
93
93
  #
94
94
  # @param name [String]
95
- # @raise [ModelNotFound] When the model cannot be found with this name.
95
+ # @raise [Vedeu::ModelNotFound] When the model cannot be found with this
96
+ # name.
96
97
  # @return [Hash<String => Object>]
97
98
  def find!(name)
98
- find(name) || fail(ModelNotFound, "Cannot find model by name: '#{name}'")
99
+ find(name) || fail(Vedeu::ModelNotFound,
100
+ "Cannot find model by name: '#{name}'")
99
101
  end
100
102
 
101
103
  # Find a model by name, registers the model by name if not found.
@@ -156,11 +158,13 @@ module Vedeu
156
158
  # Stores the model instance by name in the repository of the model.
157
159
  #
158
160
  # @param model [void] A model instance.
159
- # @raise [MissingRequired] When the name attribute is not defined.
161
+ # @raise [Vedeu::MissingRequired] When the name attribute is not defined.
160
162
  # @return [void] The model instance which was stored.
161
163
  def store(model)
162
- fail MissingRequired, "Cannot store model '#{model.class}' without a " \
163
- 'name attribute.' unless present?(model.name)
164
+ unless present?(model.name)
165
+ fail Vedeu::MissingRequired, "Cannot store model '#{model.class}' " \
166
+ 'without a name attribute.'
167
+ end
164
168
 
165
169
  log_store(model)
166
170