vedeu 0.6.12 → 0.6.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/bindings/application.rb +4 -0
  3. data/lib/vedeu/bindings/document.rb +4 -0
  4. data/lib/vedeu/bindings/focus.rb +4 -0
  5. data/lib/vedeu/bindings/menus.rb +4 -0
  6. data/lib/vedeu/bindings/movement.rb +4 -0
  7. data/lib/vedeu/bindings/refresh.rb +4 -0
  8. data/lib/vedeu/bindings/system.rb +4 -0
  9. data/lib/vedeu/bindings/visibility.rb +4 -0
  10. data/lib/vedeu/borders/dsl.rb +2 -3
  11. data/lib/vedeu/configuration/api.rb +26 -0
  12. data/lib/vedeu/configuration/configuration.rb +16 -0
  13. data/lib/vedeu/dsl/composition.rb +2 -3
  14. data/lib/vedeu/dsl/group.rb +2 -3
  15. data/lib/vedeu/dsl/interface.rb +2 -4
  16. data/lib/vedeu/dsl/keymap.rb +24 -21
  17. data/lib/vedeu/dsl/line.rb +4 -6
  18. data/lib/vedeu/dsl/presentation.rb +16 -12
  19. data/lib/vedeu/dsl/shared.rb +18 -14
  20. data/lib/vedeu/dsl/stream.rb +2 -3
  21. data/lib/vedeu/dsl/text.rb +6 -4
  22. data/lib/vedeu/dsl/view.rb +6 -8
  23. data/lib/vedeu/error.rb +12 -0
  24. data/lib/vedeu/geometry/area.rb +4 -2
  25. data/lib/vedeu/geometry/coordinate.rb +4 -4
  26. data/lib/vedeu/geometry/dimension.rb +6 -4
  27. data/lib/vedeu/geometry/dsl.rb +55 -43
  28. data/lib/vedeu/geometry/generic_coordinate.rb +4 -3
  29. data/lib/vedeu/geometry/geometry.rb +13 -11
  30. data/lib/vedeu/geometry/grid.rb +6 -5
  31. data/lib/vedeu/geometry/position.rb +12 -10
  32. data/lib/vedeu/input/key.rb +2 -3
  33. data/lib/vedeu/logging/log.rb +1 -1
  34. data/lib/vedeu/menus/menu.rb +2 -3
  35. data/lib/vedeu/models/views/view.rb +0 -2
  36. data/lib/vedeu/output/output.rb +10 -1
  37. data/lib/vedeu/output/renderers/file.rb +3 -3
  38. data/lib/vedeu/output/renderers/json.rb +2 -0
  39. data/lib/vedeu/runtime/main_loop.rb +4 -0
  40. data/lib/vedeu/templating/helpers.rb +4 -7
  41. data/lib/vedeu/terminal/buffer.rb +1 -2
  42. data/lib/vedeu/terminal/terminal.rb +4 -2
  43. data/lib/vedeu/version.rb +1 -1
  44. data/test/lib/vedeu/api/external_test.rb +14 -2
  45. data/test/lib/vedeu/bindings/visibility_test.rb +15 -0
  46. data/test/lib/vedeu/dsl/composition_test.rb +1 -1
  47. data/test/lib/vedeu/dsl/group_test.rb +1 -1
  48. data/test/lib/vedeu/dsl/interface_test.rb +3 -3
  49. data/test/lib/vedeu/dsl/line_test.rb +2 -2
  50. data/test/lib/vedeu/dsl/stream_test.rb +1 -1
  51. data/test/lib/vedeu/dsl/view_test.rb +3 -3
  52. data/test/lib/vedeu/error_test.rb +13 -0
  53. data/test/lib/vedeu/input/key_test.rb +1 -1
  54. data/test/lib/vedeu/menus/menu_test.rb +1 -1
  55. data/test/lib/vedeu/models/interface_test.rb +26 -0
  56. data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +7 -0
  57. data/test/lib/vedeu/output/renderers/file_test.rb +7 -0
  58. data/test/lib/vedeu/output/renderers/html_test.rb +7 -0
  59. data/test/lib/vedeu/output/renderers/json_test.rb +7 -0
  60. data/test/lib/vedeu/output/renderers/null_test.rb +7 -0
  61. data/test/lib/vedeu/output/renderers/terminal_test.rb +11 -0
  62. data/test/lib/vedeu/output/renderers/text_test.rb +7 -0
  63. data/test/lib/vedeu/terminal/buffer_test.rb +31 -12
  64. data/test/lib/vedeu/terminal/terminal_test.rb +24 -21
  65. data/test/support/examples/material_colours_app.rb +2 -0
  66. data/test/test_helper.rb +2 -2
  67. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3baa951de557aa4e39a7c9414fae7caea7c9efef
