vedeu 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/all.rb +2 -13
  3. data/lib/vedeu/api.rb +9 -9
  4. data/lib/vedeu/application/application_view.rb +3 -5
  5. data/lib/vedeu/bindings/bindings.rb +5 -1
  6. data/lib/vedeu/bindings/focus.rb +0 -5
  7. data/lib/vedeu/bindings/refresh.rb +0 -5
  8. data/lib/vedeu/bindings/system.rb +1 -6
  9. data/lib/vedeu/colours/all.rb +17 -0
  10. data/lib/vedeu/colours/background.rb +32 -28
  11. data/lib/vedeu/colours/backgrounds.rb +13 -9
  12. data/lib/vedeu/colours/colour.rb +106 -102
  13. data/lib/vedeu/colours/foreground.rb +32 -28
  14. data/lib/vedeu/colours/foregrounds.rb +13 -9
  15. data/lib/vedeu/colours/repository.rb +70 -0
  16. data/lib/vedeu/colours/translator.rb +267 -0
  17. data/lib/vedeu/configuration/api.rb +10 -7
  18. data/lib/vedeu/configuration/configuration.rb +2 -1
  19. data/lib/vedeu/dsl/border.rb +15 -2
  20. data/lib/vedeu/dsl/composition.rb +6 -4
  21. data/lib/vedeu/dsl/geometry.rb +14 -7
  22. data/lib/vedeu/dsl/group.rb +2 -2
  23. data/lib/vedeu/dsl/interface.rb +5 -3
  24. data/lib/vedeu/dsl/keymap.rb +9 -7
  25. data/lib/vedeu/dsl/line.rb +7 -4
  26. data/lib/vedeu/dsl/menu.rb +3 -0
  27. data/lib/vedeu/dsl/presentation.rb +20 -10
  28. data/lib/vedeu/dsl/shared.rb +4 -4
  29. data/lib/vedeu/dsl/stream.rb +2 -2
  30. data/lib/vedeu/dsl/text.rb +11 -5
  31. data/lib/vedeu/dsl/use.rb +2 -2
  32. data/lib/vedeu/dsl/view.rb +8 -6
  33. data/lib/vedeu/events/aliases.rb +91 -0
  34. data/lib/vedeu/events/all.rb +15 -0
  35. data/lib/vedeu/events/collection.rb +13 -0
  36. data/lib/vedeu/events/event.rb +244 -239
  37. data/lib/vedeu/events/repository.rb +30 -0
  38. data/lib/vedeu/events/trigger.rb +68 -64
  39. data/lib/vedeu/exceptions.rb +65 -54
  40. data/lib/vedeu/geometry/coordinate.rb +3 -1
  41. data/lib/vedeu/geometry/grid.rb +2 -4
  42. data/lib/vedeu/input/editor/all.rb +2 -1
  43. data/lib/vedeu/input/editor/{virtual_cursor.rb → cursor.rb} +10 -10
  44. data/lib/vedeu/input/editor/document.rb +7 -7
  45. data/lib/vedeu/input/editor/insert.rb +70 -0
  46. data/lib/vedeu/input/editor/line.rb +4 -16
  47. data/lib/vedeu/input/editor/lines.rb +2 -16
  48. data/lib/vedeu/input/input_translator.rb +2 -2
  49. data/lib/vedeu/input/key.rb +2 -2
  50. data/lib/vedeu/internal_api.rb +6 -6
  51. data/lib/vedeu/log/lockless_log_device.rb +0 -74
  52. data/lib/vedeu/models/focus.rb +3 -3
  53. data/lib/vedeu/models/interface.rb +3 -3
  54. data/lib/vedeu/models/menu.rb +2 -2
  55. data/lib/vedeu/models/views/char.rb +1 -1
  56. data/lib/vedeu/models/views/composition.rb +1 -1
  57. data/lib/vedeu/models/views/line.rb +1 -1
  58. data/lib/vedeu/models/views/stream.rb +1 -1
  59. data/lib/vedeu/models/views/view.rb +6 -7
  60. data/lib/vedeu/output/presentation/colour.rb +23 -21
  61. data/lib/vedeu/output/renderers/renderer_options.rb +2 -4
  62. data/lib/vedeu/output/text.rb +1 -1
  63. data/lib/vedeu/output/wordwrap.rb +18 -7
  64. data/lib/vedeu/plugins/plugin.rb +2 -2
  65. data/lib/vedeu/refresh/refresh_buffer.rb +3 -3
  66. data/lib/vedeu/refresh/refresh_group.rb +3 -3
  67. data/lib/vedeu/repositories/repository.rb +7 -6
  68. data/lib/vedeu/runtime/application.rb +1 -1
  69. data/lib/vedeu/runtime/main_loop.rb +3 -3
  70. data/lib/vedeu/runtime/router.rb +14 -11
  71. data/lib/vedeu/templating/helpers.rb +5 -5
  72. data/lib/vedeu/templating/template.rb +4 -4
  73. data/lib/vedeu/templating/view_template.rb +1 -1
  74. data/lib/vedeu/terminal/terminal.rb +2 -2
  75. data/lib/vedeu/version.rb +1 -1
  76. data/test/lib/vedeu/application/application_view_test.rb +1 -1
  77. data/test/lib/vedeu/colours/background_test.rb +93 -89
  78. data/test/lib/vedeu/colours/backgrounds_test.rb +11 -7
  79. data/test/lib/vedeu/colours/colour_test.rb +155 -151
  80. data/test/lib/vedeu/colours/foreground_test.rb +93 -89
  81. data/test/lib/vedeu/colours/foregrounds_test.rb +11 -7
  82. data/test/lib/vedeu/colours/repository_test.rb +97 -0
  83. data/test/lib/vedeu/colours/translator_test.rb +173 -0
  84. data/test/lib/vedeu/configuration/api_test.rb +4 -4
  85. data/test/lib/vedeu/dsl/border_test.rb +12 -0
  86. data/test/lib/vedeu/dsl/composition_test.rb +3 -3
  87. data/test/lib/vedeu/dsl/geometry_test.rb +11 -0
  88. data/test/lib/vedeu/dsl/group_test.rb +2 -2
  89. data/test/lib/vedeu/dsl/interface_test.rb +4 -4
  90. data/test/lib/vedeu/dsl/keymap_test.rb +8 -4
  91. data/test/lib/vedeu/dsl/line_test.rb +6 -3
  92. data/test/lib/vedeu/dsl/menu_test.rb +6 -0
  93. data/test/lib/vedeu/dsl/presentation_test.rb +16 -3
  94. data/test/lib/vedeu/dsl/stream_test.rb +1 -1
  95. data/test/lib/vedeu/dsl/text_test.rb +7 -0
  96. data/test/lib/vedeu/dsl/view_test.rb +3 -3
  97. data/test/lib/vedeu/events/aliases_test.rb +144 -0
  98. data/test/lib/vedeu/events/collection_test.rb +22 -0
  99. data/test/lib/vedeu/events/event_test.rb +84 -80
  100. data/test/lib/vedeu/events/repository_test.rb +28 -0
  101. data/test/lib/vedeu/events/trigger_test.rb +41 -37
  102. data/test/lib/vedeu/geometry/grid_test.rb +4 -4
  103. data/test/lib/vedeu/input/editor/{virtual_cursor_test.rb → cursor_test.rb} +3 -3
  104. data/test/lib/vedeu/input/editor/insert_test.rb +36 -0
  105. data/test/lib/vedeu/input/key_test.rb +1 -1
  106. data/test/lib/vedeu/models/cell_test.rb +1 -1
  107. data/test/lib/vedeu/models/focus_test.rb +4 -2
  108. data/test/lib/vedeu/models/menu_test.rb +1 -1
  109. data/test/lib/vedeu/models/views/char_test.rb +8 -4
  110. data/test/lib/vedeu/models/views/line_test.rb +4 -4
  111. data/test/lib/vedeu/models/views/stream_test.rb +3 -3
  112. data/test/lib/vedeu/models/views/view_test.rb +1 -1
  113. data/test/lib/vedeu/output/html_char_test.rb +4 -2
  114. data/test/lib/vedeu/output/presentation/colour_test.rb +5 -5
  115. data/test/lib/vedeu/output/presentation_test.rb +4 -4
  116. data/test/lib/vedeu/output/renderers/json_test.rb +4 -2
  117. data/test/lib/vedeu/plugins/plugin_test.rb +1 -1
  118. data/test/lib/vedeu/refresh/refresh_buffer_test.rb +1 -1
  119. data/test/lib/vedeu/refresh/refresh_group_test.rb +1 -1
  120. data/test/lib/vedeu/repositories/repository_test.rb +2 -2
  121. data/test/lib/vedeu/runtime/router_test.rb +6 -6
  122. data/test/lib/vedeu/templating/decoder_test.rb +2 -3
  123. data/test/lib/vedeu/templating/encoder_test.rb +2 -3
  124. data/test/lib/vedeu/templating/helpers_test.rb +6 -6
  125. data/test/lib/vedeu/templating/template_test.rb +2 -2
  126. data/test/lib/vedeu/templating/view_template_test.rb +13 -7
  127. data/test/lib/vedeu/terminal/terminal_test.rb +3 -3
  128. metadata +24 -19
  129. data/lib/vedeu/colours/colour_translator.rb +0 -260
  130. data/lib/vedeu/colours/colours.rb +0 -66
  131. data/lib/vedeu/events/event_aliases.rb +0 -87
  132. data/lib/vedeu/events/event_collection.rb +0 -9
  133. data/lib/vedeu/events/events.rb +0 -26
  134. data/test/lib/vedeu/colours/colour_translator_test.rb +0 -169
  135. data/test/lib/vedeu/colours/colours_test.rb +0 -93
  136. data/test/lib/vedeu/events/event_aliases_test.rb +0 -140
  137. data/test/lib/vedeu/events/event_collection_test.rb +0 -18
  138. data/test/lib/vedeu/events/events_test.rb +0 -24
