vedeu 0.6.69 → 0.6.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/docs/api.md +4 -0
  3. data/lib/vedeu/all.rb +5 -7
  4. data/lib/vedeu/borders/all.rb +1 -0
  5. data/lib/vedeu/borders/repository.rb +2 -6
  6. data/lib/vedeu/borders/set_attribute.rb +71 -0
  7. data/lib/vedeu/buffers/buffer.rb +6 -1
  8. data/lib/vedeu/buffers/refresh.rb +6 -1
  9. data/lib/vedeu/common.rb +2 -1
  10. data/lib/vedeu/configuration/configuration.rb +1 -1
  11. data/lib/vedeu/cursors/all.rb +1 -0
  12. data/lib/vedeu/cursors/cursor.rb +8 -27
  13. data/lib/vedeu/cursors/move.rb +69 -0
  14. data/lib/vedeu/cursors/repository.rb +1 -1
  15. data/lib/vedeu/dsl/all.rb +2 -0
  16. data/lib/vedeu/dsl/composition.rb +6 -1
  17. data/lib/vedeu/dsl/lines.rb +21 -0
  18. data/lib/vedeu/dsl/streams.rb +21 -0
  19. data/lib/vedeu/groups/clear.rb +6 -1
  20. data/lib/vedeu/groups/refresh.rb +6 -1
  21. data/lib/vedeu/input/capture.rb +6 -1
  22. data/lib/vedeu/interfaces/clear.rb +6 -1
  23. data/lib/vedeu/interfaces/interface.rb +20 -8
  24. data/lib/vedeu/models/all.rb +1 -0
  25. data/lib/vedeu/models/focus.rb +19 -14
  26. data/lib/vedeu/models/page.rb +5 -0
  27. data/lib/vedeu/models/row.rb +5 -0
  28. data/lib/vedeu/models/toggleable.rb +6 -1
  29. data/lib/vedeu/null/all.rb +0 -1
  30. data/lib/vedeu/output/all.rb +0 -2
  31. data/lib/vedeu/output/compressor.rb +2 -1
  32. data/lib/vedeu/output/wordwrap.rb +6 -1
  33. data/lib/vedeu/output/write.rb +2 -0
  34. data/lib/vedeu/presentation/all.rb +17 -0
  35. data/lib/vedeu/presentation/background.rb +47 -0
  36. data/lib/vedeu/presentation/colour.rb +42 -0
  37. data/lib/vedeu/presentation/foreground.rb +47 -0
  38. data/lib/vedeu/{output/presentation → presentation}/presentation.rb +0 -0
  39. data/lib/vedeu/{output/presentation → presentation}/style.rb +0 -0
  40. data/lib/vedeu/presentation/styles.rb +45 -0
  41. data/lib/vedeu/{output/renderers → renderers}/all.rb +5 -5
  42. data/lib/vedeu/{output/renderers → renderers}/file.rb +0 -0
  43. data/lib/vedeu/{output/renderers → renderers}/html.rb +0 -0
  44. data/lib/vedeu/{output/renderers → renderers}/json.rb +0 -0
  45. data/lib/vedeu/{output/renderers → renderers}/options.rb +5 -1
  46. data/lib/vedeu/{output → renderers}/templates/html_renderer.vedeu +0 -0
  47. data/lib/vedeu/{output/renderers → renderers}/terminal.rb +1 -1
  48. data/lib/vedeu/repositories/all.rb +1 -0
  49. data/lib/vedeu/repositories/parent.rb +32 -0
  50. data/lib/vedeu/repositories/repositories.rb +1 -0
  51. data/lib/vedeu/runtime/flags.rb +2 -0
  52. data/lib/vedeu/templating/view_template.rb +6 -1
  53. data/lib/vedeu/version.rb +1 -1
  54. data/lib/vedeu/views/all.rb +20 -0
  55. data/lib/vedeu/{models/views → views}/char.rb +33 -21
  56. data/lib/vedeu/views/chars.rb +15 -0
  57. data/lib/vedeu/{models/views → views}/composition.rb +0 -0
  58. data/lib/vedeu/{models/views → views}/html_char.rb +0 -0
  59. data/lib/vedeu/{models/views → views}/line.rb +17 -21
  60. data/lib/vedeu/views/lines.rb +15 -0
  61. data/lib/vedeu/{models/views → views}/stream.rb +16 -20
  62. data/lib/vedeu/views/streams.rb +15 -0
  63. data/lib/vedeu/{models/views → views}/view.rb +28 -17
  64. data/lib/vedeu/views/view_collection.rb +15 -0
  65. data/lib/vedeu.rb +2 -0
  66. data/test/lib/vedeu/borders/set_attribute_test.rb +62 -0
  67. data/test/lib/vedeu/common_test.rb +6 -0
  68. data/test/lib/vedeu/cursors/cursor_test.rb +0 -8
  69. data/test/lib/vedeu/cursors/move_test.rb +73 -0
  70. data/test/lib/vedeu/cursors/repository_test.rb +3 -1
  71. data/test/lib/vedeu/dsl/lines_test.rb +12 -0
  72. data/test/lib/vedeu/dsl/streams_test.rb +13 -0
  73. data/test/lib/vedeu/events/aliases_test.rb +4 -4
  74. data/test/lib/vedeu/groups/refresh_test.rb +0 -6
  75. data/test/lib/vedeu/input/store_test.rb +2 -2
  76. data/test/lib/vedeu/interfaces/interface_test.rb +6 -1
  77. data/test/lib/vedeu/models/focus_test.rb +25 -10
  78. data/test/lib/vedeu/models/page_test.rb +6 -0
  79. data/test/lib/vedeu/models/row_test.rb +12 -0
  80. data/test/lib/vedeu/presentation/background_test.rb +72 -0
  81. data/test/lib/vedeu/presentation/colour_test.rb +67 -0
  82. data/test/lib/vedeu/presentation/foreground_test.rb +73 -0
  83. data/test/lib/vedeu/{output/presentation → presentation}/presentation_test.rb +0 -0
  84. data/test/lib/vedeu/{output/presentation → presentation}/style_test.rb +0 -0
  85. data/test/lib/vedeu/{output/presentation → presentation}/styles_test.rb +7 -9
  86. data/test/lib/vedeu/{output/renderers → renderers}/all_test.rb +3 -2
  87. data/test/lib/vedeu/{output/renderers → renderers}/file_test.rb +0 -0
  88. data/test/lib/vedeu/{output/renderers → renderers}/html_test.rb +2 -1
  89. data/test/lib/vedeu/{output/renderers → renderers}/json_test.rb +1 -0
  90. data/test/lib/vedeu/{output/renderers → renderers}/options_test.rb +10 -6
  91. data/test/lib/vedeu/{output/renderers → renderers}/terminal_test.rb +0 -0
  92. data/test/lib/vedeu/repositories/repositories_test.rb +1 -0
  93. data/test/lib/vedeu/runtime/flags_test.rb +2 -0
  94. data/test/lib/vedeu/templating/helpers_test.rb +15 -6
  95. data/test/lib/vedeu/{models/views → views}/char_test.rb +0 -0
  96. data/test/lib/vedeu/{models/views → views}/composition_test.rb +0 -0
  97. data/test/lib/vedeu/{models/views → views}/html_char_test.rb +0 -0
  98. data/test/lib/vedeu/{models/views → views}/line_test.rb +6 -1
  99. data/test/lib/vedeu/views/lines_test.rb +13 -0
  100. data/test/lib/vedeu/{models/views → views}/stream_test.rb +6 -1
  101. data/test/lib/vedeu/views/streams_test.rb +13 -0
  102. data/test/lib/vedeu/views/view_collection_test.rb +13 -0
  103. data/test/lib/vedeu/{models/views → views}/view_test.rb +6 -1
  104. data/test/support/examples/material_colours_app.rb +1 -1
  105. data/test/support/helpers/presentation_colour_test_class.rb +29 -0
  106. data/test/test_helper.rb +4 -0
  107. metadata +84 -56
  108. data/lib/vedeu/models/views/all.rb +0 -16
  109. data/lib/vedeu/null/view.rb +0 -26
  110. data/lib/vedeu/output/presentation/all.rb +0 -15
  111. data/lib/vedeu/output/presentation/colour.rb +0 -100
  112. data/lib/vedeu/output/presentation/styles.rb +0 -42
  113. data/test/lib/vedeu/null/view_test.rb +0 -31
  114. data/test/lib/vedeu/output/presentation/colour_test.rb +0 -172
