vedeu 0.4.14 → 0.4.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -3
  3. data/README.md +47 -35
  4. data/docs/views.md +1 -1
  5. data/examples/material_colours_app.rb +0 -5
  6. data/lib/vedeu/cursor/cursor.rb +4 -5
  7. data/lib/vedeu/cursor/move.rb +52 -84
  8. data/lib/vedeu/cursor/refresh_cursor.rb +12 -18
  9. data/lib/vedeu/debug.rb +3 -1
  10. data/lib/vedeu/geometry/area.rb +0 -2
  11. data/lib/vedeu/geometry/coordinate.rb +10 -0
  12. data/lib/vedeu/geometry/dimension.rb +34 -18
  13. data/lib/vedeu/geometry/null_geometry.rb +10 -1
  14. data/lib/vedeu/geometry/position.rb +1 -1
  15. data/lib/vedeu/geometry/position_validator.rb +2 -2
  16. data/lib/vedeu/input/mapper.rb +4 -18
  17. data/lib/vedeu/main_loop.rb +1 -3
  18. data/lib/vedeu/models/cell.rb +11 -17
  19. data/lib/vedeu/models/interface.rb +0 -7
  20. data/lib/vedeu/output/border.rb +34 -61
  21. data/lib/vedeu/output/clear.rb +39 -14
  22. data/lib/vedeu/output/colour.rb +15 -15
  23. data/lib/vedeu/output/esc.rb +1 -1
  24. data/lib/vedeu/output/html_char.rb +18 -24
  25. data/lib/vedeu/output/null_border.rb +14 -10
  26. data/lib/vedeu/output/presentation.rb +32 -8
  27. data/lib/vedeu/output/renderers/all.rb +1 -0
  28. data/lib/vedeu/output/renderers/text_renderer.rb +40 -0
  29. data/lib/vedeu/output/translator.rb +2 -4
  30. data/lib/vedeu/output/viewport.rb +22 -13
  31. data/lib/vedeu/output/virtual_terminal.rb +0 -1
  32. data/lib/vedeu/repositories/repositories/borders.rb +3 -4
  33. data/lib/vedeu/repositories/repositories/cursors.rb +13 -1
  34. data/lib/vedeu/repositories/repositories/geometries.rb +1 -1
  35. data/lib/vedeu/support/all.rb +1 -0
  36. data/lib/vedeu/support/options.rb +65 -0
  37. data/lib/vedeu/support/terminal.rb +3 -5
  38. data/test/lib/vedeu/cursor/cursor_test.rb +0 -5
  39. data/test/lib/vedeu/cursor/move_test.rb +87 -92
  40. data/test/lib/vedeu/geometry/null_geometry_test.rb +3 -1
  41. data/test/lib/vedeu/models/cell_test.rb +13 -16
  42. data/test/lib/vedeu/models/interface_test.rb +0 -17
  43. data/test/lib/vedeu/output/border_test.rb +0 -22
  44. data/test/lib/vedeu/output/clear_test.rb +4 -2
  45. data/test/lib/vedeu/output/null_border_test.rb +8 -4
  46. data/test/lib/vedeu/output/renderers/text_renderer_test.rb +24 -0
  47. data/test/lib/vedeu/repositories/repositories/borders_test.rb +1 -13
  48. data/test/lib/vedeu/support/options_test.rb +70 -0
  49. data/vedeu.gemspec +1 -1
  50. metadata +8 -2
@@ -5,7 +5,8 @@ module Vedeu
5
5
  describe NullGeometry do
6
6
 
7
7
  let(:described) { Vedeu::NullGeometry }
8
- let(:instance) { described.new }
8
+ let(:instance) { described.new(_name) }
9
+ let(:_name) { 'null_geometry' }
9
10
 
10
11
  before do
11
12
  Vedeu::Terminal.stubs(:height).returns(25)
@@ -14,6 +15,7 @@ module Vedeu
14
15
 
15
16
  describe '#initialize' do
16
17
  it { instance.must_be_instance_of(described) }
