vedeu 0.6.30 → 0.6.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +0 -3
  3. data/lib/vedeu/all.rb +0 -3
  4. data/lib/vedeu/borders/border.rb +3 -7
  5. data/lib/vedeu/borders/refresh.rb +4 -0
  6. data/lib/vedeu/buffers/refresh.rb +4 -0
  7. data/lib/vedeu/cursors/cursor.rb +46 -36
  8. data/lib/vedeu/cursors/refresh.rb +4 -0
  9. data/lib/vedeu/distributed/server.rb +4 -0
  10. data/lib/vedeu/editor/editor.rb +4 -0
  11. data/lib/vedeu/editor/repository.rb +4 -0
  12. data/lib/vedeu/events/event.rb +6 -1
  13. data/lib/vedeu/geometry/all.rb +1 -1
  14. data/lib/vedeu/geometry/coordinate.rb +138 -36
  15. data/lib/vedeu/geometry/dimension.rb +7 -0
  16. data/lib/vedeu/geometry/repository.rb +4 -0
  17. data/lib/vedeu/groups/clear.rb +4 -0
  18. data/lib/vedeu/groups/group.rb +4 -0
  19. data/lib/vedeu/groups/refresh.rb +4 -0
  20. data/lib/vedeu/input/mapper.rb +18 -0
  21. data/lib/vedeu/interfaces/interface.rb +4 -0
  22. data/lib/vedeu/logging/log.rb +6 -2
  23. data/lib/vedeu/menus/repository.rb +4 -0
  24. data/lib/vedeu/models/focus.rb +4 -0
  25. data/lib/vedeu/output/clear/interface.rb +4 -0
  26. data/lib/vedeu/output/refresh/refresh.rb +4 -0
  27. data/lib/vedeu/runtime/application.rb +10 -0
  28. data/lib/vedeu/runtime/flags.rb +4 -0
  29. data/lib/vedeu/runtime/launcher.rb +0 -2
  30. data/lib/vedeu/runtime/router.rb +4 -0
  31. data/lib/vedeu/terminal/buffer.rb +4 -0
  32. data/lib/vedeu/terminal/terminal.rb +4 -0
  33. data/lib/vedeu/version.rb +1 -1
  34. data/test/lib/vedeu/borders/border_test.rb +0 -1
  35. data/test/lib/vedeu/geometry/coordinate.rb +167 -0
  36. data/test/lib/vedeu/input/mapper_test.rb +2 -0
  37. data/test/lib/vedeu/output/presentation/styles_test.rb +0 -1
  38. data/test/lib/vedeu/runtime/application_test.rb +1 -0
  39. data/test/test_helper.rb +1 -1
  40. data/vedeu.gemspec +1 -1
  41. metadata +6 -15
  42. data/lib/vedeu/bindings/all.rb +0 -64
  43. data/lib/vedeu/geometry/generic_coordinate.rb +0 -169
  44. data/lib/vedeu/options.rb +0 -22
  45. data/test/lib/vedeu/bindings/all_test.rb +0 -19
  46. data/test/lib/vedeu/geometry/coordinate_test.rb +0 -135
  47. data/test/lib/vedeu/geometry/generic_coordinate_test.rb +0 -45
  48. data/test/lib/vedeu/options_test.rb +0 -57
@@ -137,6 +137,13 @@ module Vedeu
137
137
 
138
138
  # Fetch the ending coordinate.
139
139
  #
140
+ # 1) if an end value was given, use that.
141
+ # 2) if a start value wasn't given, but a width or height was,
142
+ # use the width or height
143
+ # 3) if a start value was given and a width or height was given,
144
+ # add the width or height to the start and minus 1.
145
+ # 4) otherwise, use the terminal default width or height
146
+ #
140
147
  # @return [Fixnum]
141
148
  def _dn
142
149
  if dn
@@ -25,6 +25,8 @@ module Vedeu
25
25
  # @return [Vedeu::Geometry::Repository]
26
26
  def_delegators Vedeu::Geometry::Repository, :geometries
27
27
 
28
+ # :nocov:
29
+
28
30
  # See {file:docs/events/view.md#\_maximise_}
29
31
  Vedeu.bind(:_maximise_) do |name|
30
32
  Vedeu.geometries.by_name(name).maximise
