vedeu 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/all.rb +1 -2
  3. data/lib/vedeu/api.rb +1 -0
  4. data/lib/vedeu/application.rb +2 -4
  5. data/lib/vedeu/bindings.rb +13 -13
  6. data/lib/vedeu/configuration/api.rb +6 -9
  7. data/lib/vedeu/configuration/cli.rb +4 -7
  8. data/lib/vedeu/cursor/all.rb +2 -2
  9. data/lib/vedeu/cursor/{move_cursor.rb → move.rb} +6 -6
  10. data/lib/vedeu/cursor/refresh_cursor.rb +7 -4
  11. data/lib/vedeu/cursor/{toggle_cursor.rb → toggle.rb} +6 -8
  12. data/lib/vedeu/debug.rb +2 -0
  13. data/lib/vedeu/distributed/client.rb +1 -2
  14. data/lib/vedeu/distributed/server.rb +1 -1
  15. data/lib/vedeu/distributed/subprocess.rb +3 -2
  16. data/lib/vedeu/distributed/test_application.rb +2 -4
  17. data/lib/vedeu/dsl/all.rb +2 -0
  18. data/lib/vedeu/dsl/components/geometry.rb +45 -10
  19. data/lib/vedeu/dsl/interface.rb +1 -1
  20. data/lib/vedeu/events/event.rb +22 -14
  21. data/lib/vedeu/events/trigger.rb +6 -3
  22. data/lib/vedeu/geometry/all.rb +6 -1
  23. data/lib/vedeu/geometry/area.rb +151 -0
  24. data/lib/vedeu/geometry/canvas.rb +79 -0
  25. data/lib/vedeu/geometry/centre.rb +83 -0
  26. data/lib/vedeu/geometry/{content_geometry.rb → content.rb} +3 -3
  27. data/lib/vedeu/geometry/dimension.rb +81 -0
  28. data/lib/vedeu/{models → geometry}/geometry.rb +32 -0
  29. data/lib/vedeu/geometry/grid.rb +1 -2
  30. data/lib/vedeu/geometry/index_position.rb +3 -11
  31. data/lib/vedeu/geometry/limit.rb +1 -1
  32. data/lib/vedeu/geometry/position.rb +5 -0
  33. data/lib/vedeu/geometry/position_index.rb +3 -5
  34. data/lib/vedeu/geometry/position_validator.rb +1 -4
  35. data/lib/vedeu/input/input.rb +1 -2
  36. data/lib/vedeu/input/mapper.rb +2 -4
  37. data/lib/vedeu/launcher.rb +1 -1
  38. data/lib/vedeu/main_loop.rb +2 -0
  39. data/lib/vedeu/models/all.rb +1 -1
  40. data/lib/vedeu/models/cell.rb +68 -0
  41. data/lib/vedeu/models/interface.rb +4 -2
  42. data/lib/vedeu/output/all.rb +0 -1
  43. data/lib/vedeu/output/border.rb +6 -6
  44. data/lib/vedeu/output/clear.rb +6 -5
  45. data/lib/vedeu/output/colour.rb +1 -1
  46. data/lib/vedeu/output/esc.rb +2 -2
  47. data/lib/vedeu/output/output.rb +1 -3
  48. data/lib/vedeu/output/style.rb +2 -2
  49. data/lib/vedeu/output/text.rb +17 -1
  50. data/lib/vedeu/output/translator.rb +1 -8
  51. data/lib/vedeu/output/virtual_terminal.rb +3 -3
  52. data/lib/vedeu/output/wordwrap.rb +1 -1
  53. data/lib/vedeu/repositories/model.rb +1 -1
  54. data/lib/vedeu/repositories/repository.rb +1 -1
  55. data/lib/vedeu/support/log.rb +1 -1
  56. data/lib/vedeu/support/trace.rb +5 -3
  57. data/test/lib/vedeu/cursor/{move_cursor_test.rb → move_test.rb} +22 -22
  58. data/test/lib/vedeu/cursor/{toggle_cursor_test.rb → toggle_test.rb} +6 -6
  59. data/test/lib/vedeu/dsl/components/geometry_test.rb +14 -2
  60. data/test/lib/vedeu/geometry/area_test.rb +99 -0
  61. data/test/lib/vedeu/geometry/canvas_test.rb +66 -0
  62. data/test/lib/vedeu/geometry/centre_test.rb +58 -0
  63. data/test/lib/vedeu/geometry/{content_geometry_test.rb → content_test.rb} +3 -3
  64. data/test/lib/vedeu/geometry/dimension_test.rb +99 -0
  65. data/test/lib/vedeu/{models → geometry}/geometry_test.rb +0 -0
  66. data/test/lib/vedeu/geometry/index_position_test.rb +3 -9
  67. data/test/lib/vedeu/geometry/position_index_test.rb +2 -2
  68. data/test/lib/vedeu/geometry/position_test.rb +6 -0
  69. data/test/lib/vedeu/models/cell_test.rb +66 -0
  70. data/test/lib/vedeu/output/virtual_terminal_test.rb +25 -25
  71. data/vedeu.gemspec +3 -3
  72. metadata +34 -22
  73. data/lib/vedeu/output/char_builder.rb +0 -36
  74. data/test/lib/vedeu/output/char_builder_test.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80640072b141fef605a79c9713e7e0b389fe7ef6