4
- data.tar.gz: 58355bdd2dabc9b59d5c52fc99306a81afcc934b
3
+ metadata.gz: 31c6be7113f82b029855008aaaf699fbd567ae33
4
+ data.tar.gz: 1bf5c6c64eb63d6332af2645be09bf0103fc19e8
5
5
  SHA512:
6
- metadata.gz: b9f5da3a38e66ce269b8233084bfbec48fb67c2cd32abe33e71e12b03d2f77d85f816188b050b7f8d1ec92c8fdc14dcb00e5019efd8095c645de54cc39418e9c
7
- data.tar.gz: 2c44e1296ac86195023e72bc5f40cc6428de275c9115b2322f3c756f25145bb5a7c3e3efd6a3eb33c059c66d3bde4b0dca1491f8ac5d8f36df1b5276dca0186a
6
+ metadata.gz: 24727ce127fde1301bddc57102f7814fde4fb73f020012cbe0bf5d1d13c7b4023a0457691f1815f6e4ee6f5d53160843a003b53ba9dc231b12b9df8b8ac34e87
7
+ data.tar.gz: 310d942055981700a8b3f7381291b0c1a29517c85531be676eee43ff877a6dba875f53b57a424d7863949c9f975b3dba66e766d811347e634fed7f074b8edae4
@@ -18,6 +18,8 @@ module Vedeu
18
18
 
19
19
  private
20
20
 
21
+ # :nocov:
22
+
21
23
  # See {file:docs/events/application.md#\_goto_}
22
24
  def goto!
23
25
  Vedeu.bind(:_goto_) do |controller, action, **args|
@@ -27,6 +29,8 @@ module Vedeu
27
29
  Vedeu.bind_alias(:_action_, :_goto_)
28
30
  end
29
31
 
32
+ # :nocov:
33
+
30
34
  end # Application
31
35
 
32
36
  end # Bindings
@@ -27,6 +27,8 @@ module Vedeu
27
27
 
28
28
  private
29
29
 
30
+ # :nocov:
31
+
30
32
  # See {file:docs/events/document.md#\_editor_execute_}
31
33
  def editor_execute!
32
34
  Vedeu.bind(:_editor_execute_) do |name|
@@ -86,6 +88,8 @@ module Vedeu
86
88
  Vedeu.bind(:_editor_up_) { |name| Vedeu.documents.by_name(name).up }
87
89
  end
88
90
 
91
+ # :nocov:
92
+
89
93
  end # Document
90
94
 
91
95
  end # Bindings
@@ -18,6 +18,8 @@ module Vedeu
18
18
 
19
19
  private
20
20
 
21
+ # :nocov:
22
+
21
23
  # See {file:docs/events/focus.md#\_focus_by_name_}
22
24
  def focus_by_name!
23
25
  Vedeu.bind(:_focus_by_name_) { |name| Vedeu.focus_by_name(name) }
@@ -33,6 +35,8 @@ module Vedeu
33
35
  Vedeu.bind(:_focus_prev_) { Vedeu.focus_previous }