@@ -50,4 +52,6 @@ module Vedeu
50
52
  Vedeu.bind_alias(:"_geometry_#{direction}_", :"_view_#{direction}_")
51
53
  end
52
54
 
55
+ # :nocov:
56
+
53
57
  end # Vedeu
@@ -58,7 +58,11 @@ module Vedeu
58
58
  # @see Vedeu::Groups::Clear.render
59
59
  def_delegators Vedeu::Groups::Clear, :clear_by_group
60
60
 
61
+ # :nocov:
62
+
61
63
  # See {file:docs/events/visibility.md#\_clear_group_}
62
64
  Vedeu.bind(:_clear_group_) { |name| Vedeu.clear_by_group(name) }
63
65
 
66
+ # :nocov:
67
+
64
68
  end # Vedeu
@@ -179,6 +179,8 @@ module Vedeu
179
179
  # @see Vedeu::Toggleable::ClassMethods#toggle
180
180
  def_delegators Vedeu::Groups::Group, :hide_group, :show_group, :toggle_group
181
181
 
182
+ # :nocov:
183
+
182
184
  # See {file:docs/events/visibility.md#\_hide_group_}
183
185
  Vedeu.bind(:_hide_group_) { |name| Vedeu.hide_group(name) }
184
186
 
@@ -188,4 +190,6 @@ module Vedeu
188
190
  # See {file:docs/events/visibility.md#\_toggle_group_}
189
191
  Vedeu.bind(:_toggle_group_) { |name| Vedeu.toggle_group(name) }
190
192
 
193
+ # :nocov:
194
+
191
195
  end # Vedeu
@@ -64,9 +64,13 @@ module Vedeu
64
64
 
65
65
  end # Groups
66
66
 
67
+ # :nocov:
68
+
67
69
  # See {file:docs/events/refresh.md#\_refresh_group_}
68
70
  Vedeu.bind(:_refresh_group_) do |name|
69
71
  Vedeu::Groups::Refresh.by_name(name)
70
72
  end
71
73
 
74
+ # :nocov:
75
+
72
76
  end # Vedeu
@@ -134,7 +134,25 @@ module Vedeu
134
134
  # @see Vedeu::Input::Mapper.keypress
135
135
  def_delegators Vedeu::Input::Mapper, :keypress
136
136
 
137
+ # :nocov:
138
+
137
139
  # See {file:docs/events/system.md#\_keypress_}
138
140
  Vedeu.bind(:_keypress_) { |key| Vedeu.keypress(key) }
139
141
 
142
+ # See {file:docs/events/drb.md#\_drb_input_}
143
+ Vedeu.bind(:_drb_input_) do |data, type|
144
+ Vedeu.log(type: :drb, message: "Sending input (#{type})".freeze)
145
+
146
+ case type
147
+ when :command then Vedeu.trigger(:_command_, data)
148
+ when :keypress then Vedeu.trigger(:_keypress_, data)
149
+ else Vedeu.trigger(:_keypress_, data)
150
+ end
151
+ end
152
+
153
+ # See {file:docs/events/system.md#\_command_}
154
+ Vedeu.bind(:_command_) { |command| Vedeu.trigger(:command, command) }
155
+
156
+ # :nocov:
157
+
140
158
  end # Vedeu
@@ -134,6 +134,8 @@ module Vedeu
134
134
  def_delegators Vedeu::Interfaces::Interface, :hide_interface, :show_interface,
135
135
  :toggle_interface
136
136
 
137
+ # :nocov:
138
+
137
139
  # See {file:docs/events/visibility.md#\_hide_interface_}
138
140
  Vedeu.bind(:_hide_interface_) { |name| Vedeu.hide_interface(name) }
139
141
  Vedeu.bind_alias(:_hide_view_, :_hide_interface_)
@@ -146,4 +148,6 @@ module Vedeu
146
148
  Vedeu.bind(:_toggle_interface_) { |name| Vedeu.toggle_interface(name) }
147
149
  Vedeu.bind_alias(:_toggle_view_, :_toggle_interface_)
148
150
 
151
+ # :nocov:
152
+
149
153
  end # Vedeu
@@ -168,8 +168,8 @@ module Vedeu
168
168
  # @return [String]
169
169
  def timestamp
170
170
  @now = Time.now.to_f
