vedeu 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -9
  3. data/Rakefile +0 -10
  4. data/bin/composition +1 -1
  5. data/examples/single_interface_app.rb +7 -4
  6. data/lib/vedeu.rb +19 -48
  7. data/lib/vedeu/application.rb +8 -7
  8. data/lib/vedeu/configuration.rb +4 -4
  9. data/lib/vedeu/input/input.rb +3 -0
  10. data/lib/vedeu/launcher.rb +3 -0
  11. data/lib/vedeu/models/background.rb +13 -0
  12. data/lib/vedeu/models/coercions.rb +21 -0
  13. data/lib/vedeu/models/colour.rb +22 -0
  14. data/lib/vedeu/{repository → models}/command.rb +2 -0
  15. data/lib/vedeu/models/composition.rb +30 -0
  16. data/lib/vedeu/models/foreground.rb +13 -0
  17. data/lib/vedeu/models/interface.rb +62 -0
  18. data/lib/vedeu/models/interface_collection.rb +24 -0
  19. data/lib/vedeu/models/line.rb +22 -0
  20. data/lib/vedeu/models/line_collection.rb +27 -0
  21. data/lib/vedeu/models/presentation.rb +13 -0
  22. data/lib/vedeu/models/stream.rb +21 -0
  23. data/lib/vedeu/models/stream_collection.rb +27 -0
  24. data/lib/vedeu/models/style_collection.rb +23 -0
  25. data/lib/vedeu/output/interface_renderer.rb +62 -0
  26. data/lib/vedeu/output/output.rb +6 -5
  27. data/lib/vedeu/process/process.rb +15 -31
  28. data/lib/vedeu/repository/command_repository.rb +13 -14
  29. data/lib/vedeu/repository/interface_repository.rb +12 -13
  30. data/lib/vedeu/repository/repository.rb +2 -0
  31. data/lib/vedeu/{output → support}/cursor.rb +2 -0
  32. data/lib/vedeu/support/esc.rb +112 -0
  33. data/lib/vedeu/support/events.rb +21 -0
  34. data/lib/vedeu/support/geometry.rb +66 -0
  35. data/lib/vedeu/support/parser.rb +27 -0
  36. data/lib/vedeu/support/terminal.rb +31 -134
  37. data/lib/vedeu/{output → support}/translator.rb +12 -8
  38. data/lib/vedeu/{output → support}/wordwrap.rb +2 -4
  39. data/lib/vedeu/version.rb +1 -1
  40. data/test/lib/vedeu/application_test.rb +7 -2
  41. data/test/lib/vedeu/configuration_test.rb +13 -8
  42. data/test/lib/vedeu/input/input_test.rb +2 -1
  43. data/test/lib/vedeu/launcher_test.rb +7 -2
  44. data/test/lib/vedeu/models/background_test.rb +35 -0
  45. data/test/lib/vedeu/models/colour_test.rb +71 -0
  46. data/test/lib/vedeu/models/command_test.rb +109 -0
  47. data/test/lib/vedeu/models/composition_test.rb +187 -0
  48. data/test/lib/vedeu/models/foreground_test.rb +35 -0
  49. data/test/lib/vedeu/models/interface_collection_test.rb +57 -0
  50. data/test/lib/vedeu/models/interface_test.rb +220 -0
  51. data/test/lib/vedeu/models/line_collection_test.rb +69 -0
  52. data/test/lib/vedeu/models/line_test.rb +76 -0
  53. data/test/lib/vedeu/models/presentation_test.rb +8 -0
  54. data/test/lib/vedeu/models/stream_collection_test.rb +57 -0
  55. data/test/lib/vedeu/models/stream_test.rb +76 -0
  56. data/test/lib/vedeu/models/style_collection_test.rb +22 -0
  57. data/test/lib/vedeu/output/interface_renderer_test.rb +12 -0
  58. data/test/lib/vedeu/output/output_test.rb +15 -30
  59. data/test/lib/vedeu/process/process_test.rb +22 -44
  60. data/test/lib/vedeu/repository/command_repository_test.rb +22 -16
  61. data/test/lib/vedeu/repository/interface_repository_test.rb +62 -14
  62. data/test/lib/vedeu/repository/repository_test.rb +1 -0
  63. data/test/lib/vedeu/repository/storage_test.rb +13 -6
  64. data/test/lib/vedeu/{output → support}/cursor_test.rb +1 -0
  65. data/test/lib/vedeu/support/esc_test.rb +348 -0
  66. data/test/lib/vedeu/support/events_test.rb +37 -0
  67. data/test/lib/vedeu/support/exit_test.rb +1 -0
  68. data/test/lib/vedeu/support/geometry_test.rb +131 -0
  69. data/test/lib/vedeu/support/parser_test.rb +56 -0
  70. data/test/lib/vedeu/support/queue_test.rb +1 -0
  71. data/test/lib/vedeu/support/terminal_test.rb +1 -119
  72. data/test/lib/vedeu/{output → support}/translator_test.rb +17 -12
  73. data/test/lib/vedeu/{output → support}/wordwrap_test.rb +1 -0
  74. data/test/lib/vedeu/version_test.rb +1 -0
  75. data/test/lib/vedeu_test.rb +1 -0
  76. data/{lib/vedeu/repository → test/support}/dummy_command.rb +0 -0
  77. data/{lib/vedeu/repository → test/support}/dummy_interface.rb +0 -0
  78. data/test/support/json/int1_lin1_str1.json +10 -0
  79. data/test/support/json/int1_lin1_str3.json +18 -0
  80. data/test/support/json/int1_lin2_str1.json +17 -0
  81. data/test/support/json/int1_lin2_str3.json +33 -0
  82. data/test/support/json/int1_lin2_str3_styles.json +43 -0
  83. data/test/support/json/int2_lin1_str1.json +20 -0
  84. data/test/support/json/int2_lin1_str3.json +36 -0
  85. data/test/support/json/int2_lin2_str1.json +34 -0
  86. data/test/support/json/int2_lin2_str3.json +66 -0
  87. data/test/support/json/int2_lin2_str3_styles.json +158 -0
  88. data/test/support/output_1.json +9 -0
  89. data/test/support/output_1.rb +14 -0
  90. data/test/support/output_2.json +1 -0
  91. data/test/support/output_2.rb +19 -0
  92. data/test/test_helper.rb +0 -2
  93. data/vedeu.gemspec +0 -3
  94. metadata +98 -150
  95. data/config/cucumber.yml +0 -8
  96. data/documentation/composition.ebnf +0 -7
  97. data/documentation/diagram/ColourDirective.png +0 -0
  98. data/documentation/diagram/Directive.png +0 -0
  99. data/documentation/diagram/Interface.png +0 -0
  100. data/documentation/diagram/Output.png +0 -0
  101. data/documentation/diagram/PositionDirective.png +0 -0
  102. data/documentation/diagram/Stream.png +0 -0
  103. data/documentation/diagram/StyleDirective.png +0 -0
  104. data/documentation/diagram/rr-1.35.837.png +0 -0
  105. data/documentation/index.html +0 -325
  106. data/features/getting_started.feature +0 -10
  107. data/features/step_definitions/vedeu_steps.rb +0 -11
  108. data/features/support/env.rb +0 -12
  109. data/lib/vedeu/output/background.rb +0 -27
  110. data/lib/vedeu/output/base.rb +0 -57
  111. data/lib/vedeu/output/buffer/composition.rb +0 -24
  112. data/lib/vedeu/output/buffer/formatting.rb +0 -25
  113. data/lib/vedeu/output/buffer/interface.rb +0 -14
  114. data/lib/vedeu/output/buffer/line.rb +0 -14
  115. data/lib/vedeu/output/buffer/stream.rb +0 -14
  116. data/lib/vedeu/output/buffer/style.rb +0 -11
  117. data/lib/vedeu/output/colour.rb +0 -39
  118. data/lib/vedeu/output/compositor.rb +0 -72
  119. data/lib/vedeu/output/directive.rb +0 -63
  120. data/lib/vedeu/output/esc.rb +0 -61
  121. data/lib/vedeu/output/foreground.rb +0 -27
  122. data/lib/vedeu/output/geometry.rb +0 -71
  123. data/lib/vedeu/output/layer.rb +0 -9
  124. data/lib/vedeu/output/menu.rb +0 -26
  125. data/lib/vedeu/output/position.rb +0 -35
  126. data/lib/vedeu/output/style.rb +0 -38
  127. data/lib/vedeu/repository/interface.rb +0 -62
  128. data/lib/vedeu/support/json_parser.rb +0 -25
  129. data/lib/vedeu/support/options.rb +0 -4
  130. data/test/lib/vedeu/output/background_test.rb +0 -67
  131. data/test/lib/vedeu/output/base_test.rb +0 -8
  132. data/test/lib/vedeu/output/buffer/composition_test.rb +0 -57
  133. data/test/lib/vedeu/output/buffer/formatting_test.rb +0 -9
  134. data/test/lib/vedeu/output/buffer/interface_test.rb +0 -38
  135. data/test/lib/vedeu/output/buffer/line_test.rb +0 -64
  136. data/test/lib/vedeu/output/buffer/stream_test.rb +0 -61
  137. data/test/lib/vedeu/output/buffer/style_test.rb +0 -8
  138. data/test/lib/vedeu/output/colour_test.rb +0 -104
  139. data/test/lib/vedeu/output/compositor_test.rb +0 -247
  140. data/test/lib/vedeu/output/directive_test.rb +0 -82
  141. data/test/lib/vedeu/output/esc_test.rb +0 -175
  142. data/test/lib/vedeu/output/foreground_test.rb +0 -67
  143. data/test/lib/vedeu/output/geometry_test.rb +0 -190
  144. data/test/lib/vedeu/output/layer_test.rb +0 -35
  145. data/test/lib/vedeu/output/menu_test.rb +0 -13
  146. data/test/lib/vedeu/output/position_test.rb +0 -48
  147. data/test/lib/vedeu/output/style_test.rb +0 -132
  148. data/test/lib/vedeu/repository/command_test.rb +0 -73
  149. data/test/lib/vedeu/repository/dummy_command_test.rb +0 -27
  150. data/test/lib/vedeu/repository/dummy_interface_test.rb +0 -7
  151. data/test/lib/vedeu/repository/interface_test.rb +0 -79
  152. data/test/lib/vedeu/support/json_parser_test.rb +0 -45
  153. data/test/support/composition.json +0 -47
  154. data/test/support/composition.rb +0 -5
  155. data/test/support/composition.xml +0 -36
  156. data/test/support/multi_interface.json +0 -34
  157. data/test/support/single_interface.json +0 -19