34
36
  end
35
37
 
38
+ # :nocov:
39
+
36
40
  end # Focus
37
41
 
38
42
  end # Bindings
@@ -28,6 +28,8 @@ module Vedeu
28
28
 
29
29
  private
30
30
 
31
+ # :nocov:
32
+
31
33
  # See {file:docs/events/menu.md#\_menu_bottom_}
32
34
  def menu_bottom!
33
35
  Vedeu.bind(:_menu_bottom_) do |name|
@@ -88,6 +90,8 @@ module Vedeu
88
90
  Vedeu.bind(:_menu_view_) { |name| Vedeu.menus.by_name(name).view }
89
91
  end
90
92
 
93
+ # :nocov:
94
+
91
95
  end # Menus
92
96
 
93
97
  end # Bindings
@@ -21,6 +21,8 @@ module Vedeu
21
21
 
22
22
  private
23
23
 
24
+ # :nocov:
25
+
24
26
  # See {file:docs/events/movement.md#\_cursor_up_down_left_right_}
25
27
  def directional!
26
28
  %w(down left right up).each do |direction|
@@ -71,6 +73,8 @@ module Vedeu
71
73
  end
72
74
  end
73
75
 
76
+ # :nocov:
77
+
74
78
  end # Movement
75
79
 
76
80
  end # Bindings
@@ -18,6 +18,8 @@ module Vedeu
18
18
 
19
19
  private
20
20
 
21
+ # :nocov:
22
+
21
23
  # See {file:docs/events/refresh.md#\_refresh_}
22
24
  def refresh!
23
25
  Vedeu.bind(:_refresh_) do |name|
@@ -45,6 +47,8 @@ module Vedeu
45
47
  end
46
48
  end
47
49
 
50
+ # :nocov:
51
+
48
52
  end # Refresh
49
53
 
50
54
  end # Bindings
@@ -27,6 +27,8 @@ module Vedeu
27
27
 
28
28
  private
29
29
 
30
+ # :nocov:
31
+
30
32
  # See {file:docs/events/system.md#\_cleanup_}
31
33
  def cleanup!
32
34
  Vedeu.bind(:_cleanup_) do
@@ -104,6 +106,8 @@ module Vedeu
104
106
  end
105
107
  end
106
108
 
109
+ # :nocov:
110
+
107
111
  end # System
108
112
 
109
113
  end # Bindings
@@ -28,6 +28,8 @@ module Vedeu
28
28
 
29
29
  private
30
30
 
31
+ # :nocov:
32
+
31
33
  # See {file:docs/events/visibility.md#\_clear_group_}
32
34
  def clear_group!
33
35
  Vedeu.bind(:_clear_group_) do |name|
@@ -102,6 +104,8 @@ module Vedeu
102
104
  end
103
105
  end
104
106
 
107
+ # :nocov:
108
+
105
109
  end # Visibility
106
110
 
107
111
  end # Bindings
@@ -19,11 +19,10 @@ module Vedeu
19
19
  # @param name [String] The name of the interface or view to
20
20
  # which this border belongs.
21
21
  # @param block [Proc]
22
- # @raise [Vedeu::Error::InvalidSyntax]
23
- # The required block was not given.
22
+ # @raise [Vedeu::Error::RequiresBlock]
24
23
  # @return [Vedeu::Borders::Border]
25
24
  def self.border(name, &block)
26
- fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
25
+ fail Vedeu::Error::RequiresBlock unless block_given?
27
26
 
28
27
  Vedeu::Borders::Border.build(enabled: true, name: name, &block).store
29
28
  end
@@ -269,6 +269,19 @@ module Vedeu
269
269
  options[:colour_mode] = value
270
270
  end
271
271
 