171
- @time = 0.0 unless @time
172
- @last = @now unless @last
171
+ @time ||= 0.0
172
+ @last ||= @now
173
173
 
174
174
  unless @last == @time
175
175
  @time += (@now - @last).round(4)
@@ -193,7 +193,11 @@ module Vedeu
193
193
  # @see Vedeu::Logging::Log.log_stderr
194
194
  def_delegators Vedeu::Logging::Log, :log, :log_stdout, :log_stderr
195
195
 
196
+ # :nocov:
197
+
196
198
  # See {file:docs/events/system.md#\_log_}
197
199
  Vedeu.bind(:_log_) { |msg| Vedeu.log(type: :debug, message: msg) }
198
200
 
201
+ # :nocov:
202
+
199
203
  end # Vedeu
@@ -24,6 +24,8 @@ module Vedeu
24
24
  # @return [Vedeu::Menus::Repository]
25
25
  def_delegators Vedeu::Menus::Repository, :menus
26
26
 
27
+ # :nocov:
28
+
27
29
  # See {file:docs/events/menu.md#\_menu_bottom_}
28
30
  Vedeu.bind(:_menu_bottom_) do |name|
29
31
  Vedeu.menus.by_name(name).bottom_item
@@ -64,4 +66,6 @@ module Vedeu
64
66
  # See {file:docs/events/menu.md#\_menu_view_}
65
67
  Vedeu.bind(:_menu_view_) { |name| Vedeu.menus.by_name(name).view }
66
68
 
69
+ # :nocov:
70
+
67
71
  end # Vedeu
@@ -261,6 +261,8 @@ module Vedeu
261
261
  def_delegators Vedeu::Models::Focus, :focus, :focus_by_name, :focussed?,
262
262
  :focus_next, :focus_previous
263
263
 
264
+ # :nocov:
265
+
264
266
  # See {file:docs/events/focus.md#\_focus_by_name_}
265
267
  Vedeu.bind(:_focus_by_name_) { |name| Vedeu.focus_by_name(name) }
266
268
 
@@ -270,4 +272,6 @@ module Vedeu
270
272
  # See {file:docs/events/focus.md#\_focus_prev_}
271
273
  Vedeu.bind(:_focus_prev_) { Vedeu.focus_previous }
272
274
 
275
+ # :nocov:
276
+
273
277
  end # Vedeu
@@ -170,6 +170,8 @@ module Vedeu
170
170
  # @see Vedeu::Clear::Interface.clear_content_by_name
171
171
  def_delegators Vedeu::Clear::Interface, :clear_content_by_name
172
172
 
173
+ # :nocov:
174
+
173
175
  # See {file:docs/events/visibility.md#\_clear_view_}
174
176
  Vedeu.bind(:_clear_view_) { |name| Vedeu.clear_by_name(name) }
175
177
 
@@ -178,4 +180,6 @@ module Vedeu
178
180
  Vedeu.clear_content_by_name(name)
179
181
  end
180
182
 
183
+ # :nocov:
184
+
181
185
  end # Vedeu
@@ -30,7 +30,11 @@ module Vedeu
30
30
 
31
31
  end # Output
32
32
 
33
+ # :nocov:
34
+
33
35
  # See {file:docs/events/refresh.md#\_refresh_}
34
36
  Vedeu.bind(:_refresh_) { Vedeu::Output::Refresh.all }
35
37
 
38
+ # :nocov:
39
+
36
40
  end # Vedeu
@@ -137,10 +137,20 @@ module Vedeu
137
137
  # @see Vedeu::Runtime::Application.stop
138
138
  def_delegators Vedeu::Runtime::Application, :exit
139
139
 
140
+ # :nocov:
141
+
140
142
  # See {file:docs/events/system.md#\_exit_}
141
143
  Vedeu.bind(:_exit_) { Vedeu.exit }
142
144
 
143
145
  # See {file:docs/events/system.md#\_mode_switch_}
144
146
  Vedeu.bind(:_mode_switch_) { fail Vedeu::Error::ModeSwitch }
145
147
 
148
+ # See {file:docs/events/system.md#\_cleanup_}
149
+ Vedeu.bind(:_cleanup_) do
150
+ Vedeu.trigger(:_drb_stop_)
151
+ Vedeu.trigger(:cleanup)
152
+ end
153
+
154
+ # :nocov:
155
+
146
156
  end # Vedeu
