vedeu 0.4.22 → 0.4.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -5
  3. data/examples/geometry_app.rb +2 -2
  4. data/lib/vedeu/bindings.rb +2 -15
  5. data/lib/vedeu/buffers/buffer.rb +2 -6
  6. data/lib/vedeu/configuration/cli.rb +4 -4
  7. data/lib/vedeu/dsl/components/border.rb +24 -8
  8. data/lib/vedeu/dsl/components/geometry.rb +10 -0
  9. data/lib/vedeu/events/event.rb +1 -2
  10. data/lib/vedeu/geometry/area.rb +4 -1
  11. data/lib/vedeu/geometry/geometry.rb +51 -18
  12. data/lib/vedeu/geometry/grid.rb +4 -28
  13. data/lib/vedeu/launcher.rb +6 -2
  14. data/lib/vedeu/models/line.rb +1 -1
  15. data/lib/vedeu/output/clear.rb +8 -8
  16. data/lib/vedeu/output/compressor.rb +1 -0
  17. data/lib/vedeu/output/esc.rb +29 -101
  18. data/lib/vedeu/output/html_char.rb +9 -9
  19. data/lib/vedeu/output/refresh.rb +17 -5
  20. data/lib/vedeu/output/renderers/all.rb +1 -9
  21. data/lib/vedeu/output/translator.rb +1 -1
  22. data/lib/vedeu/output/viewport.rb +1 -1
  23. data/lib/vedeu/repositories/repositories/colours.rb +6 -3
  24. data/lib/vedeu/support/all.rb +1 -0
  25. data/lib/vedeu/support/template.rb +2 -1
  26. data/lib/vedeu/support/terminal.rb +2 -0
  27. data/lib/vedeu/support/timer.rb +44 -0
  28. data/test/lib/vedeu/buffers/buffer_test.rb +1 -7
  29. data/test/lib/vedeu/configuration/cli_test.rb +28 -0
  30. data/test/lib/vedeu/dsl/components/geometry_test.rb +12 -0
  31. data/test/lib/vedeu/geometry/geometry_test.rb +8 -0
  32. data/test/lib/vedeu/geometry/grid_test.rb +0 -20
  33. data/test/lib/vedeu/geometry/position_test.rb +6 -0
  34. data/test/lib/vedeu/null/border_test.rb +6 -0
  35. data/test/lib/vedeu/output/clear_test.rb +12 -6
  36. data/test/lib/vedeu/output/compressor_test.rb +29 -0
  37. data/test/lib/vedeu/output/esc_test.rb +26 -26
  38. data/test/lib/vedeu/output/presentation_test.rb +22 -0
  39. data/test/lib/vedeu/output/translator_test.rb +18 -16
  40. data/test/lib/vedeu/output/viewport_test.rb +163 -97
  41. data/test/lib/vedeu/output/virtual_terminal_test.rb +6 -0
  42. data/test/lib/vedeu/repositories/repositories/colours_test.rb +29 -4
  43. data/test/lib/vedeu/repositories/repository_test.rb +6 -0
  44. data/vedeu.gemspec +4 -4
  45. metadata +3 -44
@@ -72,103 +72,169 @@ module Vedeu
72
72
  end
73
73
  end
74
74
 
