vedeu 0.2.11 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/examples/borders_app.rb +171 -0
  3. data/lib/vedeu.rb +1 -1
  4. data/lib/vedeu/api/interface.rb +12 -0
  5. data/lib/vedeu/api/menu.rb +1 -1
  6. data/lib/vedeu/colours/colour.rb +1 -1
  7. data/lib/vedeu/models/border.rb +238 -0
  8. data/lib/vedeu/models/char.rb +1 -1
  9. data/lib/vedeu/models/composition.rb +1 -1
  10. data/lib/vedeu/models/geometry.rb +1 -1
  11. data/lib/vedeu/models/line.rb +1 -1
  12. data/lib/vedeu/models/stream.rb +1 -1
  13. data/lib/vedeu/output/output.rb +1 -1
  14. data/lib/vedeu/output/viewport.rb +34 -3
  15. data/lib/vedeu/repositories/models/cursor.rb +34 -7
  16. data/lib/vedeu/repositories/models/event.rb +1 -1
  17. data/lib/vedeu/repositories/models/group.rb +1 -1
  18. data/lib/vedeu/repositories/models/interface.rb +14 -6
  19. data/lib/vedeu/repositories/models/keymap.rb +1 -1
  20. data/lib/vedeu/repositories/models/offset.rb +1 -1
  21. data/lib/vedeu/support/trace.rb +1 -1
  22. data/test/integration/views/basic_view_test.rb +19 -0
  23. data/test/lib/vedeu/api/api_test.rb +6 -5
  24. data/test/lib/vedeu/api/helpers_test.rb +2 -6
  25. data/test/lib/vedeu/api/interface_test.rb +53 -45
  26. data/test/lib/vedeu/api/menu_test.rb +6 -0
  27. data/test/lib/vedeu/api/stream_test.rb +1 -3
  28. data/test/lib/vedeu/application_test.rb +6 -12
  29. data/test/lib/vedeu/colours/colour_test.rb +16 -5
  30. data/test/lib/vedeu/colours/translator_test.rb +7 -2
  31. data/test/lib/vedeu/configuration/cli_test.rb +9 -0
  32. data/test/lib/vedeu/input/input_test.rb +5 -5
  33. data/test/lib/vedeu/launcher_test.rb +9 -3
  34. data/test/lib/vedeu/models/border_test.rb +197 -0
  35. data/test/lib/vedeu/models/char_test.rb +18 -15
  36. data/test/lib/vedeu/models/composition_test.rb +6 -7
  37. data/test/lib/vedeu/models/geometry_test.rb +43 -49
  38. data/test/lib/vedeu/models/key_test.rb +7 -5
  39. data/test/lib/vedeu/models/line_test.rb +12 -16
  40. data/test/lib/vedeu/models/stream_test.rb +20 -10
  41. data/test/lib/vedeu/models/style_test.rb +9 -10
  42. data/test/lib/vedeu/output/compositor_test.rb +7 -22
  43. data/test/lib/vedeu/output/output_test.rb +34 -33
  44. data/test/lib/vedeu/output/viewport_test.rb +6 -6
  45. data/test/lib/vedeu/repositories/models/buffer_test.rb +13 -18
  46. data/test/lib/vedeu/repositories/models/cursor_test.rb +21 -21
  47. data/test/lib/vedeu/repositories/models/event_test.rb +10 -4
  48. data/test/lib/vedeu/{models → repositories/models}/group_test.rb +8 -9
  49. data/test/lib/vedeu/repositories/models/interface_test.rb +37 -17
  50. data/test/lib/vedeu/repositories/models/keymap_test.rb +6 -6
  51. data/test/lib/vedeu/repositories/models/menu_test.rb +6 -3
  52. data/test/lib/vedeu/repositories/models/offset_test.rb +6 -3
  53. data/test/lib/vedeu/support/bounding_area_test.rb +28 -36
  54. data/test/lib/vedeu/support/grid_test.rb +8 -0
  55. data/test/lib/vedeu/support/keymap_validator_test.rb +5 -8
  56. data/test/lib/vedeu/support/position_test.rb +3 -3
  57. data/test/lib/vedeu/support/registrar_test.rb +13 -7
  58. data/test/lib/vedeu/support/sentence_test.rb +9 -2
  59. data/test/lib/vedeu/support/trace_test.rb +5 -3
  60. data/test/test_helper.rb +12 -0
  61. data/vedeu.gemspec +1 -1
  62. metadata +8 -7
  63. data/lib/vedeu/output/view.rb +0 -64
  64. data/test/lib/vedeu/output/view_test.rb +0 -21