@@ -0,0 +1,35 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/background'
3
+ require_relative '../../../../lib/vedeu/models/colour'
4
+
5
+ module Vedeu
6
+ describe Background do
7
+ let(:described_class) { Background }
8
+ let(:described_instance) { Vedeu::Colour.new(attributes) }
9
+ let(:attributes) {
10
+ {
11
+ background: '#00ff00'
12
+ }
13
+ }
14
+
15
+ describe '#background' do
16
+ let(:subject) { described_instance.background }
17
+
18
+ it 'returns a String' do
19
+ subject.must_be_instance_of(String)
20
+ end
21
+
22
+ it 'returns an escape sequence' do
23
+ subject.must_equal("\e[48;5;46m")
24
+ end
25
+
26
+ context 'when the foreground is missing' do
27
+ let(:attributes) { {} }
28
+
29
+ it 'returns an escape sequence' do
30
+ subject.must_equal('')
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,71 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/colour'
3
+
4
+ module Vedeu
5
+ describe Colour do
6
+ let(:described_class) { Colour }
7
+ let(:described_instance) { described_class.new(attributes) }
8
+ let(:attributes) {
9
+ {
10
+ foreground: '#ff0000',
11
+ background: '#000000'
12
+ }
13
+ }
14
+
15
+ describe '#initialize' do
16
+ let(:subject) { described_instance }
17
+
18
+ it 'returns a Colour instance' do
19
+ subject.must_be_instance_of(Colour)
20
+ end
21
+ end
22
+
23
+ describe '#to_json' do
24
+ let(:subject) { described_instance.to_json }
25
+
26
+ it 'returns a String' do
27
+ subject.must_be_instance_of(String)
28
+ end
29
+
30
+ it 'returns the model as JSON' do
31
+ subject.must_equal("{\"foreground\":\"\\u001b[38;5;196m\",\"background\":\"\\u001b[48;5;16m\"}")
32
+ end
33
+ end
34
+
35
+ describe '#to_s' do
36
+ let(:subject) { described_instance.to_s }
37
+
38
+ it 'returns a String' do
39
+ subject.must_be_instance_of(String)
40
+ end
41
+
42
+ it 'returns an escape sequence' do
43
+ subject.must_equal("\e[38;5;196m\e[48;5;16m")
44
+ end
45
+
46
+ context 'when the foreground is missing' do
47
+ let(:attributes) { { background: '#000000' } }
48
+
49
+ it 'returns an escape sequence' do
50
+ subject.must_equal("\e[48;5;16m")
51
+ end
52
+ end
53
+
54
+ context 'when the background is missing' do
55
+ let(:attributes) { { foreground: '#ff0000' } }
56
+
57
+ it 'returns an escape sequence' do
58
+ subject.must_equal("\e[38;5;196m")
59
+ end
60
+ end
61
+
62
+ context 'when both are missing' do
63
+ let(:attributes) { {} }
64
+
65
+ it 'returns an empty string' do
66
+ subject.must_equal('')
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,109 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../support/dummy_command'
3
+ require_relative '../../../../lib/vedeu/models/command'
4
+
5
+ module Vedeu
6
+ describe Command do
7
+ let(:described_class) { Command }
8
+ let(:described_instance) { described_class.new(attributes) }
9
+ let(:subject) { described_instance }
10
+ let(:attributes) {
11
+ {
12
+ name: 'dummy',
13
+ entity: DummyCommand,
14
+ keyword: "dummy",
15
+ keypress: "d",
16
+ arguments: []
17
+ }
18
+ }
19
+
20
+ describe '#initialize' do
21
+ let(:subject) { described_instance }
22
+
23
+ it 'returns a Command instance' do
24
+ subject.must_be_instance_of(Command)
25
+ end
26
+ end
27
+
28
+ describe '#name' do
29
+ let(:subject) { described_instance.name }
30
+
31
+ it 'returns a String' do
32
+ subject.must_be_instance_of(String)
33
+ end
34
+
35
+ it 'has a name attribute' do
36
+ subject.must_equal('dummy')
37
+ end
38
+ end
39
+
40
+ describe '#entity' do
41
+ let(:subject) { described_instance.entity }
42
+
43
+ it 'returns a Class' do
44
+ subject.must_be_instance_of(Class)
45
+ end
46
+
47
+ it 'has an entity attribute' do
48
+ subject.must_equal(DummyCommand)
49
+ end
50
+ end
51
+
52
+ describe '#keypress' do
53
+ let(:subject) { described_instance.keypress }
54
+
55
+ it 'returns a String' do
56
+ subject.must_be_instance_of(String)
57
+ end
58
+
59
+ it 'has a keypress attribute' do
60
+ subject.must_equal('d')
61
+ end
62
+ end
63
+
64
+ describe '#keyword' do
65
+ let(:subject) { described_instance.keyword }
66
+
67
+ it 'returns a String' do
68
+ subject.must_be_instance_of(String)
69
+ end
70
+
71
+ it 'has an keyword attribute' do
72
+ subject.must_equal('dummy')
73
+ end
74
+ end
75
+
76
+ describe '#arguments' do
77
+ let(:subject) { described_instance.arguments }
78
+
79
+ it 'returns a String' do
80
+ subject.must_be_instance_of(Array)
81
+ end
82
+
83
+ it 'has an arguments attribute' do
84
+ subject.must_equal([])
85
+ end
86
+ end
87
+
88
+ describe '#execute' do
89
+ let(:subject) { described_instance.execute(args) }
90
+ let(:args) { [] }
91
+
92
+ it 'returns a Symbol' do
93
+ subject.must_be_instance_of(Symbol)
94
+ end
95
+
96
+ it 'returns the result of execution' do
97
+ subject.must_equal(:dummy)
98
+ end
99
+ end
100
+
101
+ describe '#executable' do
102
+ let(:subject) { described_instance.executable }
103
+
104
+ it 'returns a proc' do
105
+ subject.class.to_s.must_equal('Proc')
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,187 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/composition'
3
+ require_relative '../../../../lib/vedeu/repository/interface_repository'
4
+
5
+ module Vedeu
6
+ describe Composition do
7
+ let(:described_class) { Composition }
8
+ let(:described_instance) { described_class.new(attributes) }
9
+ let(:attributes) { { interfaces: interfaces } }
10
+ let(:interfaces) { { name: 'dummy', width: 40, height: 25 } }
11
+
12
+ describe '#initialize' do
13
+ let(:subject) { described_instance }
14
+
15
+ it 'returns a Composition instance' do
16
+ subject.must_be_instance_of(Composition)
17
+ end
18
+ end
19
+
20
+ describe '#enqueue' do
21
+ let(:subject) { described_instance.enqueue }
22
+
23
+ before do
24
+ InterfaceRepository.create({ name: 'dummy', width: 10, height: 2 })
25
+ end
26
+
27
+ it 'creates a composition and enqueues the interface for rendering' do
28
+ skip
29
+ end
30
+ end
31
+
32
+ describe '#to_json' do
33
+ let(:subject) { described_instance.to_json }
34
+
35
+ it 'returns a String' do
36
+ subject.must_be_instance_of(String)
37
+ end
38
+
39
+ it 'returns the model as JSON' do
40
+ subject.must_equal("{\"interfaces\":[{\"colour\":null,\"style\":\"\",\"name\":\"dummy\",\"lines\":[],\"y\":1,\"x\":1,\"z\":1,\"width\":40,\"height\":25,\"current\":\"\",\"cursor\":true}]}")
41
+ end
42
+ end
43
+
44
+ describe '#to_s' do
45
+ let(:subject) { described_instance.to_s }
46
+
47
+ it 'returns a String' do
48
+ subject.must_be_instance_of(String)
49
+ end
50
+
51
+ context 'single interface, single line, single stream' do
52
+ let(:json) { File.read('test/support/json/int1_lin1_str1.json') }
53
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
54
+
55
+ before do
56
+ InterfaceRepository.create({ name: 'int1_lin1_str1', y: 3, x: 3, width: 10, height: 3 })
57
+ end
58
+
59
+ it 'returns the stringified content' do
60
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...")
61
+ end
62
+ end
63
+
64
+ context 'single interface, single line, multiple streams' do
65
+ let(:json) { File.read('test/support/json/int1_lin1_str3.json') }
66
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
67
+
68
+ before do
69
+ InterfaceRepository.create({ name: 'int1_lin1_str3', y: 3, x: 3, width: 10, height: 3 })
70
+ end
71
+
72
+ it 'returns the stringified content' do
73
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...")
74
+ end
75
+ end
76
+
77
+ context 'single interface, multiple lines, single stream' do
78
+ let(:json) { File.read('test/support/json/int1_lin2_str1.json') }
79
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
80
+
81
+ before do
82
+ InterfaceRepository.create({ name: 'int1_lin2_str1', y: 3, x: 3, width: 10, height: 3 })
83
+ end
84
+
85
+ it 'returns the stringified content' do
86
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[4;3HSome text...")
87
+ end
88
+ end
89
+
90
+ context 'single interface, multiple lines, multiple streams' do
91
+ let(:json) { File.read('test/support/json/int1_lin2_str3.json') }
92
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
93
+
94
+ before do
95
+ InterfaceRepository.create({ name: 'int1_lin2_str3', y: 3, x: 3, width: 10, height: 3 })
96
+ end
97
+
98
+ it 'returns the stringified content' do
99
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...\e[4;3HSome text... more text...")
100
+ end
101
+ end
102
+
103
+ context 'single interface, multiple lines, multiple streams, streams contain styles' do
104
+ let(:json) { File.read('test/support/json/int1_lin2_str3_styles.json') }
105
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
106
+
107
+ before do
108
+ InterfaceRepository.create({ name: 'int1_lin2_str3_styles', y: 3, x: 3, width: 10, height: 3 })
109
+ end
110
+
111
+ it 'returns the stringified content' do
112
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\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...")
113
+ end
114
+ end
115
+
116
+ context 'multiple interfaces, single line, single stream' do
117
+ let(:json) { File.read('test/support/json/int2_lin1_str1.json') }
118
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
119
+
120
+ before do
121
+ InterfaceRepository.create({ name: 'int2_lin1_str1_1', y: 3, x: 3, width: 10, height: 3 })
122
+ InterfaceRepository.create({ name: 'int2_lin1_str1_2', y: 6, x: 6, width: 10, height: 3 })
123
+ end
124
+
125
+ it 'returns the stringified content' do
126
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6HSome text...")
127
+ end
128
+ end
129
+
130
+ context 'multiple interfaces, single line, multiple streams' do
131
+ let(:json) { File.read('test/support/json/int2_lin1_str3.json') }
132
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
133
+
134
+ before do
135
+ InterfaceRepository.create({ name: 'int2_lin1_str3_1', y: 3, x: 3, width: 10, height: 3 })
136
+ InterfaceRepository.create({ name: 'int2_lin1_str3_2', y: 6, x: 6, width: 10, height: 3 })
137
+ end
138
+
139
+ it 'returns the stringified content' do
140
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6HSome text... more text...")
141
+ end
142
+ end
143
+
144
+ context 'multiple interfaces, multiple lines, single stream' do
145
+ let(:json) { File.read('test/support/json/int2_lin2_str1.json') }
146
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
147
+
148
+ before do
149
+ InterfaceRepository.create({ name: 'int2_lin2_str1_1', y: 3, x: 3, width: 10, height: 3 })
150
+ InterfaceRepository.create({ name: 'int2_lin2_str1_2', y: 6, x: 6, width: 10, height: 3 })
151
+ end
152
+
153
+ it 'returns the stringified content' do
154
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[4;3HSome text...\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[4;3HSome text...")
155
+ end
156
+ end
157
+
158
+ context 'multiple interfaces, multiple lines, multiple streams' do
159
+ let(:json) { File.read('test/support/json/int2_lin2_str3.json') }
160
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
161
+
162
+ before do
163
+ InterfaceRepository.create({ name: 'int2_lin2_str3_1', y: 3, x: 3, width: 10, height: 3 })
164
+ InterfaceRepository.create({ name: 'int2_lin2_str3_2', y: 6, x: 6, width: 10, height: 3 })
165
+ end
166
+
167
+ it 'returns the stringified content' do
168
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...\e[4;3HSome text... more text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6HSome text... more text...\e[7;6HSome text... more text...")
169
+ end
170
+ end
171
+
172
+ context 'multiple interfaces, multiple lines, multiple streams, streams contain styles' do
173
+ let(:json) { File.read('test/support/json/int2_lin2_str3_styles.json') }
174
+ let(:attributes) { Oj.load(json, symbol_keys: true) }
175
+
176
+ before do
177
+ InterfaceRepository.create({ name: 'int2_lin2_str3_styles_1', y: 3, x: 3, width: 10, height: 3 })
178
+ InterfaceRepository.create({ name: 'int2_lin2_str3_styles_2', y: 6, x: 6, width: 10, height: 3 })
179
+ end
180
+
181
+ it 'returns the stringified content' do
182
+ subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\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...\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...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\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...\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...")
183
+ end
184
+ end
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,35 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/foreground'
3
+ require_relative '../../../../lib/vedeu/models/colour'
4
+
5
+ module Vedeu
6
+ describe Foreground do
7
+ let(:described_class) { Foreground }
8
+ let(:described_instance) { Vedeu::Colour.new(attributes) }
9
+ let(:attributes) {
10
+ {
11
+ foreground: '#ff0000'
12
+ }
13
+ }
14
+
15
+ describe '#foreground' do
16
+ let(:subject) { described_instance.foreground }
17
+
18
+ it 'returns a String' do
19
+ subject.must_be_instance_of(String)
20
+ end
21
+
22
+ it 'returns an escape sequence' do
23
+ subject.must_equal("\e[38;5;196m")
24
+ end
25
+
26
+ context 'when the foreground is missing' do
27
+ let(:attributes) { {} }
28
+
29
+ it 'returns an escape sequence' do
30
+ subject.must_equal('')
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,57 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/interface_collection'
3
+ require_relative '../../../../lib/vedeu/models/composition'
4
+
5
+ module Vedeu
6
+ describe InterfaceCollection do
7
+ let(:described_class) { InterfaceCollection }
8
+
9
+ describe '#coerce' do
10
+ let(:subject) { Vedeu::Composition.new({ interfaces: interfaces }).interfaces }
11
+ let(:interfaces) {}
12
+
13
+ context 'when there are no interfaces' do
14
+ it 'returns a Array' do
15
+ subject.must_be_instance_of(Array)
16
+ end
17
+
18
+ it 'returns an empty array' do
19
+ subject.must_equal([])
20
+ end
21
+ end
22
+
23
+ context 'when there is a single interface' do
24
+ let(:interfaces) { { name: 'dummy' } }
25
+
26
+ it 'returns an Interface' do
27
+ subject.must_be_instance_of(Array)
28
+ end
29
+
30
+ it 'contains a single Interface object' do
31
+ subject.size.must_equal(1)
32
+ end
33
+ end
34
+
35
+ context 'when there are multiple interfaces' do
36
+ let(:interfaces) {
37
+ [
38
+ { name: 'dumb' },
39
+ { name: 'dumber' }
40
+ ]
41
+ }
42
+
43
+ it 'returns an Array' do
44
+ subject.must_be_instance_of(Array)
45
+ end
46
+
47
+ it 'returns a collection of Interface objects' do
48
+ subject.first.must_be_instance_of(Interface)
49
+ end
50
+
51
+ it 'contains multiple Line objects' do
52
+ subject.size.must_equal(2)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end