vedeu 0.4.60 → 0.4.61

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/lib/vedeu.rb +2 -0
  3. data/lib/vedeu/all.rb +8 -4
  4. data/lib/vedeu/{output → borders}/border.rb +0 -0
  5. data/lib/vedeu/{output → borders}/borders.rb +0 -0
  6. data/lib/vedeu/{output → borders}/render_border.rb +24 -18
  7. data/lib/vedeu/cursor/move.rb +5 -16
  8. data/lib/vedeu/cursor/reposition.rb +3 -17
  9. data/lib/vedeu/dsl/view.rb +1 -1
  10. data/lib/vedeu/geometry/coordinate.rb +21 -11
  11. data/lib/vedeu/geometry/geometry.rb +1 -1
  12. data/lib/vedeu/geometry/position.rb +2 -2
  13. data/lib/vedeu/output/compressor.rb +3 -7
  14. data/lib/vedeu/output/style.rb +1 -1
  15. data/lib/vedeu/plugins.rb +12 -13
  16. data/lib/vedeu/plugins/plugin.rb +4 -2
  17. data/lib/vedeu/repositories/collection.rb +9 -0
  18. data/lib/vedeu/templating/all.rb +9 -0
  19. data/lib/vedeu/templating/decoder.rb +62 -0
  20. data/lib/vedeu/templating/directive.rb +0 -1
  21. data/lib/vedeu/templating/encoder.rb +62 -0
  22. data/lib/vedeu/templating/helpers.rb +10 -22
  23. data/lib/vedeu/templating/post_processor.rb +81 -0
  24. data/lib/vedeu/templating/template.rb +1 -7
  25. data/lib/vedeu/terminal_mode.rb +2 -0
  26. data/lib/vedeu/version.rb +1 -1
  27. data/test/lib/vedeu/{output → borders}/border_test.rb +0 -0
  28. data/test/lib/vedeu/{output → borders}/borders_test.rb +0 -0
  29. data/test/lib/vedeu/{output → borders}/render_border_test.rb +0 -0
  30. data/test/lib/vedeu/geometry/coordinate_test.rb +20 -17
  31. data/test/lib/vedeu/geometry/position_test.rb +1 -1
  32. data/test/lib/vedeu/models/char_test.rb +17 -18
  33. data/test/lib/vedeu/output/compressor_test.rb +5 -5
  34. data/test/lib/vedeu/output/{renderers/all_test.rb → renderers_test.rb} +0 -0
  35. data/test/lib/vedeu/output/viewport_test.rb +63 -63
  36. data/test/lib/vedeu/plugins_test.rb +12 -6
  37. data/test/lib/vedeu/repositories/collection_test.rb +14 -0
  38. data/test/lib/vedeu/templating/decoder_test.rb +37 -0
  39. data/test/lib/vedeu/templating/encoder_test.rb +38 -0
  40. data/test/lib/vedeu/templating/helpers_test.rb +11 -0
  41. data/test/lib/vedeu/templating/{preprocessor_test.rb → post_processor_test.rb} +14 -18
  42. data/test/lib/vedeu/templating/template_test.rb +3 -2
  43. data/test/support/templates/{inline.erb → plain.erb} +0 -0
  44. metadata +25 -18
  45. data/lib/vedeu/templating/preprocessor.rb +0 -81
@@ -135,7 +135,7 @@ module Vedeu
135
135
  end
136
136
 
137
137
  it 'resets to starting position when a block is given' do
138
- Position[4, 9].to_s { 'test' }.must_equal("\e[4;9Htest\e[4;9H")
138
+ Position[4, 9].to_s { 'test' }.must_equal("\e[4;9Htest")
139
139
  end
140
140
  end
141
141
 
@@ -86,7 +86,6 @@ module Vedeu
86
86
  "\\e[38;2;0;255;0m" \
87
87
  "\\e[48;2;0;85;0m" \
88
88
  "\\e[4ma" \
89
- "\\e[17;2H" \
90
89
  "'>"
91
90
  ) }
92
91
  end
@@ -105,23 +104,23 @@ module Vedeu
105
104
  it { subject.must_be_instance_of(Hash) }
106
105
 