@@ -267,14 +267,14 @@ module Vedeu
267
267
  # Return a virtual cursor to track the cursor position within the
268
268
  # document.
269
269
  #
270
- # @return [Vedeu::Editor::VirtualCursor]
270
+ # @return [Vedeu::Editor::Cursor]
271
271
  def cursor
272
- @cursor ||= Vedeu::Editor::VirtualCursor.new(y: 0,
273
- x: 0,
274
- by: by,
275
- bx: bx,
276
- byn: byn,
277
- bxn: bxn)
272
+ @cursor ||= Vedeu::Editor::Cursor.new(y: 0,
273
+ x: 0,
274
+ by: by,
275
+ bx: bx,
276
+ byn: byn,
277
+ bxn: bxn)
278
278
  end
279
279
 
280
280
  # Return only the visible lines for the document based on the current
@@ -0,0 +1,70 @@
1
+ module Vedeu
2
+
3
+ module Editor
4
+
5
+ # Manipulate the lines of an Vedeu::Editor::Document.
6
+ #
7
+ class Insert
8
+
9
+ # @return [Vedeu::Editor::Line|Vedeu::Editor::Lines]
10
+ # @see #initialize
11
+ def self.into(collection, entity, index = nil, size = 0)
12
+ new(collection, entity, index, size).insert
13
+ end
14
+
15
+ # Returns a new instance of Vedeu::Editor::Insert.
16
+ #
17
+ # @param collection [Vedeu::Editor::Line|Vedeu::Editor::Lines]
18
+ # @param entity [String]
19
+ # @param index [Fixnum]
20
+ # @param size [Fixnum]
21
+ # @return [Vedeu::Editor::Insert]
22
+ def initialize(collection, entity, index = nil, size = 0)
23
+ @collection = collection
24
+ @entity = entity
25
+ @index = index
26
+ @size = size
27
+ end
28
+
29
+ # @return [Vedeu::Editor::Line|Vedeu::Editor::Lines]
30
+ def insert
31
+ if index
32
+ if index <= 0
33
+ collection.insert(0, entity)
34
+
35
+ elsif index >= size
36
+ collection << entity
37
+
38
+ else
39
+ collection.insert(index, entity)
40
+
41
+ end
42
+ else
43
+ collection << entity
44
+
45
+ end
46
+ end
47
+
48
+ protected
49
+
50
+ # @!attribute [r] collection
51
+ # @return [Vedeu::Editor::Line|Vedeu::Editor::Lines]
52
+ attr_reader :collection
53
+
54
+ # @!attribute [r] entity
55
+ # @return [String]
56
+ attr_reader :entity
57
+
58
+ # @!attribute [r] index
59
+ # @return [Fixnum]
60
+ attr_reader :index
61
+
62
+ # @!attribute [r] size
63
+ # @return [Fixnum]
64
+ attr_reader :size
65
+
66
+ end # Insert
67
+
68
+ end # Editor
69
+
70
+ end # Vedeu
@@ -101,25 +101,13 @@ module Vedeu
101
101
  #