@@ -69,13 +69,14 @@ module Vedeu
69
69
  # @example
70
70
  # Vedeu.focus
71
71
  #
72
- # @return [String]
72
+ # @return [NilClass|String|Symbol]
73
73
  def current
74
- return storage[0] unless storage.empty?
74
+ return nil if storage.empty?
75
75
 
76
- no_interfaces_registered!
76
+ storage[0]
77
77
  end
78
78
  alias_method :focus, :current
79
+ alias_method :name, :current
79
80
 
80
81
  # Returns a boolean indicating whether the named interface is
81
82
  # focussed.
@@ -90,6 +91,14 @@ module Vedeu
90
91
  end
91
92
  alias_method :focussed?, :current?
92
93
 
94
+ # Returns a boolean indicating whether there are interfaces
95
+ # registered.
96
+ #
97
+ # @return [Boolean]
98
+ def focus?
99
+ !storage.empty?
100
+ end
101
+
93
102
  # Put the next interface relative to the current interfaces in
94
103
  # focus.
95
104
  #
@@ -97,7 +106,7 @@ module Vedeu
97
106
  # Vedeu.trigger(:_focus_next_)
98
107
  # Vedeu.focus_next
99
108
  #
100
- # @return [String]
109
+ # @return [String|Symbol]
101
110
  def next_item
