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
@@ -11,13 +11,14 @@ module Vedeu
11
11
  #
12
12
  class Lines < Vedeu::Coercers::Coercer
13
13
 
14
+ # @macro raise_fatal
14
15
  # @return [void]
15
16
  def coerce
16
17
  if coerced?
17
18
  value
18
19
 
19
20
  else
20
-
21
+ incoercible!
21
22
 
22
23
  end
23
24
  end
@@ -11,9 +11,7 @@ module Vedeu
11
11
  #
12
12
  class Page < Vedeu::Coercers::Coercer
13
13
 
14
- # @param value
15
- # [Vedeu::Models::Page|Vedeu::Models::Row|Array<void>|void]
16
- # @macro raise_invalid_syntax
14
+ # @macro raise_fatal
17
15
  # @return [Vedeu::Models::Page]
18
16
  def coerce
19
17
  if coerced?
@@ -31,9 +29,7 @@ module Vedeu
31
29
  klass.new(values)
32
30
 
33
31
  else
34
- fail Vedeu::Error::InvalidSyntax,
35
- "Cannot coerce as value is not an Array, #{klass} " \
36
- "or Vedeu::Models::Row. Is a '#{value.class.name}'."
32
+ incoercible!
37
33
 
38
34
  end
39
35
  end
@@ -27,9 +27,7 @@ module Vedeu
27
27
  klass.new(value, 1)
28
28
 
29
29
  else
30
- fail Vedeu::Error::Fatal,
31
- "Vedeu cannot coerce a '#{value.class.name}' into a " \
32
- "'#{klass}'."
30
+ incoercible!
33
31
 
34
32
  end
35
33
  end
@@ -11,7 +11,6 @@ module Vedeu
11
11
  #
12
12
  class Row < Vedeu::Coercers::Coercer
13
13
 
14
- # @param value [Vedeu::Models::Row|Array<void>|void]
15
14
  # @return [Vedeu::Models::Row]
16
15
  def coerce
17
16
  if coerced?
@@ -134,8 +134,7 @@ module Vedeu
134
134
 
135
135
  private
136
136
 
137
- # @return [Hash<Symbol => Vedeu::Colours::Background|
138
- # Vedeu::Colours:Foreground]
137
+ # @macro defaults_method
139
138
  def defaults
