vedeu 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +6 -0
  4. data/bin/vedeu_drb_client +8 -3
  5. data/bin/vedeu_drb_server +113 -0
  6. data/bin/vedeu_test +1 -1
  7. data/docs/events.md +0 -127
  8. data/examples/borders_app.rb +17 -7
  9. data/examples/configuration_app.rb +1 -1
  10. data/examples/cursor_app.rb +4 -2
  11. data/examples/drb_app.rb +113 -0
  12. data/examples/focus_app.rb +1 -1
  13. data/examples/geometry_app.rb +1 -1
  14. data/examples/hello_world.rb +1 -1
  15. data/examples/lines_app.rb +1 -1
  16. data/features/start_stop.feature +1 -1
  17. data/inch.yml +5 -0
  18. data/lib/vedeu/all.rb +2 -0
  19. data/lib/vedeu/api.rb +1 -0
  20. data/lib/vedeu/application.rb +17 -36
  21. data/lib/vedeu/bindings.rb +134 -27
  22. data/lib/vedeu/buffers/display_buffer.rb +1 -4
  23. data/lib/vedeu/configuration/api.rb +15 -14
  24. data/lib/vedeu/configuration/cli.rb +17 -16
  25. data/lib/vedeu/configuration/configuration.rb +3 -1
  26. data/lib/vedeu/cursor/cursor.rb +6 -8
  27. data/lib/vedeu/cursor/move_cursor.rb +1 -0
  28. data/lib/vedeu/cursor/toggle_cursor.rb +1 -0
  29. data/lib/vedeu/debug.rb +23 -0
  30. data/lib/vedeu/distributed/all.rb +1 -1
  31. data/lib/vedeu/distributed/client.rb +55 -13
  32. data/lib/vedeu/distributed/server.rb +207 -0
  33. data/lib/vedeu/distributed/subprocess.rb +22 -21
  34. data/lib/vedeu/distributed/templates/default_application.vedeu +3 -1
  35. data/lib/vedeu/distributed/test_application.rb +2 -1
  36. data/lib/vedeu/distributed/uri.rb +1 -0
  37. data/lib/vedeu/dsl/all.rb +4 -2
  38. data/lib/vedeu/dsl/components/border.rb +11 -10
  39. data/lib/vedeu/dsl/components/geometry.rb +1 -0
  40. data/lib/vedeu/dsl/components/keymap.rb +1 -0
  41. data/lib/vedeu/dsl/components/menu.rb +1 -0
  42. data/lib/vedeu/dsl/interface.rb +1 -0
  43. data/lib/vedeu/dsl/line.rb +3 -1
  44. data/lib/vedeu/dsl/shared/colour.rb +1 -0
  45. data/lib/vedeu/dsl/shared/style.rb +1 -0
  46. data/lib/vedeu/dsl/shared/text.rb +2 -0
  47. data/lib/vedeu/dsl/shared/use.rb +3 -0
  48. data/lib/vedeu/dsl/stream.rb +3 -1
  49. data/lib/vedeu/dsl/view.rb +1 -0
  50. data/lib/vedeu/events/event.rb +9 -6
  51. data/lib/vedeu/events/trigger.rb +18 -7
  52. data/lib/vedeu/exceptions.rb +4 -1
  53. data/lib/vedeu/input/input.rb +1 -0
  54. data/lib/vedeu/input/key.rb +0 -1
  55. data/lib/vedeu/input/keymap.rb +5 -3
  56. data/lib/vedeu/input/keys.rb +1 -0
  57. data/lib/vedeu/input/mapper.rb +1 -0
  58. data/lib/vedeu/launcher.rb +35 -12
  59. data/lib/vedeu/main_loop.rb +53 -0
  60. data/lib/vedeu/models/collection.rb +11 -3
  61. data/lib/vedeu/models/focus.rb +3 -3
  62. data/lib/vedeu/models/geometry.rb +8 -16
  63. data/lib/vedeu/models/group.rb +1 -0
  64. data/lib/vedeu/models/menu.rb +2 -1
  65. data/lib/vedeu/models/model.rb +7 -1
  66. data/lib/vedeu/models/view/char.rb +52 -44
  67. data/lib/vedeu/models/view/chars.rb +1 -0
  68. data/lib/vedeu/models/view/composition.rb +2 -1
  69. data/lib/vedeu/models/view/interface.rb +5 -3
  70. data/lib/vedeu/models/view/interfaces.rb +1 -0
  71. data/lib/vedeu/models/view/line.rb +2 -1
  72. data/lib/vedeu/models/view/stream.rb +2 -1
  73. data/lib/vedeu/models/view/streams.rb +1 -0
  74. data/lib/vedeu/output/all.rb +4 -0
  75. data/lib/vedeu/output/border.rb +75 -206
  76. data/lib/vedeu/output/compositor.rb +1 -0
  77. data/lib/vedeu/output/html_char.rb +119 -0
  78. data/lib/vedeu/output/html_renderer.rb +89 -0
  79. data/lib/vedeu/output/output.rb +48 -44
  80. data/lib/vedeu/output/position_index.rb +12 -1
  81. data/lib/vedeu/output/renderer.rb +28 -0
  82. data/lib/vedeu/output/viewport.rb +14 -14
  83. data/lib/vedeu/output/virtual_buffer.rb +56 -0
  84. data/lib/vedeu/output/virtual_terminal.rb +42 -34
  85. data/lib/vedeu/output/wordwrap.rb +3 -0
  86. data/lib/vedeu/output/writer.rb +13 -1
  87. data/lib/vedeu/presentation/background.rb +1 -0
  88. data/lib/vedeu/presentation/colour.rb +8 -7
  89. data/lib/vedeu/presentation/foreground.rb +1 -0
  90. data/lib/vedeu/presentation/presentation.rb +43 -7
  91. data/lib/vedeu/presentation/translator.rb +12 -0
  92. data/lib/vedeu/repositories/repository.rb +8 -8
  93. data/lib/vedeu/support/bounding_area.rb +2 -0
  94. data/lib/vedeu/support/coercions.rb +2 -1
  95. data/lib/vedeu/support/common.rb +1 -0
  96. data/lib/vedeu/support/console.rb +17 -23
  97. data/lib/vedeu/support/content_geometry.rb +2 -0
  98. data/lib/vedeu/support/coordinate.rb +1 -0
  99. data/lib/vedeu/support/esc.rb +58 -29
  100. data/lib/vedeu/support/grid.rb +1 -0
  101. data/lib/vedeu/support/limit.rb +9 -0
  102. data/lib/vedeu/support/log.rb +31 -9
  103. data/lib/vedeu/support/node.rb +8 -18
  104. data/lib/vedeu/support/position.rb +13 -34
  105. data/lib/vedeu/support/position_validator.rb +3 -0
  106. data/lib/vedeu/support/read.rb +1 -0
  107. data/lib/vedeu/support/refresh.rb +3 -2
  108. data/lib/vedeu/support/terminal.rb +11 -5
  109. data/lib/vedeu/support/trace.rb +16 -1
  110. data/lib/vedeu/support/visible.rb +2 -0
  111. data/lib/vedeu/support/write.rb +1 -0
  112. data/lib/vedeu/traps.rb +1 -0
  113. data/lib/vedeu.rb +2 -0
  114. data/test/integration/distributed_test.rb +10 -8
  115. data/test/lib/vedeu/api_test.rb +3 -7
  116. data/test/lib/vedeu/application_test.rb +2 -5
  117. data/test/lib/vedeu/configuration/api_test.rb +12 -0
  118. data/test/lib/vedeu/cursor/cursor_test.rb +2 -0
  119. data/test/lib/vedeu/distributed/client_test.rb +17 -7
  120. data/test/lib/vedeu/distributed/server_test.rb +56 -0
  121. data/test/lib/vedeu/distributed/test_application_test.rb +7 -3
  122. data/test/lib/vedeu/dsl/components/border_test.rb +10 -2
  123. data/test/lib/vedeu/dsl/interface_test.rb +6 -0
  124. data/test/lib/vedeu/dsl/line_test.rb +19 -0
  125. data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -26
  126. data/test/lib/vedeu/dsl/shared/text_test.rb +8 -1
  127. data/test/lib/vedeu/dsl/stream_test.rb +13 -1
  128. data/test/lib/vedeu/input/input_test.rb +1 -1
  129. data/test/lib/vedeu/input/key_test.rb +3 -16
  130. data/test/lib/vedeu/launcher_test.rb +11 -1
  131. data/test/lib/vedeu/main_loop_test.rb +41 -0
  132. data/test/lib/vedeu/models/geometry_test.rb +15 -34
  133. data/test/lib/vedeu/models/view/char_test.rb +44 -45
  134. data/test/lib/vedeu/models/view/interface_test.rb +6 -0
  135. data/test/lib/vedeu/models/view/line_test.rb +1 -1
  136. data/test/lib/vedeu/models/view/stream_test.rb +1 -1
  137. data/test/lib/vedeu/output/border_test.rb +6 -5
  138. data/test/lib/vedeu/output/compositor_test.rb +2 -20
  139. data/test/lib/vedeu/output/html_char_test.rb +85 -0
  140. data/test/lib/vedeu/output/html_renderer_test.rb +37 -0
  141. data/test/lib/vedeu/output/position_index_test.rb +2 -10
  142. data/test/lib/vedeu/output/renderer_test.rb +24 -0
  143. data/test/lib/vedeu/output/virtual_buffer_test.rb +53 -0
  144. data/test/lib/vedeu/output/virtual_terminal_test.rb +32 -2
  145. data/test/lib/vedeu/presentation/background_test.rb +41 -1
  146. data/test/lib/vedeu/presentation/colour_test.rb +10 -6
  147. data/test/lib/vedeu/presentation/foreground_test.rb +46 -6
  148. data/test/lib/vedeu/presentation/presentation_test.rb +44 -1
  149. data/test/lib/vedeu/presentation/translator_test.rb +34 -0
  150. data/test/lib/vedeu/repositories/repository_test.rb +1 -1
  151. data/test/lib/vedeu/support/bounding_area_test.rb +4 -12
  152. data/test/lib/vedeu/support/console_test.rb +9 -50
  153. data/test/lib/vedeu/support/esc_test.rb +7 -7
  154. data/test/lib/vedeu/support/position_test.rb +42 -0
  155. data/test/lib/vedeu/support/terminal_test.rb +5 -20
  156. data/test/lib/vedeu/support/write_test.rb +42 -18
  157. data/test/support/helpers/all.rb +0 -1
  158. data/test/support/helpers/repository_test_module.rb +1 -0
  159. data/test/test_helper.rb +5 -2
  160. data/vedeu.gemspec +7 -5
  161. metadata +60 -14
  162. data/lib/vedeu/distributed/application.rb +0 -91
  163. data/test/lib/vedeu/distributed/application_test.rb +0 -24
  164. data/test/support/helpers/presentation.rb +0 -16
