vedeu 0.4.62 → 0.4.63

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/all.rb +6 -5
  3. data/lib/vedeu/api.rb +5 -128
  4. data/lib/vedeu/application/application_controller.rb +0 -2
  5. data/lib/vedeu/application/application_helper.rb +0 -2
  6. data/lib/vedeu/application/application_view.rb +0 -2
  7. data/lib/vedeu/application/controller.rb +1 -1
  8. data/lib/vedeu/bindings/application.rb +12 -4
  9. data/lib/vedeu/bindings/system.rb +4 -4
  10. data/lib/vedeu/bindings/visibility.rb +6 -2
  11. data/lib/vedeu/buffers/buffer.rb +1 -1
  12. data/lib/vedeu/buffers/display_buffer.rb +2 -2
  13. data/lib/vedeu/cli/generator/templates/application/Gemfile +1 -1
  14. data/lib/vedeu/cli/generator/templates/application/application.erb +1 -1
  15. data/lib/vedeu/cli/generator/templates/application/config/configuration.erb +2 -2
  16. data/lib/vedeu/cli/generator/view.rb +2 -2
  17. data/lib/vedeu/colours/colour.rb +1 -1
  18. data/lib/vedeu/colours/colour_translator.rb +2 -2
  19. data/lib/vedeu/configuration/api.rb +1 -1
  20. data/lib/vedeu/configuration/configuration.rb +1 -1
  21. data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
  22. data/lib/vedeu/distributed/server.rb +1 -1
  23. data/lib/vedeu/dsl/border.rb +1 -1
  24. data/lib/vedeu/dsl/geometry.rb +7 -6
  25. data/lib/vedeu/dsl/view.rb +3 -3
  26. data/lib/vedeu/events/event.rb +1 -1
  27. data/lib/vedeu/events/trigger.rb +1 -1
  28. data/lib/vedeu/exceptions.rb +14 -0
  29. data/lib/vedeu/geometry/dimension.rb +1 -1
  30. data/lib/vedeu/geometry/geometry.rb +2 -2
  31. data/lib/vedeu/geometry/position_validator.rb +1 -1
  32. data/lib/vedeu/input/input.rb +6 -5
  33. data/lib/vedeu/input/keymap.rb +3 -3
  34. data/lib/vedeu/input/mapper.rb +3 -3
  35. data/lib/vedeu/internal_api.rb +147 -0
  36. data/lib/vedeu/models/char.rb +2 -2
  37. data/lib/vedeu/models/focus.rb +1 -1
  38. data/lib/vedeu/models/line.rb +1 -1
  39. data/lib/vedeu/models/stream.rb +1 -1
  40. data/lib/vedeu/output/esc.rb +1 -1
  41. data/lib/vedeu/output/presentation.rb +9 -9
  42. data/lib/vedeu/output/refresh.rb +1 -1
  43. data/lib/vedeu/output/renderers.rb +1 -1
  44. data/lib/vedeu/output/text.rb +1 -1
  45. data/lib/vedeu/output/viewport.rb +1 -1
  46. data/lib/vedeu/repositories.rb +1 -1
  47. data/lib/vedeu/repositories/repository.rb +4 -4
  48. data/lib/vedeu/{application.rb → runtime/application.rb} +0 -0
  49. data/lib/vedeu/{bootstrap.rb → runtime/bootstrap.rb} +0 -0
  50. data/lib/vedeu/{launcher.rb → runtime/launcher.rb} +1 -1
  51. data/lib/vedeu/{main_loop.rb → runtime/main_loop.rb} +1 -1
  52. data/lib/vedeu/{router.rb → runtime/router.rb} +57 -4
  53. data/lib/vedeu/terminal.rb +1 -1
  54. data/lib/vedeu/version.rb +1 -1
  55. data/test/lib/vedeu/api_test.rb +1 -15
  56. data/test/lib/vedeu/bindings/application_test.rb +3 -3
  57. data/test/lib/vedeu/internal_api_test.rb +25 -0
  58. data/test/lib/vedeu/output/clear/named_group_test.rb +8 -7
  59. data/test/lib/vedeu/output/presentation_test.rb +45 -0
  60. data/test/lib/vedeu/output/renderers_test.rb +14 -4
  61. data/test/lib/vedeu/{application_test.rb → runtime/application_test.rb} +0 -0
  62. data/test/lib/vedeu/{bootstrap_test.rb → runtime/bootstrap_test.rb} +11 -0
  63. data/test/lib/vedeu/{launcher_test.rb → runtime/launcher_test.rb} +0 -0
  64. data/test/lib/vedeu/{main_loop_test.rb → runtime/main_loop_test.rb} +0 -0
  65. data/test/lib/vedeu/{router_test.rb → runtime/router_test.rb} +13 -1
  66. metadata +20 -17