@@ -65,7 +65,11 @@ module Vedeu
65
65
  # @return [Boolean]
66
66
  def_delegators Vedeu::Runtime::Flags, :ready?, :ready!
67
67
 
68
+ # :nocov:
69
+
68
70
  # See {file:docs/events/system.md#\_initialize_}
69
71
  Vedeu.bind(:_initialize_) { Vedeu.ready! }
70
72
 
73
+ # :nocov:
74
+
71
75
  end # Vedeu
@@ -104,8 +104,6 @@ module Vedeu
104
104
  def terminate!
105
105
  Vedeu.log(type: :info, message: 'Exiting gracefully.'.freeze)
106
106
 
107
- Vedeu.log(type: :info, message: "#{Vedeu.events.all.size}")
108
-
109
107
  $stdin = STDIN
110
108
  $stdout = STDOUT
111
109
  $stderr = STDERR
@@ -193,6 +193,8 @@ module Vedeu
193
193
  # @see Vedeu::Runtime::Router#goto
194
194
  def_delegators Vedeu::Runtime::Router, :goto
195
195
 
196
+ # :nocov:
197
+
196
198
  # See {file:docs/events/application.md#\_goto_}
197
199
  Vedeu.bind(:_goto_) do |controller, action, **args|
198
200
  Vedeu::Runtime::Router.goto(controller, action, **args)
@@ -200,4 +202,6 @@ module Vedeu
200
202
 
201
203
  # Vedeu.bind_alias(:_action_, :_goto_)
202
204
 
205
+ # :nocov:
206
+
203
207
  end # Vedeu
@@ -145,6 +145,8 @@ module Vedeu
145
145
  def_delegators Vedeu::Terminal::Buffer, :clear
146
146
  def_delegators Vedeu::Terminal::Buffer, :refresh
147
147
 
148
+ # :nocov:
149
+
148
150
  # See {file:docs/events/visibility.md#\_clear_}
149
151
  Vedeu.bind(:_clear_) { Vedeu.clear }
150
152
 
@@ -156,4 +158,6 @@ module Vedeu
156
158
  Vedeu::Terminal::Buffer.write(data)
157
159
  end
158
160
 
161
+ # :nocov:
162
+
159
163
  end # Vedeu
@@ -224,7 +224,11 @@ module Vedeu
224
224
  # @see Vedeu::Terminal#width
225
225
  def_delegators Vedeu::Terminal, :height, :resize, :width
226
226
 
227
+ # :nocov:
228
+
227
229
  # See {file:docs/events/view.md#\_resize_}
228
230
  Vedeu.bind(:_resize_, delay: 0.25) { Vedeu.resize }
229
231
 
232
+ # :nocov:
233
+
230
234
  end # Vedeu
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.30'.freeze
4
+ VERSION = '0.6.31'.freeze
5
5
 
6
6
  end
@@ -51,7 +51,6 @@ module Vedeu
51
51
  describe 'accessors' do