@@ -2,12 +2,15 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
+ class FakeRenderer; end
6
+
5
7
  describe VirtualTerminal do
6
8
 
7
9
  let(:described) { Vedeu::VirtualTerminal }
8
- let(:instance) { described.new(height, width) }
10
+ let(:instance) { described.new(height, width, renderer) }
9
11
  let(:height) { 5 }
10
12
  let(:width) { 10 }
13
+ let(:renderer) { Vedeu::HTMLRenderer }
11
14
 
12
15
  describe '#initialize' do
13
16
  it { instance.must_be_instance_of(Vedeu::VirtualTerminal) }
@@ -15,8 +18,21 @@ module Vedeu
15
18
  it { instance.instance_variable_get('@cell_width').must_equal(9) }
16
19
  it { instance.instance_variable_get('@height').must_equal(5) }
17
20
  it { instance.instance_variable_get('@width').must_equal(10) }
21
+ it { instance.instance_variable_get('@renderer').must_equal(Vedeu::HTMLRenderer) }
18
22
  end
19
23
 
24
+ describe 'attr_accessor' do
25
+ context '#renderer' do
26
+ subject { instance.renderer }
27
+
28
+ it { subject.must_equal(Vedeu::HTMLRenderer) }
29
+ end
30
+ context '#renderer=' do
31
+ subject { instance.renderer=(Vedeu::FakeRenderer) }
32
+
33
+ it { subject.must_equal(Vedeu::FakeRenderer) }
34
+ end
35
+ end
20
36
  describe 'attr_reader' do
