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
@@ -20,36 +20,10 @@ module Vedeu
20
20
 
21
21
  class << self
22
22
 
23
- include Vedeu::Common
23
+ extend Forwardable
24
24
 
25
- # Coerce a document into a new instance of
26
- # Vedeu::Editor::Lines.
27
- #
28
- # @param document [Array<String>|Vedeu::Editor::Lines]
29
- # @return (see #initialize)
30
- def coerce(document)
31
- if document.is_a?(self)
32
- new(document.lines)
33
-
34
- elsif document.is_a?(Array)
35
- collection = document.map do |line|
36
- Vedeu::Editor::Line.coerce(line)
37
- end
38
-
39
- new(collection)
40
-
41
- elsif string?(document)
42
- collection = document.lines.map(&:chomp).map do |line|
43
- Vedeu::Editor::Line.coerce(line)
44
- end
45
-
46
- new(collection)
47
-
48
- else
49
- new
50
-
51
- end
52
- end
25
+ def_delegators Vedeu::Coercers::EditorLines,
26
+ :coerce
53
27
 
54
28
  end # Eigenclass
55
29
 
@@ -280,9 +280,7 @@ module Vedeu
280
280
  defaults.merge!(@options)
281
281
  end
282
282
 
283
- # The default values for a new instance of this class.
284
- #
285
- # @return [Hash<Symbol => void>]
283
+ # @macro defaults_method
286
284
  def defaults
