vedeu 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,12 +5,12 @@ module Vedeu
5
5
  describe ColourTranslator do
6
6
  describe '#background' do
7
7
  {
8
- '#5f0000' => "\e[48;5;52m",
9
- '#008700' => "\e[48;5;28m",
10
- '#0000d7' => "\e[48;5;20m",
11
- '#afafaf' => "\e[48;5;145m",
12
- '#afd700' => "\e[48;5;148m",
13
- '#af005f' => "\e[48;5;125m",
8
+ '#5f0000' => "\e[48;2;95;0;0m",
9
+ '#008700' => "\e[48;2;0;135;0m",
10
+ '#0000d7' => "\e[48;2;0;0;215m",
11
+ '#afafaf' => "\e[48;2;175;175;175m",
12
+ '#afd700' => "\e[48;2;175;215;0m",
13
+ '#af005f' => "\e[48;2;175;0;95m",
14
14
  }.map do |html_colour, terminal_colour|
15
15
  it 'translation is performed' do
16
16
  ColourTranslator.new(html_colour).background
@@ -41,12 +41,12 @@ module Vedeu
41
41
 
42
42
  describe '#foreground' do
43
43
  {
44
- '#5f0000' => "\e[38;5;52m",
45
- '#008700' => "\e[38;5;28m",
46
- '#0000d7' => "\e[38;5;20m",
47
- '#afafaf' => "\e[38;5;145m",
48
- '#afd700' => "\e[38;5;148m",
49
- '#af005f' => "\e[38;5;125m",
44
+ '#5f0000' => "\e[38;2;95;0;0m",
45
+ '#008700' => "\e[38;2;0;135;0m",
46
+ '#0000d7' => "\e[38;2;0;0;215m",
47
+ '#afafaf' => "\e[38;2;175;175;175m",
48
+ '#afd700' => "\e[38;2;175;215;0m",
49
+ '#af005f' => "\e[38;2;175;0;95m",
50
50
  }.map do |html_colour, terminal_colour|
51
51
  it 'translation is performed' do
52
52
  ColourTranslator.new(html_colour).foreground
@@ -6,7 +6,7 @@ module Vedeu
6
6
  it 'returns an escape sequence' do
7
7
  Colour.new({
8
8
  background: '#000000'
9
- }).background.must_equal("\e[48;5;16m")
9
+ }).background.must_equal("\e[48;2;0;0;0m")
10
10
  end
11
11
 
12
12
  it 'returns an empty string when the value is empty' do
@@ -18,7 +18,7 @@ module Vedeu
18
18
  it 'returns an escape sequence' do
19
19
  Colour.new({
20
20
  foreground: '#ff0000'
21
- }).foreground.must_equal("\e[38;5;196m")
21
+ }).foreground.must_equal("\e[38;2;255;0;0m")
22
22
  end
23
23
 
24
24
  it 'returns an empty string when the value is empty' do
@@ -31,19 +31,19 @@ module Vedeu
31
31
  Colour.new({
32
32
  foreground: '#ff0000',
33
33
  background: '#000000'
34
- }).to_s.must_equal("\e[38;5;196m\e[48;5;16m")
34
+ }).to_s.must_equal("\e[38;2;255;0;0m\e[48;2;0;0;0m")
35
35
  end
36
36
 
37
37
  it 'returns an escape sequence when the foreground is missing' do
38
38
  Colour.new({
39
39
  background: '#000000'
40
- }).to_s.must_equal("\e[48;5;16m")
40
+ }).to_s.must_equal("\e[48;2;0;0;0m")
41
41
  end
42
42
 
43
43
  it 'returns an escape sequence when the background is missing' do
44
44
  Colour.new({
45
45
  foreground: '#ff0000',
46
- }).to_s.must_equal("\e[38;5;196m")
46
+ }).to_s.must_equal("\e[38;2;255;0;0m")
47
47
  end
48
48
 
49
49
  it 'returns an empty string when both are missing' do
@@ -41,7 +41,7 @@ module Vedeu
41
41
  "\e[3;3H \e[3;3H" \