75
- # describe '#to_s' do
76
- # let(:cursor) { Cursor.new(cursor_attributes) }
77
- # let(:cursor_attributes) {
78
- # { name: 'lithium', ox: ox, oy: oy, visible: true, x: x, y: y }
79
- # }
80
- # let(:lines) { [] }
81
- # let(:ox) { 0 }
82
- # let(:oy) { 0 }
83
- # let(:x) { 1 }
84
- # let(:y) { 1 }
85
-
86
- # before do
87
- # interface.stubs(:cursor).returns(cursor)
88
- # end
89
-
90
- # subject { instance.to_s }
91
-
92
- # it { subject.must_be_instance_of(Array) }
93
-
94
- # context 'when there is no content' do
95
- # before { interface.stubs(:lines).returns([]) }
96
-
97
- # it { subject.must_equal([]) }
98
- # end
99
-
100
- # context 'when there is content' do
101
- # context "when the cursor's y position is outside the viewable " \
102
- # "area - negative" do
103
- # let(:ox) { -4 }
104
- # let(:oy) { -4 }
105
-
106
- # it 'scrolls the content the correct position' do
107
- # subject.must_equal("bar\ncar\nhel")
108
- # end
109
- # end
110
-
111
- # context "when the cursor's y position is inside the viewable area" do
112
- # context "when there is not enough content to fill the height" do
113
- # let(:ox) { 3 }
114
- # let(:oy) { 7 }
115
-
116
- # it "renders the visible content" do
117
- # subject.must_equal("nic\nosm\n")
118
- # end
119
- # end
120
-
121
- # context "when there is more content than the height" do
122
- # let(:ox) { 3 }
123
- # let(:oy) { 3 }
124
-
125
- # it "is cropped to show only that which fits" do
126
- # subject.must_equal("bar\ncar\nhel")
127
- # end
128
- # end
129
- # end
130
-
131
- # context "when the cursor's x position is outside the viewable area" do
132
- # context "but inside the content" do
133
- # let(:ox) { 6 }
134
- # let(:oy) { 6 }
135
-
136
- # it 'scrolls the content the correct position' do
137
- # subject.must_equal("ine\nkel\nium")
138
- # end
139
- # end
140
-
141
- # context "and outside the content" do
142
- # let(:ox) { 7 }
143
- # let(:oy) { 7 }
144
-
145
- # it "scrolls the content the correct position" do
146
- # subject.must_equal("el\num\n")
147
- # end
148
- # end
149
- # end
150
-
151
- # context "when the cursor's x position is inside the viewable area" do
152
- # context "when there is not enough content to fill the width" do
153
- # let(:ox) { 7 }
154
- # let(:oy) { 3 }
155
-
156
- # it "renders the visible content" do
157
- # subject.must_equal("um\non\num")
158
- # end
159
- # end
160
-
161
- # context "when there is more content than the width" do
162
- # let(:ox) { 3 }
163
- # let(:oy) { 3 }
164
-
165
- # it "is cropped to show only that which fits" do
166
- # subject.must_equal("bar\ncar\nhel")
167
- # end
168
- # end
169
- # end
170
- # end
171
- # end
75
+ describe '#to_s' do
76
+ let(:cursor) { Cursor.new(cursor_attributes) }
77
+ let(:cursor_attributes) {
78
+ { name: 'lithium', ox: ox, oy: oy, visible: true, x: x, y: y }
79
+ }
80
+ let(:lines) { [] }
81
+ let(:ox) { 0 }
82
+ let(:oy) { 0 }
83
+ let(:x) { 1 }
84
+ let(:y) { 1 }
85
+
86
+ subject { instance.to_s }
87
+
88
+ it { subject.must_be_instance_of(String) }
89
+
90
+ context 'when there is no content' do
91
+ before { interface.stubs(:lines).returns([]) }
92
+
93
+ it { subject.must_equal('') }
94
+ end
95
+
96
+ context 'when there is content' do
97
+ context "when the cursor's y position is outside the viewable " \
98
+ "area - negative" do
99
+ let(:ox) { -4 }
100
+ let(:oy) { -4 }
101
+
102
+ it 'scrolls the content the correct position' do
103
+ subject.must_equal(
104
+ "\e[1;1Hb\e[1;1H\n" \
105
+ "\e[1;2Ha\e[1;2H\n" \
106
+ "\e[1;3Hr\e[1;3H\n" \
107
+ "\e[2;1Hc\e[2;1H\n" \
108
+ "\e[2;2Ha\e[2;2H\n" \
109
+ "\e[2;3Hr\e[2;3H\n" \
110
+ "\e[3;1Hh\e[3;1H\n" \
111
+ "\e[3;2He\e[3;2H\n" \
112
+ "\e[3;3Hl\e[3;3H"
113
+ )
114
+ end
115
+ end
116
+
117
+ context "when the cursor's y position is inside the viewable area" do
118
+ context "when there is not enough content to fill the height" do
119
+ let(:ox) { 3 }
120
+ let(:oy) { 7 }
121
+
122
+ it "renders the visible content" do
123
+ subject.must_equal(
124
+ "\e[1;1Hb\e[1;1H\n" \
125
+ "\e[1;2Ha\e[1;2H\n" \
126
+ "\e[1;3Hr\e[1;3H\n" \
127
+ "\e[2;1Hc\e[2;1H\n" \
128
+ "\e[2;2Ha\e[2;2H\n" \
129
+ "\e[2;3Hr\e[2;3H\n" \
130
+ "\e[3;1Hh\e[3;1H\n" \
131
+ "\e[3;2He\e[3;2H\n" \
132
+ "\e[3;3Hl\e[3;3H"
133
+ )
134
+ end
135
+ end
136
+
137
+ context "when there is more content than the height" do
138
+ let(:ox) { 3 }
139
+ let(:oy) { 3 }
140
+
141
+ it "is cropped to show only that which fits" do
142
+ subject.must_equal(
143
+ "\e[1;1Hb\e[1;1H\n" \
144
+ "\e[1;2Ha\e[1;2H\n" \
145
+ "\e[1;3Hr\e[1;3H\n" \
146
+ "\e[2;1Hc\e[2;1H\n" \
147
+ "\e[2;2Ha\e[2;2H\n" \
148
+ "\e[2;3Hr\e[2;3H\n" \
149
+ "\e[3;1Hh\e[3;1H\n" \
150
+ "\e[3;2He\e[3;2H\n" \
151
+ "\e[3;3Hl\e[3;3H"
152
+ )
153
+ end
154
+ end
155
+ end
156
+
157
+ context "when the cursor's x position is outside the viewable area" do
158
+ context "but inside the content" do
159
+ let(:ox) { 6 }
160
+ let(:oy) { 6 }
161
+
162
+ it 'scrolls the content the correct position' do
163
+ subject.must_equal(
164
+ "\e[1;1Hb\e[1;1H\n" \
165
+ "\e[1;2Ha\e[1;2H\n" \
166
+ "\e[1;3Hr\e[1;3H\n" \
167
+ "\e[2;1Hc\e[2;1H\n" \
168
+ "\e[2;2Ha\e[2;2H\n" \
169
+ "\e[2;3Hr\e[2;3H\n" \
170
+ "\e[3;1Hh\e[3;1H\n" \
171
+ "\e[3;2He\e[3;2H\n" \
172
+ "\e[3;3Hl\e[3;3H"
173
+ )
174
+ end
175
+ end
176
+
177
+ context "and outside the content" do
178
+ let(:ox) { 7 }
179
+ let(:oy) { 7 }
180
+
181
+ it "scrolls the content the correct position" do
182
+ subject.must_equal(
183
+ "\e[1;1Hb\e[1;1H\n" \
184
+ "\e[1;2Ha\e[1;2H\n" \
185
+ "\e[1;3Hr\e[1;3H\n" \
186
+ "\e[2;1Hc\e[2;1H\n" \
187
+ "\e[2;2Ha\e[2;2H\n" \
188
+ "\e[2;3Hr\e[2;3H\n" \
189
+ "\e[3;1Hh\e[3;1H\n" \
190
+ "\e[3;2He\e[3;2H\n" \
191
+ "\e[3;3Hl\e[3;3H"
192
+ )
193
+ end
194
+ end
195
+ end
196
+
197
+ context "when the cursor's x position is inside the viewable area" do
198
+ context "when there is not enough content to fill the width" do
199
+ let(:ox) { 7 }
200
+ let(:oy) { 3 }
201
+
202
+ it "renders the visible content" do
203
+ subject.must_equal(
204
+ "\e[1;1Hb\e[1;1H\n" \
205
+ "\e[1;2Ha\e[1;2H\n" \
206
+ "\e[1;3Hr\e[1;3H\n" \
207
+ "\e[2;1Hc\e[2;1H\n" \
208
+ "\e[2;2Ha\e[2;2H\n" \
209
+ "\e[2;3Hr\e[2;3H\n" \
210
+ "\e[3;1Hh\e[3;1H\n" \
211
+ "\e[3;2He\e[3;2H\n" \
212
+ "\e[3;3Hl\e[3;3H"
213
+ )
214
+ end
215
+ end
216
+
217
+ context "when there is more content than the width" do
218
+ let(:ox) { 3 }
219
+ let(:oy) { 3 }
220
+
221
+ it "is cropped to show only that which fits" do
222
+ subject.must_equal(
223
+ "\e[1;1Hb\e[1;1H\n" \
224
+ "\e[1;2Ha\e[1;2H\n" \
225
+ "\e[1;3Hr\e[1;3H\n" \
226
+ "\e[2;1Hc\e[2;1H\n" \
227
+ "\e[2;2Ha\e[2;2H\n" \
228
+ "\e[2;3Hr\e[2;3H\n" \
229
+ "\e[3;1Hh\e[3;1H\n" \
230
+ "\e[3;2He\e[3;2H\n" \
231
+ "\e[3;3Hl\e[3;3H"
232
+ )
233
+ end
234
+ end
235
+ end
236
+ end
237
+ end
172
238
 