@@ -4,16 +4,16 @@ module Vedeu
4
4
 
5
5
  describe Keymap do
6
6
 
7
+ let(:described) { Keymap.new(attributes) }
8
+ let(:attributes) { {} }
9
+
7
10
  describe '.define' do
8
- it 'returns an instance of Keymap' do
9
- Keymap.define.must_be_instance_of(Keymap)
10
- end
11
+ it { return_type_for(Keymap.define, Keymap) }
11
12
  end
12
13
 
13
14
  describe '#initialize' do
14
- it 'returns an instance of itself' do
15
- Keymap.new.must_be_instance_of(Keymap)
16
- end
15
+ it { return_type_for(described, Keymap) }
16
+ it { assigns(described, '@attributes', { interfaces: [], keys: [] }) }
17
17
  end
18
18
 
19
19
  describe '#method_missing' do
@@ -4,13 +4,16 @@ module Vedeu
4
4
 
5
5
  describe Menu do
6
6
 
7
+ let(:described) { Menu.new(collection) }
7
8
  let(:collection) { ['hydrogen', 'carbon', 'nitrogen', 'oxygen'] }
8
9
  let(:menu) { Menu.new(collection) }
9
10
 
10
11
  describe '#initialize' do
11
- it 'returns a new instance of Menu' do
12
- menu.must_be_instance_of(Menu)
13
- end
12
+ it { return_type_for(described, Menu) }
13
+ it { assigns(described, '@collection', collection) }
14
+ it { assigns(described, '@name', '') }
15
+ it { assigns(described, '@current', 0) }
16
+ it { assigns(described, '@selected', nil) }
14
17
  end
15
18
 
16
19
  describe '#current' do
@@ -3,15 +3,18 @@ require 'test_helper'
3
3
  module Vedeu
4
4
 
5
5
  describe Offset do
6
+ let(:described) { Offset.new(attributes) }
6
7
  let(:offset) { Offset.new(attributes) }
7
8
  let(:attributes) { {} }
8
9
 
9
10
  before { Offsets.reset }
10
11
 
11
12
  describe '#initialize' do
12
- it 'returns a new instance of Offset' do
13
- offset.must_be_instance_of(Offset)
14
- end
13
+ it { return_type_for(described, Offset) }
14
+ it { assigns(described, '@attributes', { name: '', x: 0, y: 0 }) }
15
+ it { assigns(described, '@name', '') }
16
+ it { assigns(described, '@y', 0) }
17
+ it { assigns(described, '@x', 0) }
15
18
  end
16
19
 
17
20
  describe '#attributes' do
@@ -4,133 +4,125 @@ module Vedeu
4
4
 
5
5
  describe BoundingArea do
6
6
 
7
- let(:height) { 15 }
8
- let(:width) { 40 }
9
- let(:described_instance) { BoundingArea.new(height, width) }
7
+ let(:described) { BoundingArea.new(height, width) }
8
+ let(:height) { 15 }
9
+ let(:width) { 40 }
10
10
 
11
11
  describe '#initialize' do
12
- it 'returns an instance of itself' do
13
- described_instance.must_be_instance_of(BoundingArea)
14
- end
15
-
16
- it 'assigns the height' do
17
- described_instance.instance_variable_get("@height").must_equal(height)
18
- end
19
-
20
- it 'assigns the width' do
21
- described_instance.instance_variable_get("@width").must_equal(width)
22
- end
12
+ it { return_type_for(described, BoundingArea) }
13
+ it { assigns(described, '@height', height) }
14
+ it { assigns(described, '@width', width) }
23
15
  end
24
16
 
25
17
  describe '#height' do
26
18
  it 'returns the height' do
27
- described_instance.height.must_equal(height)
19
+ described.height.must_equal(height)
28
20
  end
29
21
  end
30
22
 
31
23
  describe '#width' do
32
24
  it 'returns the width' do
33
- described_instance.width.must_equal(width)
25
+ described.width.must_equal(width)
34
26
  end
35
27
  end
36
28
 
37
29
  describe '#top' do
38
30
  context 'when an offset is provided' do
39
31
  it 'returns the new top with the offset applied' do
40
- described_instance.top(5).must_equal(6)
32
+ described.top(5).must_equal(6)
41
33
  end
42
34
 
43
35
  context 'when the offset is greater or equal to the height' do
44
36
  it 'returns the height' do
45
- described_instance.top(20).must_equal(15)
37
+ described.top(20).must_equal(15)
46
38
  end
47
39
  end
48
40
 
49
41
  context 'when the offset is less than or equal to 1' do
