vedeu 0.4.15 → 0.4.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/examples/borders_app.rb +0 -2
  4. data/examples/colours_app.rb +0 -2
  5. data/examples/cursor_app.rb +0 -2
  6. data/examples/drb_app.rb +0 -2
  7. data/examples/focus_app.rb +0 -2
  8. data/examples/geometry_app.rb +0 -2
  9. data/examples/hello_world.rb +0 -2
  10. data/examples/lines_app.rb +0 -2
  11. data/examples/material_colours_app.rb +0 -2
  12. data/lib/vedeu/bindings.rb +2 -1
  13. data/lib/vedeu/buffers/buffer.rb +18 -10
  14. data/lib/vedeu/debug.rb +2 -1
  15. data/lib/vedeu/distributed/server.rb +14 -8
  16. data/lib/vedeu/dsl/composition.rb +3 -10
  17. data/lib/vedeu/dsl/line.rb +14 -11
  18. data/lib/vedeu/dsl/shared/colour.rb +2 -3
  19. data/lib/vedeu/geometry/coordinate.rb +0 -4
  20. data/lib/vedeu/geometry/position.rb +2 -1
  21. data/lib/vedeu/main_loop.rb +1 -1
  22. data/lib/vedeu/models/all.rb +2 -0
  23. data/lib/vedeu/models/char.rb +4 -6
  24. data/lib/vedeu/models/composition.rb +4 -2
  25. data/lib/vedeu/models/interface.rb +4 -18
  26. data/lib/vedeu/models/line.rb +4 -3
  27. data/lib/vedeu/models/null_interface.rb +15 -0
  28. data/lib/vedeu/models/stream.rb +4 -3
  29. data/lib/vedeu/output/border.rb +9 -12
  30. data/lib/vedeu/output/clear.rb +2 -2
  31. data/lib/vedeu/output/colour.rb +30 -8
  32. data/lib/vedeu/output/esc.rb +2 -1
  33. data/lib/vedeu/output/presentation.rb +37 -20
  34. data/lib/vedeu/output/renderers/all.rb +1 -0
  35. data/lib/vedeu/output/renderers/escape_sequence_renderer.rb +40 -0
  36. data/lib/vedeu/output/renderers/file_renderer.rb +9 -5
  37. data/lib/vedeu/output/renderers/html_renderer.rb +1 -1
  38. data/lib/vedeu/output/text.rb +1 -15
  39. data/lib/vedeu/output/viewport.rb +1 -1
  40. data/lib/vedeu/repositories/repositories/borders.rb +11 -11
  41. data/lib/vedeu/repositories/repositories/buffers.rb +11 -11
  42. data/lib/vedeu/repositories/repositories/cursors.rb +15 -15
  43. data/lib/vedeu/repositories/repositories/events_repository.rb +11 -11
  44. data/lib/vedeu/repositories/repositories/geometries.rb +11 -11
  45. data/lib/vedeu/repositories/repositories/groups.rb +11 -11
  46. data/lib/vedeu/repositories/repositories/interfaces_repository.rb +23 -10
  47. data/lib/vedeu/repositories/repositories/keymaps.rb +11 -11
  48. data/lib/vedeu/repositories/repositories/menus.rb +11 -11
  49. data/test/lib/vedeu/buffers/buffer_test.rb +4 -6
  50. data/test/lib/vedeu/distributed/server_test.rb +101 -3
  51. data/test/lib/vedeu/dsl/view_test.rb +6 -0
  52. data/test/lib/vedeu/input/input_test.rb +1 -1
  53. data/test/lib/vedeu/models/char_test.rb +18 -2
  54. data/test/lib/vedeu/models/composition_test.rb +0 -2
  55. data/test/lib/vedeu/models/interface_test.rb +12 -17
  56. data/test/lib/vedeu/models/line_test.rb +0 -2
  57. data/test/lib/vedeu/models/null_interface_test.rb +9 -0
  58. data/test/lib/vedeu/models/stream_test.rb +0 -2
  59. data/test/lib/vedeu/output/border_test.rb +2 -4
  60. data/test/lib/vedeu/output/clear_test.rb +17 -0
  61. data/test/lib/vedeu/output/colour_test.rb +139 -0
  62. data/test/lib/vedeu/output/output_test.rb +15 -13
  63. data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +46 -0
  64. data/test/lib/vedeu/output/renderers/file_renderer_test.rb +27 -4
  65. data/test/lib/vedeu/output/renderers/html_renderer_test.rb +14 -3
  66. data/test/lib/vedeu/repositories/repositories/interfaces_repository_test.rb +8 -0
  67. data/test/test_helper.rb +3 -2
  68. data/vedeu.gemspec +4 -4
  69. metadata +18 -10