140
139
  {
141
140
  background: Vedeu::Colours::Background.new,
@@ -39,25 +39,7 @@ module Vedeu
39
39
  .log(Vedeu.esc.green { '[api]' }, options)
40
40
  end
41
41
 
42
- # Sets boolean to allow user input. The default behaviour of
43
- # Vedeu is to be interactive.
44
- #
45
- # Vedeu.configure do
46
- # interactive! # => same as `interactive true` or
47
- # # `standalone false`
48
- # # ...
49
- # end
50
- #
51
- # Vedeu.configure do
52
- # interactive true # => Allow user input.
53
- # # ...
54
- # end
55
- #
56
- # Vedeu.configure do
57
- # interactive false # => Disallow user input.
58
- # # ...
59
- # end
60
- #
42
+ # {include:file:docs/configuration/interactive.md}
61
43
  # @param value [Boolean]
62
44
  # @return [Boolean]
63
45
  def interactive!(value = true)
@@ -65,25 +47,7 @@ module Vedeu
65
47
  end
66
48
  alias interactive interactive!
67
49
 
68
- # Sets boolean to prevent user intervention. This is the same as
69
- # setting {include:Vedeu::Config::API#interactive!} to false.
70
- #
71
- # Vedeu.configure do
72
- # standalone! # => same as `standalone true` or
73
- # # `interactive false`
74
- # # ...
75
- # end
76
- #
77
- # Vedeu.configure do
78
- # standalone true # => Disallow user input.
79
- # # ...
80
- # end
81
- #
82
- # Vedeu.configure do
83
- # standalone false # => Allow user input.
84
- # # ...
85
- # end
86
- #
50
+ # {include:file:docs/configuration/standalone.md}
87
51
  # @param value [Boolean]
88
52
  # @return [Boolean]
89
53
  def standalone!(value = true)
@@ -91,16 +55,7 @@ module Vedeu
91
55
  end
92
56
  alias standalone standalone!
93
57
 
94
- # Sets boolean to run the Vedeu main application loop once. In
95
- # effect, using `run_once!` or setting `run_once` to true will
96
- # allow Vedeu to initialize, run any client application code,
97
- # cleanup, then terminate.
98
- #
99
- # Vedeu.configure do
100
- # run_once!
101
- # # ...
102
- # end
103
- #
58
+ # {include:file:docs/configuration/run_once.md}
104
59
  # @param value [Boolean]
105
60
  # @return [Boolean]
106
61
  def run_once!(value = true)
@@ -108,13 +63,7 @@ module Vedeu
108
63
  end
109
64
  alias run_once run_once!
110
65
 
111
- # Sets boolean to run a DRb server.
112
- #
113
- # Vedeu.configure do
114
- # drb!
115
- # # ...
116
- # end
117
- #
66
+ # {include:file:docs/configuration/drb.md}
118
67
  # @param value [Boolean]
119
68
  # @return [Boolean]
120
69
  def drb!(value = true)
@@ -122,26 +71,14 @@ module Vedeu
122
71
  end
123
72
  alias drb drb!
124
73
 
125
- # Sets the hostname or IP address of the DRb server.
126
- #
127
- # Vedeu.configure do
128
- # drb_host 'localhost'
129
- # # ...
130
- # end
131
- #
74
+ # {include:file:docs/configuration/drb_host.md}
132
75
  # @param hostname [String]
133
76
  # @return [String]
134
77
  def drb_host(hostname = '')
135
78
  options[:drb_host] = hostname
136
79
  end
137
80
 
138
- # Sets the port of the DRb server.
139
- #
140
- # Vedeu.configure do
141
- # drb_port 12345
142
- # # ...
143
- # end
144
- #
81
+ # {include:file:docs/configuration/drb_port.md}
145
82
  # @param port [Fixnum|String]
146
83
  # @return [String]
147
84
  def drb_port(port = '')
@@ -350,10 +350,7 @@ module Vedeu
350
350
 
351
351
  private
352
352
 
353
- # The Vedeu default options, which of course are influenced by
354
- # environment variables also.
355
- #
356
- # @return [Hash<Symbol => void>]
353
+ # @macro defaults_method
357
354
  def defaults
358
355
  {
359
356
  background: :default,
@@ -117,9 +117,7 @@ module Vedeu
117
117
  (d...dn_position).to_a
118
118
  end
119
119
 
120
- # The default values for a new instance of this class.
121
- #
122
- # @return [Hash<Symbol => Fixnum|String|Symbol>]
120
+ # @macro defaults_method
123
121
  def defaults
124
122
  {
125
123
  geometry: nil,
@@ -229,10 +229,7 @@ module Vedeu
229
229
  type: type)
230
230
  end
231
231
 
232
- # The default values for a new instance of this class.
233
- #
234
- # @return [Hash<Symbol => Boolean|Fixnum|String|
235
- # Vedeu::Cursors::Repository>]
232
+ # @macro defaults_method
236
233
  def defaults
237
234
  {
238
235
  name: '',
@@ -270,11 +267,11 @@ module Vedeu
270
267
  end # Cursors
271
268
 
272
269
  # @!method hide_cursor
273
- # @see Vedeu::Toggleable::ClassMethods.hide
270
+ # @see Vedeu::Toggleable::SingletonMethods.hide
274
271
  # @!method show_cursor
275
- # @see Vedeu::Toggleable::ClassMethods#show
272
+ # @see Vedeu::Toggleable::SingletonMethods#show
276
273
  # @!method toggle_cursor
277
- # @see Vedeu::Toggleable::ClassMethods#toggle
274
+ # @see Vedeu::Toggleable::SingletonMethods#toggle
278
275
  def_delegators Vedeu::Cursors::Cursor,
279
276
  :hide_cursor,
280
277
  :show_cursor,
@@ -81,7 +81,7 @@ module Vedeu
81
81
  Vedeu.cursors.by_name(name)
82
82
  end
83
83
 
84
- # @return [Hash<Symbol => Fixnum|Symbol|String]
84
+ # @macro defaults_method
85
85
  def defaults
86
86
  {
87
87
  mode: :relative,
@@ -93,9 +93,7 @@ module Vedeu
93
93
  File.dirname(__FILE__) + '/templates/default_application.vedeu'
94
94
  end
95
95
 
96
- # @todo Don't like all this file reading.
97
- #
98
- # @return [Hash<Symbol => String>]
96
+ # @macro defaults_method
99
97
  def defaults
100
98
  {
101
99
  borders: read('default_borders.vedeu'),
@@ -10,8 +10,7 @@ module Vedeu
10
10
  #
11
11
  module Border
12
12
 
13
- # Provide additional behaviour as instance methods.
14
- #
13
+ # @macro module_instance_methods
15
14
  module InstanceMethods
16
15
 
17
16
  # Specify the border of an interface or view with a simple
@@ -36,7 +35,7 @@ module Vedeu
36
35
  # @param name [String|Symbol] The name of the interface; this
37
36
  # is already provided when we define the interface or view,
38
37
  # setting it here is just mirroring functionality of
39
- # {Vedeu::DSL::Border::ClassMethods.border}.
38
+ # {Vedeu::DSL::Border::SingletonMethods.border}.
40
39
  # @param block [Proc]
41
40
  # @macro raise_requires_block
42
41
  # @macro raise_missing_required
@@ -78,7 +77,7 @@ module Vedeu
78
77
 
79
78
  end # InstanceMethods
80
79
 
81
- # @macro included_module
80
+ # @macro module_included
82
81
  def self.included(klass)
83
82
  klass.include(Vedeu::DSL::Border::InstanceMethods)
84
83
  end
@@ -10,9 +10,8 @@ module Vedeu
10
10
  #
11
11
  module Geometry
12
12
 
13
- # Provide additional behaviour as class methods.
14
- #
15
- module ClassMethods
13
+ # @macro module_singleton_methods
14
+ module SingletonMethods
16
15
 
17
16
  # {include:file:docs/dsl/by_method/geometry.md}
18
17
  # @param name [String|Symbol] The name of the interface or
@@ -40,7 +39,7 @@ module Vedeu
40
39
  Vedeu::Geometries::Geometry.build(name: name, &block).store
41
40
  end
42
41
 
43
- end # ClassMethods
42
+ end # SingletonMethods
44
43
 
45
44
  # Provide additional behaviour as instance methods.
46
45
  #
@@ -50,7 +49,7 @@ module Vedeu
50
49
  # @param name [String|Symbol] The name of the interface; this
51
50
  # is already provided when we define the interface or view,
52
51
  # setting it here is just mirroring functionality of
53
- # {Vedeu::DSL::Geometry::ClassMethods#geometry}.
52
+ # {Vedeu::DSL::Geometry::SingletonMethods#geometry}.
54
53
  # @param block [Proc]
55
54
  # @macro raise_requires_block
56
55
  # @macro raise_missing_required
@@ -66,9 +65,9 @@ module Vedeu
66
65
 
67
66
  end # InstanceMethods
68
67
 
69
- # @macro included_module
68
+ # @macro module_included
70
69
  def self.included(klass)
71
- klass.extend(Vedeu::DSL::Geometry::ClassMethods)
70
+ klass.extend(Vedeu::DSL::Geometry::SingletonMethods)
72
71
  klass.include(Vedeu::DSL::Geometry::InstanceMethods)
73
72
  end
74
73
 
@@ -76,7 +76,7 @@ module Vedeu
76
76
  end
77
77
  alias center centre
78
78
 
79
- # @return [Hash]
79
+ # @macro defaults_method
80
80
  def defaults
81
81
  {
82
82
  align: :left,
@@ -113,7 +113,7 @@ module Vedeu
113
113
  Vedeu::Colours::Colour.coerce(new_colour_options)
114
114
  end
115
115
 
116
- # @return [Hash]
116
+ # @macro defaults_method
117
117
  def defaults
118
118
  {
119
119
  align: :none,
@@ -124,7 +124,7 @@ module Vedeu
124
124
  style: nil,
125
125
  truncate: false,
126
126
  width: nil,
127
- wordwrap: false,
127
+ wordwrap: true,
128
128
  }
129
129
  end
130
130
 
@@ -50,8 +50,7 @@ module Vedeu
50
50
 
51
51
  private
52
52
 
53
- # @return [Hash<Symbol => Boolean|Fixnum|NilClass|String|
54
- # Symbol]
53
+ # @macro defaults_method
55
54
  def defaults
56
55
  {
57
56
  name: nil,
@@ -193,9 +193,7 @@ module Vedeu
193
193
  'or there is no geometry registered with that name.'
194
194
  end
195
195
 
196
- # Returns the default options/attributes for this class.
197
- #
198
- # @return [Hash<Symbol => NilClass, String, Symbol>]
196
+ # @macro defaults_method
199
197
  def defaults
200
198
  {
201
199
  ellipsis: '...',
@@ -94,6 +94,13 @@ module Vedeu
94
94
  end
95
95
  alias colour= colour
96
96
 
97
+ # Instruct the view to not use wordwrapping. (Default)
98
+ #
99
+ # @return [Boolean]
100
+ def no_wordwrap!
101
+ wordwrap(false)
102
+ end
103
+
97
104
  # Define a style or styles for an interface, line or a stream.
98
105
  #
99
106
  # @param value [Array<Symbol>|Array<String>|Symbol|String]
@@ -122,6 +129,17 @@ module Vedeu
122
129
  alias styles style
123
130
  alias styles= style
124
131
 
132
+ # Specify whether the view should use wordwrapping (default).
133
+ #
134
+ # @param value [Boolean]
135
+ # @return [Boolean]
136
+ def wordwrap(value = true)
137
+ boolean = value ? true : false
138
+
139
+ model.wordwrap = boolean
140
+ end
141
+ alias wordwrap! wordwrap
142
+
125
143
  private
126
144
 
127
145
  # @return [Hash<Symbol => String>]
@@ -172,9 +172,7 @@ module Vedeu
172
172
  @geometry ||= Vedeu.geometries.by_name(name)
173
173
  end
174
174
 
175
- # Returns the default options/attributes for this class.
176
- #
177
- # @return [Hash<Symbol => Fixnum|NilClass|String|Symbol>]
175
+ # @macro defaults_method
178
176
  def defaults
179
177
  {
180
178
  name: '',
@@ -216,9 +216,7 @@ module Vedeu
216
216
  @cursor ||= Vedeu::Editor::Cursor.new(name: name)
217
217
  end
218
218
 
219
- # Returns the default options/attributes for this class.
220
- #
221
- # @return [Hash<Symbol => void|Symbol]
219
+ # @macro defaults_method
222
220
  def defaults
223
221
  {
224
222
  data: Vedeu::Editor::Lines.new([Vedeu::Editor::Line.new]),
@@ -20,18 +20,10 @@ module Vedeu
20
20
 
21
21
  class << self
22
22
 
23
- include Vedeu::Common
24
-
25
- # Coerce a line into a new instance of Vedeu::Editor::Line.
26
- #
27
- # @param collection [String|Vedeu::Editor::Line]
28
- # @return (see #initialize)
29
- def coerce(collection)
30
- return collection if collection.is_a?(self)
31
- return new(collection) if string?(collection)
32
-
33
- new
34
- end
23
+ extend Forwardable
24
+
25
+ def_delegators Vedeu::Coercers::EditorLine,
26
+ :coerce
35
27
 
36
28
  end # Eigenclass
37
29