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
@@ -2,13 +2,13 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- module DSL
5
+ module Borders
6
6
 
7
- describe Border do
7
+ describe DSL do
8
8
 
9
- let(:described) { Vedeu::DSL::Border }
9
+ let(:described) { Vedeu::Borders::DSL }
10
10
  let(:instance) { described.new(model, client) }
11
- let(:model) { Vedeu::Border.new(attributes) }
11
+ let(:model) { Vedeu::Borders::Border.new(attributes) }
12
12
  let(:client) {}
13
13
  let(:attributes) { { name: 'borders' } }
14
14
  let(:boolean) { true }
@@ -243,8 +243,8 @@ module Vedeu
243
243
  it { instance.must_respond_to(:vertical=) }
244
244
  end
245
245
 
246
- end # Border
246
+ end # DSL
247
247
 
248
- end # DSL
248
+ end # Borders
249
249
 
250
250
  end # Vedeu
@@ -2,11 +2,11 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- module Null
5
+ module Borders
6
6
 
7
- describe Border do
7
+ describe Null do
8
8
 
9
- let(:described) { Vedeu::Null::Border }
9
+ let(:described) { Vedeu::Borders::Null }
10
10
  let(:instance) { described.new(attributes) }
11
11
  let(:attributes){
12
12
  {
@@ -15,7 +15,7 @@ module Vedeu
15
15
  }
16
16
  let(:_name) { 'null_border' }
17
17
  let(:geometry) {
18
- Vedeu::Geometry.new(name: _name, x: 4, y: 6, xn: 10, yn: 12)
18
+ Vedeu::Geometry::Geometry.new(name: _name, x: 4, y: 6, xn: 10, yn: 12)
19
19
  }
20
20
 
21
21
  before { Vedeu.geometries.stubs(:by_name).returns(geometry) }
@@ -93,8 +93,8 @@ module Vedeu
93
93
  it { subject.must_equal(7) }
94
94
  end
95
95
 
96
- end # Border
96
+ end # Null
97
97
 
98
- end # Null
98
+ end # Borders
99
99
 
100
100
  end # Vedeu
@@ -0,0 +1,125 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Borders
6
+
7
+ describe Render do
8
+
9
+ let(:described) { Vedeu::Borders::Render }
10
+ let(:instance) { described.new(border) }
11
+ let(:border) {
12
+ Vedeu::Borders::Border.new(enabled: enabled,
13
+ name: _name,
14
+ title: title,
15
+ caption: caption,
16
+ show_top: show_top,
17
+ show_bottom: show_bottom,
18
+ show_left: show_left,
19
+ show_right: show_right)
20
+ }
21
+ let(:visible) { false }
22
+ let(:enabled) { false }
23
+ let(:_name) { 'Vedeu::RenderBorder' }
24
+ let(:title) {}
25
+ let(:caption) {}
26
+ let(:show_top) { true }
27
+ let(:show_bottom) { true }
28
+ let(:show_left) { true }
29
+ let(:show_right) { true }
30
+
31
+ it { described.must_respond_to(:with) }
32
+
33
+ describe '#initialize' do
34
+ it { instance.must_be_instance_of(described) }
35
+ it { instance.instance_variable_get('@border').must_equal(border) }
36
+ end
37
+
38
+ describe '#render' do
39
+ let(:geometry) {
40
+ Vedeu::Geometry::Geometry.new(name: _name, x: 1, xn: 7, y: 1, yn: 4)
41
+ }
42
+ let(:interface) {
43
+ Vedeu::Interface.new(name: _name, visible: visible)
44
+ }
45
+ before do
46
+ Vedeu.geometries.stubs(:by_name).returns(geometry)
47
+ Vedeu.interfaces.stubs(:by_name).returns(interface)
48
+ end
49
+
50
+ subject { instance.render }
51
+
52
+ context 'when the interface is not visible' do
53
+ it { subject.must_equal([]) }
54
+ end
55
+
56
+ context 'when the interface is visible' do
57
+ let(:visible) { true }
58
+
59
+ context 'when the border is not enabled' do
60
+ it { subject.must_equal([]) }
61
+ end
62
+
63
+ context 'when the border is enabled' do
64
+ let(:enabled) { true }
65
+
66
+ context 'and a title is given' do
67
+ let(:title) { 'T' }
68
+
69
+ # @todo Add more tests.
70
+ it { subject.size.must_equal(18) }
71
+ end
72
+
73
+ context 'and a title is not given' do
74
+ # @todo Add more tests.
75
+ it { subject.size.must_equal(18) }
76
+ end
77
+
78
+ context 'and a caption is given' do
79
+ let(:caption) { 'C' }
80
+
81
+ # @todo Add more tests.
82
+ it { subject.size.must_equal(18) }
83
+ end
84
+
85
+ context 'and a caption is not given' do
86
+ # @todo Add more tests.
87
+ it { subject.size.must_equal(18) }
88
+ end
89
+
90
+ context 'and the left side is disabled' do
91
+ let(:show_left) { false }
92
+
93
+ # @todo Add more tests.
94
+ it { subject.size.must_equal(16) }
95
+ end
96
+
97
+ context 'and the right side is disabled' do
98
+ let(:show_right) { false }
99
+
100
+ # @todo Add more tests.
101
+ it { subject.size.must_equal(16) }
102
+ end
103
+
104
+ context 'and the top side is disabled' do
105
+ let(:show_top) { false }
106
+
107
+ # @todo Add more tests.
108
+ it { subject.size.must_equal(13) }
109
+ end
110
+
111
+ context 'and the bottom side is disabled' do
112
+ let(:show_bottom) { false }
113
+
114
+ # @todo Add more tests.
115
+ it { subject.size.must_equal(13) }
116
+ end
117
+ end
118
+ end
119
+ end
120
+
121
+ end # Render
122
+
123
+ end # Borders
124
+
125
+ end # Vedeu
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Borders
6
+
7
+ describe Repository do
8
+
9
+ let(:described) { Vedeu::Borders::Repository }
10
+
11
+ it { described.must_respond_to(:borders) }
12
+
13
+ end # Repository
14
+
15
+ end # Borders
16
+
17
+ end # Vedeu
@@ -2,152 +2,156 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe Buffer do
6
-
7
- let(:described) { Vedeu::Buffer }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
10
- {
11
- name: _name,
12
- back: back,
13
- front: front,
14
- previous: previous,
5
+ module Buffers
6
+
7
+ describe Buffer do
8
+
9
+ let(:described) { Vedeu::Buffers::Buffer }
10
+ let(:instance) { described.new(attributes) }
11
+ let(:attributes) {
12
+ {
13
+ name: _name,
14
+ back: back,
15
+ front: front,
16
+ previous: previous,
17
+ }
15
18
  }
16
- }
17
- let(:_name) { 'krypton' }
18
- let(:back) {}
19
- let(:front) {}
20
- let(:previous) {}
21
- let(:interface) {}
22
-
23
- describe '#initialize' do
24
- it { instance.must_be_instance_of(described) }
25
- it { instance.instance_variable_get('@name').must_equal(_name) }
26
- it { instance.instance_variable_get('@back').must_equal(back) }
27
- it { instance.instance_variable_get('@front').must_equal(front) }
28
- it { instance.instance_variable_get('@previous').must_equal(previous) }
29
- it do
30
- instance.instance_variable_get('@repository').must_equal(Vedeu.buffers)
19
+ let(:_name) { 'krypton' }
20
+ let(:back) {}
21
+ let(:front) {}
22
+ let(:previous) {}
23
+ let(:interface) {}
24
+
25
+ describe '#initialize' do
26
+ it { instance.must_be_instance_of(described) }
27
+ it { instance.instance_variable_get('@name').must_equal(_name) }
28
+ it { instance.instance_variable_get('@back').must_equal(back) }
29
+ it { instance.instance_variable_get('@front').must_equal(front) }
30
+ it { instance.instance_variable_get('@previous').must_equal(previous) }
31
+ it do
32
+ instance.instance_variable_get('@repository').must_equal(Vedeu.buffers)
33
+ end
31
34
  end
32
- end
33
-
34
- describe 'accessors' do
35
- it { instance.must_respond_to(:back) }
36
- it { instance.must_respond_to(:back=) }
37
- it { instance.must_respond_to(:front) }
38
- it { instance.must_respond_to(:front=) }
39
- it { instance.must_respond_to(:previous) }
40
- it { instance.must_respond_to(:previous=) }
41
- it { instance.must_respond_to(:name) }
42
- end
43
-
44
- describe '#add' do
45
- let(:content) { Vedeu::Views::View.new(value: [Vedeu::Views::Line.new]) }
46
-
47
- subject { instance.add(content) }
48
35
 
49
- it { subject.must_equal(true) }
50
- end
36
+ describe 'accessors' do
37
+ it { instance.must_respond_to(:back) }
38
+ it { instance.must_respond_to(:back=) }
39
+ it { instance.must_respond_to(:front) }
40
+ it { instance.must_respond_to(:front=) }
41
+ it { instance.must_respond_to(:previous) }
42
+ it { instance.must_respond_to(:previous=) }
43
+ it { instance.must_respond_to(:name) }
44
+ end
51
45
 
52
- describe '#back?' do
53
- subject { instance.back? }
46
+ describe '#add' do
47
+ let(:content) { Vedeu::Views::View.new(value: [Vedeu::Views::Line.new]) }
54
48
 
55
- context 'with content' do
56
- let(:back) {
57
- Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
58
- }
49
+ subject { instance.add(content) }
59
50
 
60
51
  it { subject.must_equal(true) }
61
52
  end
62
53
 
63
- context 'without content' do
64
- it { subject.must_equal(false) }
65
- end
66
- end
54
+ describe '#back?' do
55
+ subject { instance.back? }
67
56
 
68
- describe '#clear' do
69
- let(:emptiness) { mock }
57
+ context 'with content' do
58
+ let(:back) {
59
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
60
+ }
70
61
 
71
- before do
72
- Vedeu::Clear::NamedInterface.stubs(:render).returns(emptiness)
73
- Vedeu::Output.stubs(:render).returns(emptiness)
62
+ it { subject.must_equal(true) }
63
+ end
64
+
65
+ context 'without content' do
66
+ it { subject.must_equal(false) }
67
+ end
74
68
  end
75
69
 
76
- subject { instance.clear }
70
+ describe '#clear' do
71
+ let(:emptiness) { mock }
77
72
 
78
- it {
79
- Vedeu::Clear::NamedInterface.expects(:render).with(_name).
80
- returns(emptiness)
81
- Vedeu::Output.expects(:render).with(emptiness)
82
- subject
83
- }
84
- end
73
+ before do
74
+ Vedeu::Clear::NamedInterface.stubs(:render).returns(emptiness)
75
+ Vedeu::Output.stubs(:render).returns(emptiness)
76
+ end
85
77
 
86
- describe '#front?' do
87
- subject { instance.front? }
78
+ subject { instance.clear }
88
79
 
89
- context 'with content' do
90
- let(:front) {
91
- Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
80
+ it {
81
+ Vedeu::Clear::NamedInterface.expects(:render).with(_name).
82
+ returns(emptiness)
83
+ Vedeu::Output.expects(:render).with(emptiness)
84
+ subject
92
85
  }
93
-
94
- it { subject.must_equal(true) }
95
86
  end
96
87
 
97
- context 'without content' do
98
- it { subject.must_equal(false) }
99
- end
100
- end
88
+ describe '#front?' do
89
+ subject { instance.front? }
101
90
 
102
- describe '#previous?' do
103
- subject { instance.previous? }
91
+ context 'with content' do
92
+ let(:front) {
93
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
94
+ }
104
95
 
105
- context 'with content' do
106
- let(:previous) {
107
- Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
108
- }
96
+ it { subject.must_equal(true) }
97
+ end
109
98
 
110
- it { subject.must_equal(true) }
99
+ context 'without content' do
100
+ it { subject.must_equal(false) }
101
+ end
111
102
  end
112
103
 
113
- context 'without content' do
114
- it { subject.must_equal(false) }
104
+ describe '#previous?' do
105
+ subject { instance.previous? }
106
+
107
+ context 'with content' do
108
+ let(:previous) {
109
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
110
+ }
111
+
112
+ it { subject.must_equal(true) }
113
+ end
114
+
115
+ context 'without content' do
116
+ it { subject.must_equal(false) }
117
+ end
115
118
  end
116
- end
117
119
 
118
- describe '#hide' do
119
- before { Vedeu::Output.stubs(:render) }
120
+ describe '#hide' do
121
+ before { Vedeu::Output.stubs(:render) }
120
122
 
121
- subject { instance.hide }
123
+ subject { instance.hide }
122
124
 
123
- it {
124
- Vedeu::Output.expects(:render)
125
- subject
126
- }
127
- end
125
+ it {
126
+ Vedeu::Output.expects(:render)
127
+ subject
128
+ }
129
+ end
128
130
 
129
- describe '#show' do
130
- before { Vedeu::Output.stubs(:render) }
131
+ describe '#show' do
132
+ before { Vedeu::Output.stubs(:render) }
131
133
 
132
- subject { instance.show }
134
+ subject { instance.show }
133
135
 
134
- it {
135
- Vedeu::Output.expects(:render)
136
- subject
137
- }
138
- end
136
+ it {
137
+ Vedeu::Output.expects(:render)
138
+ subject
139
+ }
140
+ end
139
141
 
140
- describe '#render' do
141
- before { Vedeu::Output.stubs(:render) }
142
+ describe '#render' do
143
+ before { Vedeu::Output.stubs(:render) }
142
144
 
143
- subject { instance.render }
145
+ subject { instance.render }
144
146
 
145
- it {
146
- Vedeu::Output.expects(:render)
147
- subject
148
- }
149
- end
147
+ it {
148
+ Vedeu::Output.expects(:render)
149
+ subject
150
+ }
151
+ end
152
+
153
+ end # Buffer
150
154
 
151
- end # Buffer
155
+ end # Buffers
152
156
 
153
157
  end # Vedeu