vedeu 0.4.43 → 0.4.44

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/bin/vedeu +19 -0
  4. data/lib/vedeu.rb +0 -34
  5. data/lib/vedeu/all.rb +4 -1
  6. data/lib/vedeu/application/application_view.rb +9 -9
  7. data/lib/vedeu/application/controller.rb +6 -5
  8. data/lib/vedeu/application/helper.rb +3 -16
  9. data/lib/vedeu/application/view.rb +3 -16
  10. data/lib/vedeu/bindings/all.rb +5 -0
  11. data/lib/vedeu/bindings/bindings.rb +115 -0
  12. data/lib/vedeu/bindings/drb.rb +45 -0
  13. data/lib/vedeu/bindings/menus.rb +53 -0
  14. data/lib/vedeu/bindings/movement.rb +76 -0
  15. data/lib/vedeu/bindings/visibility.rb +53 -0
  16. data/lib/vedeu/buffers/buffer.rb +2 -0
  17. data/lib/vedeu/cli/generator/templates/application/app/controllers/name.erb +2 -2
  18. data/lib/vedeu/cli/generator/templates/application/app/helpers/name.erb +2 -0
  19. data/lib/vedeu/cli/generator/templates/application/config/configuration.erb +3 -0
  20. data/lib/vedeu/cli/generator/view.rb +0 -5
  21. data/lib/vedeu/cli/main.rb +12 -0
  22. data/lib/vedeu/cursor/reposition.rb +4 -4
  23. data/lib/vedeu/dsl/interface.rb +0 -27
  24. data/lib/vedeu/exceptions.rb +65 -0
  25. data/lib/vedeu/geometry/geometry.rb +2 -2
  26. data/lib/vedeu/geometry/grid.rb +2 -2
  27. data/lib/vedeu/input/input.rb +34 -28
  28. data/lib/vedeu/null/geometry.rb +2 -2
  29. data/lib/vedeu/output/colour.rb +0 -2
  30. data/lib/vedeu/output/esc.rb +7 -1
  31. data/lib/vedeu/output/render_border.rb +5 -0
  32. data/lib/vedeu/output/renderers/json.rb +7 -2
  33. data/lib/vedeu/support/terminal.rb +1 -1
  34. data/lib/vedeu/version.rb +1 -1
  35. data/test/lib/vedeu/application/controller_test.rb +0 -4
  36. data/test/lib/vedeu/application/helper_test.rb +0 -8
  37. data/test/lib/vedeu/application/view_test.rb +0 -8
  38. data/test/lib/vedeu/bindings/bindings_test.rb +43 -0
  39. data/test/lib/vedeu/bindings/drb_test.rb +23 -0
  40. data/test/lib/vedeu/bindings/menus_test.rb +26 -0
  41. data/test/lib/vedeu/bindings/movement_test.rb +28 -0
  42. data/test/lib/vedeu/bindings/visibility_test.rb +27 -0
  43. data/test/lib/vedeu/buffers/buffer_test.rb +73 -38
  44. data/test/lib/vedeu/cli/main_test.rb +47 -0
  45. data/test/lib/vedeu/dsl/interface_test.rb +4 -7
  46. data/test/lib/vedeu/exceptions_test.rb +5 -0
  47. data/test/lib/vedeu/input/input_test.rb +9 -0
  48. data/test/lib/vedeu/output/esc_test.rb +4 -1
  49. metadata +21 -5
  50. data/lib/vedeu/bindings.rb +0 -275
  51. data/test/lib/vedeu/bindings_test.rb +0 -88
@@ -71,12 +71,12 @@ module Vedeu
71
71
 
72
72
  # @return [Array<Fixnum>]
73
73
  def x_xn
74
- @x_xn ||= Vedeu::Dimension.pair(default: Vedeu::Terminal.width)
74
+ @x_xn ||= Vedeu::Dimension.pair(default: Vedeu.width)
75
75
  end
76
76
 
77
77
  # @return [Array<Fixnum>]
78
78
  def y_yn
79
- @y_yn ||= Vedeu::Dimension.pair(default: Vedeu::Terminal.height)
79
+ @y_yn ||= Vedeu::Dimension.pair(default: Vedeu.height)
80
80
  end
81
81
 
82
82
  end # Geometry
@@ -108,8 +108,6 @@ module Vedeu
108
108
  end
109
109
  alias_method :to_str, :to_s
110
110
 
111
- private
112
-
113
111
  end # Colour
114
112
 
115
113
  end # Vedeu
@@ -177,7 +177,13 @@ module Vedeu
177
177
 
178
178
  # @return [String]
179
179
  def screen_exit
180
- [show_cursor, colour_reset, reset].join
180
+ [
181
+ show_cursor,
182
+ colour_reset,
183
+ reset,
184
+ Vedeu::Position.new(Vedeu.height, Vedeu.width).to_s,
185
+ "\n",
186
+ ].join
181
187
  end