18
+ it { instance.instance_variable_get('@name').must_equal(_name) }
17
19
  end
18
20
 
19
21
  describe '#centred' do
@@ -8,27 +8,24 @@ module Vedeu
8
8
  let(:instance) { described.new(attributes) }
9
9
  let(:attributes) {
10
10
  {
11
- background: background,
12
- foreground: foreground,
13
- style: style,
14
- value: value,
15
- x: x,
16
- y: y,
11
+ colour: colour,
12
+ style: style,
13
+ value: value,
14
+ x: x,
15
+ y: y,
17
16
  }
18
17
  }
19
- let(:background) { '#000000' }
20
- let(:foreground) {}
21
- let(:style) {}
22
- let(:value) {}
23
- let(:x) {}
24
- let(:y) {}
18
+ let(:colour) { Colour.new(background: '#000000') }
19
+ let(:style) {}
20
+ let(:value) {}
21
+ let(:x) {}
22
+ let(:y) {}
25
23
 
26
24
  describe '#initialize' do
27
25
  subject { instance }
28
26
 
29
27
  it { subject.must_be_instance_of(described) }
30
- it { subject.instance_variable_get('@background').must_equal(background) }
31
- it { subject.instance_variable_get('@foreground').must_equal(foreground) }
28
+ it { subject.instance_variable_get('@colour').must_equal(colour) }
32
29
  it { subject.instance_variable_get('@style').must_equal(style) }
33
30
  it { subject.instance_variable_get('@value').must_equal(value) }
34
31
  it { subject.instance_variable_get('@x').must_equal(x) }
@@ -36,14 +33,14 @@ module Vedeu
36
33
  end
37
34
 
38
35
  describe '#eql?' do
39
- let(:other) { described.new(background: '#000000') }
36
+ let(:other) { described.new(colour: Colour.new(background: '#000000')) }
40
37
 
41
38
  subject { instance.eql?(other) }
42
39
 
43
40
  it { subject.must_equal(true) }
44
41
 
45
42
  context 'when different to other' do
46
- let(:other) { described.new({}) }
43
+ let(:other) { described.new(colour: Colour.new(background: '#ff0000')) }
47
44
 
48
45
  it { subject.must_equal(false) }
49
46
  end
@@ -54,23 +54,6 @@ module Vedeu
54
54
  visible: true) }
55
55
  end
56
56
 
57
- describe '#border?' do
58
- subject { instance.border? }
59
-
60
- context 'when the interface has a border' do
61
- before { Vedeu.border('hydrogen') { } }
62
- after { Vedeu.borders.reset }
63
-
64
- it { subject.must_equal(true) }
65
- end
66
-
67
- context 'when the interface does not have a border' do
68
- before { Vedeu.borders.reset }
69
-
70
- it { subject.must_equal(false) }
71
- end
72
- end
73
-
74
57
  describe '#border' do
75
58
  subject { instance.border }
76
59
 
@@ -298,28 +298,6 @@ module Vedeu
298
298
  end
299
299
  end
300
300
 
301
- describe '#colour=' do
302
- let(:value) { { foreground: '#00ff00' } }
303
-
304
- subject { instance.colour = (value) }
305
-
306
- it do
307
- subject
308
- instance.instance_variable_get('@colour').must_be_instance_of(Colour)
309
- end
310
- end
311
-
312
- describe '#style=' do
313
- let(:value) { 'normal' }
314
-
315
- subject { instance.style = (value) }
316
-
317
- it do
318
- subject
319
- instance.instance_variable_get('@style').must_be_instance_of(Style)
320
- end
321
- end
322
-
323
301
  describe '#enabled?' do
324
302
  subject { instance.enabled? }
325
303
 
@@ -12,10 +12,12 @@ module Vedeu
12
12
 
13
13
  }
14
14
  }
15
- let(:geometry) { Vedeu::Geometry.new(x: 1, y: 1, xn: 3, yn: 3)}
16
15
  let(:visible) { true }
