vedeu 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/docs/dsl.md +3 -3
  3. data/examples/borders_app.rb +2 -0
  4. data/examples/colours_app.rb +2 -0
  5. data/examples/configuration_app.rb +2 -0
  6. data/examples/drb_app.rb +2 -0
  7. data/examples/focus_app.rb +2 -0
  8. data/examples/hello_world.rb +2 -0
  9. data/examples/material_colours_app.rb +2 -0
  10. data/lib/vedeu.rb +2 -0
  11. data/lib/vedeu/all.rb +4 -13
  12. data/lib/vedeu/api.rb +7 -6
  13. data/lib/vedeu/borders/border.rb +1 -1
  14. data/lib/vedeu/borders/render_border.rb +18 -18
  15. data/lib/vedeu/buffers/buffer.rb +18 -28
  16. data/lib/vedeu/colours/colour.rb +1 -1
  17. data/lib/vedeu/colours/colour_translator.rb +1 -1
  18. data/lib/vedeu/cursor/cursor.rb +9 -6
  19. data/lib/vedeu/dsl/border.rb +1 -1
  20. data/lib/vedeu/dsl/composition.rb +5 -5
  21. data/lib/vedeu/dsl/geometry.rb +1 -1
  22. data/lib/vedeu/dsl/group.rb +1 -1
  23. data/lib/vedeu/dsl/interface.rb +69 -93
  24. data/lib/vedeu/dsl/keymap.rb +1 -1
  25. data/lib/vedeu/dsl/line.rb +11 -11
  26. data/lib/vedeu/dsl/shared.rb +81 -0
  27. data/lib/vedeu/dsl/stream.rb +3 -3
  28. data/lib/vedeu/dsl/view.rb +76 -64
  29. data/lib/vedeu/models/escape.rb +1 -1
  30. data/lib/vedeu/models/interface.rb +3 -57
  31. data/lib/vedeu/models/menu.rb +1 -1
  32. data/lib/vedeu/models/views/all.rb +22 -0
  33. data/lib/vedeu/models/views/char.rb +175 -0
  34. data/lib/vedeu/models/views/chars.rb +13 -0
  35. data/lib/vedeu/models/views/composition.rb +73 -0
  36. data/lib/vedeu/models/views/line.rb +111 -0
  37. data/lib/vedeu/models/views/lines.rb +13 -0
  38. data/lib/vedeu/models/views/stream.rb +122 -0
  39. data/lib/vedeu/models/views/streams.rb +13 -0
  40. data/lib/vedeu/models/views/view.rb +157 -0
  41. data/lib/vedeu/models/views/view_collection.rb +13 -0
  42. data/lib/vedeu/null/view.rb +67 -0
  43. data/lib/vedeu/output/clear/named_interface.rb +4 -4
  44. data/lib/vedeu/output/compressor.rb +6 -6
  45. data/lib/vedeu/output/html_char.rb +6 -6
  46. data/lib/vedeu/output/output.rb +3 -3
  47. data/lib/vedeu/output/presentation.rb +1 -1
  48. data/lib/vedeu/output/renderers/escape_sequence.rb +1 -1
  49. data/lib/vedeu/output/renderers/file.rb +1 -1
  50. data/lib/vedeu/output/renderers/html.rb +3 -3
  51. data/lib/vedeu/output/renderers/json.rb +4 -4
  52. data/lib/vedeu/output/renderers/null.rb +1 -1
  53. data/lib/vedeu/output/renderers/terminal.rb +5 -5
  54. data/lib/vedeu/output/renderers/text.rb +3 -3
  55. data/lib/vedeu/output/style.rb +1 -1
  56. data/lib/vedeu/output/text.rb +20 -15
  57. data/lib/vedeu/output/viewport.rb +16 -23
  58. data/lib/vedeu/output/virtual_buffer.rb +9 -8
  59. data/lib/vedeu/output/virtual_terminal.rb +11 -11
  60. data/lib/vedeu/output/wordwrap.rb +5 -5
  61. data/lib/vedeu/runtime/application.rb +1 -1
  62. data/lib/vedeu/runtime/main_loop.rb +1 -1
  63. data/lib/vedeu/templating/helpers.rb +11 -10
  64. data/lib/vedeu/templating/template.rb +1 -1
  65. data/lib/vedeu/templating/view_template.rb +6 -6
  66. data/lib/vedeu/version.rb +1 -2
  67. data/test/lib/vedeu/api_test.rb +30 -30
  68. data/test/lib/vedeu/buffers/buffer_test.rb +5 -139
  69. data/test/lib/vedeu/colours/colour_translator_test.rb +3 -3
  70. data/test/lib/vedeu/configuration/api_test.rb +3 -3
  71. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +1 -1
  72. data/test/lib/vedeu/dsl/composition_test.rb +7 -7
  73. data/test/lib/vedeu/dsl/group_test.rb +2 -2
  74. data/test/lib/vedeu/dsl/interface_test.rb +31 -21
  75. data/test/lib/vedeu/dsl/keymap_test.rb +4 -4
  76. data/test/lib/vedeu/dsl/line_test.rb +8 -8
  77. data/test/lib/vedeu/dsl/stream_test.rb +4 -4
  78. data/test/lib/vedeu/dsl/text_test.rb +11 -11
  79. data/test/lib/vedeu/dsl/view_test.rb +24 -29
  80. data/test/lib/vedeu/geometry/grid_test.rb +4 -4
  81. data/test/lib/vedeu/input/key_test.rb +1 -1
  82. data/test/lib/vedeu/internal_api_test.rb +18 -18
  83. data/test/lib/vedeu/models/focus_test.rb +54 -54
  84. data/test/lib/vedeu/models/interface_test.rb +11 -105
  85. data/test/lib/vedeu/models/menu_test.rb +1 -1
  86. data/test/lib/vedeu/models/views/char_test.rb +257 -0
  87. data/test/lib/vedeu/models/views/chars_test.rb +22 -0
  88. data/test/lib/vedeu/models/views/composition_test.rb +61 -0
  89. data/test/lib/vedeu/models/views/line_test.rb +189 -0
  90. data/test/lib/vedeu/models/views/lines_test.rb +22 -0
  91. data/test/lib/vedeu/models/views/stream_test.rb +138 -0
  92. data/test/lib/vedeu/models/views/streams_test.rb +22 -0
  93. data/test/lib/vedeu/models/views/view_test.rb +40 -0
  94. data/test/lib/vedeu/null/view_test.rb +12 -0
  95. data/test/lib/vedeu/output/clear/named_interface_test.rb +4 -4
  96. data/test/lib/vedeu/output/compressor_test.rb +28 -28
  97. data/test/lib/vedeu/output/html_char_test.rb +2 -2
  98. data/test/lib/vedeu/output/presentation_test.rb +10 -14
  99. data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +20 -4
  100. data/test/lib/vedeu/output/renderers/html_test.rb +4 -4
  101. data/test/lib/vedeu/output/renderers/json_test.rb +3 -3
  102. data/test/lib/vedeu/output/text_test.rb +10 -10
  103. data/test/lib/vedeu/output/viewport_test.rb +21 -23
  104. data/test/lib/vedeu/output/virtual_buffer_test.rb +1 -1
  105. data/test/lib/vedeu/output/virtual_terminal_test.rb +1 -1
  106. data/test/lib/vedeu/output/wordwrap_test.rb +9 -9
  107. data/test/lib/vedeu/repositories/repository_test.rb +2 -2
  108. data/test/lib/vedeu/templating/helpers_test.rb +6 -39
  109. data/test/lib/vedeu/templating/template_test.rb +2 -2
  110. data/test/lib/vedeu/templating/view_template_test.rb +91 -91
  111. data/test/lib/vedeu/terminal_test.rb +1 -1
  112. metadata +33 -27
  113. data/lib/vedeu/buffers/display_buffer.rb +0 -39
  114. data/lib/vedeu/models/char.rb +0 -170
  115. data/lib/vedeu/models/chars.rb +0 -9
  116. data/lib/vedeu/models/composition.rb +0 -66
  117. data/lib/vedeu/models/line.rb +0 -112
  118. data/lib/vedeu/models/lines.rb +0 -9
  119. data/lib/vedeu/models/stream.rb +0 -122
  120. data/lib/vedeu/models/streams.rb +0 -9
  121. data/test/lib/vedeu/buffers/display_buffer_test.rb +0 -61
  122. data/test/lib/vedeu/models/char_test.rb +0 -253
  123. data/test/lib/vedeu/models/chars_test.rb +0 -18
  124. data/test/lib/vedeu/models/composition_test.rb +0 -57
  125. data/test/lib/vedeu/models/line_test.rb +0 -189
  126. data/test/lib/vedeu/models/lines_test.rb +0 -18
  127. data/test/lib/vedeu/models/stream_test.rb +0 -141
  128. data/test/lib/vedeu/models/streams_test.rb +0 -18
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Chars do
6
-
7
- let(:described) { Vedeu::Chars }
8
- let(:instance) { described.new }
9
-
10
- it { described.superclass.must_equal(Vedeu::Collection) }
11
-
12
- describe '#initialize' do
13
- it { instance.must_be_instance_of(described) }
14
- end
15
-
16
- end # Chars
17
-
18
- end # Vedeu
@@ -1,57 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Composition do
6
-
7
- let(:described) { Vedeu::Composition }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
10
- {
11
- interfaces: interfaces,
12
- colour: colour,
13
- style: style,
14
- }
15
- }
16
- let(:interfaces) { [] }
17
- let(:colour) {}
18
- let(:style) {}
19
-
20
- describe '.build' do
21
- subject {
22
- described.build({}) do
23
- # ...
24
- end
25
- }
26
-
27
- it { subject.must_be_instance_of(described) }
28
- end
29
-
30
- describe '#initialize' do
31
- it { instance.must_be_instance_of(described) }
32
- it { instance.instance_variable_get('@interfaces').must_equal(interfaces) }
33
- end
34
-
35
- describe '#add' do
36
- let(:child) { Vedeu::Interface.new }
37
-
38
- subject { instance.add(child) }
39
-
40
- it { subject.must_be_instance_of(Vedeu::InterfaceCollection) }
41
- end
42
-
43
- describe '#interfaces' do
44
- subject { instance.interfaces }
45
-
46
- it { subject.must_be_instance_of(Vedeu::InterfaceCollection) }
47
- end
48
-
49
- describe '#parent' do
50
- subject { instance.parent }
51
-
52
- it { subject.must_be_instance_of(NilClass) }
53
- end
54
-
55
- end # Composition
56
-
57
- end # Vedeu
@@ -1,189 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Line do
6
-
7
- let(:described) { Vedeu::Line }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
10
- {
11
- streams: streams,
12
- parent: parent,
13
- colour: colour,
14
- style: style,
15
- }
16
- }
17
- let(:streams) {
18
- [
19
- Stream.new(value: 'Something interesting ',
20
- parent: streams_parent,
21
- colour: Colour.new(foreground: '#ffff00'),
22
- style: Style.new('normal')),
23
- Stream.new(value: 'on this line ',
24
- parent: streams_parent,
25
- colour: Colour.new(foreground: '#00ff00'),
26
- style: Style.new('normal')),
27
- Stream.new(value: 'would be cool, eh?',
28
- parent: streams_parent,
29
- colour: Colour.new(foreground: '#0000ff'),
30
- style: Style.new('normal'))
31
- ]
32
- }
33
-
34
- let(:streams_parent) {
35
- Line.new(streams: nil, parent: parent, colour: colour, style: style)
36
- }
37
-
38
- let(:parent) { Vedeu::Interface.new(name: 'Vedeu::Line') }
39
- let(:colour) { Colour.new(foreground: '#ff0000', background: '#000000') }
40
- let(:style) { Style.new('normal') }
41
-
42
- describe '#initialize' do
43
- it { instance.must_be_instance_of(described) }
44
- it { instance.instance_variable_get('@streams').must_equal(streams) }
45
- it { instance.instance_variable_get('@parent').must_equal(parent) }
46
- end
47
-
48
- describe 'accessors' do
49
- it { instance.must_respond_to(:parent) }
50
- it { instance.must_respond_to(:parent=) }
51
- it { instance.must_respond_to(:attributes) }
52
- end
53
-
54
- describe '#add' do
55
- subject { instance.add(child) }
56
-
57
- it { instance.must_respond_to(:add) }
58
-
59
- it { instance.must_respond_to(:<<) }
60
- end
61
-
62
- describe '#chars' do
63
- subject { instance.chars }
64
-
65
- it { subject.must_be_instance_of(Array) }
66
-
67
- context 'when there is no content' do
68
- let(:streams) { [] }
69
-
70
- it { subject.must_equal([]) }
71
- end
72
-
73
- context 'when there is content' do
74
- it { subject.size.must_equal(53) }
75
- end
76
- end
77
-
78
- describe '#empty?' do
79
- subject { instance.empty? }
80
-
81
- context 'when there is no content' do
82
- let(:streams) { [] }
83
-
84
- it { subject.must_be_instance_of(TrueClass) }
85
- end
86
-
87
- context 'when there is content' do
88
- it { subject.must_be_instance_of(FalseClass) }
89
- end
90
- end
91
-
92
- describe '#eql?' do
93
- let(:other) { instance }
94
-
95
- subject { instance.eql?(other) }
96
-
97
- it { subject.must_equal(true) }
98
-
99
- context 'when different to other' do
100
- let(:other) { described.new(streams: [:other]) }
101
-
102
- it { subject.must_equal(false) }
103
- end
104
- end
105
-
106
- describe '#name' do
107
- subject { instance.name }
108
-
109
- context 'when a parent is defined' do
110
- it { subject.must_be_instance_of(String) }
111
- end
112
-
113
- context 'when a parent is not defined' do
114
- before { instance.stubs(:parent) }
115
-
116
- it { subject.must_be_instance_of(NilClass) }
117
- end
118
- end
119
-
120
- describe '#size' do
121
- subject { instance.size }
122
-
123
- it { subject.must_be_instance_of(Fixnum) }
124
-
125
- it 'returns the size of the line' do
126
- subject.must_equal(53)
127
- end
128
- end
129
-
130
- describe '#streams' do
131
- subject { instance.streams }
132
-
133
- it { instance.must_respond_to(:value) }
134
-
135
- it { subject.must_be_instance_of(Vedeu::Streams) }
136
- end
137
-
138
- describe '#to_s' do
139
- subject { instance.to_s }
140
-
141
- it { subject.must_be_instance_of(String) }
142
-
143
- it 'returns the line complete with formatting' do
144
- # (starts in Line colour)
145
- # (starts in Line style)
146
- # Stream 1 colour
147
- # Stream 1 style
148
- # Stream 1 value
149
- # (resets style to Line style)
150
- # (resets colour to Line colour)
151
- # Stream 2 colour
152
- # Stream 2 style
153
- # Stream 2 value
154
- # (resets style to Line style)
155
- # (resets colour to Line colour)
156
- # Stream 3 colour
157
- # Stream 3 style
158
- # Stream 3 value
159
- # (resets style to Line style)
160
- # (resets colour to Line colour)
161
-
162
- subject.must_equal(
163
- "\e[38;2;255;0;0m\e[48;2;0;0;0m" \
164
- "\e[24m\e[22m\e[27m" \
165
- "\e[38;2;255;255;0m" \
166
- "\e[24m\e[22m\e[27m" \
167
- 'Something interesting ' \
168
- "\e[38;2;0;255;0m" \
169
- "\e[24m\e[22m\e[27m" \
170
- 'on this line ' \
171
- "\e[38;2;0;0;255m" \
172
- "\e[24m\e[22m\e[27m" \
173
- 'would be cool, eh?'
174
- )
175
- end
176
- end
177
-
178
- describe '#width' do
179
- before { parent.stubs(:width).returns(25) }
180
-
181
- subject { instance.width }
182
-
183
- it { subject.must_be_instance_of(Fixnum) }
184
- it { subject.must_equal(25) }
185
- end
186
-
187
- end # Line
188
-
189
- end # Vedeu
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Lines do
6
-
7
- let(:described) { Vedeu::Lines }
8
- let(:instance) { described.new }
9
-
10
- it { described.superclass.must_equal(Vedeu::Collection) }
11
-
12
- describe '#initialize' do
13
- it { instance.must_be_instance_of(described) }
14
- end
15
-
16
- end # Lines
17
-
18
- end # Vedeu
@@ -1,141 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Stream do
6
-
7
- let(:described) { Vedeu::Stream }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
10
- {
11
- value: _value,
12
- parent: parent,
13
- colour: colour,
14
- style: style
15
- }
16
- }
17
- let(:_value) { 'Some text' }
18
- let(:parent) {
19
- Line.new(streams: [],
20
- parent: line_parent,
21
- colour: parent_colour,
22
- style: Style.new('normal'))
23
- }
24
- let(:parent_colour) {
25
- Colour.new(background: '#0000ff', foreground: '#ffff00')
26
- }
27
- let(:colour) {
28
- Colour.new(background: '#ff0000', foreground: '#000000')
29
- }
30
- let(:style) { Style.new('normal') }
31
- let(:line_parent) { Vedeu::Interface.new(name: 'Vedeu::Stream') }
32
-
33
- describe '#initialize' do
34
- it { instance.must_be_instance_of(described) }
35
- it { instance.instance_variable_get('@value').must_equal(_value) }
36
- it { instance.instance_variable_get('@parent').must_equal(parent) }
37
- end
38
-
39
- describe 'accessors' do
40
- it { instance.must_respond_to(:parent) }
41
- it { instance.must_respond_to(:parent=) }
42
- it { instance.must_respond_to(:value) }
43
- it { instance.must_respond_to(:content) }
44
- it { instance.must_respond_to(:data) }
45
- it { instance.must_respond_to(:text) }
46
- it { instance.must_respond_to(:value=) }
47
- it { instance.must_respond_to(:attributes) }
48
- end
49
-
50
- describe '#add' do
51
- let(:child) { instance }
52
-
53
- subject { instance.add(child) }
54
-
55
- it { subject.must_be_instance_of(Vedeu::Streams) }
56
-
57
- it { instance.must_respond_to(:<<) }
58
- end
59
-
60
- describe '#chars' do
61
- subject { instance.chars }
62
-
63
- it { subject.must_be_instance_of(Array) }
64
-
65
- context 'when there is content' do
66
- it { subject.size.must_equal(9) }
67
- end
68
-
69
- context 'when there is no content' do
70
- let(:_value) { '' }
71
-
72
- it 'returns an empty collection' do
73
- subject.must_equal([])
74
- end
75
- end
76
- end
77
-
78
- describe '#empty?' do
79
- subject { instance.empty? }
80
-
81
- context 'when there is no content' do
82
- let(:_value) { '' }
83
-
84
- it { subject.must_equal(true) }
85
- end
86
-
87
- context 'when there is content' do
88
- it { subject.must_equal(false) }
89
- end
90
- end
91
-
92
- describe '#eql?' do
93
- let(:other) { described.new(attributes) }
94
-
95
- subject { instance.eql?(other) }
96
-
97
- it { subject.must_equal(true) }
98
-
99
- context 'when different to other' do
100
- let(:other) { described.new(colour: Colour.coerce({ background: '#ff0000' })) }
101
-
102
- it { subject.must_equal(false) }
103
- end
104
- end
105
-
106
- describe '#name' do
107
- subject { instance.name }
108
-
109
- context 'when a parent is defined' do
110
- it { subject.must_be_instance_of(String) }
111
- end
112
-
113
- context 'when a parent is not defined' do
114
- before { instance.stubs(:parent) }
115
-
116
- it { subject.must_be_instance_of(NilClass) }
117
- end
118
- end
119
-
120
- describe '#size' do
121
- subject { instance.size }
122
-
123
- it { subject.must_be_instance_of(Fixnum) }
124
-
125
- it 'returns the size of the stream' do
126
- subject.must_equal(9)
127
- end
128
- end
129
-
130
- describe '#width' do
131
- before { line_parent.stubs(:width).returns(25) }
132
-
133
- subject { instance.width }
134
-
135
- it { subject.must_be_instance_of(Fixnum) }
136
- it { subject.must_equal(25) }
137
- end
138
-
139
- end # Stream
140
-
141
- end # Vedeu
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Streams do
6
-
7
- let(:described) { Vedeu::Streams }
8
- let(:instance) { described.new }
9
-
10
- it { described.superclass.must_equal(Vedeu::Collection) }
11
-
12
- describe '#initialize' do
13
- it { instance.must_be_instance_of(described) }
14
- end
15
-
16
- end # Streams
17
-
18
- end # Vedeu