182
188
 
183
189
  end # Esc
@@ -1,5 +1,8 @@
1
1
  module Vedeu
2
2
 
3
+ # Renders the provided border.
4
+ #
5
+ # @api private
3
6
  class RenderBorder
4
7
 
5
8
  extend Forwardable
@@ -197,6 +200,7 @@ module Vedeu
197
200
 
198
201
  out = []
199
202
  out << build(top_left, :top_left, *[y, x]) if left?
203
+
200
204
  if title? && width > title_characters.size
201
205
  out << titlebar
202
206
 
@@ -204,6 +208,7 @@ module Vedeu
204
208
  out << horizontal_border(:top_horizontal, y)
205
209
 
206
210
  end
211
+
207
212
  out << build(top_right, :top_right, *[y, xn]) if right?
208
213
  out
209
214
  end
@@ -13,12 +13,17 @@ module Vedeu
13
13
  def parsed
14
14
  return '' if output.nil? || output.empty?
15
15
 
16
- ::JSON.pretty_generate(sorted)
16
+ ::JSON.pretty_generate(as_hash)
17
+ end
18
+
19
+ # @return [Array]
20
+ def as_hash
21
+ sorted.map(&:to_hash)
17
22
  end
18
23
 
19
24
  # @return [Array]
20
25
  def sorted
21
- Array(output).flatten.sort { |a, b| a.position <=> b.position }.map { |char| char.to_hash }
26
+ Array(output).flatten.sort { |a, b| a.position <=> b.position }
22
27
  end
23
28
 
24
29
  end # JSON
@@ -122,7 +122,7 @@ module Vedeu
122
122
  #
123
123
  # @return [String]
124
124
  def restore_screen
125
- output(Esc.string('screen_exit'), Esc.string('clear_last_line'))
125
+ output(Esc.string('screen_exit'))
126
126
  end
127
127
 
128
128
  # Sets the cursor to be visible unless in raw mode, whereby it will be left
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.4.43'
4
+ VERSION = '0.4.44'
5
5
 
6
6
  end
@@ -17,10 +17,6 @@ module Vedeu
17
17
 
18
18
  end
19
19
 
20
- context 'InstanceMethods' do
21
-
22
- end
23
-
24
20
  end # Controller
25
21
 
26
22
  end # Vedeu
@@ -13,14 +13,6 @@ module Vedeu
13
13
  let(:described) { Vedeu::HelperTestClass }
14
14
  let(:instance) { described.new }
15
15
 
16
- context 'ClassMethods' do
17
-
18
- end
19
-
20
- context 'InstanceMethods' do
21
-
22
- end
23
-
24
16
  end # Helper
25
17
 
26
18
  end # Vedeu
@@ -13,14 +13,6 @@ module Vedeu
13
13
  let(:described) { Vedeu::ViewTestClass }
14
14
  let(:instance) { described.new }
15
15
 
16
- context 'ClassMethods' do
17
-
18
- end
19
-
20
- context 'InstanceMethods' do
21
-
22
- end
23
-
24
16
  end # View
25
17
 
26
18
  end # Vedeu