102
111
  storage.rotate!
103
112
 
@@ -108,7 +117,7 @@ module Vedeu
108
117
  # Put the next visible interface relative to the current
109
118
  # interfaces in focus.
110
119
  #
111
- # @return [String]
120
+ # @return [String|Symbol]
112
121
  def next_visible_item
113
122
  return update unless visible_items?
114
123
 
@@ -128,7 +137,7 @@ module Vedeu
128
137
  # Vedeu.trigger(:_focus_prev_)
129
138
  # Vedeu.focus_previous
130
139
  #
131
- # @return [String]
140
+ # @return [String|Symbol]
132
141
  def prev_item
133
142
  storage.rotate!(-1)
134
143
 
@@ -140,7 +149,7 @@ module Vedeu
140
149
  # Put the previous visible interface relative to the current
141
150
  # interfaces in focus.
142
151
  #
143
- # @return [String]
152
+ # @return [String|Symbol]
144
153
  def prev_visible_item
145
154
  return update unless visible_items?
146
155
 
@@ -196,13 +205,6 @@ module Vedeu
196
205
  Vedeu.interfaces.by_name(current)
197
206
  end
198
207
 
199
- # @raise [Vedeu::Error::Fatal]
200
- def no_interfaces_registered!
201
- fail Vedeu::Error::Fatal,
202
- 'No interfaces or views have been registered, therefore the ' \
203
- 'focus table is empty.'.freeze
204
- end
205
-
206
208
  # @raise [Vedeu::Error::ModelNotFound]
207
209
  def not_registered!
208
210
  fail Vedeu::Error::ModelNotFound,
@@ -244,6 +246,8 @@ module Vedeu
244
246
 
245
247
  # @!method focus
246
248
  # @see Vedeu::Models::Focus#focus
249
+ # @!method focus?
250
+ # @see Vedeu::Models::Focus#focus?
247
251
  # @!method focus_by_name
248
252
  # @see Vedeu::Models::Focus#focus_by_name
249
253
  # @!method focussed?
@@ -254,6 +258,7 @@ module Vedeu
254
258
  # @see Vedeu::Models::Focus#focus_previous
255
259
  def_delegators Vedeu::Models::Focus,
256
260
  :focus,
261
+ :focus?,
257
262
  :focus_by_name,
258
263
  :focussed?,
259
264
  :focus_next,
@@ -91,6 +91,11 @@ module Vedeu
91
91
  rows[index]
92
92
  end
93
93
 
94
+ # @return [Fixnum]
95
+ def size
96
+ rows.size
97
+ end
98
+
94
99
  end # Page
95
100
 
96
101
  end # Models
@@ -82,6 +82,11 @@ module Vedeu
82
82
  Vedeu::Views::Char.new(value: Vedeu::EscapeSequences::Esc.reset)
83
83
  end
84
84
 
85
+ # @return [Fixnum]
86
+ def size
87
+ cells.size
88
+ end
89
+
85
90
  end # Row
86
91
 
87
92
  end # Models