173
239
  end # Viewport
174
240
 
@@ -94,6 +94,12 @@ module Vedeu
94
94
  it { subject.must_be_instance_of(Array) }
95
95
  end
96
96
 
97
+ describe '#render' do
98
+ subject { instance.render }
99
+
100
+ it { subject.must_be_instance_of(String) }
101
+ end
102
+
97
103
  describe '#reset' do
98
104
  subject { instance.reset }
99
105
 
@@ -13,16 +13,30 @@ module Vedeu
13
13
  end
14
14
 
15
15
  describe '#register' do
16
- let(:colour) {}
17
- let(:escape_sequence) {}
16
+ let(:colour) { 'ff0000' }
17
+ let(:escape_sequence) { 'fake_escape_sequence' }
18
18
 
19
19
  subject { instance.register(colour, escape_sequence) }
20
+
21
+ it { subject.must_equal('fake_escape_sequence') }
20
22
  end
21
23
 
22
24
  describe '#registered?' do
23
25
  let(:colour) {}
24
26
 
25
27
  subject { instance.registered?(colour) }
28
+
29
+ context 'when the colour is registered' do
30
+ let(:colour) { '#aa0000' }
31
+
32
+ before { instance.register(colour, 'fake_escape_sequence') }
33
+
34
+ it { subject.must_equal(true) }
35
+ end
36
+
37
+ context 'when the colour is not registered' do
38
+ it { subject.must_equal(false) }
39
+ end
26
40
  end