287
285
  {
288
286
  delay: 0.0,
@@ -226,9 +226,7 @@ module Vedeu
226
226
  end
227
227
  end
228
228
 
229
- # Returns the default options/attributes for this class.
230
- #
231
- # @return [Hash<Symbol => Boolean,Fixnum,NilClass,Symbol>]
229
+ # @macro defaults_method
232
230
  def defaults
233
231
  {
234
232
  alignment: :none,
@@ -12,7 +12,7 @@ module Vedeu
12
12
 
13
13
  private
14
14
 
15
- # @see Vedeu::Geometries::Dimension#defaults
15
+ # @macro defaults_method
16
16
  def defaults
17
17
  super.merge!(default: Vedeu.width)
18
18
  end
@@ -12,7 +12,7 @@ module Vedeu
12
12
 
13
13
  private
14
14
 
15
- # @see Vedeu::Geometries::Dimension#defaults
15
+ # @macro defaults_method
16
16
  def defaults
17
17
  super.merge!(default: Vedeu.height)
18
18
  end
@@ -196,10 +196,7 @@ module Vedeu
196
196
  }
197
197
  end
198
198
 
199
- # Returns the default options/attributes for this class.
200
- #
201
- # @return [Hash<Symbol => Boolean|Fixnum|NilClass|String|Symbol|
202
- # Vedeu::Geometries::Repository]
199
+ # @macro defaults_method
203
200
  def defaults
204
201
  {
205
202
  client: nil,
@@ -62,7 +62,7 @@ module Vedeu
62
62
 
63
63
  private
64
64
 
65
- # @return [Hash<Symbol => Fixnum|String|Symbol>]
65
+ # @macro defaults_method
66
66
  def defaults
67
67
  {
68
68
  direction: :none,
@@ -158,10 +158,7 @@ module Vedeu
158
158
 
159
159
  private
160
160
 
161
- # Returns the default options/attributes for this class.
162
- #
163
- # @return [Hash<Symbol => Boolean|Set|String|
164
- # Vedeu::Groups::Repository]
161
+ # @macro defaults_method
165
162
  def defaults
166
163
  {
167
164
  members: Set.new,
@@ -183,11 +180,11 @@ module Vedeu
183
180
  end # Groups
184
181
 
185
182
  # @!method hide_group
186
- # @see Vedeu::Toggleable::ClassMethods#hide
183
+ # @see Vedeu::Toggleable::SingletonMethods#hide
187
184
  # @!method show_group
188
- # @see Vedeu::Toggleable::ClassMethods#show
185
+ # @see Vedeu::Toggleable::SingletonMethods#show
189
186
  # @!method toggle_group
190
- # @see Vedeu::Toggleable::ClassMethods#toggle
187
+ # @see Vedeu::Toggleable::SingletonMethods#toggle
191
188
  def_delegators Vedeu::Groups::Group,
192
189
  :hide_group,
193
190
  :show_group,
@@ -85,9 +85,7 @@ module Vedeu
85
85
 
86
86
  private
87
87
 
88
- # Returns the default options/attributes for this class.
89
- #
90
- # @return [Hash<Symbol => Array|String|Vedeu::Input::Repository]
88
+ # @macro defaults_method
91
89
  def defaults
92
90
  {
93
91
  name: '',
@@ -6,6 +6,8 @@ module Vedeu
6
6
 
7
7
  # A collection of {Vedeu::Input::Key} instances.
8
8
  #
9
+ # @api private
10
+ #
9
11
  class Keys < Vedeu::Repositories::Collection
10
12
 
11
13
  end # Keys
@@ -6,6 +6,8 @@ module Vedeu
6
6
 
7
7
  # Maps keys to keymaps.
8
8
  #
9
+ # @api private
10
+ #
9
11
  class Mapper
10
12
 
11
13
  class << self
@@ -6,6 +6,8 @@ module Vedeu
6
6
 
7
7
  # Rudimentary support for mouse interactions.
8
8
  #
9
+ # @api private
10
+ #
9
11
  class Mouse
10
12
 
11
13
  # Trigger an event depending on which button was pressed.
@@ -48,12 +48,6 @@ module Vedeu
48
48
  input
49
49
  end
50
50
 
51
- protected
52
-
53
- # @!attribute [r] input
54
- # @return [NilClass|String]
55
- attr_reader :input
56
-
57
51
  private
58
52
 
59
53
  # @return [IO]
@@ -66,7 +60,7 @@ module Vedeu
66
60
  mode == :cooked
67
61
  end
68
62
 
69
- # @return [Hash<Symbol => Symbol>]
63
+ # @macro defaults_method
70
64
  def defaults
71
65
  {
72
66
  mode: :cooked,
@@ -98,7 +98,7 @@ module Vedeu
98
98
  options[:content_only]
99
99
  end
100
100
 
101
- # @return [Hash<Symbol => Boolean>]
101
+ # @macro defaults_method
102
102
  def defaults
103
103
  {
104
104
  content_only: false,
@@ -43,6 +43,10 @@ module Vedeu
43
43
  # @return [Vedeu::Views::Composition]
44
44
  attr_accessor :parent
45
45
 
46
+ # @!attribute [rw] wordwrap
47
+ # @return [Boolean]
48
+ attr_accessor :wordwrap
49
+
46
50
  # @!attribute [rw] zindex
47
51
  # @return [Fixnum]
48
52
  attr_accessor :zindex
@@ -60,6 +64,7 @@ module Vedeu
60
64
  # @option attributes repository [Vedeu::Interfaces::Repository]
61
65
  # @option attributes style [Vedeu::Presentation::Style]
62
66
  # @option attributes visible [Boolean]
67
+ # @option attributes wordwrap [Boolean]
63
68
  # @option attributes zindex [Fixnum]
64
69
  # @return [Vedeu::Interfaces::Interface]
65
70
  def initialize(attributes = {})
@@ -82,6 +87,7 @@ module Vedeu
82
87
  repository: repository,
83
88
  style: style,
84
89
  visible: visible,
90
+ wordwrap: wordwrap,
85
91
  zindex: zindex,
86
92
  }
87
93
  end
@@ -140,9 +146,7 @@ module Vedeu
140
146
 
141
147
  private
142
148
 
143
- # The default values for a new instance of this class.
144
- #
145
- # @return [Hash<Symbol => void>]
149
+ # @macro defaults_method
146
150
  def defaults
147
151
  {
148
152
  client: nil,
@@ -156,6 +160,7 @@ module Vedeu
156
160
  repository: Vedeu.interfaces,
157
161
  style: :normal,
158
162
  visible: true,
163
+ wordwrap: true,
159
164
  zindex: 0,
160
165
  }
161
166
  end
@@ -165,11 +170,11 @@ module Vedeu
165
170
  end # Interfaces
166
171
 
167
172
  # @!method hide_interface
168
- # @see Vedeu::Toggleable::ClassMethods#hide
173
+ # @see Vedeu::Toggleable::SingletonMethods#hide
169
174
  # @!method show_interface
170
- # @see Vedeu::Toggleable::ClassMethods#show
175
+ # @see Vedeu::Toggleable::SingletonMethods#show
171
176
  # @!method toggle_interface
172
- # @see Vedeu::Toggleable::ClassMethods#toggle
177
+ # @see Vedeu::Toggleable::SingletonMethods#toggle
173
178
  def_delegators Vedeu::Interfaces::Interface,
174
179
  :hide_interface,
175
180
  :show_interface,
@@ -16,10 +16,10 @@ module Vedeu
16
16
  # @param log [void]
17
17
  # @return [Vedeu::Logging::LocklessLogDevice]
18
18
  def initialize(log = nil)
19
- @dev = nil
20
19
  @filename = nil
20
+ @log = log
21
21
 
22
- if log.respond_to?(:write) && log.respond_to?(:close)
22
+ if writable? && closeable?
23
23
  @dev = log
24
24
 
25
25
  else
@@ -46,8 +46,19 @@ module Vedeu
46
46
  nil
47
47
  end
48
48
 
49
+ protected
50
+
51
+ # @!attribute [r] log
52
+ # @return [String]
53
+ attr_reader :log
54
+
49
55
  private
50
56
 
57
+ # @return [Boolean]
58
+ def closable?
59
+ log.respond_to?(:close)
60
+ end
61
+
51
62
  # @param log [String]
52
63
  # @return [void]
53
64
  def open_logfile(log)
@@ -62,6 +73,11 @@ module Vedeu
62
73
  end
63
74
  end
64
75
 
76
+ # @return [Boolean]
77
+ def writable?
78
+ log.respond_to?(:write)
79
+ end
80
+
65
81
  end # LocklessLogDevice
66
82
 
67
83
  end # Logging
@@ -33,24 +33,30 @@ module Vedeu
33
33
  end
34
34
 
35
35
  # Write an entry to the log file stating how long a section of
36
- # code took in milliseconds. Useful for debugging performance.
36
+ # code took in milliseconds when debugging is enabled and a
37
+ # block was Useful for debugging performance.
37
38
  #
38
39
  # @param block [Proc]
39
40
  # @macro raise_requires_block
40
- # @return [void] The return value of the executed block.
41
+ # @return [void|NilClass] The return value of the executed
42
+ # block if given, or nil if debugging is disabled.
41
43
  def measure(&block)
42
- fail Vedeu::Error::RequiresBlock unless block_given?
44
+ if block_given?
45
+ if Vedeu.config.debug?
46
+ work = yield
43
47
 
44
- if Vedeu.config.debug?
45
- work = yield
48
+ Vedeu.log(type: :timer,
49
+ message: "#{message} took #{elapsed}ms.")
46
50
 
47
- Vedeu.log(type: :timer,
48
- message: "#{message} took #{elapsed}ms.")
51
+ work
49
52
 
50
- work
53
+ else
54
+ yield
55
+
56
+ end
51
57
 
52
58
  else
53
- yield
59
+ fail Vedeu::Error::RequiresBlock if Vedeu.config.debug?
54
60
 
55
61
  end
56
62
  end
@@ -65,6 +71,8 @@ module Vedeu
65
71
  # @return [String]
66
72
  attr_reader :message
67
73
 
74
+ private
75
+
68
76
  # Returns the elapsed time in milliseconds with 3 decimal
69
77
  # places.
70
78
  #
@@ -195,9 +195,7 @@ module Vedeu
195
195
 
196
196
  private
197
197
 
198
- # The default values for a new instance of this class.
199
- #
200
- # @return [Hash]
198
+ # @macro defaults_method
201
199
  def defaults
202
200
  {
203
201
  client: nil,
@@ -43,9 +43,8 @@ module Vedeu
43
43
  show
44
44
  end
45
45
 
46
- # Provide additional behaviour as class methods.
47
- #
48
- module ClassMethods
46
+ # @macro module_singleton_methods
47
+ module SingletonMethods
49
48
 
50
49
  # Hides the named model, or without a name, the model with same
51
50
  # name as the currently focussed interface.
@@ -143,11 +142,11 @@ module Vedeu
143
142
  Vedeu.buffers.by_name(name)
144
143
  end
145
144
 
146
- end # ClassMethods
145
+ end # SingletonMethods
147
146
 
148
- # @macro included_module
147
+ # @macro module_included
149
148
  def self.included(klass)
150
- klass.extend(Vedeu::Toggleable::ClassMethods)
149
+ klass.extend(Vedeu::Toggleable::SingletonMethods)
151
150
  end
152
151
 
153
152
  end # Toggleable
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Vedeu
4
4
 
5
+ # Classes within the Output namespace handle various aspects of
6
+ # rendering content.
7
+ #
5
8
  module Output
6
9
 
7
10
  end # Output
@@ -17,7 +17,7 @@ module Vedeu
17
17
  include Vedeu::Renderers::Options
18
18
 
19
19
  # @param (see #initialize)
20
- # @return [String]
20
+ # @return (see #render)
21
21
  def self.render(output, options = {})
22
22
  new(output, options).render
23
23
  end
@@ -2,13 +2,12 @@
2
2
 
3
3
  module Vedeu
4
4
 
5
- # Classes within the Output namespace handle various aspects of
6
- # rendering content.
7
- #
8
5
  module Output
9
6
 
10
7
  # Sends the output to the renderers.
11
8
  #
9
+ # @api public
10
+ #
12
11
  class Output
13
12
 
14
13
  include Vedeu::Common
@@ -7,7 +7,7 @@ module Vedeu
7
7
  # @see Vedeu::Bindings::System#refresh!
8
8
  class Refresh
9
9
 
10
- # @see #all
10
+ # @return (see #all)
11
11
  def self.all
12
12
  new.all
13
13
  end
@@ -16,7 +16,8 @@ module Vedeu
16
16
  include Vedeu::Presentation
17
17
 
18
18
  # @api public
19
- # @see Vedeu::Output::Write#initialize
19
+ # @param (see #initialize)
20
+ # @return (see #write)
20
21
  def self.write(output = nil, options = {})
21
22
  new(output, options).write
22
23
  end
@@ -63,7 +64,7 @@ module Vedeu
63
64
 
64
65
  private
65
66
 
66
- # @return [Hash<Symbol => Fixnum>]
67
+ # @macro defaults_method
67
68
  def defaults
68
69
  {
69
70
  x: 1,