272
+ # Sets the height of the terminal.
273
+ #
274
+ # Vedeu.configure do
275
+ # height 25
276
+ # # ...
277
+ # end
278
+ #
279
+ # @param height [Fixnum]
280
+ # @return [Fixnum]
281
+ def height(height = 25)
282
+ options[:height] = height
283
+ end
284
+
272
285
  # Sets the location of the log file.
273
286
  #
274
287
  # Vedeu.configure do
@@ -452,6 +465,19 @@ module Vedeu
452
465
  end
453
466
  end
454
467
 
468
+ # Sets the width of the terminal.
469
+ #
470
+ # Vedeu.configure do
471
+ # width 80
472
+ # # ...
473
+ # end
474
+ #
475
+ # @param width [Fixnum]
476
+ # @return [Fixnum]
477
+ def width(width = 80)
478
+ options[:width] = width
479
+ end
480
+
455
481
  private
456
482
 
457
483
  # Returns the options set via the configuration API DSL or an
@@ -139,6 +139,13 @@ module Vedeu
139
139
  instance.options[:drb_width]
140
140
  end
141
141
 
142
+ # Returns the client defined height for the terminal.
143
+ #
144
+ # @return [Fixnum]
145
+ def height
146
+ instance.options[:height]
147
+ end
148
+
142
149
  # Returns whether the application is interactive (required user
143
150
  # input) or standalone (will run until terminates of natural
144
151
  # causes.) Default is true; meaning the application will require
@@ -224,6 +231,13 @@ module Vedeu
224
231
  instance.options[:terminal_mode]
225
232
  end
226
233
 
234
+ # Returns the client defined width for the terminal.
235
+ #
236
+ # @return [Fixnum]
237
+ def width
238
+ instance.options[:width]
239
+ end
240
+
227
241
  # @param value [void]
228
242
  # @return [void]
229
243
  def options=(value)
@@ -293,6 +307,7 @@ module Vedeu
293
307
  drb_port: nil,
294
308
  drb_height: 25,
295
309
  drb_width: 80,
310
+ height: nil,
296
311
  interactive: true,
297
312
  log: nil,
298
313
  log_only: [],
@@ -303,6 +318,7 @@ module Vedeu
303
318
  stdout: nil,
304
319
  stderr: nil,
305
320
  terminal_mode: :raw,
321
+ width: nil,
306
322
  }
307
323
  end
308
324
 
@@ -71,11 +71,10 @@ module Vedeu
71
71
  # # ...
72
72
  # end
73
73
  #
74
- # @raise [Vedeu::Error::InvalidSyntax]
75
- # The required block was not given.
74
+ # @raise [Vedeu::Error::RequiresBlock]
76
75
  # @return [Vedeu::Views::Views<Vedeu::Views::View>]
77
76
  def view(name = '', &block)
78
- fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
77
+ fail Vedeu::Error::RequiresBlock unless block_given?
79
78
 
80
79
  new_model = model.member.build(new_attributes(name), &block)
81
80
 
@@ -54,11 +54,10 @@ module Vedeu
54
54
  #
55
55
  # @param name [String] The name of this group.
56
56
  # @param block [Proc]
57
- # @raise [Vedeu::Error::InvalidSyntax] The required block was
58
- # not given.
57
+ # @raise [Vedeu::Error::RequiresBlock]
59
58
  # @return [Vedeu::Models::Group]
60
59
  def self.group(name, &block)
61
- fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
60
+ fail Vedeu::Error::RequiresBlock unless block_given?
62
61
 
63
62
  Vedeu::Models::Group.build(name: name, &block).store
64
63
  end
@@ -31,13 +31,11 @@ module Vedeu
31
31
  # execution lifetime.
32
32
  # @param block [Proc] A set of attributes which define the
33
33
  # features of the interface.
34
- # @raise [Vedeu::Error::InvalidSyntax] The required block was
35
- # not given.
34
+ # @raise [Vedeu::Error::RequiresBlock]
36
35
  # @return [Vedeu::Models::Interface]
37
36
  # @todo More documentation required.