52
52
  it {
53
53
  instance.must_respond_to(:attributes)
54
- instance.must_respond_to(:attributes=)
55
54
  instance.must_respond_to(:bottom_left)
56
55
  instance.must_respond_to(:bottom_left=)
57
56
  instance.must_respond_to(:bottom_right)
@@ -0,0 +1,167 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Geometry
6
+
7
+ describe Coordinate do
8
+
9
+ let(:described) { Vedeu::Geometry::Coordinate }
10
+ let(:instance) { described.new(attributes) }
11
+ let(:attributes) {
12
+ {
13
+ name: _name,
14
+ offset: offset,
15
+ type: type,
16
+ }
17
+ }
18
+ let(:_name) {}
19
+ let(:offset) {}
20
+ let(:type) {}
21
+
22
+ describe '#initialize' do
23
+ it { instance.must_be_instance_of(described) }
24
+ it { instance.instance_variable_get('@name').must_equal(_name) }
25
+ it { instance.instance_variable_get('@offset').must_equal(offset) }
26
+ it { instance.instance_variable_get('@type').must_equal(type) }
27
+ end
28
+
29
+ describe '#dn' do
30
+ subject { instance.dn }
31
+
32
+ # it { skip }
33
+ end
34
+
35
+ describe '#position' do
36
+ subject { instance.position }
37
+
38
+ # it { skip }
39
+ end
40
+
41
+ # let(:described) { Vedeu::Geometry::Coordinate }
42
+ # let(:instance) { described.new(_name, oy, ox) }
43
+ # let(:_name) { 'coordinate' }
44
+ # let(:oy) { 0 }
45
+ # let(:ox) { 0 }
46
+ # let(:height) { 6 }
47
+ # let(:width) { 6 }
48
+ # let(:x) { 7 }
49
+ # let(:y) { 5 }
50
+ # let(:border) { Vedeu::Borders::Border.new(name: _name, enabled: true) }
51
+ # let(:geometry) {
52
+ # Vedeu::Geometry::Geometry.new(name: _name,
53
+ # height: height,
54
+ # width: width,
55
+ # x: x,
56
+ # y: y)
57
+ # }
58
+
59
+ # before do
60
+ # Vedeu.borders.stubs(:by_name).returns(border)
61
+ # Vedeu.geometries.stubs(:by_name).returns(geometry)
62
+ # end
63
+
64
+ # describe '#initialize' do
65
+ # it { instance.must_be_instance_of(described) }
66
+ # it { instance.instance_variable_get('@name').must_equal(_name) }
67
+ # it { instance.instance_variable_get('@oy').must_equal(oy) }
68
+ # it { instance.instance_variable_get('@ox').must_equal(ox) }
69
+ # end
70
+
71
+ # describe '#yn' do
72
+ # subject { instance.yn }
73
+
74
+ # context 'when the height is <= to 0' do
75
+ # let(:height) { 0 }
76
+
77
+ # it { subject.must_equal(0) }
78
+ # end
79
+
80
+ # context 'when the height is > 0' do
81
+ # it { subject.must_equal(9) }
82
+ # end
83
+ # end
84
+
85
+ # describe '#xn' do
86
+ # subject { instance.xn }
87
+
88
+ # context 'when the width is <= to 0' do
89
+ # let(:width) { 0 }
90
+
91
+ # it { subject.must_equal(0) }
92
+ # end
93
+
94
+ # context 'when the width is > 0' do
95
+ # it { subject.must_equal(11) }
96
+ # end
97
+ # end
98
+
99
+ # describe '#y' do
100
+ # let(:oy) { 0 }
101
+
102
+ # subject { instance.y }
103
+
104
+ # it { subject.must_be_instance_of(Fixnum) }
105
+
106
+ # context 'with a negative index' do
107
+ # let(:oy) { -3 }
108
+
109
+ # it { subject.must_equal(6) }
110
+ # end
111
+
112
+ # context 'with an index greater than the maximum index for y' do
113
+ # let(:oy) { 9 }
114
+
115
+ # it { subject.must_equal(9) }
116
+
117
+ # context 'but the height is negative' do
118
+ # let(:height) { -2 }
119
+
120
+ # it { subject.must_equal(1) }
121
+ # end
122
+ # end
123
+
124
+ # context 'with an index within range' do
125
+ # let(:oy) { 3 }
126
+
127
+ # it { subject.must_equal(8) }
128
+ # end
129
+ # end
130
+
131
+ # describe '#x' do
132
+ # let(:ox) { 0 }
133
+
134
+ # subject { instance.x }
135
+
136
+ # it { subject.must_be_instance_of(Fixnum) }
137
+
138
+ # context 'with a negative index' do
139
+ # let(:ox) { -3 }
140
+
141
+ # it { subject.must_equal(8) }
142
+ # end
143
+
144
+ # context 'with an index greater than the maximum index for x' do
145
+ # let(:ox) { 9 }
146
+
147
+ # it { subject.must_equal(11) }
148
+
149
+ # context 'but the width is negative' do
150
+ # let(:width) { -2 }
151
+
152
+ # it { subject.must_equal(3) }
153
+ # end
154
+ # end
155
+
156
+ # context 'with an index within range' do
157
+ # let(:ox) { 3 }
158
+
159
+ # it { subject.must_equal(10) }
160
+ # end
161
+ # end
162
+
163
+ end # Coordinate
164
+
165
+ end # Geometry
166
+
167
+ end # Vedeu