@@ -0,0 +1,43 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Bindings do
6
+
7
+ context 'the system events needed by Vedeu to run are defined' do
8
+ it { Vedeu.events.registered?(:_clear_).must_equal(true) }
9
+ it { Vedeu.events.registered?(:_clear_group_).must_equal(true) }
10
+ it { Vedeu.events.registered?(:_cleanup_).must_equal(true) }
11
+ it { Vedeu.events.registered?(:_command_).must_equal(true) }
12
+ it { Vedeu.events.registered?(:_exit_).must_equal(true) }
13
+ it { Vedeu.events.registered?(:_initialize_).must_equal(true) }
14
+ it { Vedeu.events.registered?(:_keypress_).must_equal(true) }
15
+ it { Vedeu.events.registered?(:_log_).must_equal(true) }
16
+ it { Vedeu.events.registered?(:_mode_switch_).must_equal(true) }
17
+ it { Vedeu.events.registered?(:_refresh_).must_equal(true) }
18
+ it { Vedeu.events.registered?(:_refresh_cursor_).must_equal(true) }
19
+ it { Vedeu.events.registered?(:_refresh_group_).must_equal(true) }
20
+ it { Vedeu.events.registered?(:_resize_).must_equal(true) }
21
+ end
22
+
23
+ it { Vedeu.events.registered?(:_cursor_position_).must_equal(true) }
24
+
25
+ context 'the geometry specific events are defined' do
26
+
27
+ it { Vedeu.events.registered?(:_maximise_).must_equal(true) }
28
+ it { Vedeu.events.registered?(:_unmaximise_).must_equal(true) }
29
+ end
30
+
31
+ context 'the focus specific events are defined' do
32
+ it { Vedeu.events.registered?(:_focus_by_name_).must_equal(true) }
33
+ it { Vedeu.events.registered?(:_focus_next_).must_equal(true) }
34
+ it { Vedeu.events.registered?(:_focus_prev_).must_equal(true) }
35
+ end
36
+
37
+ context 'the refresh event for all registered interfaces is defined' do
38
+ it { Vedeu.events.registered?(:_refresh_).must_equal(true) }
39
+ end
40
+
41
+ end # Bindings
42
+
43
+ end # Vedeu
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Bindings
6
+
7
+ describe DRB do
8
+
9
+ context 'the drb specific events are defined' do
10
+ it { Vedeu.events.registered?(:_drb_input_).must_equal(true) }
11
+ it { Vedeu.events.registered?(:_drb_retrieve_output_).must_equal(true) }
12
+ it { Vedeu.events.registered?(:_drb_store_output_).must_equal(true) }
13
+ it { Vedeu.events.registered?(:_drb_restart_).must_equal(true) }
14
+ it { Vedeu.events.registered?(:_drb_start_).must_equal(true) }
15
+ it { Vedeu.events.registered?(:_drb_status_).must_equal(true) }
16
+ it { Vedeu.events.registered?(:_drb_stop_).must_equal(true) }
17
+ end
18
+
19
+ end # DRB
20
+
21
+ end # Bindings
22
+
23
+ end # Vedeu
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Bindings
6
+
7
+ describe Menus do
8
+
9
+ context 'the menu specific events are defined' do
10
+ it { Vedeu.events.registered?(:_menu_bottom_).must_equal(true) }
11
+ it { Vedeu.events.registered?(:_menu_current_).must_equal(true) }
12
+ it { Vedeu.events.registered?(:_menu_deselect_).must_equal(true) }
13
+ it { Vedeu.events.registered?(:_menu_items_).must_equal(true) }
14
+ it { Vedeu.events.registered?(:_menu_next_).must_equal(true) }
15
+ it { Vedeu.events.registered?(:_menu_prev_).must_equal(true) }
16
+ it { Vedeu.events.registered?(:_menu_selected_).must_equal(true) }
17
+ it { Vedeu.events.registered?(:_menu_select_).must_equal(true) }
18
+ it { Vedeu.events.registered?(:_menu_top_).must_equal(true) }
19
+ it { Vedeu.events.registered?(:_menu_view_).must_equal(true) }
20
+ end
21
+
22
+ end # Menus
23
+
24
+ end # Bindings
25
+
26
+ end # Vedeu
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Bindings
6
+
7
+ describe Movement do
8
+
9
+ context 'the movement events are defined' do
10
+ it { Vedeu.events.registered?(:_cursor_down_).must_equal(true) }
11
+ it { Vedeu.events.registered?(:_cursor_left_).must_equal(true) }
12
+ it { Vedeu.events.registered?(:_cursor_origin_).must_equal(true) }
13
+ it { Vedeu.events.registered?(:_cursor_reposition_).must_equal(true) }
14
+ it { Vedeu.events.registered?(:_cursor_reset_).must_equal(true) }
15
+ it { Vedeu.events.registered?(:_cursor_right_).must_equal(true) }
16
+ it { Vedeu.events.registered?(:_cursor_up_).must_equal(true) }
17
+
18
+ it { Vedeu.events.registered?(:_geometry_down_).must_equal(true) }
19
+ it { Vedeu.events.registered?(:_geometry_left_).must_equal(true) }
20
+ it { Vedeu.events.registered?(:_geometry_right_).must_equal(true) }
21
+ it { Vedeu.events.registered?(:_geometry_up_).must_equal(true) }
22
+ end
23
+
24
+ end # Movement
25
+
26
+ end # Bindings
27
+
28
+ end # Vedeu
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Bindings
6
+
7
+ describe Visibility do
8
+
9
+ context 'the visibility events are defined' do
10
+ it { Vedeu.events.registered?(:_cursor_hide_).must_equal(true) }
11
+ it { Vedeu.events.registered?(:_cursor_show_).must_equal(true) }
12
+ it { Vedeu.events.registered?(:_hide_cursor_).must_equal(true) }
13
+ it { Vedeu.events.registered?(:_show_cursor_).must_equal(true) }
14
+
15
+ it { Vedeu.events.registered?(:_hide_group_).must_equal(true) }
16
+ it { Vedeu.events.registered?(:_show_group_).must_equal(true) }
17
+
18
+ it { Vedeu.events.registered?(:_hide_interface_).must_equal(true) }
19
+ it { Vedeu.events.registered?(:_show_interface_).must_equal(true) }
20
+ it { Vedeu.events.registered?(:_toggle_interface_).must_equal(true) }
21
+ end
22
+
23
+ end # Visibility
24
+
25
+ end # Bindings
26
+
27
+ end # Vedeu
@@ -23,6 +23,8 @@ module Vedeu
23
23
  before do