38
37
  def interface(name, &block)
39
- fail Vedeu::Error::InvalidSyntax,
40
- 'block not given' unless block_given?
38
+ fail Vedeu::Error::RequiresBlock unless block_given?
41
39
  fail Vedeu::Error::MissingRequired,
42
40
  'name not given' unless present?(name)
43
41
 
@@ -2,19 +2,20 @@ module Vedeu
2
2
 
3
3
  module DSL
4
4
 
5
- # You can define keymaps by name which matches a defined interface. When
6
- # that interface is in focus, keys pressed as part of this definition will
7
- # affect that interface. This allows you to form context driven behaviour
8
- # for your application.
5
+ # You can define keymaps by name which matches a defined
6
+ # interface. When that interface is in focus, keys pressed as part
7
+ # of this definition will affect that interface. This allows you
8
+ # to form context driven behaviour for your application.
9
9
  #
10
10
  class Keymap
11
11
 
12
12
  include Vedeu::Common
13
13
  include Vedeu::DSL
14
14
 
15
- # Define actions for keypresses for when specific interfaces are in focus.
16
- # Unless an interface is specified, the key will be assumed to be global,
17
- # meaning its action will happen regardless of the interface in focus.
15
+ # Define actions for keypresses for when specific interfaces are
16
+ # in focus. Unless an interface is specified, the key will be
17
+ # assumed to be global, meaning its action will happen
18
+ # regardless of the interface in focus.
18
19
  #
19
20
  # Vedeu.keymap 'some_interface' do
20
21
  # key('s') { Vedeu.trigger(:save) }
@@ -44,13 +45,13 @@ module Vedeu
44
45
  # end
45
46
  # end
46
47
  #
47
- # @param name [String] The name of the interface which this keymap relates
48
- # to.
48
+ # @param name [String] The name of the interface which this
49
+ # keymap relates to.
49
50
  # @param block [Proc]
50
- # @raise [Vedeu::Error::InvalidSyntax] The required block was not given.
51
+ # @raise [Vedeu::Error::RequiresBlock]
51
52
  # @return [Vedeu::Input::Keymap]
52
- # @todo Try to remember why we need to pre-create the keymap in the
53
- # repository.
53
+ # @todo Try to remember why we need to pre-create the keymap in
54
+ # the repository.
54
55
  def self.keymap(name, &block)
55
56
  Vedeu::Input::Keymap.new(name: name).store
56
57
 
@@ -73,11 +74,12 @@ module Vedeu
73
74
  # The key(s) pressed. Special keys can be found in
74
75
  # {Vedeu::Input::Input#specials}. When more than one key is
75
76
  # defined, then the extras are treated as aliases.
76
- # @param block [Proc] The action to perform when this key is pressed. Can
77
- # be a method call or event triggered.
77
+ # @param block [Proc] The action to perform when this key is
78
+ # pressed. Can be a method call or event triggered.
78
79
  # @raise [Vedeu::Error::InvalidSyntax]
79
- # When the required block is not given, the values parameter is
80
- # undefined, or when processing the collection, a member is undefined.
80
+ # When the required block is not given, the values parameter
81
+ # is undefined, or when processing the collection, a member
82
+ # is undefined.
81
83
  # @return [Array] A collection containing the keypress(es).
82
84
  def key(*values, &block)
83
85
  fail Vedeu::Error::InvalidSyntax,
@@ -99,12 +101,13 @@ module Vedeu
99
101
 
100
102
  # Define the name of the keymap.
101
103
  #
102
- # To only allow certain keys to work with specific interfaces, use the
103
- # same name as the interface.
104
+ # To only allow certain keys to work with specific interfaces,
105
+ # use the same name as the interface.
104
106
  #
