vedeu 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/docs/dsl.md +4 -4
  4. data/lib/vedeu/all.rb +6 -18
  5. data/lib/vedeu/api.rb +14 -13
  6. data/lib/vedeu/bindings/system.rb +5 -4
  7. data/lib/vedeu/buffers/virtual_buffer.rb +13 -11
  8. data/lib/vedeu/configuration/api.rb +4 -3
  9. data/lib/vedeu/cursors/cursor.rb +23 -18
  10. data/lib/vedeu/distributed/client.rb +11 -6
  11. data/lib/vedeu/distributed/server.rb +4 -3
  12. data/lib/vedeu/dsl/keymap.rb +6 -6
  13. data/lib/vedeu/editor/all.rb +19 -0
  14. data/lib/vedeu/{input/editor → editor}/capture.rb +1 -1
  15. data/lib/vedeu/{input/editor → editor}/cropper.rb +0 -0
  16. data/lib/vedeu/{input/editor → editor}/cursor.rb +0 -0
  17. data/lib/vedeu/{input/editor → editor}/document.rb +0 -0
  18. data/lib/vedeu/{input/editor → editor}/documents.rb +0 -0
  19. data/lib/vedeu/{input/editor → editor}/editor.rb +0 -0
  20. data/lib/vedeu/{input/editor → editor}/insert.rb +0 -0
  21. data/lib/vedeu/{input/editor → editor}/line.rb +0 -0
  22. data/lib/vedeu/{input/editor → editor}/lines.rb +0 -0
  23. data/lib/vedeu/error.rb +21 -18
  24. data/lib/vedeu/esc/borders.rb +6 -4
  25. data/lib/vedeu/esc/colours.rb +13 -12
  26. data/lib/vedeu/esc/esc.rb +11 -10
  27. data/lib/vedeu/input/all.rb +15 -0
  28. data/lib/vedeu/input/input.rb +55 -52
  29. data/lib/vedeu/input/key.rb +36 -30
  30. data/lib/vedeu/input/keymap.rb +101 -92
  31. data/lib/vedeu/input/keymaps.rb +10 -6
  32. data/lib/vedeu/input/keys.rb +8 -4
  33. data/lib/vedeu/input/mapper.rb +125 -121
  34. data/lib/vedeu/input/translator.rb +159 -0
  35. data/lib/vedeu/internal_api.rb +16 -15
  36. data/lib/vedeu/logging/all.rb +13 -0
  37. data/lib/vedeu/logging/debug.rb +84 -0
  38. data/lib/vedeu/logging/lockless_log_device.rb +65 -0
  39. data/lib/vedeu/logging/log.rb +179 -0
  40. data/lib/vedeu/logging/mono_logger.rb +26 -0
  41. data/lib/vedeu/logging/timer.rb +68 -0
  42. data/lib/vedeu/menus/all.rb +12 -0
  43. data/lib/vedeu/{dsl/menu.rb → menus/dsl.rb} +19 -18
  44. data/lib/vedeu/menus/menu.rb +234 -0
  45. data/lib/vedeu/{null/menu.rb → menus/null.rb} +6 -6
  46. data/lib/vedeu/menus/repository.rb +18 -0
  47. data/lib/vedeu/models/cell.rb +62 -55
  48. data/lib/vedeu/models/escape.rb +55 -50
  49. data/lib/vedeu/models/page.rb +74 -69
  50. data/lib/vedeu/models/row.rb +55 -51
  51. data/lib/vedeu/models/views/all.rb +1 -0
  52. data/lib/vedeu/models/views/char.rb +1 -1
  53. data/lib/vedeu/models/views/html_char.rb +165 -0
  54. data/lib/vedeu/output/renderers/html.rb +5 -4
  55. data/lib/vedeu/repositories/model.rb +2 -0
  56. data/lib/vedeu/runtime/application.rb +110 -103
  57. data/lib/vedeu/runtime/bootstrap.rb +109 -103
  58. data/lib/vedeu/runtime/flags.rb +45 -41
  59. data/lib/vedeu/runtime/launcher.rb +1 -1
  60. data/lib/vedeu/runtime/main_loop.rb +51 -46
  61. data/lib/vedeu/runtime/traps.rb +20 -16
  62. data/lib/vedeu/version.rb +1 -1
  63. data/lib/vedeu.rb +2 -2
  64. data/test/lib/vedeu/buffers/virtual_buffer_test.rb +1 -1
  65. data/test/lib/vedeu/cursors/cursor_test.rb +11 -5
  66. data/test/lib/vedeu/dsl/interface_test.rb +1 -1
  67. data/test/lib/vedeu/dsl/keymap_test.rb +2 -2
  68. data/test/lib/vedeu/{input/editor → editor}/capture_test.rb +0 -0
  69. data/test/lib/vedeu/{input/editor → editor}/cropper_test.rb +0 -0
  70. data/test/lib/vedeu/{input/editor → editor}/cursor_test.rb +0 -0
  71. data/test/lib/vedeu/{input/editor → editor}/document_test.rb +0 -0
  72. data/test/lib/vedeu/{input/editor → editor}/documents_test.rb +0 -0
  73. data/test/lib/vedeu/{input/editor → editor}/editor_test.rb +0 -0
  74. data/test/lib/vedeu/{input/editor → editor}/insert_test.rb +0 -0
  75. data/test/lib/vedeu/{input/editor → editor}/line_test.rb +0 -0
  76. data/test/lib/vedeu/{input/editor → editor}/lines_test.rb +0 -0
  77. data/test/lib/vedeu/input/input_test.rb +58 -54
  78. data/test/lib/vedeu/input/key_test.rb +29 -25
  79. data/test/lib/vedeu/input/keymap_test.rb +74 -70
  80. data/test/lib/vedeu/input/keymaps_test.rb +8 -4
  81. data/test/lib/vedeu/input/keys_test.rb +12 -8
  82. data/test/lib/vedeu/input/mapper_test.rb +64 -56
  83. data/test/lib/vedeu/input/translator_test.rb +36 -0
  84. data/test/lib/vedeu/logging/debug_test.rb +39 -0
  85. data/test/lib/vedeu/logging/lockless_log_device_test.rb +42 -0
  86. data/test/lib/vedeu/logging/log_test.rb +52 -0
  87. data/test/lib/vedeu/logging/mono_logger_test.rb +43 -0
  88. data/test/lib/vedeu/logging/timer_test.rb +44 -0
  89. data/test/lib/vedeu/{dsl/menu_test.rb → menus/dsl_test.rb} +6 -6
  90. data/test/lib/vedeu/menus/menu_test.rb +305 -0
  91. data/test/lib/vedeu/{null/menu_test.rb → menus/null_test.rb} +5 -5
  92. data/test/lib/vedeu/menus/repository_test.rb +17 -0
  93. data/test/lib/vedeu/models/cell_test.rb +54 -50
  94. data/test/lib/vedeu/models/escape_test.rb +49 -45
  95. data/test/lib/vedeu/models/page_test.rb +167 -160
  96. data/test/lib/vedeu/models/row_test.rb +71 -67
  97. data/test/lib/vedeu/models/views/html_char_test.rb +110 -0
  98. data/test/lib/vedeu/output/compressor_test.rb +44 -22
  99. data/test/lib/vedeu/output/renderers_test.rb +4 -2
  100. data/test/lib/vedeu/runtime/application_test.rb +36 -32
  101. data/test/lib/vedeu/runtime/bootstrap_test.rb +31 -26
  102. data/test/lib/vedeu/runtime/flags_test.rb +33 -29
  103. data/test/lib/vedeu/runtime/launcher_test.rb +4 -2
  104. data/test/lib/vedeu/runtime/main_loop_test.rb +28 -24
  105. data/test/lib/vedeu/runtime/traps_test.rb +8 -4
  106. data/test/test_helper.rb +4 -2
  107. metadata +66 -63
  108. data/lib/vedeu/input/editor/all.rb +0 -19
  109. data/lib/vedeu/input/input_translator.rb +0 -155
  110. data/lib/vedeu/log/debug.rb +0 -79
  111. data/lib/vedeu/log/lockless_log_device.rb +0 -61
  112. data/lib/vedeu/log/log.rb +0 -172
  113. data/lib/vedeu/log/mono_logger.rb +0 -21
  114. data/lib/vedeu/log/timer.rb +0 -63
  115. data/lib/vedeu/models/menu.rb +0 -217
  116. data/lib/vedeu/models/menus.rb +0 -14
  117. data/lib/vedeu/output/html_char.rb +0 -161
  118. data/test/lib/vedeu/input/input_translator_test.rb +0 -32
  119. data/test/lib/vedeu/log/debug_test.rb +0 -35
  120. data/test/lib/vedeu/log/lockless_log_device_test.rb +0 -29
  121. data/test/lib/vedeu/log/log_test.rb +0 -48
  122. data/test/lib/vedeu/log/mono_logger_test.rb +0 -31
  123. data/test/lib/vedeu/log/timer_test.rb +0 -40
  124. data/test/lib/vedeu/models/menu_test.rb +0 -301
  125. data/test/lib/vedeu/models/menus_test.rb +0 -13
  126. 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