@@ -80,7 +80,7 @@ module Vedeu
80
80
  # Fetch the border by name.
81
81
  #
82
82
  # @note
83
- # Vedeu::Border is used in this way because if there is not a border
83
+ # Vedeu::Border is used in this way because when there is not a border
84
84
  # defined, it will fallback to a Vedeu::Null::Border which uses
85
85
  # Vedeu::Geometry to determine it's dimensions based on the name also.
86
86
  # When a Vedeu::Geometry cannot be found, this falls back to a
@@ -182,7 +182,7 @@ module Vedeu
182
182
 
183
183
  end
184
184
  rescue NoMethodError # raised when #join is called on NilClass.
185
- Vedeu.log(type: :debug, message: 'Attempted to #join on DRb.thread.')
185
+ Vedeu.log(type: :drb, message: 'Attempted to #join on DRb.thread.')
186
186
  end
187
187
 
188
188
  protected
@@ -109,7 +109,7 @@ module Vedeu
109
109
  end
110
110
 
111
111
  # Enable the border:
112
- # (Borders are enabled by default if defined for an interface).
112
+ # (Borders are enabled by default when defined for an interface).
113
113
  #
114
114
  # Vedeu.border 'border_demo' do
115
115
  # enable!
@@ -140,7 +140,7 @@ module Vedeu
140
140
  end
141
141
 
142
142
  # Specify the number of characters/rows/lines tall the interface will be.
143
- # This value will be ignored if by `y` and `yn` are set.
143
+ # This value will be ignored when `y` and `yn` are set.
144
144
  #
145
145
  # Vedeu.geometry 'some_interface' do
146
146
  # height 8
@@ -172,7 +172,7 @@ module Vedeu
172
172
  end
173
173
 
174
174
  # Specify the number of characters/columns wide the interface will be.
175
- # This value will be ignored if by `x` and `xn` are set.
175
+ # This value will be ignored when `x` and `xn` are set.
176
176
  #
177
177
  # Vedeu.geometry 'some_interface' do
178
178
  # width 25
@@ -210,9 +210,10 @@ module Vedeu
210
210
  # Vedeu.geometry 'some_interface' do
211
211
  # xn 37 # end at column 37.
212
212
  #
213
- # xn { use('other_interface').right } # if `other_interface` changes
214
- # # ... some code # position, `some_interface`
215
- # end # will too.
213
+ # xn { use('other_interface').right } # when `other_interface`
214
+ # # changes position,
215
+ # # ... some code # `some_interface` will too.
216
+ # end
216
217
  #
217
218
  # @param value [Fixnum]
218
219
  # @param block [Proc]
@@ -228,7 +229,7 @@ module Vedeu
228
229
  # Vedeu.geometry 'some_interface' do
229
230
  # y 4 # start at row 4
230
231
  #
231
- # y { use('other_interface').north } # start on row/line 3, if
232
+ # y { use('other_interface').north } # start on row/line 3, when
232
233
  # # ... some code # `other_interface` changes
233
234
  # end # position, `some_interface`
234
235
  # # will too.
@@ -9,8 +9,8 @@ module Vedeu
9
9
  # Both of these approaches require that you have defined an interface (or
10
10
  # 'visible area') first. You can find out how to define an interface with