42
42
  "\e[4;3H \e[4;3H" \
43
43
  "\e[5;3H \e[5;3H" \
44
- "\e[3;3HSome text..."
44
+ "\e[3;3HSome text...\e[?25h"
45
45
  )
46
46
  end
47
47
 
@@ -57,7 +57,7 @@ module Vedeu
57
57
  "\e[3;3H \e[3;3H" \
58
58
  "\e[4;3H \e[4;3H" \
59
59
  "\e[5;3H \e[5;3H" \
60
- "\e[3;3HSome text... more text..."
60
+ "\e[3;3HSome text... more text...\e[?25h"
61
61
  )
62
62
  end
63
63
 
@@ -74,7 +74,7 @@ module Vedeu
74
74
  "\e[4;3H \e[4;3H" \
75
75
  "\e[5;3H \e[5;3H" \
76
76
  "\e[3;3HSome text..." \
77
- "\e[4;3HSome text..."
77
+ "\e[4;3HSome text...\e[?25h"
78
78
  )
79
79
  end
80
80
 
@@ -91,7 +91,7 @@ module Vedeu
91
91
  "\e[4;3H \e[4;3H" \
92
92
  "\e[5;3H \e[5;3H" \
93
93
  "\e[3;3HSome text... more text..." \
94
- "\e[4;3HSome text... more text..."
94
+ "\e[4;3HSome text... more text...\e[?25h"
95
95
  )
96
96
  end
97
97
 
@@ -107,7 +107,7 @@ module Vedeu
107
107
  "\e[3;3H \e[3;3H" \
108
108
  "\e[4;3H \e[4;3H" \
109
109
  "\e[5;3H \e[5;3H" \
110
- "\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..."
110
+ "\e[3;3H\e[38;2;0;0;0m\e[48;2;0;0;255m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;2;255;255;0m\e[48;2;0;255;0m\e[24m\e[21m\e[27m \e[38;2;255;255;255m\e[48;2;255;0;255m\e[1mmore text...\e[?25h"
111
111
  )
112
112
  end
113
113
 
@@ -129,11 +129,11 @@ module Vedeu
129
129
  "\e[3;3H \e[3;3H" \
130
130
  "\e[4;3H \e[4;3H" \
131
131
  "\e[5;3H \e[5;3H" \
132
- "\e[3;3HSome text..." \
132
+ "\e[3;3HSome text...\e[?25h" \
133
133
  "\e[6;6H \e[6;6H" \
134
134
  "\e[7;6H \e[7;6H" \
135
135
  "\e[8;6H \e[8;6H" \
136
- "\e[6;6HSome text..."
136
+ "\e[6;6HSome text...\e[?25h"
137
137
  )
138
138
  end
139
139
 
@@ -155,11 +155,11 @@ module Vedeu
155
155
  "\e[3;3H \e[3;3H" \
156
156
  "\e[4;3H \e[4;3H" \
157
157
  "\e[5;3H \e[5;3H" \
158
- "\e[3;3HSome text... more text..." \
158
+ "\e[3;3HSome text... more text...\e[?25h" \
159
159
  "\e[6;6H \e[6;6H" \
160
160
  "\e[7;6H \e[7;6H" \
161
161
  "\e[8;6H \e[8;6H" \
162
- "\e[6;6HSome text... more text..."
162
+ "\e[6;6HSome text... more text...\e[?25h"
163
163
  )
164
164
  end
165
165
 
@@ -182,12 +182,12 @@ module Vedeu
182
182
  "\e[4;3H \e[4;3H" \
183
183
  "\e[5;3H \e[5;3H" \
184
184
  "\e[3;3HSome text..." \
185
- "\e[4;3HSome text..." \
185
+ "\e[4;3HSome text...\e[?25h" \
186
186
  "\e[3;3H \e[3;3H" \
187
187
  "\e[4;3H \e[4;3H" \
188
188
  "\e[5;3H \e[5;3H" \
189
189
  "\e[3;3HSome text..." \
