vedeu 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/LICENSE.txt +5 -0
  4. data/bin/vedeu +3 -1
  5. data/docs/api.md +2 -0
  6. data/examples/cursor_app/cursor_app.rb +22 -7
  7. data/examples/hello_world.rb +42 -0
  8. data/lib/vedeu.rb +5 -5
  9. data/lib/vedeu/api/api.rb +16 -33
  10. data/lib/vedeu/api/helpers.rb +86 -0
  11. data/lib/vedeu/api/interface.rb +60 -17
  12. data/lib/vedeu/api/keymap.rb +5 -0
  13. data/lib/vedeu/api/line.rb +52 -34
  14. data/lib/vedeu/api/menu.rb +1 -1
  15. data/lib/vedeu/api/stream.rb +0 -34
  16. data/lib/vedeu/configuration/api.rb +10 -10
  17. data/lib/vedeu/configuration/cli.rb +1 -1
  18. data/lib/vedeu/launcher.rb +21 -6
  19. data/lib/vedeu/models/background.rb +1 -1
  20. data/lib/vedeu/models/composition.rb +1 -1
  21. data/lib/vedeu/models/cursor.rb +25 -35
  22. data/lib/vedeu/models/foreground.rb +1 -1
  23. data/lib/vedeu/models/geometry.rb +216 -6
  24. data/lib/vedeu/models/interface.rb +14 -16
  25. data/lib/vedeu/models/keymap.rb +38 -6
  26. data/lib/vedeu/models/line.rb +1 -1
  27. data/lib/vedeu/models/stream.rb +1 -1
  28. data/lib/vedeu/output/compositor.rb +1 -1
  29. data/lib/vedeu/output/render.rb +1 -5
  30. data/lib/vedeu/output/viewport.rb +37 -2
  31. data/lib/vedeu/repositories/buffers.rb +21 -27
  32. data/lib/vedeu/repositories/cursors.rb +3 -15
  33. data/lib/vedeu/repositories/focus.rb +2 -6
  34. data/lib/vedeu/repositories/groups.rb +1 -1
  35. data/lib/vedeu/repositories/interfaces.rb +1 -1
  36. data/lib/vedeu/repositories/keymaps.rb +26 -22
  37. data/lib/vedeu/repositories/menus.rb +1 -1
  38. data/lib/vedeu/repositories/offsets.rb +30 -12
  39. data/lib/vedeu/repositories/positional.rb +23 -0
  40. data/lib/vedeu/support/colour_translator.rb +1 -16
  41. data/lib/vedeu/support/esc.rb +23 -28
  42. data/lib/vedeu/support/event.rb +6 -14
  43. data/lib/vedeu/{output → support}/refresh.rb +0 -0
  44. data/lib/vedeu/support/registrar.rb +6 -14
  45. data/lib/vedeu/support/repository.rb +3 -2
  46. data/lib/vedeu/support/terminal.rb +9 -13
  47. data/lib/vedeu/support/trace.rb +2 -3
  48. data/test/integration/cursors_test.rb +9 -0
  49. data/test/integration/views/basic_view_test.rb +19 -0
  50. data/test/lib/vedeu/api/api_test.rb +28 -5
  51. data/test/lib/vedeu/api/composition_test.rb +7 -3
  52. data/test/lib/vedeu/api/defined_test.rb +9 -3
  53. data/test/lib/vedeu/api/helpers_test.rb +39 -5
  54. data/test/lib/vedeu/api/interface_test.rb +88 -8
  55. data/test/lib/vedeu/api/keymap_test.rb +5 -3
  56. data/test/lib/vedeu/api/line_test.rb +9 -3
  57. data/test/lib/vedeu/api/menu_test.rb +11 -7
  58. data/test/lib/vedeu/api/stream_test.rb +9 -31
  59. data/test/lib/vedeu/application_test.rb +25 -2
  60. data/test/lib/vedeu/configuration/api_test.rb +5 -3
  61. data/test/lib/vedeu/configuration/cli_test.rb +5 -3
  62. data/test/lib/vedeu/configuration/configuration_test.rb +5 -2
  63. data/test/lib/vedeu/input/input_test.rb +5 -2
  64. data/test/lib/vedeu/launcher_test.rb +37 -2
  65. data/test/lib/vedeu/models/background_test.rb +6 -2
  66. data/test/lib/vedeu/models/char_test.rb +9 -6
  67. data/test/lib/vedeu/models/colour_test.rb +6 -2
  68. data/test/lib/vedeu/models/composition_test.rb +4 -2
  69. data/test/lib/vedeu/models/cursor_test.rb +27 -16
  70. data/test/lib/vedeu/models/foreground_test.rb +6 -2
  71. data/test/lib/vedeu/models/geometry_test.rb +6 -2
  72. data/test/lib/vedeu/models/interface_test.rb +5 -2
  73. data/test/lib/vedeu/models/keymap_test.rb +6 -4
  74. data/test/lib/vedeu/models/line_test.rb +5 -2
  75. data/test/lib/vedeu/models/offset_test.rb +7 -3
  76. data/test/lib/vedeu/models/stream_test.rb +4 -2
  77. data/test/lib/vedeu/models/style_test.rb +5 -2
  78. data/test/lib/vedeu/output/clear_test.rb +6 -2
  79. data/test/lib/vedeu/output/compositor_test.rb +8 -4
  80. data/test/lib/vedeu/output/render_test.rb +9 -6
  81. data/test/lib/vedeu/output/view_test.rb +7 -3
  82. data/test/lib/vedeu/output/viewport_test.rb +42 -9
  83. data/test/lib/vedeu/repositories/buffers_test.rb +52 -12
  84. data/test/lib/vedeu/repositories/cursors_test.rb +4 -26
  85. data/test/lib/vedeu/repositories/events_test.rb +6 -2
  86. data/test/lib/vedeu/repositories/focus_test.rb +5 -2
  87. data/test/lib/vedeu/repositories/groups_test.rb +5 -2
  88. data/test/lib/vedeu/repositories/interfaces_test.rb +4 -2
  89. data/test/lib/vedeu/repositories/keymaps_test.rb +8 -2
  90. data/test/lib/vedeu/repositories/menus_test.rb +3 -2
  91. data/test/lib/vedeu/repositories/offsets_test.rb +26 -19
  92. data/test/lib/vedeu/repositories/positional_test.rb +50 -0
  93. data/test/lib/vedeu/support/coercions_test.rb +7 -3
  94. data/test/lib/vedeu/support/colour_translator_test.rb +6 -2
  95. data/test/lib/vedeu/support/common_test.rb +5 -3
  96. data/test/lib/vedeu/support/esc_test.rb +6 -2
  97. data/test/lib/vedeu/support/event_test.rb +6 -2
  98. data/test/lib/vedeu/support/grid_test.rb +9 -3
  99. data/test/lib/vedeu/support/keymap_validator_test.rb +5 -2
  100. data/test/lib/vedeu/support/log_test.rb +4 -2
  101. data/test/lib/vedeu/support/menu_test.rb +10 -2
  102. data/test/lib/vedeu/support/position_test.rb +10 -2
  103. data/test/lib/vedeu/support/presentation_test.rb +6 -3
  104. data/test/lib/vedeu/{output → support}/refresh_test.rb +6 -2
  105. data/test/lib/vedeu/support/registrar_test.rb +2 -2
  106. data/test/lib/vedeu/support/repository_test.rb +4 -3
  107. data/test/lib/vedeu/support/terminal_test.rb +6 -2
  108. data/test/lib/vedeu/support/trace_test.rb +17 -2
  109. data/test/lib/vedeu_test.rb +1 -1
  110. data/vedeu.gemspec +2 -2
  111. metadata +13 -13
  112. data/lib/vedeu/output/area.rb +0 -284
  113. data/lib/vedeu/support/move.rb +0 -50
  114. data/test/lib/vedeu/output/area_test.rb +0 -242
  115. data/test/lib/vedeu/support/move_test.rb +0 -35