@@ -134,7 +134,12 @@ module Vedeu
134
134
  # @param name [String|Symbol]
135
135
  # @return [Boolean]
136
136
  def cursor_visible?(name)
137
- Vedeu.buffers.by_name(name).cursor_visible?
137
+ buffer(name).cursor_visible?
138
+ end
139
+
140
+ # @return [Vedeu::Buffers::Buffer]
141
+ def buffer(name)
142
+ Vedeu.buffers.by_name(name)
138
143
  end
139
144
 
140
145
  end # ClassMethods
@@ -13,4 +13,3 @@ module Vedeu
13
13
  end # Vedeu
14
14
 
15
15
  require 'vedeu/null/generic'
16
- require 'vedeu/null/view'
@@ -12,7 +12,5 @@ require 'vedeu/output/text'
12
12
  require 'vedeu/output/output'
13
13
  require 'vedeu/output/viewport'
14
14
  require 'vedeu/output/wordwrap'
15
- require 'vedeu/output/presentation/all'
16
15
  require 'vedeu/output/refresh'
17
- require 'vedeu/output/renderers/all'
18
16
  require 'vedeu/output/write'
@@ -12,6 +12,7 @@ module Vedeu
12
12
  class Compressor
13
13
 
14
14
  include Vedeu::Common
15
+ include Vedeu::Renderers::Options
15
16
 
16
17
  # @param (see #initialize)
17
18
  # @return [String]
@@ -37,7 +38,7 @@ module Vedeu
37
38
  # - Takes approximately ~25ms for 2100 chars. (2015-07-25)
38
39
  # @return [String]
39
40
  def render
40
- return cached if Vedeu::Configuration.compression?
41
+ return cached if compress?
41
42
 
42
43
  uncompress
43
44
  end
@@ -137,6 +137,11 @@ module Vedeu
137
137
  options[:ellipsis]
138
138
  end
139
139
 
140
+ # @return [Vedeu::Geometries::Geometry]
141
+ def geometry
142
+ Vedeu.geometry.by_name(name)
143
+ end
144
+
140
145
  # Returns the word wrapping mode. One of :default, :prune or
141
146
  # :wrap;
142
147
  #
@@ -174,7 +179,7 @@ module Vedeu
174
179
  # @return [Fixnum]
175
180
  def width
176
181
  return options[:width] if present?(options[:width])
177
- return Vedeu.geometries.by_name(name).width if registered?
182
+ return geometry.width if registered?
178
183
 
179
184
  fail Vedeu::Error::MissingRequired,
180
185
  'The text provided cannot be wrapped or pruned because a :width ' \
@@ -32,6 +32,8 @@ module Vedeu
32
32
  def initialize(output = nil, options = {})
33
33
  @output = output
34
34
  @options = options
35
+ @colour = options[:colour]
36
+ @style = options[:style]
35
37
  end
36
38
 
37
39
  # @return [NilClass]