4
- data.tar.gz: ff600f46a10489bd1369e7c3af9389d5265bf802
3
+ metadata.gz: 7649a91c05398be50b8403bf37f0f2f46fbd0317
4
+ data.tar.gz: 2b8f063515e7ae529fc2877ebcf482d821cebbc0
5
5
  SHA512:
6
- metadata.gz: a28c6ab1df05e903f03820ca75492ef060253f3122f4336e7bdf164db91571afbfd6c2f8c3a8983825eba2b2d3139badd88a2012ce5a3689e994132b9a1b6dde
7
- data.tar.gz: 3968b584c4ad1161164dbc7b163f9f850fe5883255ccfa899fa3a1a3374d9d9cddace5f42e506c01c9f4d68fbfbb6d6eb306107e33d31a9eb006b880647765a4
6
+ metadata.gz: 00be70e455d52864393e79a59f678b3d3d308370eadba24d74cf1ce216b4c84c25859cce8ae33ce43d151bd0173b8c7f555fe4e0455c916a0fa33ed671077b3a
7
+ data.tar.gz: 2d82fcc1f9ee603023b99c4d1b4a7bde1c9b02578bb68feeac24a1fdaf6e41ddb98845c8336a883a04be5ec3d40fbed5de3202e50449c3052ea9d36895cdb5e7
data/lib/vedeu/all.rb CHANGED
@@ -5,9 +5,8 @@ require 'vedeu/debug'
5
5
  require 'vedeu/traps'
6
6
  require 'vedeu/exceptions'
7
7
 
8
- require 'vedeu/repositories/all'
9
-
10
8
  require 'vedeu/geometry/all'
9
+ require 'vedeu/repositories/all'
11
10
 
12
11
  require 'vedeu/api'
13
12
  require 'vedeu/bindings'
data/lib/vedeu/api.rb CHANGED
@@ -23,6 +23,7 @@ module Vedeu
23
23
 
24
24
  def_delegators Vedeu::Borders, :borders
25
25
  def_delegators Vedeu::Buffers, :buffers
26
+ def_delegators Vedeu::Canvas, :canvas
26
27
  def_delegators Vedeu::Cursors, :cursors
27
28
  def_delegators Vedeu::Cursors, :cursor
28
29
  def_delegators Vedeu::EventsRepository, :events
@@ -4,14 +4,12 @@ module Vedeu
4
4
  #
5
5
  class Application
6
6
 
7
- # @param configuration [Vedeu::Configuration]
8
- # @return [void]
7
+ # @param (see #initialize)
9
8
  def self.start(configuration)
10
9
  new(configuration).start
11
10
  end
12
11
 
13
- # @param configuration [Vedeu::Configuration]
14
- # @return [void]
12
+ # @param (see #initialize)
15
13
  def self.restart(configuration)
16
14
  new(configuration).start
17
15
  end
@@ -88,32 +88,32 @@ module Vedeu
88
88
  Vedeu.bind(:_cursor_hide_) do |name|
89
89
  named = name ? Vedeu.cursors.by_name(name) : Vedeu.cursor
90
90
 
91
- Vedeu::ToggleCursor.hide(named)
91
+ Vedeu::Toggle.hide(named)
92
92
  end
93
93
 