@@ -1,6 +1,29 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Application do
5
- end
6
- end
6
+
7
+ describe '.start' do
8
+ it { skip }
9
+ end
10
+
11
+ describe '.restart' do
12
+ it { skip }
13
+ end
14
+
15
+ describe '.stop' do
16
+ it { skip }
17
+ end
18
+
19
+ describe '#initialize' do
20
+ it { skip }
21
+ end
22
+
23
+ describe '#start' do
24
+ it { skip }
25
+ end
26
+
27
+ end # Application
28
+
29
+ end # Vedeu
@@ -1,6 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  module Configuration
5
6
 
6
7
  describe API do
@@ -242,7 +243,8 @@ module Vedeu
242
243
  end
243
244
  end
244
245
 
245
- end
246
+ end # API
247
+
248
+ end # Configuration
246
249
 
247
- end
248
- end
250
+ end # Vedeu
@@ -1,6 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  module Configuration
5
6
 
6
7
  describe CLI do
@@ -82,7 +83,8 @@ module Vedeu
82
83
  # end
83
84
  # end
84
85
 
85
- end
86
+ end # CLI
87
+
88
+ end # Configuration
86
89
 
87
- end
88
- end
90
+ end # Vedeu
@@ -1,7 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Configuration do
6
+
5
7
  before { Configuration.reset }
6
8
  after { Configuration.reset }
7
9
 
@@ -63,5 +65,6 @@ module Vedeu
63
65
  end
64
66
  end
65
67
 
66
- end
67
- end
68
+ end # Configuration
69
+
70
+ end # Vedeu
@@ -1,6 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Input do
5
6
 