@@ -48,6 +48,9 @@ module Vedeu
48
48
 
49
49
  it { proc { subject }.must_raise(InvalidSyntax) }
50
50
  end
51
+
52
+ context 'when the block is given' do
53
+ end
51
54
  end
52
55
 
53
56
  describe '.views' do
@@ -64,6 +67,9 @@ module Vedeu
64
67
 
65
68
  it { proc { subject }.must_raise(InvalidSyntax) }
66
69
  end
70
+
71
+ context 'when the block is given' do
72
+ end
67
73
  end
68
74
 
69
75
  end # View
@@ -21,7 +21,7 @@ module Vedeu
21
21
  end
22
22
 
23
23
  describe '.capture' do
24
- subject { instance.capture }
24
+ subject { described.capture(reader) }
25
25
 
26
26
  context 'when in cooked mode' do
27
27
  let(:raw_mode) { false }
@@ -8,6 +8,7 @@ module Vedeu
8
8
  let(:instance) { described.new(attributes) }
9
9
  let(:attributes) {
10
10
  {
11
+ border: border,
11
12
  colour: colour,
12
13
  parent: parent,
13
14
  position: position,
@@ -35,9 +36,7 @@ module Vedeu
35
36
  describe '#initialize' do
36
37
  it { instance.must_be_instance_of(described) }
37
38
  it { instance.instance_variable_get('@border').must_equal(border) }
38
- it { instance.instance_variable_get('@colour').must_equal(colour) }
39
39
  it { instance.instance_variable_get('@parent').must_equal(parent) }
40
- it { instance.instance_variable_get('@style').must_equal(style) }
41
40
  it { instance.instance_variable_get('@value').must_equal(value) }
42
41
 
43
42
  it { instance.must_respond_to(:value) }
@@ -190,6 +189,23 @@ module Vedeu
190
189
  end
191
190
  end
192
191
 
192
+ describe '#value' do
193
+ subject { instance.value }
194
+
195
+ it { subject.must_be_instance_of(String) }
196
+
197
+ context 'when the border attribute is defined' do
198
+ let(:border) { :top_left }
199
+ let(:value) { "\x6C" }
200
+
201
+ it { subject.must_equal("\e(0l\e(B") }
202
+ end
203
+
204
+ context 'when the border attributes is not defined' do
205
+ it { subject.must_equal('a') }
206
+ end
207
+ end
208
+
193
209
  describe '#x' do
194
210
  let(:position) { Vedeu::Position.new(17, 2) }
195
211
 
@@ -32,8 +32,6 @@ module Vedeu
32
32
 
33
33
  it { subject.must_be_instance_of(described) }
34
34
  it { subject.instance_variable_get('@interfaces').must_equal(interfaces) }
35
- it { subject.instance_variable_get('@colour').must_equal(colour) }
36
- it { subject.instance_variable_get('@style').must_equal(style) }
37
35
  end
38
36
 
39
37
  describe '#add' do
@@ -21,7 +21,7 @@ module Vedeu
21
21
  let(:parent) {}
22
22
  let(:colour) {}
23
23
  let(:style) {}
24
- let(:visible) {}
24
+ let(:visible) { true }
25
25
  let(:repository) { Vedeu.interfaces }
26
26
 
27
27
  describe '#initialize' do
@@ -30,8 +30,6 @@ module Vedeu
30
30
  it { subject.instance_variable_get('@name').must_equal(_name) }
31
31
  it { subject.instance_variable_get('@lines').must_equal(lines) }
32
32
  it { subject.instance_variable_get('@parent').must_equal(parent) }
33
- it { subject.instance_variable_get('@colour').must_equal(colour) }
34
- it { subject.instance_variable_get('@style').must_equal(style) }
35
33
  it { subject.instance_variable_get('@visible').must_equal(visible) }
36
34
  it { subject.instance_variable_get('@border').must_equal(nil) }
37
35
  it { subject.instance_variable_get('@delay').must_equal(0.0) }
@@ -40,20 +38,6 @@ module Vedeu
40
38
  it { subject.instance_variable_get('@repository').must_equal(repository) }
41
39
  end
42
40
 
43
- describe '#attributes' do
44
- subject { instance.attributes }
45
-
46
- it { subject.must_be_instance_of(Hash) }
47
-
48
- it { subject.must_equal(colour: Vedeu::Colour.coerce(colour),
49
- delay: 0.0,
50
- group: '',
51
- name: 'hydrogen',
52
- parent: nil,
53
- style: Vedeu::Style.coerce(style),
54
- visible: true) }
55
- end
56
-
57
41
  describe '#border' do
58
42
  subject { instance.border }
59
43
 
@@ -108,6 +92,17 @@ module Vedeu
108
92
 
109
93
  describe '#render' do
110
94
  subject { instance.render }
95
+
96
+ it { subject.must_be_instance_of(Array) }
97
+
98
+ context 'when the interface is visible' do
99
+ end
100
+
101
+ context 'when the interface is not visible' do
102
+ let(:visible) { false }
103
+
104
+ it { subject.must_equal([]) }
105
+ end
111
106
  end
112
107
 
113
108
  describe '#store' do
@@ -48,8 +48,6 @@ module Vedeu
48
48
  it { instance.must_be_instance_of(described) }
49
49
  it { instance.instance_variable_get('@streams').must_equal(streams) }
50
50
  it { instance.instance_variable_get('@parent').must_equal(parent) }
51
- it { instance.instance_variable_get('@colour').must_equal(colour) }
52
- it { instance.instance_variable_get('@style').must_equal(style) }
53
51
  end
54
52
 
55
53
  describe '#chars' do
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe NullInterface do
6
+
7
+ end # NullInterface
8
+
9
+ end # Vedeu
@@ -34,8 +34,6 @@ module Vedeu
34
34
  it { instance.must_be_instance_of(described) }
35
35
  it { instance.instance_variable_get('@value').must_equal(value) }
36
36
  it { instance.instance_variable_get('@parent').must_equal(parent) }
37
- it { instance.instance_variable_get('@colour').must_equal(colour) }
38
- it { instance.instance_variable_get('@style').must_equal(style) }
39
37
  end
40
38
 
41
39
  describe '#add' do
@@ -47,7 +47,7 @@ module Vedeu
47
47
  bottom_left: 'm',
48
48
  bottom_right: 'j',
49
49
  client: nil,
50
- colour: {},
50
+ colour: nil,
51
51
  enabled: false,
52
52
  horizontal: 'q',
53
53
  name: 'borders',
@@ -55,7 +55,7 @@ module Vedeu
55
55
  show_left: true,
56
56
  show_right: true,
57
57
  show_top: true,
58
- style: [],
58
+ style: nil,
59
59
  title: '',
60
60
  top_left: 'l',
61
61
  top_right: 'k',
@@ -67,13 +67,11 @@ module Vedeu
67
67
  instance.instance_variable_get('@attributes').
68
68
  must_equal(default_attributes)
69
69
  end
70
- it { instance.instance_variable_get('@colour').must_equal({}) }
71
70
  it { instance.instance_variable_get('@name').must_equal('borders') }
72
71
  it do
73
72
  instance.instance_variable_get('@repository').
74
73
  must_be_instance_of(Vedeu::Borders)
75
74
  end
76
- it { instance.instance_variable_get('@style').must_equal([]) }
77
75
  end
78
76
 
79
77
  describe 'border offset methods; bx, bxn, by, byn' do
@@ -13,10 +13,13 @@ module Vedeu
13
13
  }
14
14
  }