50
- it { described_instance.top(-1).must_equal(1) }
42
+ it { described.top(-1).must_equal(1) }
51
43
  end
52
44
  end
53
45
 
54
46
  context 'when an offset is not provided' do
55
- it { described_instance.top.must_equal(1) }
47
+ it { described.top.must_equal(1) }
56
48
  end
57
49
 
58
50
  context 'alias_method #y' do
59
- it { described_instance.y.must_equal(1) }
51
+ it { described.y.must_equal(1) }
60
52
  end
61
53
  end
62
54
 
63
55
  describe '#bottom' do
64
56
  context 'when an offset is provided' do
65
57
  it 'returns the new bottom with the offset applied' do
66
- described_instance.bottom(5).must_equal(10)
58
+ described.bottom(5).must_equal(10)
67
59
  end
68
60
 
69
61
  context 'when the offset is greater or equal to the height' do
70
- it { described_instance.bottom(30).must_equal(1) }
62
+ it { described.bottom(30).must_equal(1) }
71
63
  end
72
64
 
73
65
  context 'when the offset is less than 0' do
74
- it { described_instance.bottom(-1).must_equal(height) }
66
+ it { described.bottom(-1).must_equal(height) }
75
67
  end
76
68
  end
77
69
 
78
70
  context 'when an offset is not provided' do
79
- it { described_instance.bottom.must_equal(15) }
71
+ it { described.bottom.must_equal(15) }
80
72
  end
81
73
 
82
74
  context 'alias_method #yn' do
83
- it { described_instance.yn.must_equal(15) }
75
+ it { described.yn.must_equal(15) }
84
76
  end
85
77
  end
86
78
 
87
79
  describe '#left' do
88
80
  context 'when an offset is provided' do
89
81
  it 'returns the new left with the offset applied' do
90
- described_instance.left(5).must_equal(6)
82
+ described.left(5).must_equal(6)
91
83
  end
92
84
 
93
85
  context 'when the offset is greater or equal to the width' do
94
86
  it 'returns the width' do
95
- described_instance.left(50).must_equal(40)
87
+ described.left(50).must_equal(40)
96
88
  end
97
89
  end
98
90
 
99
91
  context 'when the offset is less than or equal to 1' do
100
- it { described_instance.left(-1).must_equal(1) }
92
+ it { described.left(-1).must_equal(1) }
101
93
  end
102
94
  end
103
95
 
104
96
  context 'when an offset is not provided' do
105
- it { described_instance.left.must_equal(1) }
97
+ it { described.left.must_equal(1) }
106
98
  end
107
99
 
108
100
  context 'alias_method #x' do
109
- it { described_instance.x.must_equal(1) }
101
+ it { described.x.must_equal(1) }
110
102
  end
111
103
  end
112
104
 
113
105
  describe '#right' do
114
106
  context 'when an offset is provided' do
115
107
  it 'returns the new right with the offset applied' do
116
- described_instance.right(5).must_equal(35)
108
+ described.right(5).must_equal(35)
117
109
  end
118
110
 
119
111
  context 'when the offset is greater or equal to the width' do
120
- it { described_instance.right(50).must_equal(1) }
112
+ it { described.right(50).must_equal(1) }
121
113
  end
122
114
 
123
115
  context 'when the offset is less than 0' do
124
- it { described_instance.right(-1).must_equal(40) }
116
+ it { described.right(-1).must_equal(40) }
125
117
  end
126
118
  end
127
119
 
128
120
  context 'when an offset is not provided' do
129
- it { described_instance.right.must_equal(40) }
121
+ it { described.right.must_equal(40) }
130
122
  end
131
123
 
132
124
  context 'alias_method #xn' do
133
- it { described_instance.xn.must_equal(40) }
125
+ it { described.xn.must_equal(40) }
134
126
  end
135
127
  end
136
128
 
@@ -16,6 +16,14 @@ module Vedeu
16
16
 
17
17
  describe Grid do
18
18
 
19
+ let(:described) { Grid.new(value) }
20
+ let(:value) { 2 }
21
+
22
+ describe '#initialize' do
23
+ it { return_type_for(described, Grid) }
24
+ it { assigns(described, '@value', value) }
25
+ end
26
+
19
27
  describe '.columns' do
20
28
  it 'raises an exception if the value is less than 1' do
21
29
  proc { Grid.columns(0) }.must_raise(OutOfRange)
@@ -4,6 +4,7 @@ module Vedeu
4
4
 
5
5
  describe KeymapValidator do
6
6
 