- describe Keymap do
6
-
7
- let(:described) { Vedeu::Keymap }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
10
- {
11
- name: map_name,
12
- keys: keys
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
- let(:map_name) { 'zirconium' }
16
- let(:keys) { [] }
17
- let(:key) { Vedeu::Key.new('a') { :output } }
18
-
19
- describe '#initialize' do
20
- it { instance.must_be_instance_of(described) }
21
- it { instance.instance_variable_get('@name').must_equal(map_name) }
22
- it { instance.instance_variable_get('@keys').must_be_instance_of(Array) }
23
- it do
24
- instance.instance_variable_get('@repository').must_equal(Vedeu.keymaps)
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
- describe 'accessors' do
29
- it { instance.must_respond_to(:name) }
30
- end
34
+ describe '#add' do
35
+ subject { instance.add(key) }
31
36
 
32
- describe '#add' do
33
- subject { instance.add(key) }
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
- context 'when the key is already defined' do
36
- before do
37
- Vedeu.keymaps.reset
38
- instance.add(key)
43
+ it { subject.must_equal(false) }
39
44
  end
40
45
 
41
- it { subject.must_equal(false) }
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
- context 'when the key is not already defined' do
45
- it { subject.must_be_instance_of(Vedeu::Keys) }
46
- end
47
- end
51
+ describe '#key_defined?' do
52
+ let(:input) { 'a' }
48
53
 
49
- describe '#key_defined?' do
50
- let(:input) { 'a' }
54
+ subject { instance.key_defined?(input) }
51
55
 
52
- subject { instance.key_defined?(input) }
56
+ context 'when the input is defined' do
57
+ let(:keys) { Vedeu::Input::Keys.new([key]) }
53
58
 
54
- context 'when the input is defined' do
55
- let(:keys) { Vedeu::Keys.new([key]) }
59
+ it { subject.must_be_instance_of(TrueClass) }
60
+ end
56
61
 
57
- it { subject.must_be_instance_of(TrueClass) }
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
- context 'when the input is not defined' do
61
- it { subject.must_be_instance_of(FalseClass) }
62
- end
63
- end
67
+ describe '#use' do
68
+ let(:input) { 'b' }
64
69
 
65
- describe '#use' do
66
- let(:input) { 'b' }
70
+ subject { instance.use(input) }
67
71
 
68
- subject { instance.use(input) }
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
- context 'when the input is defined' do
71
- let(:key_a) { Vedeu::Key.new('a') { :key_a } }
72
- let(:key_b) { Vedeu::Key.new('b') { :key_b } }
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
- it { subject.must_be_instance_of(Array) }
77
- it { subject.must_equal([:key_b]) }
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
- context 'when the input is not defined' do
81
- it { subject.must_be_instance_of(FalseClass) }
82
- end
83
- end
87
+ describe '#keys' do
88
+ subject { instance.keys }
84
89
 
85
- describe '#keys' do
86
- subject { instance.keys }
90
+ it { subject.must_be_instance_of(Vedeu::Input::Keys) }
91
+ end
87
92
 
88
- it { subject.must_be_instance_of(Vedeu::Keys) }
89
- end
93
+ describe '#name' do
94
+ subject { instance.name }
90
95
 
91
- describe '#name' do
92
- subject { instance.name }
96
+ it { subject.must_be_instance_of(String) }
97
+ end
93
98
 
94
- it { subject.must_be_instance_of(String) }
95
- end
99
+ describe '#name=' do
100
+ it { instance.must_respond_to(:name=) }
101
+ end
96
102
 
97
- describe '#name=' do
98
- it { instance.must_respond_to(:name=) }
99
- end
103
+ end # Keymap
100
104
 
101
- end # Keymap
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
- describe Keymaps do
5
+ module Input
6
6
 
7
- let(:described) { Vedeu::Keymaps }
7
+ describe Keymaps do
8
8
 
9
- it { described.must_respond_to(:keymaps) }
9
+ let(:described) { Vedeu::Input::Keymaps }
10
10
 
11
- end # Keymaps
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
- describe Keys do
5
+ module Input
6
6
 
7
- let(:described) { Vedeu::Keys }
8
- let(:instance) { described.new }
7
+ describe Keys do
9
8
 
10
- it { described.superclass.must_equal(Vedeu::Collection) }
9
+ let(:described) { Vedeu::Input::Keys }
10
+ let(:instance) { described.new }
11
11
 
12
- describe '#initialize' do
13
- it { instance.must_be_instance_of(described) }
14
- end
12
+ it { described.superclass.must_equal(Vedeu::Collection) }
15
13
 
16
- end # Keys
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
- describe Mapper do
6
-
7
- let(:described) { Vedeu::Mapper }
8
- let(:instance) { described.new(key, keymap, repository) }
9
- let(:key) {}
10
- let(:keymap) {}
11
- let(:repository) {}
12
-
13
- before { Vedeu.keymaps.reset }
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
- context 'when the repository is provided' do
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(repository)
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
- describe '.keypress' do
33
- let(:keymap) { 'test' }
34
+ describe '.keypress' do
35
+ let(:keymap) { 'test' }
34
36
 
35
- subject { described.keypress(key, keymap) }
37
+ subject { described.keypress(key, keymap) }
36
38
 
37
- context 'when the key is not provided' do
38
- it { subject.must_equal(false) }
39
- end
39
+ context 'when the key is not provided' do
40
+ it { subject.must_equal(false) }
41
+ end
40
42
 
41
- context 'when the key is provided' do
42
- let(:key) { 'a' }
43
+ context 'when the key is provided' do
44
+ let(:key) { 'a' }
43
45
 
44
- context 'and the key is defined' do
45
- let(:key_test) { Key.new('a') { :do_something } }
46
- let(:keymap_test) { Keymap.new(name: 'test', keys: [key_test]) }
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
- before { Vedeu.keymaps.store(keymap_test) }
52
+ before { Vedeu.keymaps.store(keymap_test) }
49
53
 
50
- it { subject.must_equal(true) }
51
- end
54
+ it { subject.must_equal(true) }
55
+ end
52
56
 
53
- context 'and the key is not defined' do
54
- it { subject.must_equal(false) }
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
- describe '.valid?' do
60
- let(:keymap) { 'test' }
63
+ describe '.valid?' do
64
+ let(:keymap) { 'test' }
61
65
 
62
- subject { described.valid?(key, keymap) }
66
+ subject { described.valid?(key, keymap) }
63
67
 
64
- context 'when the key is not provided' do
65
- it { subject.must_equal(false) }
66
- end
68
+ context 'when the key is not provided' do
69
+ it { subject.must_equal(false) }
70
+ end
67
71
 
68
- context 'when the key is provided' do
69
- let(:key) { 'a' }
72
+ context 'when the key is provided' do
73
+ let(:key) { 'a' }
70
74
 
71
- context 'and the key is defined' do
72
- let(:key_test) { Key.new('a') { :do_something } }
73
- let(:keymap_test) { Keymap.new(name: 'test', keys: [key_test]) }
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
- before { Vedeu.keymaps.store(keymap_test) }
81
+ before { Vedeu.keymaps.store(keymap_test) }
76
82
 
77
- it { subject.must_equal(false) }
78
- end
83
+ it { subject.must_equal(false) }
84
+ end
79
85
 
80
- context 'and the key is not defined' do
81
- it { subject.must_equal(true) }
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
- end # Mapper
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 DSL
5
+ module Menus
6
6
 
7
- describe Menu do
7
+ describe DSL do
8
8
 
9
- let(:described) { Vedeu::DSL::Menu }
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 # Menu
73
+ end # DSL
74
74
 
75
- end # DSL
75
+ end # Menus
76
76
 
77
77
  end # Vedeu