6
7
  describe '#initialize' do
@@ -63,5 +64,7 @@ module Vedeu
63
64
  end
64
65
  end
65
66
  end
66
- end
67
- end
67
+
68
+ end # Input
69
+
70
+ end # Vedeu
@@ -1,6 +1,41 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Launcher do
5
- end
6
- end
6
+ before do
7
+ Configuration.stubs(:configure)
8
+ Application.stubs(:start)
9
+ Kernel.stubs(:exit)
10
+ Kernel.stubs(:puts)
11
+ end
12
+
13
+ describe '.execute' do
14
+ it { skip }
15
+ end
16
+
17
+ describe '#initialize' do
18
+ it 'returns an instance of itself' do
19
+ Launcher.new.must_be_instance_of(Launcher)
20
+ end
21
+ end
22
+
23
+ describe '#execute!' do
24
+ it 'returns 0 for successful execution' do
25
+ Launcher.new.execute!.must_equal(0)
26
+ end
27
+
28
+ context 'when execution causes an uncaught exception' do
29
+ before { Application.stubs(:start).raises(StandardError) }
30
+
31
+ it 'returns 1 for unsuccessful execution' do
32
+ skip 'This test is incorrect and fails.'
33
+
34
+ Launcher.new.execute!.must_equal(1)
35
+ end
36
+ end
37
+ end
38
+
39
+ end # Launcher
40
+
41
+ end # Vedeu
@@ -1,7 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Background do
6
+
5
7
  describe '.escape_sequence' do
6
8
  describe 'when the colour is empty' do
7
9
  it 'returns an empty String' do
@@ -79,5 +81,7 @@ module Vedeu
79
81
  end
80
82
  end
81
83
  end
