vedeu 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +40 -0
  3. data/README.md +1 -0
  4. data/docs/dsl.md +24 -24
  5. data/lib/vedeu/all.rb +21 -44
  6. data/lib/vedeu/api.rb +13 -13
  7. data/lib/vedeu/application/application_controller.rb +2 -0
  8. data/lib/vedeu/bindings/movement.rb +53 -18
  9. data/lib/vedeu/bindings/refresh.rb +1 -1
  10. data/lib/vedeu/bindings/system.rb +2 -2
  11. data/lib/vedeu/bindings/visibility.rb +3 -3
  12. data/lib/vedeu/borders/all.rb +13 -0
  13. data/lib/vedeu/borders/border.rb +209 -202
  14. data/lib/vedeu/{dsl/border.rb → borders/dsl.rb} +15 -15
  15. data/lib/vedeu/{null/border.rb → borders/null.rb} +9 -9
  16. data/lib/vedeu/borders/render.rb +347 -0
  17. data/lib/vedeu/borders/repository.rb +19 -0
  18. data/lib/vedeu/buffers/all.rb +13 -0
  19. data/lib/vedeu/buffers/buffer.rb +182 -176
  20. data/lib/vedeu/{null/buffer.rb → buffers/null.rb} +8 -8
  21. data/lib/vedeu/buffers/repository.rb +24 -0
  22. data/lib/vedeu/buffers/virtual_buffer.rb +2 -2
  23. data/lib/vedeu/cursors/all.rb +11 -0
  24. data/lib/vedeu/cursors/cursor.rb +276 -0
  25. data/lib/vedeu/cursors/refresh.rb +84 -0
  26. data/lib/vedeu/cursors/repository.rb +34 -0
  27. data/lib/vedeu/dsl/interface.rb +9 -9
  28. data/lib/vedeu/dsl/shared.rb +11 -11
  29. data/lib/vedeu/{exceptions.rb → error.rb} +2 -2
  30. data/lib/vedeu/esc/esc.rb +1 -1
  31. data/lib/vedeu/geometry/all.rb +18 -0
  32. data/lib/vedeu/geometry/area.rb +170 -160
  33. data/lib/vedeu/geometry/coordinate.rb +61 -39
  34. data/lib/vedeu/geometry/dimension.rb +139 -132
  35. data/lib/vedeu/{dsl/geometry.rb → geometry/dsl.rb} +11 -11
  36. data/lib/vedeu/geometry/generic_coordinate.rb +159 -153
  37. data/lib/vedeu/geometry/geometry.rb +310 -212
  38. data/lib/vedeu/geometry/grid.rb +73 -69
  39. data/lib/vedeu/{null/geometry.rb → geometry/null.rb} +10 -10
  40. data/lib/vedeu/geometry/position.rb +124 -120
  41. data/lib/vedeu/geometry/repository.rb +19 -0
  42. data/lib/vedeu/input/editor/document.rb +2 -2
  43. data/lib/vedeu/internal_api.rb +8 -8
  44. data/lib/vedeu/models/escape.rb +2 -2
  45. data/lib/vedeu/models/interface.rb +1 -1
  46. data/lib/vedeu/models/page.rb +89 -0
  47. data/lib/vedeu/models/row.rb +66 -0
  48. data/lib/vedeu/models/toggleable.rb +1 -1
  49. data/lib/vedeu/models/views/char.rb +7 -6
  50. data/lib/vedeu/models/views/line.rb +1 -1
  51. data/lib/vedeu/models/views/view.rb +2 -2
  52. data/lib/vedeu/options.rb +19 -0
  53. data/lib/vedeu/output/clear/named_interface.rb +1 -1
  54. data/lib/vedeu/output/direct.rb +1 -1
  55. data/lib/vedeu/output/presentation.rb +2 -1
  56. data/lib/vedeu/output/viewport.rb +3 -3
  57. data/lib/vedeu/repositories/model.rb +9 -1
  58. data/lib/vedeu/repositories/repository.rb +5 -0
  59. data/lib/vedeu/terminal/terminal.rb +3 -3
  60. data/lib/vedeu/version.rb +1 -1
  61. data/test/lib/vedeu/borders/border_test.rb +299 -291
  62. data/test/lib/vedeu/{dsl/border_test.rb → borders/dsl_test.rb} +6 -6
  63. data/test/lib/vedeu/{null/border_test.rb → borders/null_test.rb} +6 -6
  64. data/test/lib/vedeu/borders/render_test.rb +125 -0
  65. data/test/lib/vedeu/borders/repository_test.rb +17 -0
  66. data/test/lib/vedeu/buffers/buffer_test.rb +116 -112
  67. data/test/lib/vedeu/{null/buffer_test.rb → buffers/null_test.rb} +5 -5
  68. data/test/lib/vedeu/buffers/repository_test.rb +18 -0
  69. data/test/lib/vedeu/cursors/cursor_test.rb +370 -0
  70. data/test/lib/vedeu/cursors/refresh_test.rb +69 -0
  71. data/test/lib/vedeu/cursors/repository_test.rb +41 -0
  72. data/test/lib/vedeu/dsl/interface_test.rb +5 -5
  73. data/test/lib/vedeu/{exceptions_test.rb → error_test.rb} +0 -0
  74. data/test/lib/vedeu/geometry/area_test.rb +141 -137
  75. data/test/lib/vedeu/geometry/coordinate_test.rb +93 -89
  76. data/test/lib/vedeu/geometry/dimension_test.rb +137 -133
  77. data/test/lib/vedeu/{dsl/geometry_test.rb → geometry/dsl_test.rb} +17 -17
  78. data/test/lib/vedeu/geometry/generic_coordinate_test.rb +32 -28
  79. data/test/lib/vedeu/geometry/geometry_test.rb +282 -157
  80. data/test/lib/vedeu/geometry/grid_test.rb +35 -31
  81. data/test/lib/vedeu/{null/geometry_test.rb → geometry/null_test.rb} +5 -5
  82. data/test/lib/vedeu/geometry/position_test.rb +146 -142
  83. data/test/lib/vedeu/geometry/repository_test.rb +19 -0
  84. data/test/lib/vedeu/input/editor/document_test.rb +1 -1
  85. data/test/lib/vedeu/models/escape_test.rb +1 -1
  86. data/test/lib/vedeu/models/interface_test.rb +2 -2
  87. data/test/lib/vedeu/models/page_test.rb +235 -0
  88. data/test/lib/vedeu/models/row_test.rb +111 -0
  89. data/test/lib/vedeu/models/views/char_test.rb +3 -3
  90. data/test/lib/vedeu/options_test.rb +57 -0
  91. data/test/lib/vedeu/output/clear/named_interface_test.rb +1 -1
  92. data/test/lib/vedeu/output/renderers/json_test.rb +1 -1
  93. data/test/lib/vedeu/output/viewport_test.rb +15 -9
  94. data/test/lib/vedeu/refresh/refresh_buffer_test.rb +12 -12
  95. data/test/lib/vedeu/repositories/repositories_test.rb +1 -1
  96. data/test/lib/vedeu/repositories/repository_test.rb +7 -0
  97. data/test/lib/vedeu/terminal/terminal_test.rb +1 -1
  98. data/test/test_helper.rb +1 -1
  99. data/vedeu.gemspec +2 -2
  100. metadata +57 -63
  101. data/lib/vedeu/borders/borders.rb +0 -15
  102. data/lib/vedeu/borders/render_border.rb +0 -331
  103. data/lib/vedeu/buffers/buffers.rb +0 -20
  104. data/lib/vedeu/cursor/cursor.rb +0 -174
  105. data/lib/vedeu/cursor/cursors.rb +0 -30
  106. data/lib/vedeu/cursor/move.rb +0 -239
  107. data/lib/vedeu/cursor/reposition.rb +0 -78
  108. data/lib/vedeu/geometry/geometries.rb +0 -15
  109. data/lib/vedeu/refresh/refresh_cursor.rb +0 -92
  110. data/test/lib/vedeu/borders/borders_test.rb +0 -13
  111. data/test/lib/vedeu/borders/render_border_test.rb +0 -121
  112. data/test/lib/vedeu/buffers/buffers_test.rb +0 -14
  113. data/test/lib/vedeu/cursor/cursor_test.rb +0 -246
  114. data/test/lib/vedeu/cursor/cursors_test.rb +0 -37
  115. data/test/lib/vedeu/cursor/move_test.rb +0 -301
  116. data/test/lib/vedeu/cursor/reposition_test.rb +0 -63
  117. data/test/lib/vedeu/geometry/geometries_test.rb +0 -15
  118. data/test/lib/vedeu/refresh/refresh_cursor_test.rb +0 -65