27
41
 
28
42
  describe '#reset!' do
@@ -39,6 +53,11 @@ module Vedeu
39
53
  subject { instance.retrieve(colour) }
40
54
 
41
55
  context 'when the colour can be found' do
56
+ let(:colour) { '#bb0000' }
57
+
58
+ before { instance.register(colour, 'fake_escape_sequence') }
59
+
60
+ it { subject.must_equal('fake_escape_sequence') }
42
61
  end
43
62
 
44
63
  context 'when the colour cannot be found' do
@@ -47,15 +66,21 @@ module Vedeu
47
66
  end
48
67
 
49
68
  describe '#retrieve_or_register' do
50
- let(:colour) {}
51
- let(:escape_sequence) {}
69
+ let(:colour) { '#cc0000' }
70
+ let(:escape_sequence) { 'escape_sequence' }
52
71
 
53
72
  subject { instance.retrieve_or_register(colour, escape_sequence) }
54
73
 
55
74
  context 'when the colour is registered' do
75
+ let(:colour) { '#cc0000' }
76
+
77
+ before { instance.register(colour, 'fake_escape_sequence') }
78
+
79
+ it { subject.must_equal('fake_escape_sequence') }
56
80
  end
57
81
 
58
82
  context 'when the colour is not registered' do
83
+ it { subject.must_equal('escape_sequence') }
59
84
  end
60
85
  end
61
86
 
@@ -60,6 +60,12 @@ module Vedeu
60
60
  it { instance.instance_variable_get('@storage').must_equal(storage) }
61
61
  end
62
62
 
63
+ describe '#current' do
64
+ subject { instance.current }
65
+
66
+ # it { subject.must_equal('') }
67
+ end
68
+
63
69
  describe '#find' do
64
70
  subject { instance.find(model_name) }
65
71
 
data/vedeu.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'vedeu'
7
- spec.version = '0.4.22'
7
+ spec.version = '0.4.23'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = 'A terminal case of wonderland.'
@@ -18,12 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'aruba', '0.6.2'
21
+ # spec.add_development_dependency 'aruba', '0.6.2'
22
22
  spec.add_development_dependency 'bundler', '~> 1.8'
23
- spec.add_development_dependency 'cucumber', '2.0.0'
23
+ # spec.add_development_dependency 'cucumber', '2.0.0'
24
24
  spec.add_development_dependency 'guard', '2.12.5'
25
25
  spec.add_development_dependency 'guard-bundler', '2.1.0'
26
- spec.add_development_dependency 'guard-cucumber', '1.6.0'
26
+ # spec.add_development_dependency 'guard-cucumber', '1.6.0'
27
27
  spec.add_development_dependency 'guard-minitest', '2.4.4'
28
28
  spec.add_development_dependency 'inch', '0.6.2'
29
29
  spec.add_development_dependency 'minitest', '5.6.1'
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.22
4
+ version: 0.4.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-22 00:00:00.000000000 Z
11
+ date: 2015-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: aruba
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 0.6.2
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 0.6.2
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +24,6 @@ dependencies:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
26
  version: '1.8'
41
- - !ruby/object:Gem::Dependency
42
- name: cucumber
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 2.0.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 2.0.0
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: guard
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +52,6 @@ dependencies:
80
52
  - - '='
81
53
  - !ruby/object:Gem::Version
82
54
  version: 2.1.0
83
- - !ruby/object:Gem::Dependency
84
- name: guard-cucumber
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 1.6.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 1.6.0
97
55
  - !ruby/object:Gem::Dependency
98
56
  name: guard-minitest
99
57
  requirement: !ruby/object:Gem::Requirement
@@ -480,6 +438,7 @@ files:
480
438
  - lib/vedeu/support/options.rb
481
439
  - lib/vedeu/support/template.rb
482
440
  - lib/vedeu/support/terminal.rb
441
+ - lib/vedeu/support/timer.rb
483
442
  - lib/vedeu/support/trace.rb
484
443
  - lib/vedeu/support/visibility.rb
485
444
  - lib/vedeu/traps.rb