7
+ let(:described) { KeymapValidator.new(storage, key, interface) }
7
8
  let(:storage) {
8
9
  {
9
10
  'dubnium' => {
@@ -50,14 +51,10 @@ module Vedeu
50
51
  end
51
52
 
52
53
  describe '#initialize' do
53
- it 'returns an instance of itself' do
54
- storage = {}
55
- key = ''
56
- interface = ''
57
-
58
- KeymapValidator.new(storage, key, interface)
59
- .must_be_instance_of(KeymapValidator)
60
- end
54
+ it { return_type_for(described, KeymapValidator) }
55
+ it { assigns(described, '@storage', storage) }
56
+ it { assigns(described, '@key', key) }
57
+ it { assigns(described, '@interface', interface) }
61
58
  end
62
59
 
63
60
  end # KeymapValidator
@@ -4,10 +4,10 @@ module Vedeu
4
4
 
5
5
  describe Position do
6
6
 
7
+ let(:described) { Position.new(12, 19) }
8
+
7
9
  describe '#initialize' do
8
- it 'returns an instance of Position' do
9
- Position.new.must_be_instance_of(Position)
10
- end
10
+ it { return_type_for(described, Position) }
11
11
  end
12
12
 
13
13
  describe '#to_s' do
@@ -4,6 +4,14 @@ module Vedeu
4
4
 
5
5
  describe Registrar do
6
6
 
7
+ let(:described) { Registrar.new(attributes) }
8
+ let(:attributes) {
9
+ {
10
+ name: 'mendelevium',
11
+ group: 'elements'
12
+ }
13
+ }
14
+
7
15
  before do
8
16
  Buffers.reset
9
17
  Interfaces.reset
@@ -12,13 +20,6 @@ module Vedeu
12
20
  end
13
21
 
14
22
  describe '.record' do
15
- let(:attributes) {
16
- {
17
- name: 'mendelevium',
18
- group: 'elements'
19
- }
20
- }
21
-
22
23
  it 'raises an exception if the attributes does not have a :name key' do
23
24
  attributes = { no_name_key: '' }
24
25
 
@@ -83,6 +84,11 @@ module Vedeu
83
84
  end
84
85
  end
85
86
 
87
+ describe '#initialize' do
88
+ it { return_type_for(described, Registrar) }
89
+ it { assigns(described, '@attributes', attributes) }
90
+ end
91
+
86
92
  end # Registrar
87
93
 
88
94
  end # Vedeu
@@ -4,8 +4,15 @@ module Vedeu
4
4
 
5
5
  describe Sentence do
6
6
 
7
- let(:elements) { ['Hydrogen'] }
8
- let(:label) { 'elements' }
7
+ let(:described) { Sentence.new(elements, label) }
8
+ let(:elements) { ['Hydrogen'] }
9
+ let(:label) { 'elements' }
10
+
11
+ describe '#initialize' do
12
+ it { return_type_for(described, Sentence) }
13
+ it { assigns(described, '@elements', elements) }
14
+ it { assigns(described, '@label', label) }
15
+ end
9
16
 
10
17
  describe '.construct' do
11
18
  subject { Sentence.construct(elements, label) }
@@ -4,14 +4,16 @@ module Vedeu
4
4
 
5
5
  describe Trace do
6
6
 
7
+ let(:described) { Trace.new(options) }
8
+ let(:options) { {} }
9
+
7
10
  describe '.call' do
8
11
  it { skip }
9
12
  end
10
13
 
11
14
  describe '#initialize' do
12
- it 'returns an instance of Trace' do
13
- Trace.new.must_be_instance_of(Trace)
14
- end
15
+ it { return_type_for(described, Trace) }
16
+ it { assigns(described, '@options', options) }
15
17
  end
16
18
 
17
19
  describe '#trace' do
data/test/test_helper.rb CHANGED
@@ -16,6 +16,18 @@ module MiniTest
16
16
  class << self
17
17
  alias_method :context, :describe
18
18
  end # Spec eigenclass
19
+
20
+ def assigns(subject, instance_variable, value)
21
+ subject.instance_variable_get(instance_variable).must_equal(value)
22
+ end
23
+
24
+ def return_type_for(subject, value)
25
+ subject.must_be_instance_of(value)
26
+ end
27
+
28
+ def return_value_for(subject, value)
29
+ subject.must_equal(value)
30
+ end
19
31
  end
20
32
  end
21
33
 
data/vedeu.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'vedeu'
7
- spec.version = '0.2.11'
7
+ spec.version = '0.2.12'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -186,6 +186,7 @@ files:
186
186
  - docs/api.md
187
187
  - docs/events.md
188
188
  - docs/getting_started.md
189
+ - examples/borders_app.rb
189
190
  - examples/configuration_app.rb
190
191
  - examples/cursor_app.rb
191
192
  - examples/focus_app.rb
@@ -211,6 +212,7 @@ files:
211
212
  - lib/vedeu/configuration/configuration.rb
212
213
  - lib/vedeu/input/input.rb
213
214
  - lib/vedeu/launcher.rb
215
+ - lib/vedeu/models/border.rb
214
216
  - lib/vedeu/models/char.rb
215
217
  - lib/vedeu/models/composition.rb
216
218
  - lib/vedeu/models/geometry.rb
@@ -220,7 +222,6 @@ files:
220
222
  - lib/vedeu/models/style.rb
221
223
  - lib/vedeu/output/compositor.rb
222
224
  - lib/vedeu/output/output.rb
223
- - lib/vedeu/output/view.rb
224
225
  - lib/vedeu/output/viewport.rb
225
226
  - lib/vedeu/repositories/buffers.rb
226
227
  - lib/vedeu/repositories/cursors.rb
@@ -290,17 +291,16 @@ files:
290
291
  - test/lib/vedeu/configuration/configuration_test.rb
291
292
  - test/lib/vedeu/input/input_test.rb
292
293
  - test/lib/vedeu/launcher_test.rb
294
+ - test/lib/vedeu/models/border_test.rb
293
295
  - test/lib/vedeu/models/char_test.rb
294
296
  - test/lib/vedeu/models/composition_test.rb
295
297
  - test/lib/vedeu/models/geometry_test.rb
296
- - test/lib/vedeu/models/group_test.rb
297
298
  - test/lib/vedeu/models/key_test.rb
298
299
  - test/lib/vedeu/models/line_test.rb
299
300
  - test/lib/vedeu/models/stream_test.rb
300
301
  - test/lib/vedeu/models/style_test.rb
301
302
  - test/lib/vedeu/output/compositor_test.rb
302
303
  - test/lib/vedeu/output/output_test.rb
303
- - test/lib/vedeu/output/view_test.rb
304
304
  - test/lib/vedeu/output/viewport_test.rb
305
305
  - test/lib/vedeu/repositories/buffers_test.rb
306
306
  - test/lib/vedeu/repositories/cursors_test.rb
@@ -313,6 +313,7 @@ files:
313
313
  - test/lib/vedeu/repositories/models/buffer_test.rb
314
314
  - test/lib/vedeu/repositories/models/cursor_test.rb
315
315
  - test/lib/vedeu/repositories/models/event_test.rb
316
+ - test/lib/vedeu/repositories/models/group_test.rb
316
317
  - test/lib/vedeu/repositories/models/interface_test.rb
317
318
  - test/lib/vedeu/repositories/models/keymap_test.rb
318
319
  - test/lib/vedeu/repositories/models/menu_test.rb
@@ -405,17 +406,16 @@ test_files:
405
406
  - test/lib/vedeu/configuration/configuration_test.rb
406
407
  - test/lib/vedeu/input/input_test.rb
407
408
  - test/lib/vedeu/launcher_test.rb
409
+ - test/lib/vedeu/models/border_test.rb
408
410
  - test/lib/vedeu/models/char_test.rb
409
411
  - test/lib/vedeu/models/composition_test.rb
410
412
  - test/lib/vedeu/models/geometry_test.rb
411
- - test/lib/vedeu/models/group_test.rb
412
413
  - test/lib/vedeu/models/key_test.rb
413
414
  - test/lib/vedeu/models/line_test.rb
414
415
  - test/lib/vedeu/models/stream_test.rb
415
416
  - test/lib/vedeu/models/style_test.rb
416
417
  - test/lib/vedeu/output/compositor_test.rb
417
418
  - test/lib/vedeu/output/output_test.rb
418
- - test/lib/vedeu/output/view_test.rb
419
419
  - test/lib/vedeu/output/viewport_test.rb
420
420
  - test/lib/vedeu/repositories/buffers_test.rb
421
421
  - test/lib/vedeu/repositories/cursors_test.rb
@@ -428,6 +428,7 @@ test_files:
428
428
  - test/lib/vedeu/repositories/models/buffer_test.rb
429
429
  - test/lib/vedeu/repositories/models/cursor_test.rb
430
430
  - test/lib/vedeu/repositories/models/event_test.rb
431
+ - test/lib/vedeu/repositories/models/group_test.rb
431
432
  - test/lib/vedeu/repositories/models/interface_test.rb
432
433
  - test/lib/vedeu/repositories/models/keymap_test.rb
433
434
  - test/lib/vedeu/repositories/models/menu_test.rb