vedeu 0.8.9 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -0
  3. data/docs/configuration/drb.md +6 -0
  4. data/docs/configuration/drb_host.md +6 -0
  5. data/docs/configuration/drb_port.md +6 -0
  6. data/docs/configuration/interactive.md +21 -0
  7. data/docs/configuration/run_once.md +8 -0
  8. data/docs/configuration/standalone.md +20 -0
  9. data/docs/dsl.md +1 -1
  10. data/lib/vedeu.rb +15 -5
  11. data/lib/vedeu/application/controller.rb +5 -6
  12. data/lib/vedeu/borders/border.rb +1 -5
  13. data/lib/vedeu/borders/title.rb +6 -1
  14. data/lib/vedeu/buffers/buffer.rb +1 -3
  15. data/lib/vedeu/buffers/empty.rb +1 -3
  16. data/lib/vedeu/buffers/refresh.rb +1 -1
  17. data/lib/vedeu/buffers/view.rb +1 -1
  18. data/lib/vedeu/cells/border.rb +1 -1
  19. data/lib/vedeu/cells/borders/edges/bottom_horizontal.rb +1 -1
  20. data/lib/vedeu/cells/borders/edges/left_vertical.rb +1 -1
  21. data/lib/vedeu/cells/borders/edges/right_vertical.rb +1 -1
  22. data/lib/vedeu/cells/borders/edges/top_horizontal.rb +1 -1
  23. data/lib/vedeu/cells/borders/horizontal.rb +1 -1
  24. data/lib/vedeu/cells/borders/vertical.rb +1 -1
  25. data/lib/vedeu/cells/borders/vertices/bottom_left.rb +1 -1
  26. data/lib/vedeu/cells/borders/vertices/bottom_right.rb +1 -1
  27. data/lib/vedeu/cells/borders/vertices/top_left.rb +1 -1
  28. data/lib/vedeu/cells/borders/vertices/top_right.rb +1 -1
  29. data/lib/vedeu/cells/cursor.rb +1 -1
  30. data/lib/vedeu/cells/empty.rb +1 -1
  31. data/lib/vedeu/coercers/coercer.rb +8 -0
  32. data/lib/vedeu/coercers/colour.rb +6 -4
  33. data/lib/vedeu/coercers/editor_line.rb +4 -1
  34. data/lib/vedeu/coercers/editor_lines.rb +18 -3
  35. data/lib/vedeu/coercers/lines.rb +2 -1
  36. data/lib/vedeu/coercers/page.rb +2 -6
  37. data/lib/vedeu/coercers/position.rb +1 -3
  38. data/lib/vedeu/coercers/row.rb +0 -1
  39. data/lib/vedeu/colours/colour.rb +1 -2
  40. data/lib/vedeu/configuration/api.rb +6 -69
  41. data/lib/vedeu/configuration/configuration.rb +1 -4
  42. data/lib/vedeu/cursors/coordinate.rb +1 -3
  43. data/lib/vedeu/cursors/cursor.rb +4 -7
  44. data/lib/vedeu/cursors/reposition.rb +1 -1
  45. data/lib/vedeu/distributed/test_application.rb +1 -3
  46. data/lib/vedeu/dsl/border.rb +3 -4
  47. data/lib/vedeu/dsl/geometry.rb +6 -7
  48. data/lib/vedeu/dsl/helpers/align.rb +1 -1
  49. data/lib/vedeu/dsl/helpers/attributes.rb +2 -2
  50. data/lib/vedeu/dsl/helpers/truncate.rb +1 -2
  51. data/lib/vedeu/dsl/helpers/wordwrap.rb +1 -3
  52. data/lib/vedeu/dsl/presentation.rb +18 -0
  53. data/lib/vedeu/editor/cursor.rb +1 -3
  54. data/lib/vedeu/editor/document.rb +1 -3
  55. data/lib/vedeu/editor/line.rb +4 -12
  56. data/lib/vedeu/editor/lines.rb +3 -29
  57. data/lib/vedeu/events/event.rb +1 -3
  58. data/lib/vedeu/geometries/area/dimension.rb +1 -3
  59. data/lib/vedeu/geometries/area/x_dimension.rb +1 -1
  60. data/lib/vedeu/geometries/area/y_dimension.rb +1 -1
  61. data/lib/vedeu/geometries/geometry.rb +1 -4
  62. data/lib/vedeu/geometries/move.rb +1 -1
  63. data/lib/vedeu/groups/group.rb +4 -7
  64. data/lib/vedeu/input/keymap.rb +1 -3
  65. data/lib/vedeu/input/keys.rb +2 -0
  66. data/lib/vedeu/input/mapper.rb +2 -0
  67. data/lib/vedeu/input/mouse.rb +2 -0
  68. data/lib/vedeu/input/read.rb +1 -7
  69. data/lib/vedeu/interfaces/clear.rb +1 -1
  70. data/lib/vedeu/interfaces/interface.rb +11 -6
  71. data/lib/vedeu/logging/lockless_log_device.rb +18 -2
  72. data/lib/vedeu/logging/timer.rb +17 -9
  73. data/lib/vedeu/menus/menu.rb +1 -3
  74. data/lib/vedeu/models/toggleable.rb +5 -6
  75. data/lib/vedeu/output/all.rb +3 -0
  76. data/lib/vedeu/output/compressor.rb +1 -1
  77. data/lib/vedeu/output/output.rb +2 -3
  78. data/lib/vedeu/output/refresh.rb +1 -1
  79. data/lib/vedeu/output/write.rb +3 -2
  80. data/lib/vedeu/renderers/options.rb +1 -3
  81. data/lib/vedeu/repositories/defaults.rb +1 -1
  82. data/lib/vedeu/repositories/model.rb +5 -6
  83. data/lib/vedeu/repositories/registerable.rb +6 -8
  84. data/lib/vedeu/runtime/flags.rb +2 -2
  85. data/lib/vedeu/support/y_coordinate.rb +1 -1
  86. data/lib/vedeu/version.rb +1 -1
  87. data/lib/vedeu/views/composition.rb +1 -3
  88. data/lib/vedeu/views/default_attributes.rb +2 -4
  89. data/lib/vedeu/views/value.rb +6 -8
  90. data/lib/vedeu/views/view.rb +9 -3
  91. data/test/lib/vedeu/application/application_helper_test.rb +3 -2
  92. data/test/lib/vedeu/application/controller_test.rb +10 -11
  93. data/test/lib/vedeu/application/helper_test.rb +3 -2
  94. data/test/lib/vedeu/application/view_test.rb +4 -3
  95. data/test/lib/vedeu/coercers/editor_line_test.rb +21 -0
  96. data/test/lib/vedeu/coercers/editor_lines_test.rb +41 -0
  97. data/test/lib/vedeu/coercers/page_test.rb +1 -1
  98. data/test/lib/vedeu/cursors/dsl_test.rb +11 -10
  99. data/test/lib/vedeu/dsl/dsl_test.rb +3 -2
  100. data/test/lib/vedeu/dsl/elements_test.rb +19 -21
  101. data/test/lib/vedeu/dsl/presentation_test.rb +42 -0
  102. data/test/lib/vedeu/editor/collection_test.rb +5 -4
  103. data/test/lib/vedeu/editor/line_test.rb +4 -27
  104. data/test/lib/vedeu/editor/lines_test.rb +4 -54
  105. data/test/lib/vedeu/logging/timer_test.rb +11 -1
  106. data/test/lib/vedeu/models/toggleable_test.rb +27 -25
  107. data/test/lib/vedeu/output/compressor_cache_test.rb +0 -3
  108. data/test/lib/vedeu/presentation/colour_test.rb +13 -12
  109. data/test/lib/vedeu/presentation/presentation_test.rb +4 -2
  110. data/test/lib/vedeu/presentation/styles_test.rb +5 -3
  111. data/test/lib/vedeu/renderers/options_test.rb +10 -12
  112. data/test/lib/vedeu/repositories/assemblage_test.rb +11 -10
  113. data/test/lib/vedeu/repositories/collection_test.rb +1 -1
  114. data/test/lib/vedeu/repositories/defaults_test.rb +9 -7
  115. data/test/lib/vedeu/repositories/model_test.rb +10 -9
  116. data/test/lib/vedeu/repositories/registerable_test.rb +19 -18
  117. data/test/lib/vedeu/repositories/repository_test.rb +7 -7
  118. data/test/lib/vedeu/repositories/store_test.rb +14 -13
  119. data/test/lib/vedeu/templating/helpers_test.rb +9 -8
  120. data/test/lib/vedeu/views/default_attributes_test.rb +17 -17
  121. data/test/lib/vedeu/views/value_test.rb +0 -1
  122. data/test/support/helpers/model_test_class.rb +1 -2
  123. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83b3e4909563317ccf8df15a1f8e0106f27ca00a