94
94
  # Show the cursor of the named interface or interface currently in focus.
95
95
  Vedeu.bind(:_cursor_show_) do |name|
96
96
  named = name ? Vedeu.cursors.by_name(name) : Vedeu.cursor
97
97
 
98
- Vedeu::ToggleCursor.show(named)
98
+ Vedeu::Toggle.show(named)
99
99
  end
100
100
 
101
- # @see {Vedeu::MoveCursor}
102
- Vedeu.bind(:_cursor_down_) { |name| Vedeu::MoveCursor.by_name(:down, name) }
101
+ # @see {Vedeu::Move}
102
+ Vedeu.bind(:_cursor_down_) { |name| Vedeu::Move.by_name(:down, name) }
103
103
 
104
- # @see {Vedeu::MoveCursor}
105
- Vedeu.bind(:_cursor_left_) { |name| Vedeu::MoveCursor.by_name(:left, name) }
104
+ # @see {Vedeu::Move}
105
+ Vedeu.bind(:_cursor_left_) { |name| Vedeu::Move.by_name(:left, name) }
106
106
 
107
- # @see {Vedeu::MoveCursor}
108
- Vedeu.bind(:_cursor_right_) { |name| Vedeu::MoveCursor.by_name(:right, name) }
107
+ # @see {Vedeu::Move}
108
+ Vedeu.bind(:_cursor_right_) { |name| Vedeu::Move.by_name(:right, name) }
109
109
 
110
- # @see {Vedeu::MoveCursor}
111
- Vedeu.bind(:_cursor_up_) { |name| Vedeu::MoveCursor.by_name(:up, name) }
110
+ # @see {Vedeu::Move}
111
+ Vedeu.bind(:_cursor_up_) { |name| Vedeu::Move.by_name(:up, name) }
112
112
 
113
- # @see {Vedeu::MoveCursor}
114
- Vedeu.bind(:_cursor_origin_) { |name| Vedeu::MoveCursor.by_name(:origin, name) }
113
+ # @see {Vedeu::Move}
114
+ Vedeu.bind(:_cursor_origin_) { |name| Vedeu::Move.by_name(:origin, name) }
115
115
 
116
- # @see {Vedeu::MoveCursor}
116
+ # @see {Vedeu::Move}
117
117
  Vedeu.bind(:_cursor_reset_) { |name| Vedeu.trigger(:_cursor_origin_, name) }
118
118
 
119
119
  # When triggered with an interface name will focus that interface and
@@ -11,6 +11,11 @@ module Vedeu
11
11
 
12
12
  include Vedeu::Common
13
13
 
14
+ # @param (see #initialize)
15
+ def self.configure(&block)
16
+ new(&block).configuration
17
+ end
18
+
14
19
  # Configure Vedeu via a simple configuration API DSL. Options set here
15
20
  # override the default Vedeu configuration set in
16
21
  # {Vedeu::Configuration#defaults}.
@@ -20,14 +25,6 @@ module Vedeu
20
25
  # ...
21
26
  #
22
27
  # @param block [Proc]
23
- # @return [Hash]
24
- def self.configure(&block)
25
- new(&block).configuration
26
- end
27
-
28
- # Returns an instance of Configuration::API.
29
- #
30
- # @param block [Proc]
31
28
  # @return [Configuration::API]
32
29
  def initialize(&block)
33
30
  instance_eval(&block) if block_given?
@@ -35,7 +32,7 @@ module Vedeu
35
32
 
36
33
  # Returns the configuration options set up by the API DSL.
37
34
  #
38
- # @return [Hash]
35
+ # @return [Hash<Symbol => Boolean, Fixnum, String>]
39
36
  def configuration