102
102
  # @param character [String]
103
103
  # @param index [Fixnum|NilClass]
104
- # @return [String]
104
+ # @return [Vedeu::Editor::Line]
105
105
  def insert_character(character, index = nil)
106
- new_line = if index
107
- if index <= 0
108
- line.insert(0, character)
109
-
110
- elsif index >= size
111
- line << character
112
-
113
- else
114
- line.insert(index, character)
106
+ return self unless character
115
107
 
116
- end
117
- else
118
- line + character
119
-
120
- end
108
+ insert = Vedeu::Editor::Insert.into(line, character, index, size)
121
109
 
122
- Vedeu::Editor::Line.coerce(new_line)
110
+ Vedeu::Editor::Line.coerce(insert)
123
111
  end
124
112
 
125
113
  # Return the size of the line in characters.
@@ -137,23 +137,9 @@ module Vedeu
137
137
  def insert_line(line, index = nil)
138
138
  return self unless line
139
139
 
140
- new_lines = if index
141
- if index <= 0
142
- lines.insert(0, line)
140
+ insert = Vedeu::Editor::Insert.into(lines, line, index, size)
143
141
 
144
- elsif index >= size
145
- lines << line
146
-
147
- else
148
- lines.insert(index, line)
149
-
150
- end
151
- else
152
- lines << line
153
-
154
- end
155
-
156
- Vedeu::Editor::Lines.coerce(new_lines)
142
+ Vedeu::Editor::Lines.coerce(insert)
157
143
  end