15
15
  let(:visible) { true }
16
+ let(:drb) { false }
16
17
 
17
18
  before do
18
19
  Vedeu::Border.new(name: 'xenon').store
19
20
  Vedeu::Geometry.new(name: 'xenon', x: 1, y: 1, xn: 3, yn: 3).store
21
+ Vedeu::Configuration.stubs(:drb?).returns(drb)
22
+ Vedeu.renderers.stubs(:render)
20
23
  end
21
24
 
22
25
  describe '#initialize' do
@@ -33,7 +36,12 @@ module Vedeu
33
36
  subject { described.clear(interface, options) }
34
37
 
35
38
  context 'when the interface is visible' do
39
+ context 'when DRb is enabled' do
40
+ let(:drb) { true }
41
+ end
36
42
 
43
+ context 'when DRb is not enabled' do
44
+ end
37
45
  end
38
46
 
39
47
  context 'when the interface is not visible' do
@@ -50,6 +58,15 @@ module Vedeu
50
58
 
51
59
  it { subject.must_be_instance_of(Array) }
52
60
  it { subject.flatten.size.must_equal(9) }
61
+
62
+ context 'when the interface is visible' do
63
+ end
64
+
65
+ context 'when the interface is not visible' do
66
+ let(:visible) { false }
67
+
68
+ it { subject.must_equal([]) }
69
+ end
53
70
  end