@@ -0,0 +1,17 @@
1
+ module Vedeu
2
+
3
+ # This module allows the sharing of presentation concerns between
4
+ # the models: Interface, View, Line and Stream.
5
+ #
6
+ module Presentation
7
+
8
+ end # Presentation
9
+
10
+ end # Vedeu
11
+
12
+ require 'vedeu/presentation/background'
13
+ require 'vedeu/presentation/foreground'
14
+ require 'vedeu/presentation/colour'
15
+ require 'vedeu/presentation/styles'
16
+ require 'vedeu/presentation/style'
17
+ require 'vedeu/presentation/presentation'
@@ -0,0 +1,47 @@
1
+ module Vedeu
2
+
3
+ module Presentation
4
+
5
+ module Colour
6
+
7
+ module Background
8
+
9
+ include Vedeu::Repositories::Parent
10
+
11
+ # When the background colour for the model exists, return it,
12
+ # otherwise returns the parent background colour, or an empty
13
+ # Vedeu::Colours::Background.
14
+ #
15
+ # @return [Vedeu::Colours::Background]
16
+ def background
17
+ @background ||= if colour && present?(colour.background)
18
+ colour.background
19
+
20
+ elsif self.is_a?(Vedeu::Views::Char) && name
21
+ interface.colour.background
22
+
23
+ elsif parent && present?(parent.background)
24
+ parent.background
25
+
26
+ else
27
+ Vedeu::Colours::Background.new
28
+
29
+ end
30
+ end
31
+
32
+ # Allows the setting of the background colour by coercing the
33
+ # given value into a Vedeu::Colours::Background colour.
34
+ #
35
+ # @return [Vedeu::Colours::Background]
36
+ def background=(value)
37
+ @background = colour.background = value
38
+ @_colour = @colour = colour
39
+ end
40
+
41
+ end # Background
42
+
43
+ end # Colour
44
+
45
+ end # Presentation
46
+
47
+ end # Vedeu
@@ -0,0 +1,42 @@
1
+ module Vedeu
2
+
3
+ module Presentation
4
+
5
+ # Provides colour related presentation behaviour.
6
+ #
7
+ module Colour
8
+
9
+ include Vedeu::Repositories::Parent
10
+ include Vedeu::Presentation::Colour::Background
11
+ include Vedeu::Presentation::Colour::Foreground
12
+
13
+ # @return [Vedeu::Colours::Colour]
14
+ def colour
15
+ @_colour ||= if @colour
16
+ Vedeu::Colours::Colour.coerce(@colour)
17
+
18
+ elsif self.is_a?(Vedeu::Views::Char) && name
19
+ Vedeu::Colours::Colour.coerce(interface.colour)
20
+
21
+ elsif parent && present?(parent.colour)
22
+ Vedeu::Colours::Colour.coerce(parent.colour)
23
+
24
+ else
25
+ Vedeu::Colours::Colour.new
26
+
27
+ end
28
+ end
29
+
30
+ # Allows the setting of the model's colour by coercing the given
31
+ # value into a Vedeu::Colours::Colour.
32
+ #
33
+ # @return [Vedeu::Colours::Colour]
34
+ def colour=(value)
35
+ @_colour = @colour = Vedeu::Colours::Colour.coerce(value)
36
+ end
37
+
38
+ end # Colour
39
+
40
+ end # Presentation
41
+
42
+ end # Vedeu
@@ -0,0 +1,47 @@
1
+ module Vedeu
2
+
3
+ module Presentation
4
+
5
+ module Colour
6
+
7
+ module Foreground
8
+
9
+ include Vedeu::Repositories::Parent
10
+
11
+ # When the foreground colour for the model exists, return it,
12
+ # otherwise returns the parent foreground colour, or an empty
13
+ # Vedeu::Colours::Foreground.
14
+ #
15
+ # @return [Vedeu::Colours::Foreground]
16
+ def foreground
17
+ @foreground ||= if colour && present?(colour.foreground)
18
+ colour.foreground
19
+
20
+ elsif self.is_a?(Vedeu::Views::Char) && name
21
+ interface.colour.foreground
22
+
23
+ elsif parent && present?(parent.foreground)
24
+ parent.foreground
25
+
26
+ else
27
+ Vedeu::Colours::Foreground.new
28
+
29
+ end
30
+ end
31
+
32
+ # Allows the setting of the foreground colour by coercing the
33
+ # given value into a Vedeu::Colours::Foreground colour.
34
+ #
35
+ # @return [Vedeu::Colours::Foreground]
36
+ def foreground=(value)
37
+ @foreground = colour.foreground = value
38
+ @_colour = @colour = colour
39
+ end
40
+
41
+ end # Foreground
42
+
43
+ end # Colour
44
+
45
+ end # Presentation
46
+
47
+ end # Vedeu
@@ -0,0 +1,45 @@
1
+ module Vedeu
2
+
3
+ module Presentation
4
+
5
+ # Provides style related presentation behaviour.
6
+ #
7
+ module Styles
8
+
9
+ include Vedeu::Common
10
+ include Vedeu::Repositories::Parent
11
+
12
+ # When the style for the model exists, return it, otherwise
13
+ # returns the parent style, or an empty
14
+ # {Vedeu::Presentation::Style}.
15
+ #
16
+ # @return [Vedeu::Presentation::Style]
17
+ def style
18
+ @_style ||= if @style
19
+ Vedeu::Presentation::Style.coerce(@style)
20
+
21
+ elsif self.is_a?(Vedeu::Views::Char) && name
22
+ Vedeu::Presentation::Style.coerce(interface.style)
23
+
24
+ elsif parent && present?(parent.style)
25
+ Vedeu::Presentation::Style.coerce(parent.style)
26
+
27
+ else
28
+ Vedeu::Presentation::Style.new
29
+
30
+ end
31
+ end
32
+
33
+ # Allows the setting of the style by coercing the given value
34
+ # into a {Vedeu::Presentation::Style}.
35
+ #
36
+ # @return [Vedeu::Presentation::Style]
37
+ def style=(value)
38
+ @_style = @style = Vedeu::Presentation::Style.coerce(value)
39
+ end
40
+
41
+ end # Style
42
+
43
+ end # Presentation
44
+
45
+ end # Vedeu
@@ -140,8 +140,8 @@ module Vedeu
140
140
 