@@ -1,63 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Reposition do
6
-
7
- let(:described) { Vedeu::Reposition }
8
- let(:instance) { described.new(entity, _name, y, x) }
9
- let(:entity) { Vedeu::Cursor }
10
- let(:_name) { 'reposition' }
11
- let(:x) { 4 }
12
- let(:y) { 7 }
13
-
14
- describe '#initialize' do
15
- it { instance.must_be_instance_of(described) }
16
- it { instance.instance_variable_get('@entity').must_equal(entity) }
17
- it { instance.instance_variable_get('@name').must_equal(_name) }
18
- it { instance.instance_variable_get('@x').must_equal(x) }
19
- it { instance.instance_variable_get('@y').must_equal(y) }
20
- end
21
-
22
- describe '.to' do
23
- # let(:new_entity) { Vedeu::Cursor.new(name: _name, y: 8, x: 5, oy: 7, ox: 4) }
24
-
25
- before do
26
- # entity.stubs(:new).returns(new_entity)
27
- Vedeu::Cursor.new(name: _name, x: 1, y: 1, ox: 1, oy: 1)
28
- Vedeu.stubs(:trigger)
29
- end
30
- after { Vedeu.cursors.reset }
31
-
32
- subject { described.to(entity, _name, y, x) }
33
-
34
- it { subject.must_be_instance_of(entity) }
35
-
36
- # it 'creates and stores a new entity' do
37
- # entity.expects(:new).
38
- # with(name: _name, y: 8, x: 5, oy: 7, ox: 4)
39
-
40
- # subject
41
- # end
42
-
43
- # it 'refreshes the named interface to reflect the new position' do
44
- # Vedeu.expects(:trigger).with(:_clear_, _name)
45
- # Vedeu.expects(:trigger).with(:_refresh_, _name)
46
- # Vedeu.expects(:trigger).with(:_refresh_cursor_, _name)
47
-
48
- # subject
49
- # end
50
-
51
- it { subject.x.must_equal(5) }
52
- it { subject.y.must_equal(8) }
53
- it { subject.ox.must_equal(4) }
54
- it { subject.oy.must_equal(7) }
55
- end
56
-
57
- describe '#to' do
58
- it { instance.must_respond_to(:to) }
59
- end
60
-
61
- end # Reposition
62
-
63
- end # Vedeu
@@ -1,15 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Geometries do
6
-
7
- let(:described) { Vedeu::Geometries }
8
-
9
- after { Vedeu.geometries.reset }
10
-
11
- it { described.must_respond_to(:geometries) }
12
-
13
- end # Geometries
14
-
15
- end # Vedeu
@@ -1,65 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe RefreshCursor do
6
-
7
- let(:described) { Vedeu::RefreshCursor }
8
- let(:instance) { described.new(_name) }
9
- let(:_name) { 'refresh_cursor' }
10
- let(:expected) {}
11
- let(:ox) { 0 }
12
- let(:oy) { 0 }
13
-
14
- describe '#initialize' do
15
- it { instance.must_be_instance_of(described) }
16
- it { instance.instance_variable_get('@name').must_equal(_name) }
17
- end
18
-
19
- describe '.by_name' do
20
- before do
21
- Vedeu.geometry 'refresh_cursor' do
22
- x 1
23
- xn 3
24
- y 1
25
- yn 3
26
- end
27
- Vedeu::Cursor.new(name: 'refresh_cursor', ox: ox, oy: oy).store
28
-
29
- Vedeu::Terminal.stubs(:output).returns(expected)
30
-
31
- Vedeu.stubs(:trigger)
32
- end
33
-
34
- subject { described.by_name(_name) }
35
-
36
- it 'renders the cursor in the terminal' do
37
- Vedeu::Terminal.expects(:output).with("\e[1;1H\e[?25l")
38
- subject
39
- end
40
-
41
- context 'when the cursors offset position is outside the viewable area' do
42
- let(:ox) { 3 }
43
- let(:oy) { 3 }
44
-
45
- it 'refreshes the view' do
46
- Vedeu.expects(:trigger).with(:_refresh_, _name)
47
- subject
48
- end
49
- end
50
-
51
- context 'when the cursors offset position is inside the viewable area' do
52
- it 'does not refresh the view' do
53
- Vedeu.expects(:trigger).with(:_refresh_, _name).never
54
- subject
55
- end
56
- end
57
- end
58
-
59
- describe '#by_name' do
60
- it { instance.must_respond_to(:by_name) }
61
- end
62
-
63
- end # RefreshCursor
64
-
65
- end # Vedeu