24
24
  Vedeu.stubs(:trigger)
25
25
  # Vedeu.interfaces.stubs(:by_name).returns(interface)
26
+ Vedeu::Visibility.stubs(:show)
27
+ Vedeu::Visibility.stubs(:hide)
26
28
  end
27
29
  after { Vedeu.interfaces.reset }
28
30
 
@@ -142,71 +144,104 @@ module Vedeu
142
144
  end
143
145
 
144
146
  describe '#hide' do
147
+ let(:interface) {
148
+ Vedeu::Interface.new({ name: _name, visible: visible })
149
+ }
150
+ let(:_name) { 'Buffer#hide' }
151
+ let(:visible) {}
152
+
153
+ before do
154
+ interface.store
155
+ Vedeu::Output.stubs(:render)
156
+ end
157
+ after do
158
+ Vedeu.interfaces.reset
159
+ end
160
+
145
161
  subject { instance.hide }
146
162
 
147
163
  context 'when the interface is visible' do
148
- # before do
149
- # Vedeu::Visibility.stubs(:hide)
150
- # instance.stubs(:clear)
151
- # end
152
- # after do
153
- # Vedeu.interfaces.reset
154
- # end
155
-
156
- # let(:_name) { 'Buffer#hide' }
157
- # let(:interface) { Vedeu.interface('Buffer') {} }
158
-
159
- # it {
160
- # Vedeu::Visibility.expects(:hide).with(interface)
161
- # instance.expects(:clear)
162
- # subject
163
- # }
164
+ let(:visible) { true }
165
+
166
+ it {
167
+ Vedeu::Visibility.expects(:hide).with(interface)
168
+ subject
169
+ }
164
170
  end
165
171
 
166
172
  context 'when the interface is not visible' do
173
+ let(:visible) { false }
174
+
167
175
  it { subject.must_be_instance_of(NilClass) }
168
176
  end
169
177
  end
170
178
 
171
179
  describe '#show' do
180
+ let(:interface) {
181
+ Vedeu::Interface.new({ name: _name, visible: visible })
182
+ }
183
+ let(:_name) { 'Buffer#show' }
184
+ let(:visible) {}
185
+
186
+ before do
187
+ interface.store
188
+ Vedeu::Output.stubs(:render)
189
+ end
190
+ after do
191
+ Vedeu.interfaces.reset
192
+ end
193
+
172
194
  subject { instance.show }
173
195
 
174
196
  context 'when the interface is visible' do
175
- # it { subject.must_be_instance_of(NilClass) }
176
- # it { skip }
197
+ let(:visible) { true }
198
+
199
+ it { subject.must_be_instance_of(NilClass) }
177
200
  end
178
201
 
179
202
  context 'when the interface is not visible' do
180
- # it { skip }
181
-
182
- # before do
183
- # Vedeu::Visibility.stubs(:show)
184
- # instance.stubs(:render)
185
- # end
186
- # after do
187
- # Vedeu.interfaces.reset
188
- # end
189
-
190
- # let(:_name) { 'Buffer#show' }
191
- # let(:interface) { Vedeu.interface('Buffer#show') {} }
192
-
193
- # it {
194
- # Vedeu::Visibility.expects(:show).with(interface)
195
- # instance.expects(:render)
196
- # subject
197
- # }
203
+ let(:visible) { false }
204
+
205
+ it {
206
+ Vedeu::Visibility.expects(:show).with(interface)
207
+ subject
208
+ }
198
209
  end
199
210
  end
200
211
 
201
212
  describe '#toggle' do
213
+ let(:interface) {
214
+ Vedeu::Interface.new({ name: _name, visible: visible })
215
+ }
216
+ let(:_name) { 'Buffer#toggle' }
217
+ let(:visible) {}
218
+
219
+ before do
220
+ interface.store
221
+ Vedeu::Output.stubs(:render)
222
+ end
223
+ after do
224
+ Vedeu.interfaces.reset
225
+ end
226
+
202
227
  subject { instance.toggle }
203
228
 
204
229
  context 'when the interface is visible' do
205
- # it { skip }
230
+ let(:visible) { true }
231
+
232
+ it {
233
+ Vedeu::Visibility.expects(:hide).with(interface)
234
+ subject
235
+ }
206
236
  end
207
237
 
208
238
  context 'when the interface is not visible' do
209
- # it { skip }
239
+ let(:visible) { false }
240
+
241
+ it {
242
+ Vedeu::Visibility.expects(:show).with(interface)
243
+ subject
244
+ }
210
245
  end
211
246
  end
212
247