54
71
 
55
72
  describe '#write' do
@@ -20,6 +20,145 @@ module Vedeu
20
20
  it { subject.instance_variable_get('@attributes').must_equal(attributes) }
21
21
  end
22
22
 
23
+ describe '.coerce' do
24
+ let(:value) {}
25
+
26
+ subject { described.coerce(value) }
27
+
28
+ it { subject.must_be_instance_of(described) }
29
+
30
+ context 'when the value is nil' do
31
+ it { subject.must_be_instance_of(described) }
32
+ it { subject.attributes.must_equal({ background: '', foreground: '' }) }
33
+ end
34
+
35
+ context 'when the value is a Vedeu::Colour' do
36
+ let(:attributes) {
37
+ {
38
+ background: '#ff00ff',
39
+ foreground: '#220022',
40
+ }
41
+ }
42
+ let(:value) { Vedeu::Colour.new(attributes) }
43
+
44
+ it { subject.must_be_instance_of(described) }
45
+ it { subject.attributes.must_equal(attributes) }
46
+ end
47
+
48
+ context 'when the value is a Hash' do
49
+ context 'when the hash has a :colour defined' do
50
+ context 'when the value of :colour is a Vedeu::Colour' do
51
+ let(:attributes) {
52
+ {
53
+ background: '#002200',
54
+ foreground: '#00ff00',
55
+ }
56
+ }
57
+ let(:value) {
58
+ {
59
+ colour: Vedeu::Colour.new(attributes),
60
+ }
61
+ }
62
+
63
+ it { subject.must_be_instance_of(described) }
64
+ it { subject.attributes.must_equal(attributes) }
65
+ end
66
+
67
+ context 'when the value of :colour is a Hash' do
68
+ context 'and a :background is defined' do
69
+ let(:value) {
70
+ {
71
+ colour: {
72
+ background: '#7700ff'
73
+ }
74
+ }
75
+ }
76
+
77
+ it { subject.must_be_instance_of(described) }
78
+ it { subject.attributes.must_equal({
79
+ background: '#7700ff',
80
+ foreground: '',
81
+ }) }
82
+ end
83
+
84
+ context 'and a :foreground is defined' do
85
+ let(:value) {
86
+ {
87
+ colour: {
88
+ foreground: '#220077'
89
+ }
90
+ }
91
+ }
92
+
93
+ it { subject.must_be_instance_of(described) }
94
+ it { subject.attributes.must_equal({
95
+ background: '',
96
+ foreground: '#220077',
97
+ }) }
98
+ end
99
+
100
+ context 'and neither a :background or :foreground is defined' do
101
+ let(:value) {
102
+ {
103
+ colour: 'wrong'
104
+ }
105
+ }
106
+
107
+ it { subject.must_be_instance_of(described) }
108
+ it { subject.attributes.must_equal({
109
+ background: '',
110
+ foreground: '',
111
+ }) }
112
+ end
113
+ end
114
+ end
115
+
116
+ context 'when the hash does not have a :colour defined' do
117
+ context 'when the hash has a :background defined' do
118
+ let(:value) {
119
+ {
120
+ background: '#000022'
121
+ }
122
+ }
123
+
124
+ it { subject.must_be_instance_of(described) }
125
+ it { subject.attributes.must_equal({
126
+ background: '#000022',
127
+ foreground: '',
128
+ }) }
129
+ end
130
+
131
+ context 'when the hash has a :foreground defined' do
132
+ let(:value) {
133
+ {
134
+ foreground: '#aadd00'
135
+ }
136
+ }
137
+
138
+ it { subject.must_be_instance_of(described) }
139
+ it { subject.attributes.must_equal({
140
+ background: '',
141
+ foreground: '#aadd00',
142
+ }) }
143
+ end
144
+
145
+ context 'when neither a :background or :foreground is defined' do
146
+ let(:value) {
147
+ {
148
+ irrelevant: true
149
+ }
150
+ }
151
+
152
+ it { subject.must_be_instance_of(described) }
153
+ it { subject.attributes.must_equal({
154
+ background: '',
155
+ foreground: '',
156
+ }) }
157
+ end
158
+ end
159
+ end
160
+ end
161
+
23
162
  describe '#background' do