107
106
  it { subject.must_equal(
108
- border: '',
109
- colour: {
110
- background: '',
111
- foreground: '',
112
- },
113
- parent: {
114
- background: '',
115
- foreground: '',
107
+ border: '',
108
+ colour: {
109
+ background: '',
110
+ foreground: '',
111
+ },
112
+ parent: {
113
+ background: '',
114
+ foreground: '',
115
+ style: '',
116
+ },
117
+ position: {
118
+ y: nil,
119
+ x: nil
120
+ },
116
121
  style: '',
117
- },
118
- position: {
119
- y: nil,
120
- x: nil
121
- },
122
- style: '',
123
- value: 'a',
124
- ) }
122
+ value: 'a')
123
+ }
125
124
  end
126
125
 
127
126
  describe '#to_html' do
@@ -138,7 +137,7 @@ module Vedeu
138
137
  context 'when a position is specified' do
139
138
  let(:position) { Vedeu::Position[17, 2] }
140
139
 
141
- it { subject.must_equal("\e[17;2Ha\e[17;2H") }
140
+ it { subject.must_equal("\e[17;2Ha") }
142
141
  end
143
142
 
144
143
  context 'when a position is not specified' do
@@ -16,11 +16,7 @@ module Vedeu
16
16
  end
17
17
 
18
18
  describe '.render' do
19
- it { described.must_respond_to(:render) }
20
- end
21
-
22
- describe '#render' do
23
- subject { instance.render }
19
+ subject { described.render(output) }
24
20
 
25
21
  it { subject.must_be_instance_of(String) }
26
22
 
@@ -117,6 +113,10 @@ module Vedeu
117
113
  end
118
114
  end
119
115
 
116
+ describe '#render' do
117
+ it { instance.must_respond_to(:render) }
118
+ end
119
+
120
120
  end # Compressor
121
121
 
122
122
  end # Vedeu
@@ -104,15 +104,15 @@ module Vedeu
104
104
 
105
105
  it 'scrolls the content the correct position' do
106
106
  subject.must_equal(
107
- "\e[1;1Hb\e[1;1H\n" \
108
- "\e[1;2Ha\e[1;2H\n" \
109
- "\e[1;3Hr\e[1;3H\n" \
110
- "\e[2;1Hc\e[2;1H\n" \
111
- "\e[2;2Ha\e[2;2H\n" \
112
- "\e[2;3Hr\e[2;3H\n" \
113
- "\e[3;1Hh\e[3;1H\n" \
114
- "\e[3;2He\e[3;2H\n" \
115
- "\e[3;3Hl\e[3;3H"
107
+ "\e[1;1Hb\n" \
108
+ "\e[1;2Ha\n" \
109
+ "\e[1;3Hr\n" \
110
+ "\e[2;1Hc\n" \
111
+ "\e[2;2Ha\n" \
112
+ "\e[2;3Hr\n" \
113
+ "\e[3;1Hh\n" \
114
+ "\e[3;2He\n" \
115
+ "\e[3;3Hl"
116
116
  )
117
117
  end
118
118
  end
@@ -124,15 +124,15 @@ module Vedeu
124
124
 
125
125
  it "renders the visible content" do
126
126
  subject.must_equal(
127
- "\e[1;1Hb\e[1;1H\n" \
128
- "\e[1;2Ha\e[1;2H\n" \
129
- "\e[1;3Hr\e[1;3H\n" \
130
- "\e[2;1Hc\e[2;1H\n" \
131
- "\e[2;2Ha\e[2;2H\n" \
132
- "\e[2;3Hr\e[2;3H\n" \
133
- "\e[3;1Hh\e[3;1H\n" \
134
- "\e[3;2He\e[3;2H\n" \
135
- "\e[3;3Hl\e[3;3H"
127
+ "\e[1;1Hb\n" \
128
+ "\e[1;2Ha\n" \
129
+ "\e[1;3Hr\n" \
130
+ "\e[2;1Hc\n" \
131
+ "\e[2;2Ha\n" \
132
+ "\e[2;3Hr\n" \
133
+ "\e[3;1Hh\n" \
134
+ "\e[3;2He\n" \
135
+ "\e[3;3Hl"
136
136
  )
137
137
  end
138
138
  end