4
- data.tar.gz: fc3fce16bcc6f5648854b4897b493aaf6b04857e
3
+ metadata.gz: 2b0005acf22666df61aa974c5fa63a7a2efe5e8b
4
+ data.tar.gz: 1534526ad0f0118be2c7d56513bc879a8d3da466
5
5
  SHA512:
6
- metadata.gz: 32aa195136e7b3cbbfa16018dba9c6da366df448e2a4a432c232485808bbad8d0c5dd4f9154d5313ccb9a1867373b607142dad8859a90474c738deca068d2f94
7
- data.tar.gz: efdbc099065362fd76ecc407f50915ebad6285b0f36707153fe7a2266f8603be7620aaefb87abb34871730db610527bddfda04783258c51b9bf9051273727019
6
+ metadata.gz: 19ef391ed3888dde03e08ca67767adb96d46a623d1b7a472b53eb55dc3bf6835caaf790610a88275b16162c79bad110e0338a122dff7ebb2bdd648fd530c7af2
7
+ data.tar.gz: 7cae3f72bfc99f04dbd03dc9b6f4b20e620bb18d3850395da822b506856b6a61b2c98095fa33f338825d90c87d4203887212d66abcef100e321b7f008dad6e86
@@ -3,5 +3,6 @@ ratings:
3
3
  - lib/**
4
4
  exclude_paths:
5
5
  - "examples/*"
6
+ - "integrations/*"
6
7
  - "test/*"
7
8
  - "vendor/*"
@@ -0,0 +1,6 @@
1
+ Sets boolean to run a DRb server.
2
+
3
+ Vedeu.configure do
4
+ drb!
5
+ # ...
6
+ end
@@ -0,0 +1,6 @@
1
+ Sets the hostname or IP address of the DRb server.
2
+
3
+ Vedeu.configure do
4
+ drb_host 'localhost'
5
+ # ...
6
+ end
@@ -0,0 +1,6 @@
1
+ Sets the port of the DRb server.
2
+
3
+ Vedeu.configure do
4
+ drb_port 12345
5
+ # ...
6
+ end
@@ -0,0 +1,21 @@
1
+ Sets boolean to allow user input. The default behaviour of Vedeu is to
2
+ be interactive. This is the same as setting
3
+ {Vedeu::Config::API#standalone} to false.
4
+
5
+ # same as `interactive true` or `standalone false`.
6
+ Vedeu.configure do
7
+ interactive!
8
+ # ...
9
+ end
10
+
11
+ # => Allow user input.
12
+ Vedeu.configure do
13
+ interactive true
14
+ # ...
15
+ end
16
+
17
+ # => Disallow user input.
18
+ Vedeu.configure do
19
+ interactive false
20
+ # ...
21
+ end
@@ -0,0 +1,8 @@
1
+ Sets boolean to run the Vedeu main application loop once. In effect,
2
+ using `run_once!` or setting `run_once` to true will allow Vedeu to
3
+ initialize, run any client application code, cleanup, then terminate.
4
+
5
+ Vedeu.configure do
6
+ run_once!
7
+ # ...
8
+ end
@@ -0,0 +1,20 @@
1
+ Sets boolean to prevent user intervention. This is the same as setting
2
+ {Vedeu::Config::API#interactive} to false.
3
+
4
+ # Same as `standalone true` or `interactive false`.
5
+ Vedeu.configure do
6
+ standalone!
7
+ # ...
8
+ end
9
+
10
+ # => Disallow user input.
11
+ Vedeu.configure do
12
+ standalone true
13
+ # ...
14
+ end
15
+
16
+ # => Allow user input.
17
+ Vedeu.configure do
18
+ standalone false
19
+ # ...
20
+ end
@@ -113,7 +113,7 @@ end
113
113
 
114
114
  ### Creating a new named geometry
115
115
 
116
- {include:Vedeu::DSL::Geometry::ClassMethods#geometry}
116
+ {include:Vedeu::DSL::Geometry::SingletonMethods#geometry}
117
117
 
118
118
  ### Setting the interface dimensions
119
119
 
@@ -46,14 +46,24 @@ end # Vedeu
46
46
 
47
47
  # Define some Yard macros used throughout the project.
48
48
  #
49
- # @!macro [new] included_module
50
- # Provide additional behaviour to a class or module.
49
+ # @!macro [new] defaults_method
50
+ # The default options/attributes for a new instance of this class.
51
+ #
52
+ # @return [Hash<Symbol => void>]
51
53
  #
52
- # When a ClassMethods submodule and/or an InstanceMethods submodule
53
- # is defined within this module, then provide these methods as
54
- # class or instance methods to the including class or module.
54
+ # @!macro [new] module_included
55
+ # Provide additional behaviour to a class or module.
55
56
  #
56
57
  # @param klass [Class]
57
58
  # @return [void]
59
+ #
60
+ # @!macro [new] module_instance_methods
61
+ # Provide additional behaviour as instance methods to the including
62
+ # class or module.
63
+ #
64
+ # @!macro [new] module_singleton_methods
65
+ # Provide additional behaviour as singleton methods to the including
66
+ # class or module.
67
+ #
58
68
 
59
69
  require 'vedeu/all'
@@ -6,9 +6,8 @@ module Vedeu
6
6
  #
7
7
  module Controller
8
8
 
9
- # Provide additional behaviour as class methods.
10
- #
11
- module ClassMethods
9
+ # @macro module_singleton_methods
10
+ module SingletonMethods
12
11
 
13
12
  attr_writer :controller_name
14
13
 
@@ -73,11 +72,11 @@ module Vedeu
73
72
  alias action_name action
74
73
  alias actions action
75
74
 
76
- end # ClassMethods
75
+ end # SingletonMethods
77
76
 
78
- # @macro included_module
77
+ # @macro module_included
79
78
  def self.included(klass)
80
- klass.extend(Vedeu::Controller::ClassMethods)
79
+ klass.extend(Vedeu::Controller::SingletonMethods)
81
80
  end
82
81
 
83
82
  end # Controller
@@ -304,11 +304,7 @@ module Vedeu
304
304
  }
305
305
  end
306
306
 
307
- # The default values for a new instance of this class.
308
- #
309
- # @return [Hash<Symbol => Boolean|Hash|NilClass|String|Symbol|
310
- # Vedeu::Borders::Repository|Vedeu::Presentation::Style>]
311
- # @see Vedeu::EscapeSequences::Borders
307
+ # @macro defaults_method
312
308
  def defaults
313
309
  {
314
310
  bottom_horizontal: nil,
@@ -52,7 +52,7 @@ module Vedeu
52
52
  def render
53
53
  return horizontal if empty?
54
54
 
55
- horizontal[start_index..(start_index + (size - 1))] = chars
55
+ horizontal[start_index..end_index] = chars
56
56
 
57
57
  horizontal
58
58
  end
@@ -121,6 +121,11 @@ module Vedeu
121
121
  value.empty?
122
122
  end
123
123
 
124
+ # @return [Fixnum]
125
+ def end_index
126
+ start_index + (size - 1)
127
+ end
128
+
124
129
  # @return [Vedeu::Geometries::Geometry]
125
130
  def geometry
126
131
  @_geometry ||= Vedeu.geometries.by_name(name)
@@ -174,9 +174,7 @@ module Vedeu
174
174
 
175
175
  private
176
176
 
177
- # Returns the default options/attributes for this class.
178
- #
179
- # @return [Hash<Symbol => NilClass, String>]
177
+ # @macro defaults_method
180
178
  def defaults
181
179
  {
182
180
  back: nil,
@@ -41,9 +41,7 @@ module Vedeu
41
41
 
42
42
  private
43
43
 
44
- # Returns the default options/attributes for this class.
45
- #
46
- # @return [Hash<Symbol => Fixnum|NilClass|String|Symbol>]
44
+ # @macro defaults_method
47
45
  def defaults
48
46
  {
49
47
  height: Vedeu.height,
@@ -71,7 +71,7 @@ module Vedeu
71
71
  defaults.merge!(@options)
72
72
  end
73
73
 
74
- # @return [Hash<Symbol => Boolean>]
74
+ # @macro defaults_method
75
75
  def defaults
76
76
  {
77
77
  content_only: false,
@@ -70,7 +70,7 @@ module Vedeu
70
70
  y: by).buffer
71
71
  end
72
72
 
73
- # @return [Hash<Symbol => NilClass|String|Symbol]
73
+ # @macro defaults_method
74
74
  def defaults
75
75
  {
76
76
  name: nil,
@@ -56,7 +56,7 @@ module Vedeu
56
56
 
57
57
  private
58
58
 
59
- # @return [Hash<Symbol => Hash<void>>]
59
+ # @macro defaults_method
60
60
  def defaults
61
61
  super
62
62
  end
@@ -18,7 +18,7 @@ module Vedeu
18
18
 
19
19
  private
20
20
 
21
- # @return [Hash<Symbol => String>]
21
+ # @macro defaults_method
22
22
  def defaults
23
23
  super.merge!(value: Vedeu.esc.horizontal)
24
24
  end
@@ -18,7 +18,7 @@ module Vedeu
18
18
 
19
19
  private
20
20
 
21
- # @return [Hash<Symbol => String>]
21
+ # @macro defaults_method
22
22
  def defaults
23
23
  super.merge!(value: Vedeu.esc.vertical)
24
24
  end
@@ -18,7 +18,7 @@ module Vedeu
18
18
 
19
19
  private
20
20
 
21
- # @return [Hash<Symbol => String>]
21
+ # @macro defaults_method
22
22
  def defaults
23
23
  super.merge!(value: Vedeu.esc.vertical)
24
24
  end
@@ -18,7 +18,7 @@ module Vedeu
18
18
 
19
19
  private
20
20
 
21
- # @return [Hash<Symbol => String>]
21
+ # @macro defaults_method
22
22
  def defaults
23
23
  super.merge!(value: Vedeu.esc.horizontal)
24
24
  end
@@ -28,7 +28,7 @@ module Vedeu
28
28
 
29
29
  private
30
30
 
31
- # @return [Hash<Symbol => String>]
31
+ # @macro defaults_method
32
32
  def defaults
33
33
  super.merge!(value: Vedeu.esc.horizontal)
34
34
  end
@@ -28,7 +28,7 @@ module Vedeu
28
28
 
29
29
  private
30
30
 
31
- # @return [Hash<Symbol => String>]
31
+ # @macro defaults_method
32
32
  def defaults
33
33
  super.merge!(value: Vedeu.esc.vertical)
34
34
  end
@@ -23,7 +23,7 @@ module Vedeu
23
23
 
24
24
  private
25
25
 
26
- # @return [Hash<Symbol => String>]
26
+ # @macro defaults_method
27
27
  def defaults
28
28
  super.merge!(position: Vedeu::Geometries::Position.new(yn, x),
29
29
  value: Vedeu.esc.bottom_left)
@@ -23,7 +23,7 @@ module Vedeu
23
23
 
24
24
  private
25
25
 
26
- # @return [Hash<Symbol => String>]
26
+ # @macro defaults_method
27
27
  def defaults
28
28
  super.merge!(position: Vedeu::Geometries::Position.new(yn, xn),
29
29
  value: Vedeu.esc.bottom_right)
@@ -23,7 +23,7 @@ module Vedeu
23
23
 
24
24
  private
25
25
 
26
- # @return [Hash<Symbol => String>]
26
+ # @macro defaults_method
27
27
  def defaults
28
28
  super.merge!(position: Vedeu::Geometries::Position.new(y, x),
29
29
  value: Vedeu.esc.top_left)
@@ -23,7 +23,7 @@ module Vedeu
23
23
 
24
24
  private
25
25
 
26
- # @return [Hash<Symbol => String>]
26
+ # @macro defaults_method
27
27
  def defaults
28
28
  super.merge!(position: Vedeu::Geometries::Position.new(y, xn),
29
29
  value: Vedeu.esc.top_right)
@@ -56,7 +56,7 @@ module Vedeu
56
56
 
57
57
  private
58
58
 
59
- # @return [Hash]
59
+ # @macro defaults_method
60
60
  def defaults
61
61
  super.merge!(position: Vedeu::Geometries::Position.new(1, 1))
62
62
  end
@@ -96,7 +96,7 @@ module Vedeu
96
96
 
97
97
  private
98
98
 
99
- # @return [Hash<Symbol => Hash<void>|NilClass|String>]
99
+ # @macro defaults_method
100
100
  def defaults
101
101
  {
102
102
  colour: {},
@@ -46,6 +46,14 @@ module Vedeu
46
46
  value.is_a?(klass)
47
47
  end
48
48
 
49
+ # @macro raise_fatal
50
+ # @return [void]
51
+ def incoercible!
52
+ fail Vedeu::Error::Fatal,
53
+ "Vedeu cannot coerce a '#{value.class.name}' into a " \
54
+ "'#{klass}'."
55
+ end
56
+
49
57
  # @macro raise_not_implemented
50
58
  # @return [Class]
51
59
  def klass
@@ -11,8 +11,6 @@ module Vedeu
11
11
  #
12
12
  class Colour < Vedeu::Coercers::Coercer
13
13
 
14
- include Vedeu::Common
15
-
16
14
  # @macro raise_fatal
17
15
  # @return [void]
18
16
  def coerce
@@ -29,17 +27,21 @@ module Vedeu
29
27
  klass.new(foreground: value)
30
28
 
31
29
  elsif hash?(value)
32
- attributes = Vedeu::Coercers::ColourAttributes.coerce(value)
33
30
  klass.new(attributes)
34
31
 
35
32
  else
36
- fail Vedeu::Error::Fatal, 'Vedeu cannot coerce this colour.'
33
+ incoercible!
37
34
 
38
35
  end
39
36
  end
40
37
 
41
38
  private
42
39
 
40
+ # @return [Hash]
41
+ def attributes
42
+ Vedeu::Coercers::ColourAttributes.coerce(value)
43
+ end
44
+
43
45
  # @return [Boolean]
44
46
  def background?
45
47
  value.is_a?(Vedeu::Colours::Background)
@@ -16,8 +16,11 @@ module Vedeu
16
16
  if coerced?
17
17
  value
18
18
 
19
- else
19
+ elsif string?(value)
20
+ klass.new(value)
20
21
 
22
+ else
23
+ klass.new
21
24
 
22
25
  end
23
26
  end
@@ -11,13 +11,28 @@ module Vedeu
11
11
  #
12
12
  class EditorLines < Vedeu::Coercers::Coercer
13
13
 
14
- # @return [void]
14
+ # @macro raise_fatal
15
+ # @return [Vedeu::Editor::Lines]
15
16
  def coerce
16
17
  if coerced?
17
- value
18
+ klass.new(value.lines)
18
19
 
19
- else
20
+ elsif value.is_a?(Array)
21
+ collection = value.map do |line|
22
+ Vedeu::Editor::Line.coerce(line)
23
+ end
24
+
25
+ klass.new(collection)
26
+
27
+ elsif string?(value)
28
+ collection = value.lines.map(&:chomp).map do |line|
29
+ Vedeu::Editor::Line.coerce(line)
30
+ end
20
31
 
32
+ klass.new(collection)
33
+
34
+ else
35
+ klass.new
21
36
 
22
37
  end
23
38
  end