11
11
  # Vedeu here. The examples in 'Immediate Render' and 'Deferred View' use
12
- # these interface definitions: (Note: if you use these examples, ensure your
13
- # terminal is at least 70 characters in width and 5 lines in height.)
12
+ # these interface definitions: (Note: should you use these examples, ensure
13
+ # your terminal is at least 70 characters in width and 5 lines in height.)
14
14
  #
15
15
  # Vedeu.interface 'main' do
16
16
  # geometry do
@@ -111,7 +111,7 @@ module Vedeu
111
111
 
112
112
  # Directly write a view buffer to the terminal. Using this method means
113
113
  # that the refresh event does not need to be triggered after creating
114
- # the views, though can be later triggered if needed.
114
+ # the views, though can be later triggered when needed.
115
115
  #
116
116
  # Vedeu.renders do
117
117
  # view 'some_interface' do
@@ -236,7 +236,7 @@ module Vedeu
236
236
  false
237
237
  end
238
238
 
239
- # Returns a boolean indicating if this event has a deadline.
239
+ # Returns a boolean indicating whether this event has a deadline.
240
240
  #
241
241
  # @return [Boolean]
242
242
  def deadline?
@@ -28,7 +28,7 @@ module Vedeu
28
28
  @repository = Vedeu.events
29
29
  end
30
30
 
31
- # Trigger the event and return the result (if one) or an array of results.
31
+ # Trigger the event and return the result or an array of results.
32
32
  #
33
33
  # @return [Array]
34
34
  def trigger
@@ -1,5 +1,19 @@
1
1
  module Vedeu
2
2
 
3
+ # Raised with Vedeu attempts to access a client application controller that
4
+ # does not exist.
5
+ #
6
+ class ControllerNotFound < StandardError
7
+
8
+ end # ControllerNotFound
9
+
10
+ # Raised with Vedeu attempts to access a client application controller's
11
+ # action that does not exist.
12
+ #
13
+ class ActionNotFound < StandardError
14
+
15
+ end # ActionNotFound
16
+
3
17
  # Raised with Vedeu attempts to access a named model that does not exist.
4
18
  #
5
19
  class ModelNotFound < StandardError
@@ -123,7 +123,7 @@ module Vedeu
123
123
  (default / 2) + (length / 2)
124
124
  end
125
125
 
126
- # Fetch the starting coordinate, or use 1 if not set.
126
+ # Fetch the starting coordinate, or use 1 when not set.
127
127
  #
128
128
  # @return [Fixnum]
129
129
  def _d
@@ -123,9 +123,9 @@ module Vedeu
123
123
  work
124
124
  end
125
125
 
126
- # Will unmaximise the named interface geometry. Previously, if a geometry
126
+ # Will unmaximise the named interface geometry. Previously, when a geometry
127
127
  # was maximised, then triggering the unmaximise event will return it to its
128
- # usual defined size (terminal size permitting: if the terminal has been
128
+ # usual defined size (terminal size permitting: when the terminal has been
129
129
  # resized, then the new geometry size should adapt).
130
130
  #
131
131
  # @example
@@ -39,7 +39,7 @@ module Vedeu
39
39
  end
40
40
 
41
41
  # Ensures the coordinates provided are within the terminal, interface and
42
- # if applicable, bordered interface area.
42
+ # when applicable, bordered interface area.
43
43
  #
44
44
  # @return [PositionValidator]
45
45
  def validate
@@ -22,8 +22,9 @@ module Vedeu
22
22
  @reader = reader
23
23
  end
24
24
 
25
- # Triggers either a ':_command_' event with the command if the reader is in
26
- # cooked mode, or if raw mode, the keypress event with the key(s) pressed.
25
+ # Triggers either a ':_command_' event with the command when the reader is
26
+ # in cooked mode, or when in raw mode, the keypress event with the key(s)
27
+ # pressed.
27
28
  #
28
29
  # @return [Array|String|Symbol]
29
30
  def capture
@@ -52,8 +53,8 @@ module Vedeu
52
53
  end