@@ -143,15 +143,15 @@ module Vedeu
143
143
 
144
144
  it "is cropped to show only that which fits" do
145
145
  subject.must_equal(
146
- "\e[1;1Hb\e[1;1H\n" \
147
- "\e[1;2Ha\e[1;2H\n" \
148
- "\e[1;3Hr\e[1;3H\n" \
149
- "\e[2;1Hc\e[2;1H\n" \
150
- "\e[2;2Ha\e[2;2H\n" \
151
- "\e[2;3Hr\e[2;3H\n" \
152
- "\e[3;1Hh\e[3;1H\n" \
153
- "\e[3;2He\e[3;2H\n" \
154
- "\e[3;3Hl\e[3;3H"
146
+ "\e[1;1Hb\n" \
147
+ "\e[1;2Ha\n" \
148
+ "\e[1;3Hr\n" \
149
+ "\e[2;1Hc\n" \
150
+ "\e[2;2Ha\n" \
151
+ "\e[2;3Hr\n" \
152
+ "\e[3;1Hh\n" \
153
+ "\e[3;2He\n" \
154
+ "\e[3;3Hl"
155
155
  )
156
156
  end
157
157
  end
@@ -164,15 +164,15 @@ module Vedeu
164
164
 
165
165
  it 'scrolls the content the correct position' do
166
166
  subject.must_equal(
167
- "\e[1;1Hb\e[1;1H\n" \
168
- "\e[1;2Ha\e[1;2H\n" \
169
- "\e[1;3Hr\e[1;3H\n" \
170
- "\e[2;1Hc\e[2;1H\n" \
171
- "\e[2;2Ha\e[2;2H\n" \
172
- "\e[2;3Hr\e[2;3H\n" \
173
- "\e[3;1Hh\e[3;1H\n" \
174
- "\e[3;2He\e[3;2H\n" \
175
- "\e[3;3Hl\e[3;3H"
167
+ "\e[1;1Hb\n" \
168
+ "\e[1;2Ha\n" \
169
+ "\e[1;3Hr\n" \
170
+ "\e[2;1Hc\n" \
171
+ "\e[2;2Ha\n" \
172
+ "\e[2;3Hr\n" \
173
+ "\e[3;1Hh\n" \
174
+ "\e[3;2He\n" \
175
+ "\e[3;3Hl"
176
176
  )
177
177
  end
178
178
  end
@@ -183,15 +183,15 @@ module Vedeu
183
183
 
184
184
  it "scrolls the content the correct position" do
185
185
  subject.must_equal(
186
- "\e[1;1Hb\e[1;1H\n" \
187
- "\e[1;2Ha\e[1;2H\n" \
188
- "\e[1;3Hr\e[1;3H\n" \
189
- "\e[2;1Hc\e[2;1H\n" \
190
- "\e[2;2Ha\e[2;2H\n" \
191
- "\e[2;3Hr\e[2;3H\n" \
192
- "\e[3;1Hh\e[3;1H\n" \
193
- "\e[3;2He\e[3;2H\n" \
194
- "\e[3;3Hl\e[3;3H"
186
+ "\e[1;1Hb\n" \
187
+ "\e[1;2Ha\n" \
188
+ "\e[1;3Hr\n" \
189
+ "\e[2;1Hc\n" \
190
+ "\e[2;2Ha\n" \
191
+ "\e[2;3Hr\n" \
192
+ "\e[3;1Hh\n" \
193
+ "\e[3;2He\n" \
194
+ "\e[3;3Hl"
195
195
  )
196
196
  end
197
197
  end
@@ -204,15 +204,15 @@ module Vedeu
204
204
 
205
205
  it "renders the visible content" do
206
206
  subject.must_equal(
207
- "\e[1;1Hb\e[1;1H\n" \
208
- "\e[1;2Ha\e[1;2H\n" \
209
- "\e[1;3Hr\e[1;3H\n" \
210
- "\e[2;1Hc\e[2;1H\n" \
211
- "\e[2;2Ha\e[2;2H\n" \
212
- "\e[2;3Hr\e[2;3H\n" \
213
- "\e[3;1Hh\e[3;1H\n" \
214
- "\e[3;2He\e[3;2H\n" \
215
- "\e[3;3Hl\e[3;3H"
207
+ "\e[1;1Hb\n" \
208
+ "\e[1;2Ha\n" \
209
+ "\e[1;3Hr\n" \
210
+ "\e[2;1Hc\n" \
211
+ "\e[2;2Ha\n" \
212
+ "\e[2;3Hr\n" \
213
+ "\e[3;1Hh\n" \
214
+ "\e[3;2He\n" \
215
+ "\e[3;3Hl"
216
216
  )
