vedeu 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu.rb +0 -18
- data/lib/vedeu/output/colour.rb +18 -7
- data/lib/vedeu/output/compositor.rb +20 -8
- data/lib/vedeu/process/process.rb +1 -5
- data/lib/vedeu/repository/command.rb +12 -0
- data/lib/vedeu/repository/command_repository.rb +10 -2
- data/lib/vedeu/repository/dummy_command.rb +2 -0
- data/lib/vedeu/repository/dummy_interface.rb +3 -1
- data/lib/vedeu/repository/interface.rb +31 -4
- data/lib/vedeu/repository/interface_repository.rb +5 -1
- data/lib/vedeu/repository/storage.rb +1 -1
- data/lib/vedeu/support/terminal.rb +13 -3
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/application_test.rb +6 -2
- data/test/lib/vedeu/launcher_test.rb +3 -1
- data/test/lib/vedeu/output/background_test.rb +30 -10
- data/test/lib/vedeu/output/colour_test.rb +39 -2
- data/test/lib/vedeu/output/compositor_test.rb +48 -14
- data/test/lib/vedeu/output/directive_test.rb +24 -8
- data/test/lib/vedeu/output/esc_test.rb +48 -16
- data/test/lib/vedeu/output/foreground_test.rb +30 -10
- data/test/lib/vedeu/output/geometry_test.rb +78 -28
- data/test/lib/vedeu/output/position_test.rb +9 -3
- data/test/lib/vedeu/output/renderer_test.rb +15 -5
- data/test/lib/vedeu/output/style_test.rb +30 -10
- data/test/lib/vedeu/output/translator_test.rb +3 -1
- data/test/lib/vedeu/process/event_loop_test.rb +12 -4
- data/test/lib/vedeu/process/exit_test.rb +6 -2
- data/test/lib/vedeu/process/input_test.rb +9 -3
- data/test/lib/vedeu/process/output_test.rb +12 -4
- data/test/lib/vedeu/process/process_test.rb +24 -8
- data/test/lib/vedeu/process/queue_test.rb +32 -8
- data/test/lib/vedeu/repository/command_repository_test.rb +27 -9
- data/test/lib/vedeu/repository/command_test.rb +33 -9
- data/test/lib/vedeu/repository/dummy_command_test.rb +9 -3
- data/test/lib/vedeu/repository/interface_repository_test.rb +18 -6
- data/test/lib/vedeu/repository/interface_test.rb +39 -11
- data/test/lib/vedeu/repository/repository_test.rb +24 -8
- data/test/lib/vedeu/repository/storage_test.rb +39 -2
- data/test/lib/vedeu/support/terminal_test.rb +68 -16
- data/test/lib/vedeu/version_test.rb +3 -1
- data/test/test_helper.rb +3 -0
- data/vedeu.gemspec +13 -12
- metadata +45 -30
@@ -5,12 +5,16 @@ module Vedeu
|
|
5
5
|
let(:described_class) { Position }
|
6
6
|
let(:described_instance) { described_class.new }
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'returns a Position instance' do
|
9
|
+
described_instance.must_be_instance_of(Position)
|
10
|
+
end
|
9
11
|
|
10
12
|
describe '.set' do
|
11
13
|
let(:subject) { described_class.set }
|
12
14
|
|
13
|
-
it
|
15
|
+
it 'returns a String' do
|
16
|
+
subject.must_be_instance_of(String)
|
17
|
+
end
|
14
18
|
|
15
19
|
context 'when no coordinates are provided' do
|
16
20
|
it 'returns a position escape sequence' do
|
@@ -32,7 +36,9 @@ module Vedeu
|
|
32
36
|
describe '.reset' do
|
33
37
|
let(:subject) { described_class.reset }
|
34
38
|
|
35
|
-
it
|
39
|
+
it 'returns a String' do
|
40
|
+
subject.must_be_instance_of(String)
|
41
|
+
end
|
36
42
|
|
37
43
|
it 'returns a position escape sequence' do
|
38
44
|
subject.must_equal("\e[1;1H")
|
@@ -6,21 +6,31 @@ module Vedeu
|
|
6
6
|
let(:described_instance) { described_class.new(composition) }
|
7
7
|
let(:composition) { [] }
|
8
8
|
|
9
|
-
it
|
9
|
+
it 'returns a Renderer instance' do
|
10
|
+
described_instance.must_be_instance_of(Renderer)
|
11
|
+
end
|
10
12
|
|
11
13
|
describe '.write' do
|
12
14
|
let(:subject) { described_class.write(composition) }
|
13
15
|
|
14
|
-
it
|
16
|
+
it 'returns an Array' do
|
17
|
+
subject.must_be_instance_of(Array)
|
18
|
+
end
|
15
19
|
|
16
|
-
it
|
20
|
+
it 'returns an empty array' do
|
21
|
+
subject.must_equal([])
|
22
|
+
end
|
17
23
|
|
18
24
|
context 'capturing i/o' do
|
19
25
|
let(:captured) { capture_io { subject }.join }
|
20
26
|
|
21
|
-
it
|
27
|
+
it 'returns a String' do
|
28
|
+
captured.must_be_instance_of(String)
|
29
|
+
end
|
22
30
|
|
23
|
-
it
|
31
|
+
it 'returns an empty string' do
|
32
|
+
captured.must_equal("")
|
33
|
+
end
|
24
34
|
end
|
25
35
|
end
|
26
36
|
end
|
@@ -8,56 +8,76 @@ module Vedeu
|
|
8
8
|
let(:subject) { described_class.set(style) }
|
9
9
|
let(:style) {}
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'returns a String' do
|
12
|
+
subject.must_be_instance_of(String)
|
13
|
+
end
|
12
14
|
|
13
|
-
it
|
15
|
+
it 'returns an empty string' do
|
16
|
+
subject.must_equal('')
|
17
|
+
end
|
14
18
|
|
15
19
|
context 'when the style is bold' do
|
16
20
|
let(:style) { :bold }
|
17
21
|
|
18
|
-
it
|
22
|
+
it 'returns an escape sequence' do
|
23
|
+
subject.must_equal("\e[1m")
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
21
27
|
context 'when the style is clear' do
|
22
28
|
let(:style) { :clear }
|
23
29
|
|
24
|
-
it
|
30
|
+
it 'returns an escape sequence' do
|
31
|
+
subject.must_equal("\e[2J")
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
35
|
context 'when the style is hide_cursor' do
|
28
36
|
let(:style) { :hide_cursor }
|
29
37
|
|
30
|
-
it
|
38
|
+
it 'returns an escape sequence' do
|
39
|
+
subject.must_equal("\e[?25l")
|
40
|
+
end
|
31
41
|
end
|
32
42
|
|
33
43
|
context 'when the style is inverse' do
|
34
44
|
let(:style) { :inverse }
|
35
45
|
|
36
|
-
it
|
46
|
+
it 'returns an escape sequence' do
|
47
|
+
subject.must_equal("\e[7m")
|
48
|
+
end
|
37
49
|
end
|
38
50
|
|
39
51
|
context 'when the style is reset' do
|
40
52
|
let(:style) { :reset }
|
41
53
|
|
42
|
-
it
|
54
|
+
it 'returns an escape sequence' do
|
55
|
+
subject.must_equal("\e[0m")
|
56
|
+
end
|
43
57
|
end
|
44
58
|
|
45
59
|
context 'when the style is normal' do
|
46
60
|
let(:style) { :normal }
|
47
61
|
|
48
|
-
it
|
62
|
+
it 'returns an escape sequence' do
|
63
|
+
subject.must_equal("\e[0m")
|
64
|
+
end
|
49
65
|
end
|
50
66
|
|
51
67
|
context 'when the style is show_cursor' do
|
52
68
|
let(:style) { :show_cursor }
|
53
69
|
|
54
|
-
it
|
70
|
+
it 'returns an escape sequence' do
|
71
|
+
subject.must_equal("\e[?25h")
|
72
|
+
end
|
55
73
|
end
|
56
74
|
|
57
75
|
context 'when the style is underline' do
|
58
76
|
let(:style) { :underline }
|
59
77
|
|
60
|
-
it
|
78
|
+
it 'returns an escape sequence' do
|
79
|
+
subject.must_equal("\e[4m")
|
80
|
+
end
|
61
81
|
end
|
62
82
|
end
|
63
83
|
end
|
@@ -5,7 +5,9 @@ module Vedeu
|
|
5
5
|
let(:described_class) { Translator }
|
6
6
|
let(:html_colour) {}
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'returns a Translator instance' do
|
9
|
+
described_class.new(html_colour).must_be_instance_of(Translator)
|
10
|
+
end
|
9
11
|
|
10
12
|
describe '#translate' do
|
11
13
|
{
|
@@ -12,20 +12,28 @@ module Vedeu
|
|
12
12
|
Output.stubs(:render)
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'returns an EventLoop instance' do
|
16
|
+
subject.must_be_instance_of(EventLoop)
|
17
|
+
end
|
16
18
|
|
17
|
-
it
|
19
|
+
it 'sets an instance variable' do
|
20
|
+
subject.instance_variable_get("@running").must_equal(true)
|
21
|
+
end
|
18
22
|
|
19
23
|
describe '.main_sequence' do
|
20
24
|
let(:subject) { described_class.main_sequence }
|
21
25
|
|
22
|
-
|
26
|
+
it 'returns a FalseClass' do
|
27
|
+
subject.must_be_instance_of(FalseClass)
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
describe '#stop' do
|
26
32
|
let(:subject) { described_class.new.stop }
|
27
33
|
|
28
|
-
|
34
|
+
it 'returns a FalseClass' do
|
35
|
+
subject.must_be_instance_of(FalseClass)
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
@@ -7,9 +7,13 @@ module Vedeu
|
|
7
7
|
describe '.dispatch' do
|
8
8
|
let(:subject) { described_class.dispatch }
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'returns a Symbol' do
|
11
|
+
subject.must_be_instance_of(Symbol)
|
12
|
+
end
|
11
13
|
|
12
|
-
it
|
14
|
+
it 'returns the symbol :stop' do
|
15
|
+
subject.must_equal(:stop)
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -8,14 +8,20 @@ module Vedeu
|
|
8
8
|
|
9
9
|
before { Terminal.stubs(:input).returns(input) }
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'return an Input instance' do
|
12
|
+
subject.must_be_instance_of(Input)
|
13
|
+
end
|
12
14
|
|
13
15
|
describe '.capture' do
|
14
16
|
let(:subject) { described_class.capture }
|
15
17
|
|
16
|
-
it
|
18
|
+
it 'returns an Array' do
|
19
|
+
subject.must_be_instance_of(Array)
|
20
|
+
end
|
17
21
|
|
18
|
-
it
|
22
|
+
it 'returns the entered characters' do
|
23
|
+
subject.wont_be_empty
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|
@@ -12,21 +12,29 @@ module Vedeu
|
|
12
12
|
Queue.stubs(:dequeue).returns(result)
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'returns an Output instance' do
|
16
|
+
subject.must_be_instance_of(Output)
|
17
|
+
end
|
16
18
|
|
17
19
|
describe '.render' do
|
18
20
|
let(:subject) { described_class.render }
|
19
21
|
|
20
|
-
it
|
22
|
+
it 'returns a NilClass' do
|
23
|
+
subject.must_be_instance_of(NilClass)
|
24
|
+
end
|
21
25
|
|
22
26
|
context 'when the result is empty' do
|
23
|
-
it
|
27
|
+
it 'returns a NilClass' do
|
28
|
+
subject.must_be_instance_of(NilClass)
|
29
|
+
end
|
24
30
|
end
|
25
31
|
|
26
32
|
context 'when the result is not empty' do
|
27
33
|
let(:result) { { 'dummy' => [['test...']] } }
|
28
34
|
|
29
|
-
it
|
35
|
+
it 'returns an Array' do
|
36
|
+
subject.must_be_instance_of(Array)
|
37
|
+
end
|
30
38
|
end
|
31
39
|
end
|
32
40
|
end
|
@@ -7,7 +7,9 @@ module Vedeu
|
|
7
7
|
let(:result) {}
|
8
8
|
let(:subject) { described_class.new }
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'returns a Process instance' do
|
11
|
+
subject.must_be_instance_of(Process)
|
12
|
+
end
|
11
13
|
|
12
14
|
describe '.evaluate' do
|
13
15
|
let(:subject) { described_class.evaluate }
|
@@ -23,26 +25,34 @@ module Vedeu
|
|
23
25
|
after { Queue.clear }
|
24
26
|
|
25
27
|
context 'when there is no input' do
|
26
|
-
it
|
28
|
+
it 'returns a NilClass' do
|
29
|
+
subject.must_be_instance_of(NilClass)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
context 'when the input is a keypress' do
|
30
34
|
let(:input) { "q" }
|
31
35
|
|
32
36
|
context 'but there is no result' do
|
33
|
-
it
|
37
|
+
it 'returns a NilClass' do
|
38
|
+
subject.must_be_instance_of(NilClass)
|
39
|
+
end
|
34
40
|
end
|
35
41
|
|
36
42
|
context 'or the result is :stop' do
|
37
43
|
let(:result) { :stop }
|
38
44
|
|
39
|
-
it
|
45
|
+
it 'raises an exception' do
|
46
|
+
proc { subject }.must_raise(Collapse)
|
47
|
+
end
|
40
48
|
end
|
41
49
|
|
42
50
|
context 'or the result is anything else' do
|
43
51
|
let(:result) { :something_else }
|
44
52
|
|
45
|
-
it
|
53
|
+
it 'returns an Array' do
|
54
|
+
subject.must_be_instance_of(Array)
|
55
|
+
end
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
@@ -50,19 +60,25 @@ module Vedeu
|
|
50
60
|
let(:input) { "quit" }
|
51
61
|
|
52
62
|
context 'but there is no result' do
|
53
|
-
it
|
63
|
+
it 'returns a NilClass' do
|
64
|
+
subject.must_be_instance_of(NilClass)
|
65
|
+
end
|
54
66
|
end
|
55
67
|
|
56
68
|
context 'or the result is :stop' do
|
57
69
|
let(:result) { :stop }
|
58
70
|
|
59
|
-
it
|
71
|
+
it 'raises an exception' do
|
72
|
+
proc { subject }.must_raise(Collapse)
|
73
|
+
end
|
60
74
|
end
|
61
75
|
|
62
76
|
context 'or the result is anything else' do
|
63
77
|
let(:result) { :something_else }
|
64
78
|
|
65
|
-
it
|
79
|
+
it 'returns an Array' do
|
80
|
+
subject.must_be_instance_of(Array)
|
81
|
+
end
|
66
82
|
end
|
67
83
|
end
|
68
84
|
end
|
@@ -10,13 +10,17 @@ module Vedeu
|
|
10
10
|
let(:subject) { described_class.dequeue }
|
11
11
|
|
12
12
|
context 'when the queue is empty' do
|
13
|
-
it
|
13
|
+
it 'returns a NilClass' do
|
14
|
+
subject.must_be_instance_of(NilClass)
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
18
|
context 'when the queue is not empty' do
|
17
19
|
before { described_class.enqueue(:result) }
|
18
20
|
|
19
|
-
it
|
21
|
+
it 'returns the first entry added' do
|
22
|
+
subject.must_be_instance_of(Symbol)
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
@@ -24,29 +28,49 @@ module Vedeu
|
|
24
28
|
let(:subject) { described_class.enqueue(result) }
|
25
29
|
let(:result) { :result }
|
26
30
|
|
27
|
-
it
|
31
|
+
it 'returns an Array' do
|
32
|
+
subject.must_be_instance_of(Array)
|
33
|
+
end
|
28
34
|
|
29
|
-
it
|
35
|
+
it 'contains the enqueued item' do
|
36
|
+
subject.size.must_equal(1)
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
40
|
describe '.size' do
|
33
41
|
let(:subject) { described_class.size }
|
34
42
|
|
35
|
-
it
|
43
|
+
it 'returns a Fixnum' do
|
44
|
+
subject.must_be_instance_of(Fixnum)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns the size of the queue' do
|
48
|
+
subject.must_equal(0)
|
49
|
+
end
|
36
50
|
end
|
37
51
|
|
38
52
|
describe '.clear' do
|
39
53
|
let(:subject) { described_class.clear }
|
40
54
|
|
41
|
-
it
|
55
|
+
it 'returns an Array' do
|
56
|
+
subject.must_be_instance_of(Array)
|
57
|
+
end
|
42
58
|
|
43
|
-
it
|
59
|
+
it 'returns an empty array' do
|
60
|
+
subject.must_be_empty
|
61
|
+
end
|
44
62
|
end
|
45
63
|
|
46
64
|
describe '.view' do
|
47
65
|
let(:subject) { described_class.view }
|
48
66
|
|
49
|
-
it
|
67
|
+
it 'returns a String' do
|
68
|
+
subject.must_be_instance_of(String)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns the queue as a String' do
|
72
|
+
subject.must_equal("[]")
|
73
|
+
end
|
50
74
|
end
|
51
75
|
end
|
52
76
|
end
|
@@ -24,13 +24,21 @@ module Vedeu
|
|
24
24
|
context 'when the command was found by keypress' do
|
25
25
|
let(:input) { 'b' }
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'returns the Command instance' do
|
28
|
+
subject.must_be_instance_of(Command)
|
29
|
+
end
|
28
30
|
|
29
|
-
it
|
31
|
+
it 'returns the correct command' do
|
32
|
+
subject.name.must_equal('banana')
|
33
|
+
end
|
30
34
|
|
31
|
-
it
|
35
|
+
it 'returns the correct command' do
|
36
|
+
subject.name.wont_equal('apple')
|
37
|
+
end
|
32
38
|
|
33
|
-
it
|
39
|
+
it 'returns the correct command' do
|
40
|
+
subject.keypress.must_equal('b')
|
41
|
+
end
|
34
42
|
end
|
35
43
|
end
|
36
44
|
|
@@ -40,20 +48,30 @@ module Vedeu
|
|
40
48
|
context 'when the command was found by keyword' do
|
41
49
|
let(:input) { 'apple' }
|
42
50
|
|
43
|
-
it
|
51
|
+
it 'returns the Command instance' do
|
52
|
+
subject.must_be_instance_of(Command)
|
53
|
+
end
|
44
54
|
|
45
|
-
it
|
55
|
+
it 'returns the correct command' do
|
56
|
+
subject.keypress.must_equal('a')
|
57
|
+
end
|
46
58
|
|
47
|
-
it
|
59
|
+
it 'returns the correct command' do
|
60
|
+
subject.keypress.wont_equal('b')
|
61
|
+
end
|
48
62
|
|
49
|
-
it
|
63
|
+
it 'returns the correct command' do
|
64
|
+
subject.name.wont_equal('banana')
|
65
|
+
end
|
50
66
|
end
|
51
67
|
end
|
52
68
|
|
53
69
|
describe '.klass' do
|
54
70
|
let(:subject) { described_class.klass }
|
55
71
|
|
56
|
-
it
|
72
|
+
it 'returns Command' do
|
73
|
+
subject.must_equal(Command)
|
74
|
+
end
|
57
75
|
end
|
58
76
|
end
|
59
77
|
end
|