141
141
  end # Vedeu
142
142
 
143
- require 'vedeu/output/renderers/options'
144
- require 'vedeu/output/renderers/file'
145
- require 'vedeu/output/renderers/html'
146
- require 'vedeu/output/renderers/json'
147
- require 'vedeu/output/renderers/terminal'
143
+ require 'vedeu/renderers/options'
144
+ require 'vedeu/renderers/file'
145
+ require 'vedeu/renderers/html'
146
+ require 'vedeu/renderers/json'
147
+ require 'vedeu/renderers/terminal'
File without changes
File without changes
File without changes
@@ -12,8 +12,12 @@ module Vedeu
12
12
  # @return [Hash<Symbol => void>]
13
13
  attr_writer :options
14
14
 
15
+ # Returns a boolean indicating whether the content should be
16
+ # compressed if compression is available.
17
+ #
18
+ # @return [Boolean]
15
19
  def compress?
16
- options[:compression] || false
20
+ options[:compression] || Vedeu::Configuration.compression? || false
17
21
  end
18
22
 
19
23
  private
@@ -35,7 +35,7 @@ module Vedeu
35
35
  # @param output [Vedeu::Models::Page]
36
36
  # @return [Array<Array<Vedeu::Views::Char>>]
37
37
  def parse(output)
38
- Vedeu::Output::Compressor.render(output)
38
+ Vedeu::Output::Compressor.render(output, options)
39
39
  end
40
40
 
41
41
  end # Terminal
@@ -13,6 +13,7 @@ require 'vedeu/repositories/collection'
13
13
  require 'vedeu/repositories/defaults'
14
14
  require 'vedeu/repositories/repositories'
15
15
  require 'vedeu/repositories/model'
16
+ require 'vedeu/repositories/parent'
16
17
  require 'vedeu/repositories/store'
17
18
  require 'vedeu/repositories/registerable'
18
19
  require 'vedeu/repositories/repository'
@@ -0,0 +1,32 @@
1
+ module Vedeu
2
+
3
+ module Repositories
4
+
5
+ # When included into a class, provides the mechanism to retrieve
6
+ # the parent object for the class if available.
7
+ #
8
+ module Parent
9
+
10
+ include Vedeu::Common
11
+
12
+ # @return [NilClass|void]
13
+ def parent
14
+ @_parent ||= present?(@parent) ? @parent : nil
15
+ end
16
+
17
+ # @return [NilClass|String|Symbol]
18
+ def name
19
+ @_name ||= if present?(@name)
20
+ @name
21
+
22
+ elsif parent && present?(parent.name)
23
+ parent.name
24
+
25
+ end
26
+ end
27
+
28
+ end # Parent
29
+
30
+ end # Repositories
31
+
32
+ end # Vedeu
@@ -44,6 +44,7 @@ module Vedeu
44
44
 
45
45
  true
46
46
  end
47
+ alias_method :reset, :reset!
47
48
 
48
49
  private
49
50
 
@@ -26,6 +26,7 @@ module Vedeu
26
26
  def reset!
27
27
  instance.reset!
28
28
  end
29
+ alias_method :reset, :reset!
29
30
 
30
31
  end # Eigenclass
31
32
 
@@ -44,6 +45,7 @@ module Vedeu
44
45
  def reset!
45
46
  self.options = defaults
46
47
  end
48
+ alias_method :reset, :reset!
47
49
 
48
50
  private
49
51
 
@@ -76,10 +76,15 @@ module Vedeu
76
76
  #
77
77
  # @return (see Vedeu::Interfaces::Repository#by_name)
78
78
  def interface
79
- Vedeu.interfaces.by_name(options[:name])
79
+ Vedeu.interfaces.by_name(name)
80
80
  end
81
81
  alias_method :interface?, :interface
