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
@@ -1,35 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe Layer do
5
- let(:described_class) { Layer }
6
- let(:described_instance) { described_class.new(index) }
7
- let(:index) {}
8
-
9
- it 'returns a Layer instance' do
10
- described_instance.must_be_instance_of(Layer)
11
- end
12
-
13
- describe '#index' do
14
- let(:subject) { described_instance.index }
15
-
16
- it 'returns a Fixnum' do
17
- subject.must_be_instance_of(Fixnum)
18
- end
19
-
20
- context 'using a index' do
21
- let(:index) { 2 }
22
-
23
- it 'returns the index' do
24
- subject.must_equal(2)
25
- end
26
- end
27
-
28
- context 'using the default' do
29
- it 'returns the default' do
30
- subject.must_equal(0)
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,13 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe Menu do
5
- let(:described_class) { Menu }
6
- let(:described_instance) { described_class.new(index) }
7
- let(:index) {}
8
-
9
- it 'returns a Menu instance' do
10
- described_instance.must_be_instance_of(Menu)
11
- end
12
- end
13
- end
@@ -1,48 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe Position do
5
- let(:described_class) { Position }
6
- let(:described_instance) { described_class.new }
7
-
8
- it 'returns a Position instance' do
9
- described_instance.must_be_instance_of(Position)
10
- end
11
-
12
- describe '.set' do
13
- let(:subject) { described_class.set }
14
-
15
- it 'returns a String' do
16
- subject.must_be_instance_of(String)
17
- end
18
-
19
- context 'when no coordinates are provided' do
20
- it 'returns a position escape sequence' do
21
- subject.must_equal('')
22
- end
23
- end
24
-
25
- context 'when coordinates are provided' do
26
- let(:subject) { described_class.set(y, x) }
27
- let(:y) { 12 }
28
- let(:x) { 19 }
29
-
30
- it 'returns a position escape sequence' do
31
- subject.must_equal("\e[12;19H")
32
- end
33
- end
34
- end
35
-
36
- describe '.reset' do
37
- let(:subject) { described_class.reset }
38
-
39
- it 'returns a String' do
40
- subject.must_be_instance_of(String)
41
- end
42
-
43
- it 'returns a position escape sequence' do
44
- subject.must_equal("\e[1;1H")
45
- end
46
- end
47
- end
48
- end
@@ -1,132 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe Style do
5
- let(:described_class) { Style }
6
-
7
- describe '.set' do
8
- let(:subject) { described_class.set(style) }
9
- let(:style) {}
10
-
11
- it 'returns a String' do
12
- subject.must_be_instance_of(String)
13
- end
14
-
15
- it 'returns an empty string' do
16
- subject.must_equal('')
17
- end
18
-
19
- context 'when the style is blink' do
20
- let(:style) { :blink }
21
-
22
- it 'returns an escape sequence' do
23
- subject.must_equal("\e[5m")
24
- end
25
- end
26
-
27
- context 'when the style is blink off' do
28
- let(:style) { :blink_off }
29
-
30
- it 'returns an escape sequence' do
31
- subject.must_equal("\e[25m")
32
- end
33
- end
34
-
35
- context 'when the style is bold' do
36
- let(:style) { :bold }
37
-
38
- it 'returns an escape sequence' do
39
- subject.must_equal("\e[1m")
40
- end
41
- end
42
-
43
- context 'when the style is bold off' do
44
- let(:style) { :bold_off }
45
-
46
- it 'returns an escape sequence' do
47
- subject.must_equal("\e[21m")
48
- end
49
- end
50
-
51
- context 'when the style is clear' do
52
- let(:style) { :clear }
53
-
54
- it 'returns an escape sequence' do
55
- subject.must_equal("\e[2J")
56
- end
57
- end
58
-
59
- context 'when the style is hide_cursor' do
60
- let(:style) { :hide_cursor }
61
-
62
- it 'returns an escape sequence' do
63
- subject.must_equal("\e[?25l")
64
- end
65
- end
66
-
67
- context 'when the style is negative' do
68
- let(:style) { :negative }
69
-
70
- it 'returns an escape sequence' do
71
- subject.must_equal("\e[7m")
72
- end
73
- end
74
-
75
- context 'when the style is positive' do
76
- let(:style) { :positive }
77
-
78
- it 'returns an escape sequence' do
79
- subject.must_equal("\e[27m")
80
- end
81
- end
82
-
83
- context 'when the style is reset' do
84
- let(:style) { :reset }
85
-
86
- it 'returns an escape sequence' do
87
- subject.must_equal("\e[0m")
88
- end
89
- end
90
-
91
- context 'when the style is normal' do
92
- let(:style) { :normal }
93
-
94
- it 'returns an escape sequence' do
95
- subject.must_equal("\e[24m\e[21m\e[27m")
96
- end
97
- end
98
-
99
- context 'when the style is dim' do
100
- let(:style) { :dim }
101
-
102
- it 'returns an escape sequence' do
103
- subject.must_equal("\e[2m")
104
- end
105
- end
106
-
107
- context 'when the style is show_cursor' do
108
- let(:style) { :show_cursor }
109
-
110
- it 'returns an escape sequence' do
111
- subject.must_equal("\e[?25h")
112
- end
113
- end
114
-
115
- context 'when the style is underline' do
116
- let(:style) { :underline }
117
-
118
- it 'returns an escape sequence' do
119
- subject.must_equal("\e[4m")
120
- end
121
- end
122
-
123
- context 'when the style is underline off' do
124
- let(:style) { :underline_off }
125
-
126
- it 'returns an escape sequence' do
127
- subject.must_equal("\e[24m")
128
- end
129
- end
130
- end
131
- end
132
- end
@@ -1,73 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe Command do
5
- let(:described_class) { Command }
6
- let(:described_instance) { described_class.new(attributes) }
7
- let(:subject) { described_instance }
8
- let(:attributes) {
9
- {
10
- name: 'dummy',
11
- entity: DummyCommand,
12
- keyword: "dummy",
13
- keypress: "d",
14
- arguments: []
15
- }
16
- }
17
-
18
- it 'returns a Command instance' do
19
- subject.must_be_instance_of(Command)
20
- end
21
-
22
- it 'has a name attribute' do
23
- subject.name.must_be_instance_of(String)
24
-
25
- subject.name.must_equal('dummy')
26
- end
27
-
28
- it 'has an entity attribute' do
29
- subject.entity.must_be_instance_of(Class)
30
-
31
- subject.entity.must_equal(DummyCommand)
32
- end
33
-
34
- it 'has a keypress attribute' do
35
- subject.keypress.must_be_instance_of(String)
36
-
37
- subject.keypress.must_equal('d')
38
- end
39
-
40
- it 'has an keyword attribute' do
41
- subject.keyword.must_be_instance_of(String)
42
-
43
- subject.keyword.must_equal('dummy')
44
- end
45
-
46
- it 'has an arguments attribute' do
47
- subject.arguments.must_be_instance_of(Array)
48
-
49
- subject.arguments.must_equal([])
50
- end
51
-
52
- describe '#execute' do
53
- let(:subject) { described_instance.execute(args) }
54
- let(:args) { [] }
55
-
56
- it 'returns a Symbol' do
57
- subject.must_be_instance_of(Symbol)
58
- end
59
-
60
- it 'returns the result of execution' do
61
- subject.must_equal(:dummy)
62
- end
63
- end
64
-
65
- describe '#executable' do
66
- let(:subject) { described_instance.executable }
67
-
68
- it 'returns a proc' do
69
- subject.class.to_s.must_equal('Proc')
70
- end
71
- end
72
- end
73
- end
@@ -1,27 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe DummyCommand do
5
- let(:described_class) { DummyCommand }
6
- let(:subject) { described_class.dispatch(command) }
7
- let(:command) {}
8
-
9
- it 'returns a Symbol' do
10
- subject.must_be_instance_of(Symbol)
11
- end
12
-
13
- context 'when the value exists' do
14
- let(:command) { :test_command }
15
-
16
- it 'returns the value' do
17
- subject.must_equal(:test_command)
18
- end
19
- end
20
-
21
- context 'when the value does not exist' do
22
- it 'returns the default value' do
23
- subject.must_equal(:dummy)
24
- end
25
- end
26
- end
27
- end
@@ -1,7 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe DummyInterface do
5
- let(:described_class) { DummyInterface }
6
- end
7
- end
@@ -1,79 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe Interface do
5
- let(:described_class) { Interface }
6
- let(:described_instance) { described_class.new(attributes) }
7
- let(:subject) { described_instance }
8
- let(:attributes) {
9
- {
10
- name: 'dummy',
11
- width: 15,
12
- height: 2,
13
- x: 1,
14
- y: 1,
15
- fg: :red,
16
- bg: :blue,
17
- cursor: true,
18
- }
19
- }
20
- let(:result) {}
21
-
22
- before { InterfaceRepository.create(attributes) }
23
- after { InterfaceRepository.reset }
24
-
25
- it 'returns an Interface instance' do
26
- subject.must_be_instance_of(Interface)
27
- end
28
-
29
- it 'sets an instance variable' do
30
- subject.instance_variable_get('@attributes').must_equal(attributes)
31
- end
32
-
33
- it 'sets an instance variable' do
34
- subject.instance_variable_get('@name').must_equal('dummy')
35
- end
36
-
37
- describe '#refresh' do
38
- let(:subject) { described_instance.refresh }
39
-
40
- # it 'returns a Array' do
41
- # subject.must_be_instance_of(Array)
42
- # end
43
- end
44
-
45
- describe '#geometry' do
46
- let(:subject) { described_instance.geometry }
47
-
48
- it 'returns a Geometry' do
49
- subject.must_be_instance_of(Geometry)
50
- end
51
- end
52
-
53
- describe '#colour' do
54
- let(:subject) { described_instance.colour }
55
-
56
- it 'returns a Colour' do
57
- subject.must_be_instance_of(Colour)
58
- end
59
- end
60
-
61
- describe '#cursor' do
62
- let(:subject) { described_instance.cursor }
63
-
64
- context 'when the cursor is on' do
65
- it 'returns an escape sequence' do
66
- subject.must_be_instance_of(String)
67
- end
68
- end
69
-
70
- context 'when the cursor is off' do
71
- let(:attributes) { { cursor: false } }
72
-
73
- it 'returns an escape sequence' do
74
- subject.must_be_instance_of(String)
75
- end
76
- end
77
- end
78
- end
79
- end
@@ -1,45 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe JSONParser do
5
- let(:described_class) { JSONParser }
6
- let(:subject) { described_class.new(json) }
7
- let(:json) { "[]" }
8
-
9
- it 'returns a JSONParser instance' do
10
- subject.must_be_instance_of(JSONParser)
11
- end
12
-
13
- it 'sets an instance variable' do
14
- subject.instance_variable_get("@json").must_equal(json)
15
- end
16
-
17
- context 'when the instance variable is nil' do
18
- let(:json) {}
19
-
20
- it 'set the instance variable to empty string' do
21
- subject.instance_variable_get("@json").must_equal('')
22
- end
23
- end
24
-
25
- describe '#parse' do
26
- let(:subject) { described_class.parse(json) }
27
-
28
- context 'when the JSON contains a single interface' do
29
- let(:json) { File.read('test/support/single_interface.json') }
30
-
31
- it 'returns a Composition instance' do
32
- subject.must_be_instance_of(Buffer::Composition)
33
- end
34
- end
35
-
36
- context 'when the JSON contains multiple interfaces' do
37
- let(:json) { File.read('test/support/multi_interface.json') }
38
-
39
- it 'returns a Composition instance' do
40
- subject.must_be_instance_of(Buffer::Composition)
41
- end
42
- end
43
- end
44
- end
45
- end