217
217
  end
218
218
  end
@@ -223,15 +223,15 @@ module Vedeu
223
223
 
224
224
  it "is cropped to show only that which fits" do
225
225
  subject.must_equal(
226
- "\e[1;1Hb\e[1;1H\n" \
227
- "\e[1;2Ha\e[1;2H\n" \
228
- "\e[1;3Hr\e[1;3H\n" \
229
- "\e[2;1Hc\e[2;1H\n" \
230
- "\e[2;2Ha\e[2;2H\n" \
231
- "\e[2;3Hr\e[2;3H\n" \
232
- "\e[3;1Hh\e[3;1H\n" \
233
- "\e[3;2He\e[3;2H\n" \
234
- "\e[3;3Hl\e[3;3H"
226
+ "\e[1;1Hb\n" \
227
+ "\e[1;2Ha\n" \
228
+ "\e[1;3Hr\n" \
229
+ "\e[2;1Hc\n" \
230
+ "\e[2;2Ha\n" \
231
+ "\e[2;3Hr\n" \
232
+ "\e[3;1Hh\n" \
233
+ "\e[3;2He\n" \
234
+ "\e[3;3Hl"
235
235
  )
236
236
  end
237
237
  end
@@ -14,8 +14,7 @@ module Vedeu
14
14
  describe '#load' do
15
15
  subject { instance.load }
16
16
 
17
- # @todo
18
- # it { skip }
17
+ it { subject.must_be_instance_of(Array) }
19
18
  end
20
19
 
21
20
  describe '#register' do
@@ -31,15 +30,22 @@ module Vedeu
31
30
  describe '#find' do
32
31
  subject { instance.find }
33
32
 
34
- # @todo
35
- # it { skip }
33
+ it { subject.must_be_instance_of(Array) }
36
34
  end
37
35
 
38
36
  describe '#names' do
39
37
  subject { instance.names }
40
38
 
41
- # @todo
42
- # it { skip }
39
+ it { subject.must_be_instance_of(Hash) }
40
+
41
+ context 'when no plugins are registered' do
42
+ it { subject.must_equal({}) }
43
+ end
44
+
45
+ context 'when plugins are registered' do
46
+ # @todo
47
+ # it { skip }
48
+ end
43
49
  end
44
50
 
45
51
  end # Plugins
@@ -88,6 +88,20 @@ module Vedeu
88
88
  end
89
89
  end
90
90
 
91
+ describe '#eql?' do
92
+ let(:other) { instance }
93
+
94
+ subject { instance.eql?(other) }
95
+
96
+ it { subject.must_equal(true) }
97
+
98
+ context 'when different to other' do
99
+ let(:other) { described.new([:different]) }
100
+
101
+ it { subject.must_equal(false) }
102
+ end
103
+ end
104
+
91
105
  describe '#size' do
92
106
  subject { instance.size }
