vedeu 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/docs/dsl.md +4 -4
- data/lib/vedeu/all.rb +6 -18
- data/lib/vedeu/api.rb +14 -13
- data/lib/vedeu/bindings/system.rb +5 -4
- data/lib/vedeu/buffers/virtual_buffer.rb +13 -11
- data/lib/vedeu/configuration/api.rb +4 -3
- data/lib/vedeu/cursors/cursor.rb +23 -18
- data/lib/vedeu/distributed/client.rb +11 -6
- data/lib/vedeu/distributed/server.rb +4 -3
- data/lib/vedeu/dsl/keymap.rb +6 -6
- data/lib/vedeu/editor/all.rb +19 -0
- data/lib/vedeu/{input/editor → editor}/capture.rb +1 -1
- data/lib/vedeu/{input/editor → editor}/cropper.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/cursor.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/document.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/documents.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/editor.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/insert.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/line.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/lines.rb +0 -0
- data/lib/vedeu/error.rb +21 -18
- data/lib/vedeu/esc/borders.rb +6 -4
- data/lib/vedeu/esc/colours.rb +13 -12
- data/lib/vedeu/esc/esc.rb +11 -10
- data/lib/vedeu/input/all.rb +15 -0
- data/lib/vedeu/input/input.rb +55 -52
- data/lib/vedeu/input/key.rb +36 -30
- data/lib/vedeu/input/keymap.rb +101 -92
- data/lib/vedeu/input/keymaps.rb +10 -6
- data/lib/vedeu/input/keys.rb +8 -4
- data/lib/vedeu/input/mapper.rb +125 -121
- data/lib/vedeu/input/translator.rb +159 -0
- data/lib/vedeu/internal_api.rb +16 -15
- data/lib/vedeu/logging/all.rb +13 -0
- data/lib/vedeu/logging/debug.rb +84 -0
- data/lib/vedeu/logging/lockless_log_device.rb +65 -0
- data/lib/vedeu/logging/log.rb +179 -0
- data/lib/vedeu/logging/mono_logger.rb +26 -0
- data/lib/vedeu/logging/timer.rb +68 -0
- data/lib/vedeu/menus/all.rb +12 -0
- data/lib/vedeu/{dsl/menu.rb → menus/dsl.rb} +19 -18
- data/lib/vedeu/menus/menu.rb +234 -0
- data/lib/vedeu/{null/menu.rb → menus/null.rb} +6 -6
- data/lib/vedeu/menus/repository.rb +18 -0
- data/lib/vedeu/models/cell.rb +62 -55
- data/lib/vedeu/models/escape.rb +55 -50
- data/lib/vedeu/models/page.rb +74 -69
- data/lib/vedeu/models/row.rb +55 -51
- data/lib/vedeu/models/views/all.rb +1 -0
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/html_char.rb +165 -0
- data/lib/vedeu/output/renderers/html.rb +5 -4
- data/lib/vedeu/repositories/model.rb +2 -0
- data/lib/vedeu/runtime/application.rb +110 -103
- data/lib/vedeu/runtime/bootstrap.rb +109 -103
- data/lib/vedeu/runtime/flags.rb +45 -41
- data/lib/vedeu/runtime/launcher.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +51 -46
- data/lib/vedeu/runtime/traps.rb +20 -16
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu.rb +2 -2
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +1 -1
- data/test/lib/vedeu/cursors/cursor_test.rb +11 -5
- data/test/lib/vedeu/dsl/interface_test.rb +1 -1
- data/test/lib/vedeu/dsl/keymap_test.rb +2 -2
- data/test/lib/vedeu/{input/editor → editor}/capture_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/cropper_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/cursor_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/document_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/documents_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/editor_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/insert_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/line_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/lines_test.rb +0 -0
- data/test/lib/vedeu/input/input_test.rb +58 -54
- data/test/lib/vedeu/input/key_test.rb +29 -25
- data/test/lib/vedeu/input/keymap_test.rb +74 -70
- data/test/lib/vedeu/input/keymaps_test.rb +8 -4
- data/test/lib/vedeu/input/keys_test.rb +12 -8
- data/test/lib/vedeu/input/mapper_test.rb +64 -56
- data/test/lib/vedeu/input/translator_test.rb +36 -0
- data/test/lib/vedeu/logging/debug_test.rb +39 -0
- data/test/lib/vedeu/logging/lockless_log_device_test.rb +42 -0
- data/test/lib/vedeu/logging/log_test.rb +52 -0
- data/test/lib/vedeu/logging/mono_logger_test.rb +43 -0
- data/test/lib/vedeu/logging/timer_test.rb +44 -0
- data/test/lib/vedeu/{dsl/menu_test.rb → menus/dsl_test.rb} +6 -6
- data/test/lib/vedeu/menus/menu_test.rb +305 -0
- data/test/lib/vedeu/{null/menu_test.rb → menus/null_test.rb} +5 -5
- data/test/lib/vedeu/menus/repository_test.rb +17 -0
- data/test/lib/vedeu/models/cell_test.rb +54 -50
- data/test/lib/vedeu/models/escape_test.rb +49 -45
- data/test/lib/vedeu/models/page_test.rb +167 -160
- data/test/lib/vedeu/models/row_test.rb +71 -67
- data/test/lib/vedeu/models/views/html_char_test.rb +110 -0
- data/test/lib/vedeu/output/compressor_test.rb +44 -22
- data/test/lib/vedeu/output/renderers_test.rb +4 -2
- data/test/lib/vedeu/runtime/application_test.rb +36 -32
- data/test/lib/vedeu/runtime/bootstrap_test.rb +31 -26
- data/test/lib/vedeu/runtime/flags_test.rb +33 -29
- data/test/lib/vedeu/runtime/launcher_test.rb +4 -2
- data/test/lib/vedeu/runtime/main_loop_test.rb +28 -24
- data/test/lib/vedeu/runtime/traps_test.rb +8 -4
- data/test/test_helper.rb +4 -2
- metadata +66 -63
- data/lib/vedeu/input/editor/all.rb +0 -19
- data/lib/vedeu/input/input_translator.rb +0 -155
- data/lib/vedeu/log/debug.rb +0 -79
- data/lib/vedeu/log/lockless_log_device.rb +0 -61
- data/lib/vedeu/log/log.rb +0 -172
- data/lib/vedeu/log/mono_logger.rb +0 -21
- data/lib/vedeu/log/timer.rb +0 -63
- data/lib/vedeu/models/menu.rb +0 -217
- data/lib/vedeu/models/menus.rb +0 -14
- data/lib/vedeu/output/html_char.rb +0 -161
- data/test/lib/vedeu/input/input_translator_test.rb +0 -32
- data/test/lib/vedeu/log/debug_test.rb +0 -35
- data/test/lib/vedeu/log/lockless_log_device_test.rb +0 -29
- data/test/lib/vedeu/log/log_test.rb +0 -48
- data/test/lib/vedeu/log/mono_logger_test.rb +0 -31
- data/test/lib/vedeu/log/timer_test.rb +0 -40
- data/test/lib/vedeu/models/menu_test.rb +0 -301
- data/test/lib/vedeu/models/menus_test.rb +0 -13
- data/test/lib/vedeu/output/html_char_test.rb +0 -106
@@ -2,102 +2,106 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
{
|
11
|
-
|
12
|
-
|
5
|
+
module Input
|
6
|
+
|
7
|
+
describe Keymap do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Input::Keymap }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:attributes) {
|
12
|
+
{
|
13
|
+
name: map_name,
|
14
|
+
keys: keys
|
15
|
+
}
|
13
16
|
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
let(:map_name) { 'zirconium' }
|
18
|
+
let(:keys) { [] }
|
19
|
+
let(:key) { Vedeu::Input::Key.new('a') { :output } }
|
20
|
+
|
21
|
+
describe '#initialize' do
|
22
|
+
it { instance.must_be_instance_of(described) }
|
23
|
+
it { instance.instance_variable_get('@name').must_equal(map_name) }
|
24
|
+
it { instance.instance_variable_get('@keys').must_be_instance_of(Array) }
|
25
|
+
it do
|
26
|
+
instance.instance_variable_get('@repository').must_equal(Vedeu.keymaps)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'accessors' do
|
31
|
+
it { instance.must_respond_to(:name) }
|
25
32
|
end
|
26
|
-
end
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
end
|
34
|
+
describe '#add' do
|
35
|
+
subject { instance.add(key) }
|
31
36
|
|
32
|
-
|
33
|
-
|
37
|
+
context 'when the key is already defined' do
|
38
|
+
before do
|
39
|
+
Vedeu.keymaps.reset
|
40
|
+
instance.add(key)
|
41
|
+
end
|
34
42
|
|
35
|
-
|
36
|
-
before do
|
37
|
-
Vedeu.keymaps.reset
|
38
|
-
instance.add(key)
|
43
|
+
it { subject.must_equal(false) }
|
39
44
|
end
|
40
45
|
|
41
|
-
|
46
|
+
context 'when the key is not already defined' do
|
47
|
+
it { subject.must_be_instance_of(Vedeu::Input::Keys) }
|
48
|
+
end
|
42
49
|
end
|
43
50
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
51
|
+
describe '#key_defined?' do
|
52
|
+
let(:input) { 'a' }
|
48
53
|
|
49
|
-
|
50
|
-
let(:input) { 'a' }
|
54
|
+
subject { instance.key_defined?(input) }
|
51
55
|
|
52
|
-
|
56
|
+
context 'when the input is defined' do
|
57
|
+
let(:keys) { Vedeu::Input::Keys.new([key]) }
|
53
58
|
|
54
|
-
|
55
|
-
|
59
|
+
it { subject.must_be_instance_of(TrueClass) }
|
60
|
+
end
|
56
61
|
|
57
|
-
|
62
|
+
context 'when the input is not defined' do
|
63
|
+
it { subject.must_be_instance_of(FalseClass) }
|
64
|
+
end
|
58
65
|
end
|
59
66
|
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
67
|
+
describe '#use' do
|
68
|
+
let(:input) { 'b' }
|
64
69
|
|
65
|
-
|
66
|
-
let(:input) { 'b' }
|
70
|
+
subject { instance.use(input) }
|
67
71
|
|
68
|
-
|
72
|
+
context 'when the input is defined' do
|
73
|
+
let(:key_a) { Vedeu::Input::Key.new('a') { :key_a } }
|
74
|
+
let(:key_b) { Vedeu::Input::Key.new('b') { :key_b } }
|
75
|
+
let(:key_c) { Vedeu::Input::Key.new('c') { :key_c } }
|
76
|
+
let(:keys) { Vedeu::Input::Keys.new([key_a, key_b, key_c]) }
|
69
77
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
let(:key_c) { Vedeu::Key.new('c') { :key_c } }
|
74
|
-
let(:keys) { Vedeu::Keys.new([key_a, key_b, key_c]) }
|
78
|
+
it { subject.must_be_instance_of(Array) }
|
79
|
+
it { subject.must_equal([:key_b]) }
|
80
|
+
end
|
75
81
|
|
76
|
-
|
77
|
-
|
82
|
+
context 'when the input is not defined' do
|
83
|
+
it { subject.must_be_instance_of(FalseClass) }
|
84
|
+
end
|
78
85
|
end
|
79
86
|
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
87
|
+
describe '#keys' do
|
88
|
+
subject { instance.keys }
|
84
89
|
|
85
|
-
|
86
|
-
|
90
|
+
it { subject.must_be_instance_of(Vedeu::Input::Keys) }
|
91
|
+
end
|
87
92
|
|
88
|
-
|
89
|
-
|
93
|
+
describe '#name' do
|
94
|
+
subject { instance.name }
|
90
95
|
|
91
|
-
|
92
|
-
|
96
|
+
it { subject.must_be_instance_of(String) }
|
97
|
+
end
|
93
98
|
|
94
|
-
|
95
|
-
|
99
|
+
describe '#name=' do
|
100
|
+
it { instance.must_respond_to(:name=) }
|
101
|
+
end
|
96
102
|
|
97
|
-
|
98
|
-
it { instance.must_respond_to(:name=) }
|
99
|
-
end
|
103
|
+
end # Keymap
|
100
104
|
|
101
|
-
end #
|
105
|
+
end # Input
|
102
106
|
|
103
107
|
end # Vedeu
|
@@ -2,12 +2,16 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Input
|
6
6
|
|
7
|
-
|
7
|
+
describe Keymaps do
|
8
8
|
|
9
|
-
|
9
|
+
let(:described) { Vedeu::Input::Keymaps }
|
10
10
|
|
11
|
-
|
11
|
+
it { described.must_respond_to(:keymaps) }
|
12
|
+
|
13
|
+
end # Keymaps
|
14
|
+
|
15
|
+
end # Input
|
12
16
|
|
13
17
|
end # Vedeu
|
@@ -2,17 +2,21 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Input
|
6
6
|
|
7
|
-
|
8
|
-
let(:instance) { described.new }
|
7
|
+
describe Keys do
|
9
8
|
|
10
|
-
|
9
|
+
let(:described) { Vedeu::Input::Keys }
|
10
|
+
let(:instance) { described.new }
|
11
11
|
|
12
|
-
|
13
|
-
it { instance.must_be_instance_of(described) }
|
14
|
-
end
|
12
|
+
it { described.superclass.must_equal(Vedeu::Collection) }
|
15
13
|
|
16
|
-
|
14
|
+
describe '#initialize' do
|
15
|
+
it { instance.must_be_instance_of(described) }
|
16
|
+
end
|
17
|
+
|
18
|
+
end # Keys
|
19
|
+
|
20
|
+
end # Input
|
17
21
|
|
18
22
|
end # Vedeu
|
@@ -2,87 +2,95 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
describe '#initialize' do
|
16
|
-
it { instance.must_be_instance_of(described) }
|
17
|
-
it { instance.instance_variable_get('@key').must_equal(key) }
|
18
|
-
it { instance.instance_variable_get('@name').must_equal(keymap) }
|
19
|
-
it do
|
20
|
-
instance.instance_variable_get('@repository').must_equal(Vedeu.keymaps)
|
21
|
-
end
|
5
|
+
module Input
|
6
|
+
|
7
|
+
describe Mapper do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Input::Mapper }
|
10
|
+
let(:instance) { described.new(key, keymap, repository) }
|
11
|
+
let(:key) {}
|
12
|
+
let(:keymap) {}
|
13
|
+
let(:repository) {}
|
22
14
|
|
23
|
-
|
24
|
-
let(:repository) { Vedeu::Repository.new }
|
15
|
+
before { Vedeu.keymaps.reset }
|
25
16
|
|
17
|
+
describe '#initialize' do
|
18
|
+
it { instance.must_be_instance_of(described) }
|
19
|
+
it { instance.instance_variable_get('@key').must_equal(key) }
|
20
|
+
it { instance.instance_variable_get('@name').must_equal(keymap) }
|
26
21
|
it do
|
27
|
-
instance.instance_variable_get('@repository').must_equal(
|
22
|
+
instance.instance_variable_get('@repository').must_equal(Vedeu.keymaps)
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the repository is provided' do
|
26
|
+
let(:repository) { Vedeu::Repository.new }
|
27
|
+
|
28
|
+
it do
|
29
|
+
instance.instance_variable_get('@repository').must_equal(repository)
|
30
|
+
end
|
28
31
|
end
|
29
32
|
end
|
30
|
-
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
describe '.keypress' do
|
35
|
+
let(:keymap) { 'test' }
|
34
36
|
|
35
|
-
|
37
|
+
subject { described.keypress(key, keymap) }
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
context 'when the key is not provided' do
|
40
|
+
it { subject.must_equal(false) }
|
41
|
+
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
+
context 'when the key is provided' do
|
44
|
+
let(:key) { 'a' }
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
context 'and the key is defined' do
|
47
|
+
let(:key_test) { Vedeu::Input::Key.new('a') { :do_something } }
|
48
|
+
let(:keymap_test) {
|
49
|
+
Vedeu::Input::Keymap.new(name: 'test', keys: [key_test])
|
50
|
+
}
|
47
51
|
|
48
|
-
|
52
|
+
before { Vedeu.keymaps.store(keymap_test) }
|
49
53
|
|
50
|
-
|
51
|
-
|
54
|
+
it { subject.must_equal(true) }
|
55
|
+
end
|
52
56
|
|
53
|
-
|
54
|
-
|
57
|
+
context 'and the key is not defined' do
|
58
|
+
it { subject.must_equal(false) }
|
59
|
+
end
|
55
60
|
end
|
56
61
|
end
|
57
|
-
end
|
58
62
|
|
59
|
-
|
60
|
-
|
63
|
+
describe '.valid?' do
|
64
|
+
let(:keymap) { 'test' }
|
61
65
|
|
62
|
-
|
66
|
+
subject { described.valid?(key, keymap) }
|
63
67
|
|
64
|
-
|
65
|
-
|
66
|
-
|
68
|
+
context 'when the key is not provided' do
|
69
|
+
it { subject.must_equal(false) }
|
70
|
+
end
|
67
71
|
|
68
|
-
|
69
|
-
|
72
|
+
context 'when the key is provided' do
|
73
|
+
let(:key) { 'a' }
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
|
75
|
+
context 'and the key is defined' do
|
76
|
+
let(:key_test) { Vedeu::Input::Key.new('a') { :do_something } }
|
77
|
+
let(:keymap_test) {
|
78
|
+
Vedeu::Input::Keymap.new(name: 'test', keys: [key_test])
|
79
|
+
}
|
74
80
|
|
75
|
-
|
81
|
+
before { Vedeu.keymaps.store(keymap_test) }
|
76
82
|
|
77
|
-
|
78
|
-
|
83
|
+
it { subject.must_equal(false) }
|
84
|
+
end
|
79
85
|
|
80
|
-
|
81
|
-
|
86
|
+
context 'and the key is not defined' do
|
87
|
+
it { subject.must_equal(true) }
|
88
|
+
end
|
82
89
|
end
|
83
90
|
end
|
84
|
-
end
|
85
91
|
|
86
|
-
|
92
|
+
end # Mapper
|
93
|
+
|
94
|
+
end # Input
|
87
95
|
|
88
96
|
end # Vedeu
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Input
|
6
|
+
|
7
|
+
describe Translator do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Input::Translator }
|
10
|
+
let(:instance) { described.new(code) }
|
11
|
+
let(:code) {}
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(described) }
|
15
|
+
it { instance.instance_variable_get('@code').must_equal(code) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.translate' do
|
19
|
+
context 'when the code is not recognised' do
|
20
|
+
it { described.translate('a').must_equal('a') }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when the code is recognised' do
|
24
|
+
it { described.translate("\e[H").must_equal(:home) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#translate' do
|
29
|
+
it { instance.must_respond_to(:translate) }
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Translator
|
33
|
+
|
34
|
+
end # Input
|
35
|
+
|
36
|
+
end # Vedeu
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Logging
|
6
|
+
|
7
|
+
describe Debug do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Logging::Debug }
|
10
|
+
|
11
|
+
before do
|
12
|
+
File.stubs(:open).with('/tmp/profile.html', 'w').returns(:some_code)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.debug' do
|
16
|
+
let(:filename) { 'profile.html' }
|
17
|
+
let(:some_code) { :some_code }
|
18
|
+
|
19
|
+
context 'when the block is not given' do
|
20
|
+
subject { described.debug(filename) }
|
21
|
+
|
22
|
+
it { subject.must_equal(nil) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the block is given' do
|
26
|
+
subject { described.debug(filename) { some_code } }
|
27
|
+
|
28
|
+
it {
|
29
|
+
::File.expects(:open).with('/tmp/profile.html', 'w')
|
30
|
+
subject
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end # Debug
|
36
|
+
|
37
|
+
end # Logging
|
38
|
+
|
39
|
+
end # Vedeu
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Logging
|
6
|
+
|
7
|
+
describe LocklessLogDevice do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Logging::LocklessLogDevice }
|
10
|
+
let(:instance) { described.new(file_or_filename) }
|
11
|
+
let(:file_or_filename) {}
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
# it { instance.must_be_instance_of(described) }
|
15
|
+
# it {
|
16
|
+
# instance.instance_variable_get('@file_or_filename').
|
17
|
+
# must_equal(file_or_filename)
|
18
|
+
# }
|
19
|
+
|
20
|
+
# @todo Add more tests.
|
21
|
+
# it { skip }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#write' do
|
25
|
+
subject { instance.write(message) }
|
26
|
+
|
27
|
+
# @todo Add more tests.
|
28
|
+
# it { skip }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#close' do
|
32
|
+
subject { instance.close }
|
33
|
+
|
34
|
+
# @todo Add more tests.
|
35
|
+
# it { skip }
|
36
|
+
end
|
37
|
+
|
38
|
+
end # LocklessLogDevice
|
39
|
+
|
40
|
+
end # Logging
|
41
|
+
|
42
|
+
end # Vedeu
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Logging
|
6
|
+
|
7
|
+
describe Log do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Logging::Log }
|
10
|
+
let(:_message) { 'Some message...' }
|
11
|
+
let(:force) { false }
|
12
|
+
let(:type) { :info }
|
13
|
+
|
14
|
+
describe '.log' do
|
15
|
+
subject { described.log(message: _message, force: force, type: type) }
|
16
|
+
|
17
|
+
it { subject.must_equal(
|
18
|
+
"\e[97m[info] \e[39m\e[39mSome message...\e[39m"
|
19
|
+
) }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.log_stdout' do
|
23
|
+
let(:type) { :create }
|
24
|
+
let(:_message) { 'Logging to stdout...' }
|
25
|
+
|
26
|
+
subject { described.log_stdout(type: type, message: _message) }
|
27
|
+
|
28
|
+
it {
|
29
|
+
capture_io { subject }.must_equal(
|
30
|
+
["\e[92m[create] \e[39m\e[32mLogging to stdout...\e[39m\n", ""]
|
31
|
+
)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.log_stdout' do
|
36
|
+
let(:type) { :debug }
|
37
|
+
let(:_message) { 'Logging to stderr...' }
|
38
|
+
|
39
|
+
subject { described.log_stderr(type: type, message: _message) }
|
40
|
+
|
41
|
+
it {
|
42
|
+
capture_io { subject }.must_equal(
|
43
|
+
["", "\e[91m[debug] \e[39m\e[31mLogging to stderr...\e[39m\n"]
|
44
|
+
)
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Log
|
49
|
+
|
50
|
+
end # Logging
|
51
|
+
|
52
|
+
end # Vedeu
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Logging
|
6
|
+
|
7
|
+
describe MonoLogger do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Logging::MonoLogger }
|
10
|
+
let(:instance) { described.new(logdev) }
|
11
|
+
let(:logdev) {}
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(described) }
|
15
|
+
it {
|
16
|
+
instance.instance_variable_get('@level').must_equal(Logger::DEBUG)
|
17
|
+
}
|
18
|
+
it {
|
19
|
+
instance.instance_variable_get('@default_formatter').
|
20
|
+
must_be_instance_of(::Logger::Formatter)
|
21
|
+
}
|
22
|
+
it { instance.instance_variable_get('@Formatter').must_equal(nil) }
|
23
|
+
|
24
|
+
context 'when a log device is given' do
|
25
|
+
# it {
|
26
|
+
# instance.instance_variable_get('@logdev').
|
27
|
+
# must_be_instance_of(Vedeu::Logging::LocklessLogDevice)
|
28
|
+
# }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when a log device is not given' do
|
32
|
+
# it {
|
33
|
+
# instance.instance_variable_get('@logdev').
|
34
|
+
# must_be_instance_of(Vedeu::Logging::LocklessLogDevice)
|
35
|
+
# }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end # MonoLogger
|
40
|
+
|
41
|
+
end # Logging
|
42
|
+
|
43
|
+
end # Vedeu
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Logging
|
6
|
+
|
7
|
+
describe Timer do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Logging::Timer }
|
10
|
+
let(:instance) { described.new(_message) }
|
11
|
+
let(:_message) { 'Testing' }
|
12
|
+
let(:_time) { mock('Time') }
|
13
|
+
let(:started) { 1434492219.5238185 }
|
14
|
+
|
15
|
+
before do
|
16
|
+
Time.stubs(:now).returns(_time)
|
17
|
+
_time.stubs(:to_f).returns(started)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#initialize' do
|
21
|
+
it { instance.must_be_instance_of(described) }
|
22
|
+
it { instance.instance_variable_get('@message').must_equal(_message) }
|
23
|
+
it { instance.instance_variable_get('@started').must_equal(started) }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.timer' do
|
27
|
+
it { described.must_respond_to(:timer) }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#measure' do
|
31
|
+
subject { instance.measure { } }
|
32
|
+
|
33
|
+
it {
|
34
|
+
Vedeu.expects(:log).with(type: :timer,
|
35
|
+
message: "Testing took 0.0ms.")
|
36
|
+
subject
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
end # Timer
|
41
|
+
|
42
|
+
end # Logging
|
43
|
+
|
44
|
+
end # Vedeu
|
@@ -2,13 +2,13 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
module
|
5
|
+
module Menus
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe DSL do
|
8
8
|
|
9
|
-
let(:described) { Vedeu::DSL
|
9
|
+
let(:described) { Vedeu::Menus::DSL }
|
10
10
|
let(:instance) { described.new(model) }
|
11
|
-
let(:model) { Vedeu::Menu.new(attributes) }
|
11
|
+
let(:model) { Vedeu::Menus::Menu.new(attributes) }
|
12
12
|
let(:attributes) {
|
13
13
|
{
|
14
14
|
collection: collection,
|
@@ -70,8 +70,8 @@ module Vedeu
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
end #
|
73
|
+
end # DSL
|
74
74
|
|
75
|
-
end #
|
75
|
+
end # Menus
|
76
76
|
|
77
77
|
end # Vedeu
|