190
- "\e[4;3HSome text..."
190
+ "\e[4;3HSome text...\e[?25h"
191
191
  )
192
192
  end
193
193
 
@@ -210,12 +210,12 @@ module Vedeu
210
210
  "\e[4;3H \e[4;3H" \
211
211
  "\e[5;3H \e[5;3H" \
212
212
  "\e[3;3HSome text... more text..." \
213
- "\e[4;3HSome text... more text..." \
213
+ "\e[4;3HSome text... more text...\e[?25h" \
214
214
  "\e[6;6H \e[6;6H" \
215
215
  "\e[7;6H \e[7;6H" \
216
216
  "\e[8;6H \e[8;6H" \
217
217
  "\e[6;6HSome text... more text..." \
218
- "\e[7;6HSome text... more text..."
218
+ "\e[7;6HSome text... more text...\e[?25h"
219
219
  )
220
220
  end
221
221
 
@@ -237,13 +237,13 @@ module Vedeu
237
237
  "\e[3;3H \e[3;3H" \
238
238
  "\e[4;3H \e[4;3H" \
239
239
  "\e[5;3H \e[5;3H" \
240
- "\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..." \
241
- "\e[4;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..." \
240
+ "\e[3;3H\e[38;2;0;0;0m\e[48;2;0;0;255m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;2;255;255;0m\e[48;2;0;255;0m\e[24m\e[21m\e[27m \e[38;2;255;255;255m\e[48;2;255;0;255m\e[1mmore text..." \
241
+ "\e[4;3H\e[38;2;0;0;0m\e[48;2;0;0;255m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;2;255;255;0m\e[48;2;0;255;0m\e[24m\e[21m\e[27m \e[38;2;255;255;255m\e[48;2;255;0;255m\e[1mmore text...\e[?25h" \
242
242
  "\e[6;6H \e[6;6H" \
243
243
  "\e[7;6H \e[7;6H" \
244
244
  "\e[8;6H \e[8;6H" \
245
- "\e[6;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..." \
246
- "\e[7;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..."
245
+ "\e[6;6H\e[38;2;0;0;0m\e[48;2;0;0;255m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;2;255;255;0m\e[48;2;0;255;0m\e[24m\e[21m\e[27m \e[38;2;255;255;255m\e[48;2;255;0;255m\e[1mmore text..." \
246
+ "\e[7;6H\e[38;2;0;0;0m\e[48;2;0;0;255m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;2;255;255;0m\e[48;2;0;255;0m\e[24m\e[21m\e[27m \e[38;2;255;255;255m\e[48;2;255;0;255m\e[1mmore text...\e[?25h"
247
247
  )
248
248
  end
249
249
  end
@@ -16,8 +16,7 @@ module Vedeu
16
16
  x: 5,
17
17
  width: 10,
18
18
  height: 15,
19
- },
20
- current: "\e[1;1H#initialize"
19
+ }
21
20
  })
22
21
  }
23
22
 
@@ -40,8 +39,7 @@ module Vedeu
40
39
  height: 15
41
40
  },
42
41
  cursor: true,
43
- delay: 0.0,
44
- current: "\e[1;1H#initialize"
42
+ delay: 0.0
45
43
  }
46
44
  )
47
45
  end
@@ -84,9 +82,12 @@ module Vedeu
84
82
  end
85
83
 
86
84
  describe '#cursor' do
87
- it 'returns the value' do
88
- interface.cursor.must_equal(true)
89
- Interface.new({ cursor: false }).cursor.must_equal(false)
85
+ it 'returns an escape sequence when the cursor is enabled (default)' do
86
+ Interface.new({ cursor: true }).cursor.must_equal("\e[?25h")
87
+ end
88
+
89
+ it 'returns an escape sequence when the cursor is disabled' do
90
+ Interface.new({ cursor: false }).cursor.must_equal("\e[?25l")
90
91
  end
91
92
  end
92
93
 
@@ -110,10 +111,10 @@ module Vedeu
110
111
  height: 3
111
112
  }