105
- # When the name '_global_' is used, all keys in the keymap block will be
106
- # available to all interfaces. Once a key has been defined in the
107
- # '_global_' keymap, it cannot be used for a specific interface.
107
+ # When the name '_global_' is used, all keys in the keymap block
108
+ # will be available to all interfaces. Once a key has been
109
+ # defined in the '_global_' keymap, it cannot be used for a
110
+ # specific interface.
108
111
  #
109
112
  # Vedeu.keymap do
110
113
  # name 'some_interface'
@@ -59,8 +59,7 @@ module Vedeu
59
59
  # end
60
60
  # end
61
61
  #
62
- # @raise [Vedeu::Error::InvalidSyntax] When no block or value is
63
- # provided.
62
+ # @raise [Vedeu::Error::RequiresBlock]
64
63
  # @return [Vedeu::Views::Lines]
65
64
  def line(value = '', &block)
66
65
  if block_given?
@@ -73,7 +72,7 @@ module Vedeu
73
72
  value: [build_stream(value)])
74
73
 
75
74
  else
76
- fail Vedeu::Error::InvalidSyntax, 'block not given'
75
+ fail Vedeu::Error::RequiresBlock unless block_given?
77
76
 
78
77
  end
79
78
 
@@ -100,12 +99,11 @@ module Vedeu
100
99
  # end
101
100
  #
102
101
  # @param block [Proc]
103
- # @raise [Vedeu::Error::InvalidSyntax] The required block was
104
- # not given.
102
+ # @raise [Vedeu::Error::RequiresBlock]
105
103
  # @return [Vedeu::Views::Streams<Vedeu::Views::Stream>]
106
104
  # @see Vedeu::DSL::Stream for subdirectives.
107
105
  def streams(&block)
108
- fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
106
+ fail Vedeu::Error::RequiresBlock unless block_given?
109
107
 
110
108
  model.add(model.member.build(attributes, &block))
111
109
  end
@@ -2,18 +2,20 @@ module Vedeu
2
2
 
3
3
  module DSL
4
4
 
5
- # Provides colour and style helpers for use in the {Vedeu::DSL::Interface},
6
- # {Vedeu::DSL::Line} and {Vedeu::DSL::Stream} classes.
5
+ # Provides colour and style helpers for use in the
6
+ # {Vedeu::DSL::Interface}, {Vedeu::DSL::Line} and
7
+ # {Vedeu::DSL::Stream} classes.
7
8
  #
8
9
  module Presentation
9
10
 
10
- # Define the background colour for an interface, line, or a stream. When
11
- # called with a block, will create a new stream with the background colour
12
- # specified. When the block terminates, the background will return to that
13
- # of the parent.
11
+ # Define the background colour for an interface, line, or a
12
+ # stream. When called with a block, will create a new stream
13
+ # with the background colour specified. When the block
14
+ # terminates, the background will return to that of the parent.
14
15
  #
15
- # @note The last defined background colour for a particular interface,
16
- # line or stream overrides previously defined entries in the same block.
16
+ # @note The last defined background colour for a particular
17
+ # interface, line or stream overrides previously defined
18
+ # entries in the same block.
17
19
  #
18
20
  # @param value [String] A HTML/CSS value.
19
21
  #
@@ -56,11 +58,13 @@ module Vedeu
56
58
  alias_method :fgcolor=, :foreground
57
59
 
58
60
  # Define either or both foreground and background colours for an
59
- # interface, line or a stream. At least one attribute is required.
61
+ # interface, line or a stream. At least one attribute is
62
+ # required.
60
63
  #
61
- # @note Rejects invalid keys and empty/nil attributes. Also, the last
62
- # defined colour for a particular interface, line or stream overrides
63
- # previously defined entries in the same block.
64
+ # @note Rejects invalid keys and empty/nil attributes. Also, the
65
+ # last defined colour for a particular interface, line or
66
+ # stream overrides previously defined entries in the same
67
+ # block.
64
68
  #
65
69
  # @param attrs [Hash] See {Vedeu::Colours::Colour}
66
70
  #