158
144
 
159
145
  # Returns the line at the given index.
@@ -37,7 +37,7 @@ module Vedeu
37
37
  @symbols ||= f_keys.merge!(ctrl_letters).merge!(specials)
38
38
  end
39
39
 
40
- # @return [Hash<String => Symbol]
40
+ # @return [Hash<String => Symbol>]
41
41
  def ctrl_letters
42
42
  {
43
43
  "\u0001" => :ctrl_a,
@@ -72,7 +72,7 @@ module Vedeu
72
72
  }
73
73
  end
74
74
 
75
- # @return [Hash<String => Symbol]
75
+ # @return [Hash<String => Symbol>]
76
76
  def f_keys
77
77
  {
78
78
  "\eOP" => :f1,
@@ -13,10 +13,10 @@ module Vedeu
13
13
  #
14
14
  # @param input [String|Symbol]
15
15
  # @param block [Proc]
16
- # @raise [Vedeu::InvalidSyntax] The required block was not given.
16
+ # @raise [Vedeu::Error::InvalidSyntax] The required block was not given.
17
17
  # @return [Vedeu::Key]
18
18
  def initialize(input = nil, &block)
19
- fail Vedeu::InvalidSyntax, 'block not given' unless block_given?
19
+ fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
20
20
 
21
21
  @input = input
22
22
  @output = block
@@ -16,8 +16,8 @@ module Vedeu
16
16
  # Vedeu.background_colours
17
17
  #
18
18
  # @!method background_colours
19
- # @return [Vedeu::Backgrounds]
20
- def_delegators Vedeu::Backgrounds, :background_colours
19
+ # @return [Vedeu::Colours::Backgrounds]
20
+ def_delegators Vedeu::Colours::Backgrounds, :background_colours
21
21
 
22
22
  # Manipulate the repository of borders.
23
23
  #
@@ -70,8 +70,8 @@ module Vedeu
70
70
  # Vedeu.events
71
71
  #
72
72
  # @!method events
73
- # @return [Vedeu::Events]
74
- def_delegators Vedeu::Events, :events
73
+ # @return [Vedeu::Events::Repository]
74
+ def_delegators Vedeu::Events::Repository, :events
75
75
 
76
76
  # Manipulate the repository of foreground colours.
77
77
  #
@@ -79,8 +79,8 @@ module Vedeu
79
79
  # Vedeu.foreground_colours
80
80
  #
81
81
  # @!method foreground_colours
82
- # @return [Vedeu::Foregrounds]
83
- def_delegators Vedeu::Foregrounds, :foreground_colours
82
+ # @return [Vedeu::Colours::Foregrounds]
83
+ def_delegators Vedeu::Colours::Foregrounds, :foreground_colours
84
84
 
85
85
  # Manipulate the repository of geometries.
86
86
  #
@@ -59,77 +59,3 @@ module Vedeu
59
59
  end # LocklessLogDevice
60
60
 
61
61
  end # Vedeu
62
-
63
- # module Vedeu
64
-
65
- # # Ensures we can always write to the log file by creating a lock-less
66
- # # log device.
67
- # #
68
- # class LocklessLogDevice < Logger::LogDevice
69
-
70
- # # Returns a new instance of Vedeu::LocklessLogDevice.
71
- # #
72
- # # @param file_or_filename [void]
73
- # # @return [Vedeu::LocklessLogDevice]
74
- # def initialize(file_or_filename = nil)
75
- # @file_or_filename = file_or_filename
76
- # end
77
-
78
- # # @param message [String]
79
- # # @return [void]
80
- # def write(message)
81
- # device.write(message)
82
-
83
- # rescue StandardError => exception
84
- # warn("Log writing failed. #{exception}")
85
-
86
- # end
87
-
88
- # # @return [void]
89
- # def close
90
- # device.close
91
-
92
- # rescue
93
- # nil
94
-
95
- # end
96
-
97
- # protected
98
-
99
- # # @!attribute [r] file_or_filename
100
- # # @return [String]
101
- # attr_reader :file_or_filename
102
- # alias_method :file, :file_or_filename
103
- # alias_method :filename, :file_or_filename
104
-
105
- # private
106
-
107
- # # @return [File]
108
- # def device
109
- # if file?
110
- # file
111
-
112
- # elsif exists?
113
- # open(filename, (File::WRONLY | File::APPEND))
114
-
115
- # else
116
- # device = open(filename, (File::WRONLY | File::APPEND | File::CREAT))
117
- # device.sync = true
118
-
119
- # end
120
- # end
121
-
122
- # # @return [Boolean]
123
- # def exists?
124
- # FileTest.exist?(filename)
125
- # end
126
-
127
- # # @return [Boolean]
128
- # def file?
129
- # file_or_filename.respond_to?(:write) &&
130
- # file_or_filename.respond_to?(:close)
131
- # end
132
-
133
- # end # LocklessLogDevice
134
-
135
- # end # Vedeu
@@ -49,12 +49,12 @@ module Vedeu
49
49
  # Vedeu.focus_by_name('name')
50
50
  #
51
51
  # @param name [String] The interface to focus; must be defined.
52
- # @raise [Vedeu::ModelNotFound] When the interface cannot be found.
52
+ # @raise [Vedeu::Error::ModelNotFound] When the interface cannot be found.
53
53
  # @return [String] The name of the interface now in focus.
54
54
  def by_name(name)
55
55
  unless registered?(name)
56
- fail Vedeu::ModelNotFound, "Cannot focus '#{name}' as this interface " \
57
- 'has not been registered.'
56
+ fail Vedeu::Error::ModelNotFound,
57
+ "Cannot focus '#{name}' as this interface has not been registered."
58
58
  end
59
59
 
60
60
  storage.rotate!(storage.index(name))
@@ -41,7 +41,7 @@ module Vedeu
41
41
  #
42
42
  # @param attributes [Hash]
43
43
  # @option attributes client [Vedeu::Client]
44
- # @option attributes colour [Vedeu::Colour]
44
+ # @option attributes colour [Vedeu::Colours::Colour]
45
45
  # @option attributes delay [Float]
46
46
  # @option attributes group [String]
47
47
  # @option attributes name [String]
@@ -91,8 +91,8 @@ module Vedeu
91
91
  def defaults
92
92
  {
93
93
  client: nil,
94
- colour: Vedeu::Colour.coerce(background: :default,
95
- foreground: :default),
94
+ colour: Vedeu::Colours::Colour.coerce(background: :default,
95
+ foreground: :default),
96
96
  delay: 0.0,
97
97
  group: '',
98
98
  name: '',
@@ -49,10 +49,10 @@ module Vedeu
49
49
  # # ...
50
50
  # end
51
51
  #
52
- # @raise [Vedeu::InvalidSyntax] The required block was not given.
52
+ # @raise [Vedeu::Error::InvalidSyntax] The required block was not given.
53
53
  # @return [API::Menu]
54
54
  def self.menu(name = '', &block)
55
- fail Vedeu::InvalidSyntax, 'block not given' unless block_given?
55
+ fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
56
56
 
57
57
  build(name: name, &block).store
58
58
  end
@@ -34,7 +34,7 @@ module Vedeu
34
34
  # @param attributes [Hash]
35
35
  # @option attributes border [NilClass|Symbol] A symbol representing the
36
36
  # border 'piece' this Vedeu::Views::Char represents.
37
- # @option attributes colour [Vedeu::Colour]
37
+ # @option attributes colour [Vedeu::Colours::Colour]
38
38
  # @option attributes parent [Vedeu::Views::Line]
39
39
  # @option attributes position [Vedeu::Position]
40
40
  # @option attributes style [Vedeu::Style]
@@ -24,7 +24,7 @@ module Vedeu
24
24
  #
25
25
  # @param attributes [Hash]
26
26
  # @option attributes client [void]
27
- # @option attributes colour [Vedeu::Colour]
27
+ # @option attributes colour [Vedeu::Colours::Colour]
28
28
  # @option attributes style [Vedeu::Style]
29
29
  # @option attributes value [Vedeu::Views::ViewCollection]
30
30
  # @return [Vedeu::Views::Composition]
@@ -25,7 +25,7 @@ module Vedeu
25
25
  # Returns a new instance of Vedeu::Views::Line.
26
26
  #
27
27
  # @param attributes [Hash]
28
- # @option attributes colour [Vedeu::Colour]
28
+ # @option attributes colour [Vedeu::Colours::Colour]
29
29
  # @option attributes parent [Vedeu::Views::View]
30
30
  # @option attributes style [Vedeu::Style]
31
31
  # @option attributes value [Vedeu::Views::Streams]
@@ -31,7 +31,7 @@ module Vedeu
31
31
  # Returns a new instance of Vedeu::Views::Stream.
32
32
  #
33
33
  # @param attributes [Hash]
34
- # @option attributes colour [Vedeu::Colour]
34
+ # @option attributes colour [Vedeu::Colours::Colour]
35
35
  # @option attributes style [Vedeu::Style]
36
36
  # @option attributes parent [Vedeu::Views::Line]
37
37
  # @option attributes value [String]
@@ -41,7 +41,7 @@ module Vedeu
41
41
  #
42
42
  # @param attributes [Hash]
43
43
  # @option attributes client [Vedeu::Client]
44
- # @option attributes colour [Vedeu::Colour]
44
+ # @option attributes colour [Vedeu::Colours::Colour]
45
45
  # @option attributes value [Vedeu::Views::Lines]
46
46
  # @option attributes name [String]
47
47
  # @option attributes parent [Vedeu::Views::Composition]
@@ -100,12 +100,11 @@ module Vedeu
100
100
  # be shown next time a refresh event is triggered with this name.
101
101
  # Called by {Vedeu::DSL::View.views}.
102
102
  #
103
- # @raise [Vedeu::InvalidSyntax] The name is not defined.
103
+ # @raise [Vedeu::Error::InvalidSyntax] The name is not defined.
104
104
  # @return [Vedeu::Views::View]
105
105
  def store_deferred
106
- unless present?(name)
107
- fail Vedeu::InvalidSyntax, 'Cannot store an interface without a name.'
108
- end
106
+ fail Vedeu::Error::InvalidSyntax,
107
+ 'Cannot store an interface without a name.' unless present?(name)
109
108
 
110
109
  Vedeu.buffers.by_name(name).add(self)
111
110
 
@@ -127,8 +126,8 @@ module Vedeu
127
126
  def defaults
128
127
  {
129
128
  client: nil,
130
- colour: Vedeu::Colour.coerce(background: :default,
131
- foreground: :default),
129
+ colour: Vedeu::Colours::Colour.coerce(background: :default,
130
+ foreground: :default),
132
131
  name: '',
133
132
  parent: nil,
134
133
  style: :normal,
@@ -7,9 +7,10 @@ module Vedeu
7
7
  module Colour
8
8
 
9
9
  # When the background colour for the model exists, return it, otherwise
10
- # returns the parent background colour, or an empty Vedeu::Background.
10
+ # returns the parent background colour, or an empty
11
+ # Vedeu::Colours::Background.
11
12
  #
12
- # @return [Vedeu::Background]
13
+ # @return [Vedeu::Colours::Background]
13
14
  def background
14
15
  @background ||= if colour
15
16
  colour.background
@@ -18,47 +19,48 @@ module Vedeu
18
19
  parent.background
19
20
 
20
21
  else
21
- Vedeu::Background.new
22
+ Vedeu::Colours::Background.new
22
23
 
23
24
  end
24
25
  end
25
26
 
26
27
  # Allows the setting of the background colour by coercing the given value
27
- # into a Vedeu::Background colour.
28
+ # into a Vedeu::Colours::Background colour.
28
29
  #
29
- # @return [Vedeu::Background]
30
+ # @return [Vedeu::Colours::Background]
30
31
  def background=(value)
31
- @colour = Vedeu::Colour.coerce(
32
- background: Vedeu::Background.coerce(value),
32
+ @colour = Vedeu::Colours::Colour.coerce(
33
+ background: Vedeu::Colours::Background.coerce(value),
33
34
  foreground: colour.foreground)
34
35
  end
35
36
 
36
- # @return [Vedeu::Colour]
37
+ # @return [Vedeu::Colours::Colour]
37
38
  def colour
38
39
  @colour ||= if attributes[:colour]
39
- Vedeu::Colour.coerce(attributes[:colour])
40
+ Vedeu::Colours::Colour.coerce(attributes[:colour])
40
41
 
41
42
  elsif parent
42
- Vedeu::Colour.coerce(parent.colour)
43
+ Vedeu::Colours::Colour.coerce(parent.colour)
43
44
 
44
45
  else
45
- Vedeu::Colour.new
46
+ Vedeu::Colours::Colour.new
46
47
 
47
48
  end
48
49
  end
49
50
 
50
51
  # Allows the setting of the model's colour by coercing the given value
51
- # into a Vedeu::Colour.
52
+ # into a Vedeu::Colours::Colour.
52
53
  #
53
- # @return [Vedeu::Colour]
54
+ # @return [Vedeu::Colours::Colour]
54
55
  def colour=(value)
55
- @colour = Vedeu::Colour.coerce(value)
56
+ @colour = Vedeu::Colours::Colour.coerce(value)
56
57
  end
57
58
 
58
59
  # When the foreground colour for the model exists, return it, otherwise
59
- # returns the parent foreground colour, or an empty Vedeu::Foreground.
60
+ # returns the parent foreground colour, or an empty
61
+ # Vedeu::Colours::Foreground.
60
62
  #
61
- # @return [Vedeu::Foreground]
63
+ # @return [Vedeu::Colours::Foreground]
62
64
  def foreground
63
65
  @foreground ||= if colour
64
66
  colour.foreground
@@ -67,19 +69,19 @@ module Vedeu
67
69
  parent.foreground
68
70
 
69
71
  else
70
- Vedeu::Foreground.new
72
+ Vedeu::Colours::Foreground.new
71
73
 
72
74
  end
73
75
  end
74
76
 
75
77
  # Allows the setting of the foreground colour by coercing the given value
76
- # into a Vedeu::Foreground colour.
78
+ # into a Vedeu::Colours::Foreground colour.
77
79
  #
78
- # @return [Vedeu::Foreground]
80
+ # @return [Vedeu::Colours::Foreground]
79
81
  def foreground=(value)
80
- @colour = Vedeu::Colour.coerce(
82
+ @colour = Vedeu::Colours::Colour.coerce(
81
83
  background: colour.background,
82
- foreground: Vedeu::Foreground.coerce(value))
84
+ foreground: Vedeu::Colours::Foreground.coerce(value))
83
85
  end
84
86
 
85
87
  end # Colour