21
37
  context '#cell_height' do
22
38
  subject { instance.cell_height }
@@ -81,8 +97,22 @@ module Vedeu
81
97
  end
82
98
  end
83
99
 
100
+ describe '#output' do
101
+ let(:data) {}
102
+
103
+ subject { instance.output(data) }
104
+
105
+ it { subject.must_be_instance_of(Array) }
106
+ end
107
+
108
+ describe '#reset' do
109
+ subject { instance.reset }
110
+
111
+ it { subject.must_be_instance_of(Array) }
112
+ end
113
+
84
114
  describe '#write' do
85
- let(:data) { Vedeu::Char.new('a') }
115
+ let(:data) { Vedeu::Char.new({ value: 'a' }) }
86
116
 
87
117
  subject { instance.write(y, x, data) }
88
118
 
@@ -4,6 +4,10 @@ module Vedeu
4
4
 
5
5
  describe Background do
6
6
 
7
+ let(:described) { Vedeu::Background }
8
+ let(:instance) { described.new(colour) }
9
+ let(:colour) {}
10
+
7
11
  describe '.escape_sequence' do
8
12
  describe 'when the colour is empty' do
9
13
  it 'returns an empty String' do
@@ -16,7 +20,7 @@ module Vedeu
16
20
  red: "\e[41m",