112
113
  }).to_s.must_equal(
113
- "\e[38;5;196m\e[48;5;16m" \
114
+ "\e[38;2;255;0;0m\e[48;2;0;0;0m" \
114
115
  "\e[1;1H \e[1;1H" \
115
116
  "\e[2;1H \e[2;1H" \
116
- "\e[3;1H \e[3;1H"
117
+ "\e[3;1H \e[3;1H\e[?25h"
117
118
  )
118
119
  end
119
120
  end
@@ -2,29 +2,21 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
  describe Line do
5
- let(:line) {
6
- Line.new({
5
+ let(:line) { Line.new(attributes) }
6
+ let(:attributes) {
7
+ {
7
8
  colour: {
8
9
  foreground: '#ff0000',
9
10
  background: '#000000'
10
11
  },
11
12
  streams: [],
12
13
  style: 'normal'
13
- })
14
+ }
14
15
  }
15
16
 
16
17
  describe '#attributes' do
17
18
  it 'returns the attributes' do
18
- line.attributes.must_equal(
19
- {
20
- colour: {
21
- foreground: '#ff0000',
22
- background: '#000000'
23
- },
24
- streams: [],
25
- style: 'normal'
26
- }
27
- )
19
+ line.attributes.must_equal(attributes)
28
20
  end
29
21
  end
30
22
 
@@ -49,7 +41,7 @@ module Vedeu
49
41
  describe '#to_s' do
50
42
  it 'returns a String' do
51
43
  line.to_s.must_equal(
52
- "\e[38;5;196m\e[48;5;16m" \
44
+ "\e[38;2;255;0;0m\e[48;2;0;0;0m" \
53
45
  "\e[24m\e[21m\e[27m"
54
46
  )
55
47
  end
@@ -5,10 +5,10 @@ module Vedeu
5
5
  before { Store.reset }
6
6
 
7
7
  describe '#create' do
8
- it 'creates and returns the stored record' do
8
+ it 'stores the interface attributes and returns the storage collection' do
9
9
  attributes = { name: 'sulphur' }
10
10
 
11
- Store.create(attributes).must_equal({ name: 'sulphur' })
11
+ Store.create(attributes).must_equal({ 'sulphur' => { name: 'sulphur' } })
12
12
  end
13
13
  end
14
14
 
@@ -88,7 +88,7 @@ module Vedeu
88
88
 
89
89
  it 'returns a String' do
90
90
  stream.to_s.must_equal(
91
- "\e[38;5;196m\e[48;5;16m" \
91
+ "\e[38;2;255;0;0m\e[48;2;0;0;0m" \
92
92
  "\e[24m\e[21m\e[27m" \
93
93
  "Some text "
94
94
  )
@@ -99,7 +99,7 @@ module Vedeu
99
99
 
100
100
  it 'returns a String' do
101
101
  stream.to_s.must_equal(
102
- "\e[38;5;196m\e[48;5;16m" \
102
+ "\e[38;2;255;0;0m\e[48;2;0;0;0m" \
103
103
  "\e[24m\e[21m\e[27m" \
104
104
  " Some text "
105
105
  )
@@ -111,7 +111,7 @@ module Vedeu
111
111
 
112
112
  it 'returns a String' do
113
113
  stream.to_s.must_equal(
114
- "\e[38;5;196m\e[48;5;16m" \
114
+ "\e[38;2;255;0;0m\e[48;2;0;0;0m" \
115
115
  "\e[24m\e[21m\e[27m" \
116
116
  " Some text"
117
117
  )
@@ -122,7 +122,7 @@ module Vedeu
122
122
  describe 'when a width is not set' do
123
123
  it 'returns a String' do
124
124
  stream.to_s.must_equal(
125
- "\e[38;5;196m\e[48;5;16m" \
125
+ "\e[38;2;255;0;0m\e[48;2;0;0;0m" \
126
126
  "\e[24m\e[21m\e[27m" \
127
127
  "Some text"
128
128
  )
@@ -2,115 +2,24 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
  describe Buffers do
5
+ before do
6
+ Buffers.reset
7
+ end
8
+
5
9
  describe '.create' do
6
10
  it 'creates an entry for the interface, and saves :clear' do
7
11
  end
8
12
  end
9
13
 
10
14
  describe '.enqueue' do
11
- it 'saves the new sequence for the interface into :next' do
12
- end
13
- end
14
-
15
- describe '.refresh' do
16
15
  it 'raises an exception if the interface cannot be found by name' do
16
+ name = 'unknown'
17
+ sequence = '...'
18
+ proc { Buffers.enqueue(name, sequence) }.must_raise(RefreshFailed)
17
19
  end
18
20
 
19
- # describe '#refresh' do
20
- # let(:attributes) {
21
- # {
22
- # name: '#refresh',
23
- # lines: [],
24
- # colour: {
25
- # foreground: '#ff0000',
26
- # background: '#000000'
27
- # },
28
- # geometry: {
29
- # width: 3,
30
- # height: 3
31
- # }
32
- # }
33
- # }
34
-
35
- # it 'returns a blank interface when there is no content to display (initial state)' do
36
- # Terminal.stub(:output, nil) do
37
- # Interface.new(attributes).refresh.must_equal(
38
- # "\e[38;5;196m\e[48;5;16m" \
39
- # "\e[1;1H \e[1;1H" \
40
- # "\e[2;1H \e[2;1H" \
41
- # "\e[3;1H \e[3;1H"
42
- # )
43
- # end
44
- # end
45
-
46
- # it 'returns the fresh content when content is queued up to be displayed' do
47
- # attributes = {
48
- # name: '#refresh',
49
- # lines: [
50
- # { streams: [{ text: '#refresh' }] },
51
- # { streams: [{ text: '#refresh' }] },
52
- # { streams: [{ text: '#refresh' }] }
53
- # ],
54
- # colour: {
55
- # foreground: '#ff0000',
56
- # background: '#000000'
57
- # },
58
- # geometry: {
59
- # width: 11,
60
- # height: 3
61
- # }
62
- # }
63
- # interface = Interface.new(attributes)
64
- # diode = interface.enqueue
65
-
66
- # Terminal.stub(:output, nil) do
67
- # interface.refresh.must_equal(
68
- # "\e[38;5;196m\e[48;5;16m" \
69
- # "\e[1;1H \e[1;1H" \
70
- # "\e[2;1H \e[2;1H" \
71
- # "\e[3;1H \e[3;1H" \
72
- # "\e[1;1H#refresh" \
73
- # "\e[2;1H#refresh" \
74
- # "\e[3;1H#refresh"
75
- # )
76
- # end
77
- # end
78
-
79
- # it 'returns the previously shown content when there is stale content from last run' do
80
- # attributes = {
81
- # name: '#refresh',
82
- # lines: [],
83
- # colour: {
84
- # foreground: '#ff0000',
85
- # background: '#000000'
86
- # },
87
- # geometry: {
88
- # width: 11,
89
- # height: 3
90
- # }
91
- # }
92
- # interface = Interface.new(attributes)
93
- # interface.current = "\e[38;5;196m\e[48;5;16m" \
94
- # "\e[1;1H \e[1;1H" \
95
- # "\e[2;1H \e[2;1H" \
96
- # "\e[3;1H \e[3;1H" \
97
- # "\e[1;1H#refresh" \
98
- # "\e[2;1H#refresh" \
99
- # "\e[3;1H#refresh"
100
-
101
- # Terminal.stub(:output, nil) do
102
- # interface.refresh.must_equal(
103
- # "\e[38;5;196m\e[48;5;16m" \
104
- # "\e[1;1H \e[1;1H" \
105
- # "\e[2;1H \e[2;1H" \
106
- # "\e[3;1H \e[3;1H" \
107
- # "\e[1;1H#refresh" \
108
- # "\e[2;1H#refresh" \
109
- # "\e[3;1H#refresh"
110
- # )
111
- # end
112
- # end
113
- # end
21
+ it 'saves the new sequence for the interface into :next' do
22
+ end
114
23
  end
115
24
 
116
25
  describe '.refresh_all' do