82
82
 
83
+ # @return [String|Symbol]
84
+ def name
85
+ options[:name]
86
+ end
87
+
83
88
  # Returns the stream directives for the line.
84
89
  #
85
90
  # @param line [String]
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.69'.freeze
4
+ VERSION = '0.6.70'.freeze
5
5
 
6
6
  end
@@ -0,0 +1,20 @@
1
+ module Vedeu
2
+
3
+ # View related models.
4
+ #
5
+ module Views
6
+
7
+ end # Views
8
+
9
+ end # Vedeu
10
+
11
+ require 'vedeu/views/chars'
12
+ require 'vedeu/views/char'
13
+ require 'vedeu/views/html_char'
14
+ require 'vedeu/views/streams'
15
+ require 'vedeu/views/stream'
16
+ require 'vedeu/views/lines'
17
+ require 'vedeu/views/line'
18
+ require 'vedeu/views/view_collection'
19
+ require 'vedeu/views/view'
20
+ require 'vedeu/views/composition'
@@ -2,14 +2,6 @@ module Vedeu
2
2
 
3
3
  module Views
4
4
 
5
- # A collection of {Vedeu::Views::Char} instances.
6
- #
7
- # @api private
8
- #
9
- class Chars < Vedeu::Repositories::Collection
10
-
11
- end # Chars
12
-
13
5
  # A Char represents a single character of the terminal. It is a
14
6
  # container for the a single character in a
15
7
  # {Vedeu::Views::Stream}.
@@ -20,12 +12,9 @@ module Vedeu
20
12
  class Char
21
13
 
22
14
  include Comparable
15
+ include Vedeu::Repositories::Parent
23
16
  include Vedeu::Presentation
24
17
 
25
- # @!attribute [r] attributes
26
- # @return [Hash]
27
- attr_reader :attributes
28
-
29
18
  # @!attribute [rw] border
30
19
  # @return [NilClass|Symbol]
31
20
  attr_accessor :border
@@ -56,11 +45,22 @@ module Vedeu
56
45
  # @option attributes value [String]
57
46
  # @return [Vedeu::Views::Char]
58
47
  def initialize(attributes = {})
59
- @attributes = attributes
60
- @border = @attributes[:border]
61
- @name = @attributes[:name]
62
- @parent = @attributes[:parent]
63
- @value = @attributes[:value]
48
+ defaults.merge!(attributes).each do |key, value|
49
+ instance_variable_set("@#{key}", value)
50
+ end
51
+ end
52
+
53
+ # @return [Hash<Symbol => void>]
54
+ def attributes
55
+ {
56
+ border: @border,
57
+ # colour: colour,
58
+ name: @name,
59
+ parent: @parent,
60
+ position: position,
61
+ style: @style,
62
+ value: value,
63
+ }
64
64
  end
65
65
 
66
66
  # @return [Boolean]
@@ -96,16 +96,15 @@ module Vedeu
96
96
 
97
97
  # @return [Vedeu::Geometries::Position]
98
98
  def position
99
- @position ||= Vedeu::Geometries::Position.coerce(@attributes[:position])
99
+ @_position ||= Vedeu::Geometries::Position.coerce(@position)
100
100
  end
101
101
 
102
102
  # Sets the position of the Vedeu::Views::Char.
103
103
  #
104
- # @param value [Vedeu::Geometries::Position]
104
+ # @param value [Array<void>|Hash<void>|Vedeu::Geometries::Position]
105
105
  # @return [Vedeu::Geometries::Position]
106
106
  def position=(value)
107
- @position = @attributes[:position] = Vedeu::Geometries::Position
108
- .coerce(value)
107
+ @_position = @position = Vedeu::Geometries::Position.coerce(value)
109
108
  end
110
109
 
111
110
  # @return [String]
@@ -166,6 +165,19 @@ module Vedeu
166
165
  }
167
166
  end
168
167
 
168
+ # @return [Hash<Symbol => void>]
169
+ def defaults
170
+ {
171
+ border: nil,
172
+ colour: nil,
173
+ name: nil,
174
+ parent: nil,
175
+ position: nil,
176
+ style: nil,
177
+ value: '',
178
+ }
179
+ end
180
+
169
181
  # @return [Hash<Symbol => String>]
170
182
  def parent_to_hash
171
183
  return {} unless parent