17
21
  yellow: "\e[43m",
18
22
  magenta: "\e[45m",
19
- white: "\e[47m",
23
+ white: "\e[107m",
20
24
  default: "\e[49m",
21
25
  unknown: '',
22
26
  }.map do |colour, result|
@@ -82,6 +86,42 @@ module Vedeu
82
86
  end
83
87
  end
84
88
 
89
+ describe '.to_html' do
90
+ subject { instance.to_html }
91
+
92
+ context 'when the colour is empty' do
93
+ let(:colour) {}
94
+
95
+ it 'returns an empty String' do
96
+ subject.must_equal('')
97
+ end
98
+ end
99
+
100
+ context 'when the colour is named (3-bit / 8 colours)' do
101
+ let(:colour) { :red }
102
+
103
+ it 'returns an empty String' do
104
+ subject.must_equal('')
105
+ end
106
+ end
107
+
108
+ context 'when the colour is numbered (8-bit / 256 colours)' do
109
+ let(:colour) { 118 }
110
+
111
+ it 'returns an empty String' do
112
+ subject.must_equal('')
113
+ end
114
+ end
115
+
116
+ context 'when the colour is a CSS value' do
117
+ let(:colour) { '#afd700' }
118
+
119
+ it 'returns the colour as a CSS value' do
120
+ subject.must_equal('#afd700')
121
+ end
122
+ end
123
+ end
124
+
85
125
  end # Background
86
126
 
87
127
  end # Vedeu
@@ -21,7 +21,7 @@ module Vedeu
21
21
  describe '#background' do
22
22
  subject { instance.background }
23
23
 
24
- it { subject.must_be_instance_of(String) }
24
+ it { subject.must_be_instance_of(Vedeu::Background) }
25
25
 
26
26
  context 'with a background' do
27
27
  let(:attributes) {
@@ -30,20 +30,22 @@ module Vedeu
30
30
  }
31
31
  }
32
32
 
33
- it { subject.must_equal("\e[48;2;0;0;0m") }
33
+ it { subject.to_s.must_equal("\e[48;2;0;0;0m") }
34
+ it { subject.to_html.must_equal('#000000') }
34
35
  end
35
36
 
36
37
  context 'without a background' do
37
38
  let(:attributes) { {} }
38
39
 
39
- it { subject.must_equal('') }
40
+ it { subject.to_s.must_equal('') }
41
+ it { subject.to_html.must_equal('') }
40
42
  end
41
43
  end
42
44
 
43
45
  describe '#foreground' do
44
46
  subject { instance.foreground }
45
47
 
46
- it { subject.must_be_instance_of(String) }
48
+ it { subject.must_be_instance_of(Vedeu::Foreground) }
47
49
 
48
50
  context 'with a foreground' do
49
51
  let(:attributes) {
@@ -52,13 +54,15 @@ module Vedeu
52
54
  }
53
55
  }
54
56
 
55
- it { subject.must_equal("\e[38;2;255;0;0m") }
57
+ it { subject.to_s.must_equal("\e[38;2;255;0;0m") }
58
+ it { subject.to_html.must_equal('#ff0000') }
56
59
  end
57
60
 
58
61
  context 'without a foreground' do
59
62
  let(:attributes) { {} }
60
63
 
61
- it { subject.must_equal('') }
64
+ it { subject.to_s.must_equal('') }
65
+ it { subject.to_html.must_equal('') }
62
66
  end
63
67
  end