17
16
 
18
- before { interface.stubs(:geometry).returns(geometry) }
17
+ before do
18
+ Vedeu::Border.new(name: 'xenon').store
19
+ Vedeu::Geometry.new(name: 'xenon', x: 1, y: 1, xn: 3, yn: 3).store
20
+ end
19
21
 
20
22
  describe '#initialize' do
21
23
  it { instance.must_be_instance_of(Vedeu::Clear) }
@@ -5,13 +5,17 @@ module Vedeu
5
5
  describe NullBorder do
6
6
 
7
7
  let(:described) { Vedeu::NullBorder }
8
- let(:instance) { described.new(interface) }
9
- let(:interface) { stub('Interface', geometry: geometry) }
10
- let(:geometry) { stub('Geometry', x: 4, y: 6, xn: 10, yn: 12) }
8
+ let(:instance) { described.new(_name) }
9
+ let(:_name) { 'null_border' }
10
+
11
+ before do
12
+ Vedeu::Geometry.new(name: _name, x: 4, y: 6, xn: 10, yn: 12).store
13
+ end
14
+ after { Vedeu.geometries.reset }
11
15
 
12
16
  describe '#initialize' do
13
17
  it { instance.must_be_instance_of(Vedeu::NullBorder) }
14
- it { instance.instance_variable_get('@interface').must_equal(interface) }
18
+ it { instance.instance_variable_get('@name').must_equal(_name) }
15
19
  end
16
20
 
17
21
  describe '#bx' do
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe TextRenderer do
6
+
7
+ let(:described) { Vedeu::TextRenderer }
8
+ let(:instance) { described.new(output) }
9
+ let(:output) {}
10
+
11
+ describe '#initialize' do
12
+ it { instance.must_be_instance_of(Vedeu::TextRenderer) }
13
+ it { instance.instance_variable_get('@output').must_equal([output]) }
14
+ end
15
+
16
+ describe '.render' do
17
+ subject { described.render }
18
+
19
+ it { subject.must_be_instance_of(String) }
20
+ end
21
+
22
+ end # TextRenderer
23
+
24
+ end # Vedeu
@@ -30,19 +30,7 @@ module Vedeu
30
30
  context 'when the border does not exist' do
31
31
  let(:_name) { 'nitrogen' }
32
32
 
33
- context 'and an interface with this name exists' do
34
- before do
35
- Vedeu.interface 'nitrogen' do
36
- end
37
- end
38
- after { Vedeu.interfaces.reset }
39
-
40
- it { subject.must_be_instance_of(Vedeu::NullBorder) }
41
- end
42
-
43
- context 'and an interface with this name does not exist' do
44
- it { subject.must_be_instance_of(NilClass) }
45
- end
33
+ it { subject.must_be_instance_of(Vedeu::NullBorder) }
46
34
  end
47
35
  end
48
36
 
@@ -0,0 +1,70 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Options do
6
+
7
+ let(:described) { Vedeu::Options }
8
+ let(:instance) { described.new(options) }
9
+ let(:options) {
10
+ {}
11
+ }
12
+
13
+ describe '#initialize' do
14
+ it { instance.must_be_instance_of(described) }
15
+ it { instance.instance_variable_get('@_options').must_equal(options) }
16
+ end
17
+
18
+ describe '#_build' do
19
+ subject { instance._build }
20
+
21
+ it { subject.must_be_instance_of(described) }
22
+
23
+ context 'with no options' do
24
+ it 'defines no methods' do
25
+ subject
26
+ instance._defined.must_equal([])
27
+ end
28
+ end
29
+
30
+ context 'with a predicate option' do
31
+ let(:options) {
32
+ {
33
+ predicate: false
34
+ }
35
+ }
36
+
37
+ it 'defines the method and the predicate as an alias to that method' do
38
+ subject
39
+ instance.must_respond_to(:predicate)
40
+ instance.predicate.must_equal(false)
41
+
42
+ instance.must_respond_to(:predicate?)
43
+ instance.predicate?.must_equal(false)
44
+
45
+ instance._defined.must_equal([:predicate, :predicate?])
46
+ end
47
+ end
48
+
49
+ context 'with a normal option' do
50
+ let(:options) {
51
+ {
52
+ some_option: 'some_value'
53
+ }
54
+ }
55
+
56
+ it 'defines the method' do
57
+ subject
58
+ instance.must_respond_to(:some_option)
59
+ instance.some_option.must_equal('some_value')
60
+
61
+ instance.wont_respond_to(:some_option?)
62
+
63
+ instance._defined.must_equal([:some_option])
64
+ end
65
+ end
66
+ end
67
+
68
+ end # Option
69
+
70
+ end # Vedeu
@@ -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.4.14'
7
+ spec.version = '0.4.15'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = '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.4.14
4
+ version: 0.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-09 00:00:00.000000000 Z
11
+ date: 2015-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -416,6 +416,7 @@ files:
416
416
  - lib/vedeu/output/renderers/json_renderer.rb