82
- end
83
- end
84
+
85
+ end # Background
86
+
87
+ end # Vedeu
@@ -1,8 +1,10 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Char do
5
- let(:instance) { Char.new(attributes) }
6
+
7
+ let(:char) { Char.new(attributes) }
6
8
  let(:attributes) {
7
9
  {
8
10
  colour: { foreground: '#ffff00', background: '#0000ff' },
@@ -21,20 +23,20 @@ module Vedeu
21
23
 
22
24
  describe '#initialize' do
23
25
  it 'returns a new instance of Char' do
24
- instance.must_be_instance_of(Char)
26
+ char.must_be_instance_of(Char)
25
27
  end
26
28
  end
27
29
 
28
30
  describe '#to_s' do
29
31
  it 'returns a String' do
30
- instance.to_s.must_be_instance_of(String)
32
+ char.to_s.must_be_instance_of(String)
31
33
  end
32
34
 
33
35
  it 'returns the escape sequences and content' do
34
36
  # - char colours and style as set in Stream#chars.
35
37
  # - the value.
36
38
  # - the colours and style of the line which the Char belongs to.
37
- instance.to_s.must_equal(
39
+ char.to_s.must_equal(
38
40
  "\e[38;2;255;255;0m\e[48;2;0;0;255m" \
39
41
  "a" \
40
42
  "\e[38;2;0;255;0m\e[48;2;255;0;255m"
@@ -42,5 +44,6 @@ module Vedeu
42
44
  end
43
45
  end
44
46
 
45
- end
46
- end
47
+ end # Char
48
+
49
+ end # Vedeu
@@ -1,7 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Colour do
6
+
5
7
  describe '#initialize' do
6
8
  it 'returns an instance of itself' do
7
9
  attributes = {}
@@ -58,5 +60,7 @@ module Vedeu
58
60
  Colour.new.to_s.must_equal('')
59
61
  end
60
62
  end
61
- end
62
- end
63
+
64
+ end # Colour
65
+
66
+ end # Vedeu
@@ -3,6 +3,7 @@ require 'test_helper'
3
3
  require 'json'
4
4
 
5
5
  module Vedeu
6
+
6
7
  describe Composition do
7
8
 
8
9
  before { Buffers.reset }
@@ -40,5 +41,6 @@ module Vedeu
40
41
  end
41
42
  end
42
43
 
43
- end
44
- end
44
+ end # Composition
45
+
46
+ end # Vedeu
@@ -1,13 +1,15 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Cursor do
6
+
5
7
  let(:attributes) {
6
8
  {
7
- name: 'silver',
8
- state: :show,
9
- x: 19,
10
- y: 8
9
+ name: 'silver',
10
+ state: :show,
11
+ x: 19,
12
+ y: 8
11
13
  }
12
14
  }
13
15
 
@@ -96,16 +98,6 @@ module Vedeu
96
98
  end
97
99
  end
98
100
 
99
- describe '#visible?' do
100
- it 'returns false when the cursor is not visible' do
101
- Cursor.new({ state: :hide }).visible?.must_equal(false)
102
- end
103
-
104
- it 'returns true when the cursor is visible' do
105
- Cursor.new({ state: :show }).visible?.must_equal(true)
106
- end
107
- end
108
-
109
101
  describe '#show' do
110
102
  it 'sets the state attribute to :show' do
111
103
  cursor = Cursor.new(attributes)
@@ -127,10 +119,27 @@ module Vedeu
127
119
  cursor.attributes.must_equal(
128
120
  { name: 'silver', state: :hide, x: 19, y: 8 }
129
121
  )
122
+ cursor.to_s.must_equal("\e[8;19H\e[?25l")
130
123
  end
131
124
  end
132
125
 
133
126
  describe '#to_s' do
127
+ context 'when the cursor state is :show' do
128
+ it 'returns an escape sequence for showing the cursor (and position)' do
129
+ cursor = Cursor.new(attributes)
130
+ cursor.show
131
+ cursor.to_s.must_equal("\e[8;19H\e[?25h")
132
+ end
133
+ end
134
+
135
+ context 'when the cursor state is :hide' do
136
+ it 'returns an escape sequence for hiding the cursor (and position)' do
137
+ cursor = Cursor.new(attributes)
138
+ cursor.hide
139
+ cursor.to_s.must_equal("\e[8;19H\e[?25l")
140
+ end
141
+ end
142
+
134
143
  it 'returns the escape sequence to position and set the visibility of ' \
135
144
  'the cursor' do
136
145
  Cursor.new(attributes).to_s.must_equal("\e[8;19H\e[?25h")
@@ -143,5 +152,7 @@ module Vedeu
143
152
  end.must_equal("\e[8;19H\e[?25h\e[8;19H\e[?25h")
144
153
  end
145
154
  end
146
- end
147
- end
155
+
156
+ end # Cursor
157
+
158
+ end # Vedeu
@@ -1,7 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Foreground do
6
+
5
7
  describe '.escape_sequence' do
6
8
  describe 'when the colour is empty' do
7
9
  it 'returns an empty String' do
@@ -79,5 +81,7 @@ module Vedeu
79
81
  end
80
82
  end
81
83
  end
82
- end
83
- end
84
+
85
+ end # Foreground
86
+
87
+ end # Vedeu
@@ -1,7 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Geometry do
6
+
5
7
  describe '#initialize' do
6
8
  it 'returns an instance of itself' do
7
9
  attributes = {}
@@ -273,5 +275,7 @@ module Vedeu
273
275
  )
274
276
  end
275
277
  end
276
- end
277
- end
278
+
279
+ end # Geometry
280
+
281
+ end # Vedeu
@@ -1,6 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Interface do
5
6
  let(:interface) { Vedeu.use('#initialize') }
6
7
 
@@ -26,6 +27,7 @@ module Vedeu
26
27
  it 'returns the value' do
27
28
  interface.attributes.must_equal(
28
29
  {
30
+ cursor: :hide,
29
31
  name: '#initialize',
30
32
  group: 'my_group',
31
33
  lines: [],
@@ -103,5 +105,6 @@ module Vedeu
103
105
  end
104
106
  end
105
107
 
106
- end
107
- end
108
+ end # Interface
109
+
110
+ end # Vedeu
@@ -1,11 +1,12 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Keymap do
5
6
 
6
7
  describe '.define' do
7
- it '' do
8
- skip
8
+ it 'returns an instance of Keymap' do
9
+ Keymap.define.must_be_instance_of(Keymap)
9
10
  end
10
11
  end
11
12
 
@@ -21,5 +22,6 @@ module Vedeu
21
22
  end
22
23
  end
23
24
 
24
- end
25
- end
25
+ end # Keymap
26
+
27
+ end # Vedeu
@@ -1,6 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Line do
5
6
  let(:line) { Line.new(attributes) }
6
7
  let(:attributes) {
@@ -120,5 +121,7 @@ module Vedeu
120
121
  Line.new.some_missing_method(:test).must_equal(nil)
121
122
  end
122
123
  end
123
- end
124
- end
124
+
125
+ end # Line
126
+
127
+ end # Vedeu
@@ -1,6 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
+
4
5
  describe Offset do
5
6
  let(:offset) { Offset.new(attributes) }
6
7
  let(:attributes) { {} }
@@ -14,8 +15,10 @@ module Vedeu
14
15
  end
15
16
 
16
17
  describe '#attributes' do
18
+ let(:attributes) { { name: 'roentgenium', y: 5, x: 12 } }
19
+
17
20
  it 'returns the attributes' do
18
- skip
21
+ offset.attributes.must_equal(attributes)
19
22
  end
20
23
  end
21
24
 
@@ -117,5 +120,6 @@ module Vedeu
117
120
  end
118
121
  end
119
122
 
120
- end
121
- end
123
+ end # Offset
124
+
125
+ end # Vedeu