40
37
  options.merge!({
41
38
  system_keys: Configuration.default_system_keys.merge!(system_keys)
@@ -9,17 +9,14 @@ module Vedeu
9
9
  #
10
10
  class CLI
11
11
 
12
- # Configure Vedeu via command-line arguments. Options set here via
13
- # arguments override the client application configuration set via
14
- # {Vedeu::API#configure}.
15
- #
16
- # @param args [Array]
17
- # @return [Hash]
12
+ # @param (see #initialize)
18
13
  def self.configure(args = [])
19
14
  new(args).configuration
20
15
  end
21
16
 
22
- # Returns an instance of Configuration::CLI.
17
+ # Configure Vedeu via command-line arguments. Options set here via
18
+ # arguments override the client application configuration set via
19
+ # {Vedeu::API#configure}.
23
20
  #
24
21
  # @param args [Array]
25
22
  # @return [Configuration::CLI]
@@ -1,8 +1,8 @@
1
1
  require 'vedeu/repositories/all'
2
2
  require 'vedeu/cursor/cursor'
3
- require 'vedeu/cursor/move_cursor'
3
+ require 'vedeu/cursor/move'
4
4
  require 'vedeu/cursor/refresh_cursor'
5
- require 'vedeu/cursor/toggle_cursor'
5
+ require 'vedeu/cursor/toggle'
6
6
 
7
7
  module Vedeu
8
8
  end # Vedeu
@@ -33,7 +33,7 @@ module Vedeu
33
33
  # The cursor will move freely within the bounds of the interface,
34
34
  # irrespective of content.
35
35
  #
36
- class MoveCursor
36
+ class Move
37
37
 
38
38
  extend Forwardable
39
39
 
@@ -46,13 +46,13 @@ module Vedeu
46
46
  :height,
47
47
  :width
48
48
 
49
- # Returns an instance of MoveCursor.
49
+ # Returns an instance of Move.
50
50
  #
51
51
  # @param cursor [Cursor]
52
52
  # @param interface [Interface]
53
53
  # @param dy [Fixnum] Move up (-1), or down (1), or no action (0).
54
54
  # @param dx [Fixnum] Move left (-1), or right (1), or no action (0).
55
- # @return [MoveCursor]
55
+ # @return [Move]
56
56
  def initialize(cursor, interface, dy = 0, dx = 0)
57
57
  @cursor = cursor
58
58
  @dy = dy || 0
@@ -81,7 +81,7 @@ module Vedeu
81
81
 
82
82
  end
83
83
 
84
- new_cursor = Vedeu::MoveCursor.send(direction, cursor, interface)
84
+ new_cursor = Vedeu::Move.send(direction, cursor, interface)
85
85
 
86
86
  Vedeu.trigger(:_refresh_cursor_, new_cursor.name)
87
87
 
@@ -162,7 +162,7 @@ module Vedeu
162
162
  # @return [Vedeu::Interface]
163
163
  attr_reader :interface
164
164
 
165
- # @return [Hash]
165
+ # @return [Hash<Symbol => Fixnum>]
166
166
  def moved_attributes
167
167
  {
168
168
  x: validator.x,
@@ -225,6 +225,6 @@ module Vedeu
225
225
  width
226
226
  end
227
227
 
228
- end # MoveCursor
228
+ end # Move
229
229
 
230
230
  end # Vedeu
@@ -1,9 +1,11 @@
1
1
  module Vedeu
2
2
 
3
+ # Handle the refreshing (redrawing) of a cursor, without redrawing the whole
4
+ # interface; unless the cursor's offset has caused the view to change.
5
+ #
3
6
  class RefreshCursor
4
7
 
5
- # @param name [String] The name of the cursor.
6
- # @return [Array]
8
+ # @param (see #initialize)
7
9
  def self.render(name)
8
10
  new(name).render
9
11
  end
@@ -29,7 +31,8 @@ module Vedeu
29
31
 
30
32
  # @return [Boolean]
31
33
  def refresh_view?
32
- new_cursor.ox >= interface_width || new_cursor.oy >= interface_height
34
+ new_cursor.ox >= interface_width ||
35
+ new_cursor.oy >= interface_height
33
36
  end
34
37
 
35
38
  # @return [Vedeu::Cursor]
@@ -37,7 +40,7 @@ module Vedeu
37
40
  @new_cursor ||= Vedeu::Cursor.new(cursor.attributes.merge(position))
38
41
  end
39
42
 
40
- # @return [Hash]
43
+ # @return [Hash<Symbol => Fixnum>]
41
44
  def position
42
45
  {
43
46
  x: validated_position.x,
@@ -2,20 +2,19 @@ module Vedeu
2
2
 
3
3
  # Adjusts the visibility of the cursor.
4
4
  #
5
- class ToggleCursor
5
+ class Toggle
6
6
 
7
- # Returns an instance of ToggleCursor.
7
+ # Returns an instance of Toggle.
8
8
  #
9
9
  # @param cursor [Cursor]
10
- # @return [ToggleCursor]
10
+ # @return [Toggle]
11
11
  def initialize(cursor)
12
12
  @cursor = cursor
13
13
  end
14
14
 
15
15
  # Hides the cursor.
16
16
  #
17
- # @param cursor [Cursor]
18
- # @return [Cursor]
17
+ # @param (see #initialize)
19
18
  def self.hide(cursor)
20
19
  return cursor if cursor.invisible?
21
20
 
@@ -24,8 +23,7 @@ module Vedeu
24
23
 
25
24
  # Shows the cursor.
26
25
  #
27
- # @param cursor [Cursor]
28
- # @return [Cursor]
26
+ # @param (see #initialize)
29
27
  def self.show(cursor)
30
28
  return cursor if cursor.visible?
31
29
 
@@ -52,6 +50,6 @@ module Vedeu
52
50
  # @return [Vedeu::Cursor]
53
51
  attr_reader :cursor
54
52
 
55
- end # ToggleCursor
53
+ end # Toggle
56
54
 
57
55
  end # Vedeu
data/lib/vedeu/debug.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Vedeu
2
2
 
3
+ # :nocov:
3
4
  # Helps to debug a running application by providing a stack trace of its
4
5
  # execution upon exiting.
5
6
  #
@@ -22,5 +23,6 @@ module Vedeu
22
23
  # RubyProf::CallTreePrinter.new(result).print(file)
23
24
  end
24
25
  end
26
+ # :nocov:
25
27
 
26
28
  end # Vedeu
@@ -13,8 +13,7 @@ module Vedeu
13
13
  #
14
14
  class Client
15
15
 
16
- # @param uri [String]
17
- # @return [Client]
16
+ # @param (see #initialize)
18
17
  def self.connect(uri)
19
18
  new(uri).connect
20
19
  end
@@ -13,7 +13,7 @@ module Vedeu
13
13
 
14
14
  include Singleton
15
15
 
16
- # @see Vedeu::Distributed::Server#input
16
+ # @param (see #input)
17
17
  def self.input(data, type = :key)
18
18
  instance.input(data, type)
19
19
  end
@@ -7,8 +7,7 @@ module Vedeu
7
7
  #
8
8
  class Subprocess
9
9
 
10
- # @param application [Vedeu::TestApplication]
11
- # @return [Array]
10
+ # @param (see #initialize)
12
11
  def self.execute!(application)
13
12
  new(application).execute!
14
13
  end
@@ -20,6 +19,7 @@ module Vedeu
20
19
  @pid = nil
21
20
  end
22
21
 
22
+ # :nocov:
23
23
  # @return [Array]
24
24
  def execute!
25
25
  file_open && file_write && file_close
@@ -32,6 +32,7 @@ module Vedeu
32
32
 
33
33
  self
34
34
  end
35
+ # :nocov:
35
36
 
36
37
  # Sends the KILL signal to the process.
37
38
  #
@@ -48,14 +48,12 @@ module Vedeu
48
48
  # @return [String]
49
49
  attr_accessor :views
50
50
 
51
- # @param attributes [Hash]
52
- # @param block [Proc]
53
- # @return [String]
51
+ # @param (see #initialize)
54
52
  def self.build(attributes = {}, &block)
55
53
  new(attributes).build(&block)
56
54
  end
57
55
 
58
- # @param attributes [Hash]
56
+ # @param attributes [Hash<Symbol => String>]
59
57
  # @option attributes borders [String]
60
58
  # @option attributes configuration [String]
61
59
  # @option attributes events [String]
data/lib/vedeu/dsl/all.rb CHANGED
@@ -16,6 +16,7 @@ module Vedeu
16
16
 
17
17
  private
18
18
 
19
+ # :nocov:
19
20
  # Attempts to find the missing method on the client object.
20
21
  #
21
22
  # @param method [Symbol] The name of the method sought.
@@ -27,6 +28,7 @@ module Vedeu
27
28
 
28
29
  client.send(method, *args, &block) if client
29
30
  end
31
+ # :nocov:
30
32
 
31
33
  end # DSL
32
34
 
@@ -1,4 +1,4 @@
1
- require 'vedeu/models/geometry'
1
+ require 'vedeu/geometry/geometry'
2
2
  require 'vedeu/dsl/shared/all'
3
3
 
4
4
  module Vedeu
@@ -62,13 +62,15 @@ module Vedeu
62
62
 
63
63
  # Specify the number of characters/rows/lines tall the interface will be.
64
64
  #
65
- # @param value [Fixnum]
66
- #
67
65
  # @example
68
66
  # geometry 'some_interface' do
69
67
  # height 8
70
68
  # # ...
71
69
  #
70
+ # @note
71
+ # This value will be ignored if by `y` and `yn` are set.
72
+ #
73
+ # @param value [Fixnum]
72
74
  # @return [Fixnum]
73
75
  def height(value)
74
76
  model.height = value
@@ -83,6 +85,9 @@ module Vedeu
83
85
  # width 25
84
86
  # # ...
85
87
  #
88
+ # @note
89
+ # This value will be ignored if by `x` and `xn` are set.
90
+ #
86
91
  # @return [Fixnum]
87
92
  def width(value)
88
93
  model.width = value
@@ -90,9 +95,6 @@ module Vedeu
90
95
 
91
96
  # Specify the starting x position (column) of the interface.
92
97
  #
93
- # @param value [Fixnum]
94
- # @param block [Proc]
95
- #
96
98
  # @example
97
99
  # geometry 'some_interface' do
98
100
  # x 7 # start on column 7.
@@ -104,17 +106,32 @@ module Vedeu
104
106
  # # position, `some_interface` will
105
107
  # # too.
106
108
  #
109
+ # @param value [Fixnum]
110
+ # @param block [Proc]
107
111
  # @return [Fixnum]
108
- def x(value = 0, &block)
112
+ def x(value = 1, &block)
109
113
  return model.x = block if block_given?
110
114
 
111
115
  model.x = value
112
116
  end
113
117
 
114
- # Specify the starting y position (row/line) of the interface.
118
+ # Specify the ending x position (column) of the interface.
119
+ #
120
+ # @example
121
+ # geometry 'some_interface' do
122
+ # xn 37 # end at column 37.
123
+ # # ...
124
+ #
125
+ # @note
126
+ # This value will override `width`.
115
127
  #
116
128
  # @param value [Fixnum]
117
- # @param block [Proc]
129
+ # @return [Fixnum]
130
+ def xn(value)
131
+ model.xn = value
132
+ end
133
+
134
+ # Specify the starting y position (row/line) of the interface.
118
135
  #
119
136
  # @example
120
137
  # geometry 'some_interface' do
@@ -127,13 +144,31 @@ module Vedeu
127
144
  # # position, `some_interface`
128
145
  # # will too.
129
146
  #
147
+ # @param value [Fixnum]
148
+ # @param block [Proc]
130
149
  # @return [Fixnum]
131
- def y(value = 0, &block)
150
+ def y(value = 1, &block)
132
151
  return model.y = block if block_given?
133
152
 
134
153
  model.y = value
135
154
  end
136
155
 
156
+ # Specify the ending y position (row/line) of the interface.
157
+ #
158
+ # @example
159
+ # geometry 'some_interface' do
160
+ # yn 24 # end at row 24.
161
+ # # ...
162
+ #
163
+ # @note
164
+ # This value will override `height`.
165
+ #
166
+ # @param value [Fixnum]
167
+ # @return [Fixnum]
168
+ def yn(value)
169
+ model.yn = value
170
+ end
171
+
137
172
  private
138
173
 
139
174
  # @!attribute [r] client
@@ -1,6 +1,6 @@
1
1
  require 'vedeu/cursor/cursor'
2
2
  require 'vedeu/models/focus'
3
- require 'vedeu/models/geometry'
3
+ require 'vedeu/geometry/geometry'
4
4
  require 'vedeu/models/group'
5
5
  require 'vedeu/models/line'
6
6
  require 'vedeu/output/border'
@@ -15,21 +15,21 @@ module Vedeu
15
15
  # Events described here assume that you have either included Vedeu in your
16
16
  # class:
17
17
  #
18
- # class SomeClassInYourApplication
19
- # include Vedeu
18
+ # class SomeClassInYourApplication
19
+ # include Vedeu
20
20
  #
21
- # bind :event_name do |arg1, arg2|
22
- # # Things that should happen when the event is triggered; these can be
23
- # # method calls or the triggering of another event or events.
24
- # end
21
+ # bind :event_name do |arg1, arg2|
22
+ # # Things that should happen when the event is triggered; these can be
23
+ # # method calls or the triggering of another event or events.
24
+ # end
25
25
  #
26
26
  # or, you are prepared to use the `Vedeu` prefix:
27
27
  #
28
- # class SomeClassInYourApplication
29
- # Vedeu.bind(:event_name) do
30
- # # Not all events you define will have arguments; like methods.
31
- # :do_stuff
32
- # end
28
+ # class SomeClassInYourApplication
29
+ # Vedeu.bind(:event_name) do
30
+ # # Not all events you define will have arguments; like methods.
31
+ # :do_stuff
32
+ # end
33
33
  #
34
34
  class Event
35
35
 
@@ -104,6 +104,7 @@ module Vedeu
104
104
 
105
105
  end
106
106
 
107
+ # @param (see Vedeu::Trigger.trigger)
107
108
  # @see Vedeu::Trigger.trigger
108
109
  def self.trigger(name, *args)
109
110
  Vedeu::Trigger.trigger(name, *args)
@@ -111,9 +112,7 @@ module Vedeu
111
112
 
112
113
  # Returns a new instance of Event.
113
114
  #
114
- # @param name [Symbol]
115
- # @param options [Hash]
116
- # @param closure [Proc] The code to be executed when the event is triggered.
115
+ # @param (see Vedeu::Event.bind)
117
116
  # @return [Event]
118
117
  def initialize(name, options = {}, closure)
119
118
  @name = name
@@ -237,6 +236,8 @@ module Vedeu
237
236
  false
238
237
  end
239
238
 
239
+ # Returns the time in seconds since the last triggering of this event.
240
+ #
240
241
  # @return [Float]
241
242
  def elapsed_time
242
243
  now - @executed_at
@@ -257,16 +258,23 @@ module Vedeu
257
258
  @now = 0
258
259
  end
259
260
 
261
+ # Returns a boolean indicating if this event has a deadline.
262
+ #
260
263
  # @return [Boolean]
261
264
  def has_deadline?
262
265
  @deadline > 0
263
266
  end
264
267
 
268
+ # Resets the deadline of this event.
269
+ #
265
270
  # @return [Fixnum]
266
271
  def reset_deadline
267
272
  @deadline = 0
268
273
  end
269
274
 
275
+ # Sets the deadline for when this event can be executed to a point in the
276
+ # future determined by the amount of debounce time left.
277
+ #
270
278
  # @return [NilClass]
271
279
  def set_deadline
272
280
  @deadline = now + debounce
@@ -18,15 +18,16 @@ module Vedeu
18
18
  new(name, *args).trigger
19
19
  end
20
20
 
21
- # @see Vedeu::Trigger.trigger
22
- # @return [Trigger]
21
+ # @param (see .trigger)
22
+ # @return [Vedeu::Trigger]
23
23
  def initialize(name, *args)
24
24
  @name = name
25
25
  @args = args
26
26
  @repository = Vedeu.events
27
27
  end
28
28
 
29
- # @see Vedeu::Trigger.trigger
29
+ # Trigger the event and return the result (if one) or an array of results.
30
+ #
30
31
  # @return [Array]
31
32
  def trigger
32
33
  if results.one?
@@ -57,6 +58,8 @@ module Vedeu
57
58
  @results ||= registered_events.map { |event| event.trigger(*args) }
58
59
  end
59
60
 
61
+ # Return all of the registered events for this name.
62
+ #
60
63
  # @return [Array|Array<Vedeu::Event>]
61
64
  def registered_events
62
65
  return [] unless repository.registered?(name)
@@ -1,6 +1,11 @@
1
+ require 'vedeu/geometry/area'
1
2
  require 'vedeu/geometry/bounding_area'
2
- require 'vedeu/geometry/content_geometry'
3
+ require 'vedeu/geometry/canvas'
4
+ require 'vedeu/geometry/centre'
5
+ require 'vedeu/geometry/content'
3
6
  require 'vedeu/geometry/coordinate'
7
+ require 'vedeu/geometry/dimension'
8
+ require 'vedeu/geometry/geometry'
4
9
  require 'vedeu/geometry/grid'
5
10
  require 'vedeu/geometry/index_position'
6
11
  require 'vedeu/geometry/limit'