24
163
  subject { instance.background }
25
164
 
@@ -7,6 +7,11 @@ module Vedeu
7
7
  let(:described) { Vedeu::Output }
8
8
  let(:instance) { described.new(content) }
9
9
  let(:content) {}
10
+ let(:drb) { false }
11
+
12
+ before do
13
+ Vedeu::Configuration.stubs(:drb?).returns(drb)
14
+ end
10
15
 
11
16
  describe '#initialize' do
12
17
  it { instance.must_be_instance_of(described) }
@@ -14,27 +19,24 @@ module Vedeu
14
19
  end
15
20
 
16
21
  describe '.render' do
17
- let(:rendered) { interface.render }
18
-
19
- before do
20
- Vedeu.renderers.stubs(:render)
21
- # Vedeu::FileRenderer.stubs(:render)
22
- # Vedeu::HTMLRenderer.stubs(:to_file)
23
- # Vedeu::TerminalRenderer.stubs(:render).returns(rendered)
24
- end
22
+ before { Vedeu.renderers.stubs(:render) }
25
23
 
26
24
  subject { described.render(content) }
27
25
 
28
- # context 'when DRb is enabled' do
29
- # it { }
30
- # end
26
+ context 'when DRb is enabled' do
27
+ let(:drb) { true }
31
28
 
32
- # context 'when DRb is not enabled' do
29
+ it { }
30
+ end
31
+
32
+ context 'when DRb is not enabled' do
33
33
  # it 'sends the rendered interface to the Terminal' do
34
34
  # Vedeu::TerminalRenderer.expects(:render)
35
35
  # subject.must_be_instance_of(Array)
36
36
  # end
37
- # end
37
+ end
38
+
39
+ it { Vedeu.renderers.expects(:render).with(content); subject }
38
40
  end
39
41
 
40
42
  end # Output
@@ -0,0 +1,46 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe EscapeSequenceRenderer do
6
+
7
+ let(:described) { Vedeu::EscapeSequenceRenderer }
8
+ let(:instance) { described.new(output) }
9
+ let(:output) {}
10
+
11
+ describe '#initialize' do
12
+ it { instance.must_be_instance_of(described) }
13
+ it { instance.instance_variable_get('@output').must_equal(output) }
14
+ end
15
+
16
+ describe '.render' do
17
+ subject { described.render(output) }
18
+
19
+ it { subject.must_be_instance_of(String) }
20
+
21
+ context 'when there is no output' do
22
+ it { subject.must_equal('') }
23
+ end
24
+
25
+ context 'when there is output' do
26
+ let(:output) {
27
+ [
28
+ Vedeu::Char.new(value: 't', colour: { background: '#ff0000', foreground: '#ffffff' }),
29
+ Vedeu::Char.new(value: 'e', colour: { background: '#ffff00', foreground: '#000000' }),
30
+ Vedeu::Char.new(value: 's', colour: { background: '#00ff00', foreground: '#000000' }),
31
+ Vedeu::Char.new(value: 't', colour: { background: '#00ffff', foreground: '#000000' }),
32
+ ]
33
+ }
34
+
35
+ it { subject.must_equal(
36
+ "\\e[38;2;255;255;255m\\e[48;2;255;0;0mt\n" \
37
+ "\\e[38;2;0;0;0m\\e[48;2;255;255;0me\n" \
38
+ "\\e[38;2;0;0;0m\\e[48;2;0;255;0ms\n" \
39
+ "\\e[38;2;0;0;0m\\e[48;2;0;255;255mt\n")
40
+ }
41
+ end
42
+ end
43
+
44
+ end # EscapeSequenceRenderer
45
+
46
+ end # Vedeu