64
68
 
@@ -4,19 +4,23 @@ module Vedeu
4
4
 
5
5
  describe Foreground do
6
6
 
7
+ let(:described) { Vedeu::Foreground }
8
+ let(:instance) { described.new(colour) }
9
+ let(:colour) {}
10
+
7
11
  describe '.escape_sequence' do
8
- describe 'when the colour is empty' do
12
+ context 'when the colour is empty' do
9
13
  it 'returns an empty String' do
10
14
  Foreground.escape_sequence('').must_equal('')
11
15
  end
12
16
  end
13
17
 
14
- describe 'when the colour is named (3-bit / 8 colours)' do
18
+ context 'when the colour is named (3-bit / 8 colours)' do
15
19
  {
16
20
  red: "\e[31m",
17
21
  yellow: "\e[33m",
18
22
  magenta: "\e[35m",
19
- white: "\e[37m",
23
+ white: "\e[97m",
20
24
  default: "\e[39m",
21
25
  unknown: '',
22
26
  }.map do |colour, result|
@@ -26,7 +30,7 @@ module Vedeu
26
30
  end
27
31
  end
28
32
 
29
- describe 'when the colour is numbered (8-bit / 256 colours)' do
33
+ context 'when the colour is numbered (8-bit / 256 colours)' do
30
34
  {
31
35
  24 => "\e[38;5;24m",
32
36
  56 => "\e[38;5;56m",
@@ -43,7 +47,7 @@ module Vedeu
43
47
  end
44
48
  end
45
49
 
46
- describe 'when the colour is a CSS value (8-bit / 256 colours)' do
50
+ context 'when the colour is a CSS value (8-bit / 256 colours)' do
47
51
  before { Configuration.stubs(:colour_mode).returns(8) }
48
52
 
49
53
  {
@@ -63,7 +67,7 @@ module Vedeu
63
67
  end
64
68
  end
65
69
 
66
- describe 'when the colour is a CSS value (24-bit / 16.8mil colours)' do
70
+ context 'when the colour is a CSS value (24-bit / 16.8mil colours)' do
67
71
  {
68
72
  '#5f0000' => "\e[38;2;95;0;0m",
69
73
  '#008700' => "\e[38;2;0;135;0m",
@@ -82,6 +86,42 @@ module Vedeu
82
86
  end
83
87
  end
84
88
 
89
+ describe '.to_html' do
90
+ subject { instance.to_html }
91
+
92
+ context 'when the colour is empty' do
93
+ let(:colour) {}
94
+
95
+ it 'returns an empty String' do
96
+ subject.must_equal('')
97
+ end
98
+ end
99
+
100
+ context 'when the colour is named (3-bit / 8 colours)' do
101
+ let(:colour) { :red }
102
+
103
+ it 'returns an empty String' do
104
+ subject.must_equal('')
105
+ end
106
+ end
107
+
108
+ context 'when the colour is numbered (8-bit / 256 colours)' do
109
+ let(:colour) { 118 }
110
+
111
+ it 'returns an empty String' do
112
+ subject.must_equal('')
113
+ end
114
+ end
115
+
116
+ context 'when the colour is a CSS value' do
117
+ let(:colour) { '#afd700' }
118
+
119
+ it 'returns the colour as a CSS value' do
120
+ subject.must_equal('#afd700')
121
+ end
122
+ end
123
+ end
124
+
85
125
  end # Foreground
86
126
 
87
127
  end # Vedeu
@@ -2,10 +2,47 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
+ class PresentationTestClass
6
+ include Presentation
7
+
8
+ def attributes
9
+ {
10
+ colour: { background: '#000033', foreground: '#aadd00' },
11
+ style: ['bold']
12
+ }
13
+ end
14
+ end # PresentationTestClass
15
+
5
16
  describe Presentation do
6
17
 
7
18
  let(:receiver) { PresentationTestClass.new }
8
19
 
20
+ describe '#background' do
21
+ subject { receiver.background }
22
+
23
+ it { subject.must_be_instance_of(Vedeu::Background) }
24
+ end
25
+
26
+ describe '#foreground' do
27
+ subject { receiver.foreground }
28
+
29
+ it { subject.must_be_instance_of(Vedeu::Foreground) }
30
+ end
31
+
32
+ describe '#parent_background' do
33
+ subject { receiver.parent_background }
34
+ end
35
+
36
+ describe '#parent_foreground' do
37
+ subject { receiver.parent_foreground }
38
+ end
39
+
40
+ describe '#colour' do
41
+ subject { receiver.colour }
42
+
43
+ it { subject.must_be_instance_of(Vedeu::Colour) }
44
+ end
45
+
9
46
  describe '#colour=' do
10
47
  let(:colour) { Colour.new({ foreground: '#00ff00', background: '#000000' }) }
11
48
 
@@ -14,6 +51,12 @@ module Vedeu
14
51
  it { subject.must_be_instance_of(Colour) }
15
52
  end
16
53
 
54
+ describe '#style' do
55
+ subject { receiver.style }
56
+
57
+ it { subject.must_be_instance_of(Vedeu::Style) }
58
+ end
59
+
17
60
  describe '#style=' do
18
61
  let(:style) { Style.new('normal') }
19
62
 
@@ -26,7 +69,7 @@ module Vedeu
26
69
  let(:line) {
27
70
  Vedeu::Line.new({
28
71
  streams: [],
29
- parent: mock('Interface'),
72
+ parent: Vedeu::Interface.new,
30
73
  colour: Colour.new({ foreground: '#00ff00', background: '#000000' }),
31
74
  style: Style.new('normal')
32
75
  })
@@ -56,6 +56,40 @@ module Vedeu
56
56
  end
57
57
  end
58
58
 
59
+ describe '#to_html' do
60
+ subject { instance.to_html }
61
+
62
+ context 'when no colour is given' do
63
+ let(:colour) {}
64
+
65
+ it { subject.must_equal('') }
66
+ end
67
+
68
+ context 'when the colour is a terminal named colour; e.g. :red' do
69
+ let(:colour) { :red }
70
+
71
+ it { subject.must_equal('') }
72
+ end
73
+
74
+ context 'when the colour is a terminal numbered colour; e.g. 122' do
75
+ let(:colour) { 122 }
76
+
77
+ it { subject.must_equal('') }
78
+ end
79
+
80
+ context 'when the colour is a HTML/CSS colour (RGB specified)' do
81
+ let(:colour) { '#ff0000' }
82
+
83
+ it { subject.must_equal('#ff0000') }
84
+ end
85
+
86
+ context 'when the colour is not supported' do
87
+ let(:colour) { [:not_supported] }
88
+
89
+ it { subject.must_equal('') }
90
+ end
91
+ end
92
+
59
93
  end # Translator
60
94
 
61
95
  end # Vedeu
@@ -83,7 +83,7 @@ module Vedeu
83
83
  end
84
84
 
85
85
  context 'when the storage is not empty' do
86
- let(:storage) { [mock] }
86
+ let(:storage) { [:item] }
87
87
 
88
88
  it { subject.must_equal(false) }
89
89
  end
@@ -47,9 +47,7 @@ module Vedeu
47
47
  it { described.top.must_equal(1) }
48
48
  end
49
49
 
50
- context 'alias_method #y' do
51
- it { described.y.must_equal(1) }
52
- end
50
+ it { described.must_respond_to(:y) }
53
51
  end
54
52
 
55
53
  describe '#bottom' do
@@ -71,9 +69,7 @@ module Vedeu
71
69
  it { described.bottom.must_equal(15) }
72
70
  end
73
71
 
74
- context 'alias_method #yn' do
75
- it { described.yn.must_equal(15) }
76
- end
72
+ it { described.must_respond_to(:yn) }
77
73
  end
78
74
 
79
75
  describe '#left' do
@@ -97,9 +93,7 @@ module Vedeu
97
93
  it { described.left.must_equal(1) }
98
94
  end
99
95
 
100
- context 'alias_method #x' do
101
- it { described.x.must_equal(1) }
102
- end
96
+ it { described.must_respond_to(:x) }
103
97
  end
104
98
 
105
99
  describe '#right' do
@@ -121,9 +115,7 @@ module Vedeu
121
115
  it { described.right.must_equal(40) }
122
116
  end
123
117
 
124
- context 'alias_method #xn' do
125
- it { described.xn.must_equal(40) }
126
- end
118
+ it { described.must_respond_to(:xn) }
127
119
  end
128
120
 
129
121
  end # BoundingArea
@@ -77,17 +77,8 @@ module Vedeu
77
77
 
78
78
  it { subject.must_be_instance_of(Fixnum) }
79
79
 
80
- context 'alias method #tyn' do
81
- subject { instance.tyn }
82
-
83
- it { subject.must_be_instance_of(Fixnum) }
84
- end
85
-
86
- context 'alias method #yn' do
87
- subject { instance.yn }
88
-
89
- it { subject.must_be_instance_of(Fixnum) }
90
- end
80
+ it { instance.must_respond_to(:tyn) }
81
+ it { instance.must_respond_to(:yn) }
91
82
  end
92
83
 
93
84
  describe '#origin' do
@@ -96,29 +87,10 @@ module Vedeu
96
87
  it { subject.must_be_instance_of(Fixnum) }
97
88
  it { subject.must_equal(1) }
98
89
 
99
- context 'alias method #x' do
100
- subject { instance.x }
101
-
102
- it { subject.must_be_instance_of(Fixnum) }
103
- end
104
-
105
- context 'alias method #y' do
106
- subject { instance.y }
107
-
108
- it { subject.must_be_instance_of(Fixnum) }
109
- end
110
-
111
- context 'alias method #tx' do
112
- subject { instance.tx }
113
-
114
- it { subject.must_be_instance_of(Fixnum) }
115
- end
116
-
117
- context 'alias method #ty' do
118
- subject { instance.ty }
119
-
120
- it { subject.must_be_instance_of(Fixnum) }
121
- end
90
+ it { instance.must_respond_to(:x) }
91
+ it { instance.must_respond_to(:y) }
92
+ it { instance.must_respond_to(:tx) }
93
+ it { instance.must_respond_to(:ty) }
122
94
  end
123
95
 
124
96
  describe '#raw' do
@@ -135,11 +107,7 @@ module Vedeu
135
107
  it { subject.must_be_instance_of(Array) }
136
108
  it { subject.must_equal([24, 32]) }
137
109
 
138
- context 'alias method #winsize' do
139
- subject { instance.winsize }
140
-
141
- it { subject.must_be_instance_of(Array) }
142
- end
110
+ it { instance.must_respond_to(:winsize) }
143
111
  end
144
112
 
145
113
  describe '#width' do
@@ -147,17 +115,8 @@ module Vedeu
147
115
 
148
116
  it { subject.must_be_instance_of(Fixnum) }
149
117
 
150
- context 'alias method #txn' do
151
- subject { instance.txn }
152
-
153
- it { subject.must_be_instance_of(Fixnum) }
154
- end
155
-
156
- context 'alias method #xn' do
157
- subject { instance.xn }
158
-
159
- it { subject.must_be_instance_of(Fixnum) }
160
- end
118
+ it { instance.must_respond_to(:txn) }
119
+ it { instance.must_respond_to(:xn) }
161
120
  end
162
121
 
163
122
  end # Console
@@ -52,7 +52,7 @@ module Vedeu
52
52
  end
53
53
 
54
54
  it 'returns an escape sequence when the style is bg_reset' do
55
- Esc.string('bg_reset').must_equal("\e[48;2;49m")
55
+ Esc.string('bg_reset').must_equal("\e[49m")
56
56
  end
57
57
 
58
58
  it 'returns an escape sequence when the style is blink' do
@@ -72,19 +72,19 @@ module Vedeu
72
72
  end
73
73
 
74
74
  it 'returns an escape sequence when the style is clear' do
75
- Esc.string('clear').must_equal("\e[38;2;39m\e[48;2;49m\e[2J")
75
+ Esc.string('clear').must_equal("\e[39m\e[49m\e[2J")
76
76
  end
77
77
 
78
78
  it 'returns an escape sequence when the style is clear_line' do
79
- Esc.string('clear_line').must_equal("\e[38;2;39m\e[48;2;49m\e[2K")
79
+ Esc.string('clear_line').must_equal("\e[39m\e[49m\e[2K")
80
80
  end
81
81
 
82
82
  it 'returns an escape sequence when the style is colour_reset' do
83
- Esc.string('colour_reset').must_equal("\e[38;2;39m\e[48;2;49m")
83
+ Esc.string('colour_reset').must_equal("\e[39m\e[49m")
84
84
  end
85
85
 
86
86
  it 'returns an escape sequence when the style is fg_reset' do
87
- Esc.string('fg_reset').must_equal("\e[38;2;39m")
87
+ Esc.string('fg_reset').must_equal("\e[39m")
88
88
  end
89
89
 
90
90
  it 'returns an escape sequence when the style is hide_cursor' do
@@ -92,11 +92,11 @@ module Vedeu
92
92
  end
93
93
 
94
94
  it 'returns an escape sequence when the style is screen_init' do
95
- Esc.string('screen_init').must_equal("\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l")
95
+ Esc.string('screen_init').must_equal("\e[0m\e[39m\e[49m\e[2J\e[?25l")
96
96
  end
97
97
 
98
98
  it 'returns an escape sequence when the style is screen_exit' do
99
- Esc.string('screen_exit').must_equal("\e[?25h\e[38;2;39m\e[48;2;49m\e[0m")
99
+ Esc.string('screen_exit').must_equal("\e[?25h\e[39m\e[49m\e[0m")
100
100
  end
101
101
 
102
102
  it 'returns an escape sequence when the style is negative' do
@@ -15,12 +15,54 @@ module Vedeu
15
15
  it { instance.instance_variable_get('@x').must_equal(x) }
16
16
  end
17
17
 
18
+ describe '.coerce' do
19
+ let(:value) {}
20
+
21
+ subject { described.coerce(value) }
22
+
23
+ context 'when the value is already a Position' do
24
+ let(:value) { instance }
25
+
26
+ it { subject.must_equal(instance) }
27
+ end
28
+
29
+ context 'when the value is an Array' do
30
+ let(:value) { [2, 8] }
31
+
32
+ it { subject.must_be_instance_of(described) }
33
+ it { subject.y.must_equal(2) }
34
+ it { subject.x.must_equal(8) }
35
+ end
36
+
37
+ context 'when the value is something unhandled' do
38
+ it { subject.must_be_instance_of(NilClass) }
39
+ end
40
+ end
41
+
18
42
  describe '#inspect' do
19
43
  subject { instance.inspect }
20
44
 
21
45
  it { subject.must_equal("<Vedeu::Position (y:12 x:19)>") }
22
46
  end
23
47
 
48
+ describe '#==' do
49
+ let(:other) {}
50
+
51
+ subject { instance == other }
52
+
53
+ context 'when they are equal' do
54
+ let(:other) { described.new(12, 19) }
55
+
56
+ it { subject.must_equal(true) }
57
+ end
58
+
59
+ context 'when they are not equal' do
60
+ let(:other) { described.new(2, 9) }
61
+
62
+ it { subject.must_equal(false) }
63
+ end
64
+ end
65
+
24
66
  describe '#to_s' do
25
67
  # subject { described.new.to_s }
26
68
 
@@ -98,7 +98,7 @@ module Vedeu
98
98
  subject { Terminal.clear }
99
99
 
100
100
  it 'clears the screen' do
101
- subject.must_equal(["\e[38;2;39m\e[48;2;49m\e[2J"])
101
+ subject.must_equal(["\e[39m\e[49m\e[2J"])
102
102
  end
103
103
  end
104
104
 
@@ -193,15 +193,8 @@ module Vedeu
193
193
  Terminal.origin.must_equal(1)
194
194
  end
195
195
 
196
- context 'alias_methods' do
197
- it 'returns 1' do
198
- Terminal.x.must_equal(1)
199
- end
200
-
201
- it 'returns 1' do
202
- Terminal.y.must_equal(1)
203
- end
204
- end
196
+ it { Terminal.must_respond_to(:x) }
197
+ it { Terminal.must_respond_to(:y) }
205
198
  end
206
199
 
207
200
  describe '.width' do
@@ -218,11 +211,7 @@ module Vedeu
218
211
  end
219
212
  end
220
213
 
221
- context 'alias_methods' do
222
- it 'returns the xn coordinate of the terminal' do
223
- Terminal.xn.must_equal(80)
224
- end
225
- end
214
+ it { Terminal.must_respond_to(:xn) }
226
215
  end
227
216
 
228
217
  describe '.height' do
@@ -239,11 +228,7 @@ module Vedeu
239
228
  end
240
229
  end
241
230
 
242
- context 'alias_methods' do
243
- it 'returns the yn coordinate of the terminal' do
244
- Terminal.yn.must_equal(25)
245
- end
246
- end
231
+ it { Terminal.must_respond_to(:yn) }
247
232
  end
248
233
 
249
234
  describe '.size' do