53
54
  alias_method :command, :input
54
55
 
55
- # Returns the translated (if possible) keypress(es) as either a String or a
56
- # Symbol.
56
+ # Returns the translated (when possible) keypress(es) as either a String or
57
+ # a Symbol.
57
58
  #
58
59
  # @return [String|Symbol]
59
60
  def keypress
@@ -62,7 +63,7 @@ module Vedeu
62
63
  specials.fetch(key, key)
63
64
  end
64
65
 
65
- # Translates (if possible) entered escape sequences into symbols
66
+ # Translates (when possible) entered escape sequences into symbols
66
67
  # representing the key which was pressed.
67
68
  #
68
69
  # @return [Hash]
@@ -52,8 +52,8 @@ module Vedeu
52
52
  keys.any? { |key| key.input == input }
53
53
  end
54
54
 
55
- # Triggers the action associated with the key, if it is registered with this
56
- # keymap.
55
+ # When the given input is registered with this keymap, this method triggers
56
+ # the action associated with the key.
57
57
  #
58
58
  # @param input [String|Symbol]
59
59
  # @return [Array|FalseClass]
@@ -87,7 +87,7 @@ module Vedeu
87
87
  def valid?(key)
88
88
  return true unless key_defined?(key.input)
89
89
 
90
- Vedeu.log(type: :debug,
90
+ Vedeu.log(type: :input,
91
91
  message: "Keymap '#{name}' already defines '#{key.input}'.")
92
92
 
93
93
  false
@@ -5,7 +5,7 @@ module Vedeu
5
5
  class Mapper
6
6
 
7
7
  # Takes a key as a keypress and sends it to registered keymaps. If found,
8
- # the associated action is fired, if not, we move to the next keymap or
8
+ # the associated action is fired, otherwise, we move to the next keymap or
9
9
  # return false.
10
10
  #
11
11
  # @example
@@ -21,7 +21,7 @@ module Vedeu
21
21
  new(key, name).keypress
22
22
  end
23
23
 
24
- # Checks a key is valid; i.e. not already registered to a keymap. If the
24
+ # Checks a key is valid; i.e. not already registered to a keymap. When the
25
25
  # key is registered, then the key is invalid and cannot be used again.
26
26
  #
27
27
  # @param (see #initialize)
@@ -51,7 +51,7 @@ module Vedeu
51
51
  def keypress
52
52
  return false unless key
53
53
 
54
- Vedeu.log(type: :debug, message: "Key detected: #{key.inspect}")
54
+ Vedeu.log(type: :input, message: "Key detected: #{key.inspect}")
55
55
 
56
56
  return true if key_defined? && keymap.use(key)
57
57
 
@@ -0,0 +1,147 @@
1
+ module Vedeu
2
+
3
+ # Vedeu's internal API methods provide convenient ways to access Vedeu's
4
+ # internals. They are not supposed to be used by client applications as they
5
+ # have limited value there.
6
+ #
7
+ module InternalAPI
8
+
9
+ extend Forwardable
10
+
11
+ module_function
12
+
13
+ # Manipulate the repository of background colours.
14
+ #
15
+ # @example
16
+ # Vedeu.background_colours
17
+ #
18
+ # @!method background_colours
19
+ # @return [Vedeu::Backgrounds]
20
+ def_delegators Vedeu::Backgrounds, :background_colours
21
+
22
+ # Manipulate the repository of borders.
23
+ #
24
+ # @example
25
+ # Vedeu.borders
26
+ #
27
+ # @!method borders
28
+ # @return [Vedeu::Borders]
29
+ def_delegators Vedeu::Borders, :borders
30
+
31
+ # Manipulate the repository of buffers.
32
+ #
33
+ # @example
34
+ # Vedeu.buffers
35
+ #
36
+ # @!method buffers
37
+ # @return [Vedeu::Buffers]
38
+ def_delegators Vedeu::Buffers, :buffers
39
+
40
+ # Manipulate the repository of cursors.
41
+ #
42
+ # @example
43
+ # Vedeu.cursors
44
+ #
45
+ # @!method cursors
46
+ # @return [Vedeu::Cursors]
47
+ def_delegators Vedeu::Cursors, :cursors
48
+
49
+ # Manipulate the repository of events.
50
+ #
51
+ # @example
52
+ # Vedeu.events
53
+ #
54
+ # @!method events
55
+ # @return [Vedeu::Events]
56
+ def_delegators Vedeu::Events, :events
57
+
58
+ # Manipulate the repository of foreground colours.
59
+ #
60
+ # @example
61
+ # Vedeu.foreground_colours
62
+ #
63
+ # @!method foreground_colours
64
+ # @return [Vedeu::Foregrounds]
65
+ def_delegators Vedeu::Foregrounds, :foreground_colours
66
+
67
+ # Manipulate the repository of geometries.
68
+ #
69
+ # @example
70
+ # Vedeu.geometries
71
+ #
72
+ # @!method geometries
73
+ # @return [Vedeu::Geometries]
74
+ def_delegators Vedeu::Geometries, :geometries
75
+
76
+ # Manipulate the repository of groups.
77
+ #
78
+ # @example
79
+ # Vedeu.groups
80
+ #
81
+ # @!method groups
82
+ # @return [Vedeu::Groups]
83
+ def_delegators Vedeu::Groups, :groups
84
+
85
+ # Manipulate the repository of interfaces.
86
+ #
87
+ # @example
88
+ # Vedeu.interfaces
89
+ #
90
+ # @!method interfaces
91
+ # @return [Vedeu::Interfaces]
92
+ def_delegators Vedeu::Interfaces, :interfaces
93
+
94
+ # Manipulate the repository of keymaps.
95
+ #
96
+ # @example
97
+ # Vedeu.keymaps
98
+ #
99
+ # @!method keymaps
100
+ # @return [Vedeu::Keymaps]
101
+ def_delegators Vedeu::Keymaps, :keymaps
102
+
103
+ # Manipulate the repository of menus.
104
+ #
105
+ # @example
106
+ # Vedeu.menus
107
+ #
108
+ # @!method menus
109
+ # @return [Vedeu::Menus]
110
+ def_delegators Vedeu::Menus, :menus
111
+
112
+ # @example
113
+ # Vedeu.renderer
114
+ # Vedeu.renderers
115
+ #
116
+ # @!method renderer
117
+ # @see Vedeu::Renderers#renderer
118
+ # @!method renderers
119
+ # @see Vedeu::Renderers#renderers
120
+ def_delegators Vedeu::Renderers, :renderer, :renderers
121
+
122
+ # Instruct the terminal to resize. This will happen automatically as the
123
+ # terminal recieves SIGWINCH signals.
124
+ #
125
+ # @example
126
+ # Vedeu.resize
127
+ #
128
+ # @!method resize
129
+ # @see Vedeu::Terminal#resize
130
+ def_delegators Vedeu::Terminal, :resize
131
+
132
+ # Measure the execution time of the code in the given block.
133
+ #
134
+ # @example
135
+ # Vedeu.timer do
136
+ # # ... some code here ...
137
+ # end
138
+ #
139
+ # @!method timer
140
+ # @see Vedeu::Timer.timer
141
+ def_delegators Vedeu::Timer, :timer
142
+
143
+ end # InternalAPI
144
+
145
+ extend InternalAPI
146
+
147
+ end # Vedeu
@@ -101,14 +101,14 @@ module Vedeu
101
101
  end
102
102
  end
103
103
 
104
- # Returns the x position for the Char if set.
104
+ # Returns the x position for the Char when set.
105
105
  #
106
106
  # @return [Fixnum|NilClass]
107
107
  def x
108
108
  position.x if position
109
109
  end
110
110
 
111
- # Returns the y position for the Char if set.
111
+ # Returns the y position for the Char when set.
112
112
  #
113
113
  # @return [Fixnum|NilClass]
114
114
  def y
@@ -188,7 +188,7 @@ module Vedeu
188
188
  private
189
189
 
190
190
  # Return the name of the interface in focus after triggering the refresh
191
- # event for that interface. Returns false if the storage is empty.
191
+ # event for that interface. Returns false when the storage is empty.
192
192
  #
193
193
  # @return [String|FalseClass]
194
194
  def update
@@ -75,7 +75,7 @@ module Vedeu
75
75
  end
76
76
  alias_method :value, :streams
77
77
 
78
- # Delegate to Vedeu::Interface#width if available.
78
+ # Delegate to Vedeu::Interface#width when available.
79
79
  #
80
80
  # @return [Fixnum]
81
81
  def width
@@ -94,7 +94,7 @@ module Vedeu
94
94
  value.size
95
95
  end
96
96
 
97
- # Delegate to Vedeu::Line#width if available.
97
+ # Delegate to Vedeu::Line#width when available.
98
98
  #
99
99
  # @return [Fixnum]
100
100
  def width
@@ -22,7 +22,7 @@ module Vedeu
22
22
  end
23
23
 
24
24
  # Return the escape sequence string from the list of recognised sequence
25
- # 'commands', or an empty string if the 'command' cannot be found.
25
+ # 'commands', or an empty string when the 'command' cannot be found.
26
26
  #
27
27
  # @param value [String|Symbol]
28
28
  # @return [String]
@@ -5,7 +5,7 @@ module Vedeu
5
5
  #
6
6
  module Presentation
7
7
 
8
- # Returns the background colour for the model, or if it does not exist,
8
+ # When the background colour for the model exists, return it, otherwise
9
9
  # returns the parent background colour, or an empty Vedeu::Background.
10
10
  #
11
11
  # @return [Vedeu::Background]
@@ -51,7 +51,7 @@ module Vedeu
51
51
  @colour = attributes[:colour] = Vedeu::Colour.coerce(value)
52
52
  end
53
53
 
54
- # Returns the foreground colour for the model, or if it does not exist,
54
+ # When the foreground colour for the model exists, return it, otherwise
55
55
  # returns the parent foreground colour, or an empty Vedeu::Foreground.
56
56
  #
57
57
  # @return [Vedeu::Foreground]
@@ -75,8 +75,8 @@ module Vedeu
75
75
  background: colour.background)