93
107
 
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Templating
6
+
7
+ describe Decoder do
8
+
9
+ let(:described) { Vedeu::Templating::Decoder }
10
+ let(:instance) { described.new(data) }
11
+ let(:data) {
12
+ "eJxj4ci3EgpLTUkttbJyzs/JLy1itxJwSEpMzk4vyi/NS8m3EoPKOsHF2Kx4HJLBaj" \
13
+ "2VeJTT0gyAgM2KzTUEqDMtvygVXacbXIzNmgOkxcAApInNmjMEAAMcJsQ="
14
+ }
15
+ let(:expected) {
16
+ Vedeu::Colour.new(background: '#ff0000', foreground: '#00ff00')
17
+ }
18
+
19
+ describe '#initialize' do
20
+ it { instance.instance_variable_get('@data').must_equal(data) }
21
+ end
22
+
23
+ describe '.process' do
24
+ subject { described.process(data) }
25
+
26
+ it { subject.must_equal(expected) }
27
+ end
28
+
29
+ describe '#process' do
30
+ it { instance.must_respond_to(:process) }
31
+ end
32
+
33
+ end # Decoder
34
+
35
+ end # Templating
36
+
37
+ end # Vedeu
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Templating
6
+
7
+ describe Encoder do
8
+
9
+ let(:described) { Vedeu::Templating::Encoder }
10
+ let(:instance) { described.new(data) }
11
+ let(:data) {
12
+ Vedeu::Colour.new(background: '#ff0000', foreground: '#00ff00')
13
+ }
14
+ let(:expected) {
15
+ "eJxj4ci3EgpLTUkttbJyzs/JLy1itxJwSEpMzk4vyi/NS8m3EoPKOsHF2Kx4HJLBaj" \
16
+ "2VeJTT0gyAgM2KzTUEqDMtvygVXacbXIzNmgOkxcAApInNmjMEAAMcJsQ="
17
+ }
18
+
19
+ describe '#initialize' do
20
+ it { instance.instance_variable_get('@data').must_equal(data) }
21
+ end
22
+
23
+ describe '.process' do
24
+ subject { described.process(data) }
25
+
26
+ it { subject.must_equal(expected) }
27
+ end
28
+
29
+ describe '#process' do
30
+ it { instance.must_respond_to(:process) }
31
+ end
32
+
33
+ end # Encoder
34
+
35
+ end # Templating
36
+
37
+ end # Vedeu
38
+
@@ -94,6 +94,17 @@ module Vedeu
94
94
  it { subject.must_equal(expected) }
95
95
  end
96
96
 
97
+ describe '#style' do
98
+ let(:expected) {
99
+ Vedeu::Stream.new(value: 'style text',
100
+ style: Vedeu::Style.coerce(:bold))
101
+ }
102
+
103
+ subject { instance.style(:bold) { 'style text' } }
104
+
105
+ it { subject.must_equal(expected) }
106
+ end
107
+
97
108
  end # Helpers
98
109
 
99
110
  end # Templating
@@ -4,44 +4,40 @@ module Vedeu
4
4
 
5
5
  module Templating
6
6
 
7
- describe Preprocessor do
8
-
9
- let(:described) { Vedeu::Templating::Preprocessor }
10
- let(:instance) { described.new(lines) }
11
- let(:lines) {
12
- [
13
- "Some text here\n",
14
- "{{ colour(foreground: '#0f0') { 'Yay!' } }}\n",
15
- "More text here\n"
16
- ]
7
+ describe PostProcessor do
8
+
9
+ let(:described) { Vedeu::Templating::PostProcessor }
10
+ let(:instance) { described.new(content) }
11
+ let(:content) {
12
+ "Some text here\n" \
13
+ "{{ colour(foreground: '#0f0') { 'Yay!' } }}\n" \
14
+ "More text here\n"
17
15
  }
18
16
  let(:expected) {
19
- [
17
+ Vedeu::Streams.new([
20
18
  Vedeu::Stream.new(value: 'Some text here'),
21
19
  Vedeu::Stream.new(value: 'Yay!',
22
20
  colour: Vedeu::Colour.coerce(foreground: '#0f0')),
23
21
  Vedeu::Stream.new(value: 'More text here')
24
- ]
22
+ ])
25
23
  }
26
24
 
27
25
  describe '#initialize' do
28
26
  it { instance.must_be_instance_of(described) }
29
- it { instance.instance_variable_get('@lines').must_equal(lines) }
27
+ it { instance.instance_variable_get('@content').must_equal(content) }
30
28
  end
31
29
 
32
30
  describe '.process' do
33
- subject { described.process(lines) }
31
+ subject { described.process(content) }
34
32
 
35
33
  it { subject.must_equal(expected) }
36
34
  end
37
35
 
38
36
  describe '#process' do
39
- subject { instance.process }
40
-
41
- it { subject.must_equal(expected) }
37
+ it { instance.must_respond_to(:process) }
42
38
  end
43
39
 
44
- end # Preprocessor
40
+ end # PostProcessor
45
41
 
46
42
  end # Templating
47
43