417
417
  - lib/vedeu/output/renderers/null_renderer.rb
418
418
  - lib/vedeu/output/renderers/terminal_renderer.rb
419
+ - lib/vedeu/output/renderers/text_renderer.rb
419
420
  - lib/vedeu/output/style.rb
420
421
  - lib/vedeu/output/templates/html_renderer.vedeu
421
422
  - lib/vedeu/output/text.rb
@@ -456,6 +457,7 @@ files:
456
457
  - lib/vedeu/support/all.rb
457
458
  - lib/vedeu/support/common.rb
458
459
  - lib/vedeu/support/log.rb
460
+ - lib/vedeu/support/options.rb
459
461
  - lib/vedeu/support/template.rb
460
462
  - lib/vedeu/support/terminal.rb
461
463
  - lib/vedeu/support/trace.rb
@@ -539,6 +541,7 @@ files:
539
541
  - test/lib/vedeu/output/renderers/json_renderer_test.rb
540
542
  - test/lib/vedeu/output/renderers/null_renderer_test.rb
541
543
  - test/lib/vedeu/output/renderers/terminal_renderer_test.rb
544
+ - test/lib/vedeu/output/renderers/text_renderer_test.rb
542
545
  - test/lib/vedeu/output/style_test.rb
543
546
  - test/lib/vedeu/output/text_test.rb
544
547
  - test/lib/vedeu/output/translator_test.rb
@@ -573,6 +576,7 @@ files:
573
576
  - test/lib/vedeu/storage/store_test.rb
574
577
  - test/lib/vedeu/support/common_test.rb
575
578
  - test/lib/vedeu/support/log_test.rb
579
+ - test/lib/vedeu/support/options_test.rb
576
580
  - test/lib/vedeu/support/template_test.rb
577
581
  - test/lib/vedeu/support/terminal_test.rb
578
582
  - test/lib/vedeu/support/trace_test.rb
@@ -693,6 +697,7 @@ test_files:
693
697
  - test/lib/vedeu/output/renderers/json_renderer_test.rb
694
698
  - test/lib/vedeu/output/renderers/null_renderer_test.rb
695
699
  - test/lib/vedeu/output/renderers/terminal_renderer_test.rb
700
+ - test/lib/vedeu/output/renderers/text_renderer_test.rb
696
701
  - test/lib/vedeu/output/style_test.rb
697
702
  - test/lib/vedeu/output/text_test.rb
698
703
  - test/lib/vedeu/output/translator_test.rb
@@ -727,6 +732,7 @@ test_files:
727
732
  - test/lib/vedeu/storage/store_test.rb
728
733
  - test/lib/vedeu/support/common_test.rb
729
734
  - test/lib/vedeu/support/log_test.rb
735
+ - test/lib/vedeu/support/options_test.rb
730
736
  - test/lib/vedeu/support/template_test.rb
731
737
  - test/lib/vedeu/support/terminal_test.rb
732
738
  - test/lib/vedeu/support/trace_test.rb