76
76
  end
77
77
 
78
- # Returns the parent background colour if a parent colour is available, or
79
- # an empty Vedeu::Background.
78
+ # When a parent colour is available, returns the parent background colour,
79
+ # otherwise an empty Vedeu::Background.
80
80
  #
81
81
  # @return [Vedeu::Background]
82
82
  def parent_background
@@ -89,15 +89,15 @@ module Vedeu
89
89
  end
90
90
  end
91
91
 
92
- # Returns the parent colour if available or NilClass.
92
+ # Returns the parent colour when available or NilClass.
93
93
  #
94
94
  # @return [String|NilClass]
95
95
  def parent_colour
96
96
  parent.colour if parent
97
97
  end
98
98
 
99
- # Returns the parent foreground colour if a parent colour is available, or
100
- # an empty Vedeu::Foreground.
99
+ # When a parent colour is available, returns the parent foreground colour,
100
+ # otherwise an empty Vedeu::Foreground.
101
101
  #
102
102
  # @return [Vedeu::Foreground]
103
103
  def parent_foreground
@@ -110,7 +110,7 @@ module Vedeu
110
110
  end
111
111
  end
112
112
 
113
- # Returns the parent style if available or NilClass.
113
+ # Returns the parent style when available or NilClass.
114
114
  #
115
115
  # @return [String|NilClass]
116
116
  def parent_style
@@ -142,7 +142,7 @@ module Vedeu
142
142
  @style = Vedeu::Style.coerce(value)
143
143
  end
144
144
 
145
- # Converts the colours and styles to escape sequences, and if the parent
145
+ # Converts the colours and styles to escape sequences, and when the parent
146
146
  # model has previously set the colour and style, reverts back to that for
147
147
  # consistent formatting.
148
148
  #