vedeu 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +3 -0
  3. data/Rakefile +16 -7
  4. data/examples/borders_app.rb +58 -55
  5. data/lib/vedeu/api.rb +1 -1
  6. data/lib/vedeu/application.rb +25 -25
  7. data/lib/vedeu/bindings.rb +5 -7
  8. data/lib/vedeu/configuration/api.rb +0 -2
  9. data/lib/vedeu/configuration/cli.rb +0 -2
  10. data/lib/vedeu/configuration/configuration.rb +0 -2
  11. data/lib/vedeu/cursor/cursor.rb +0 -2
  12. data/lib/vedeu/debug.rb +2 -2
  13. data/lib/vedeu/distributed/server.rb +0 -2
  14. data/lib/vedeu/dsl/components/border.rb +15 -19
  15. data/lib/vedeu/dsl/components/geometry.rb +14 -18
  16. data/lib/vedeu/dsl/components/keymap.rb +28 -32
  17. data/lib/vedeu/dsl/composition.rb +27 -9
  18. data/lib/vedeu/events/all.rb +1 -0
  19. data/lib/vedeu/events/event.rb +6 -8
  20. data/lib/vedeu/events/events.rb +10 -0
  21. data/lib/vedeu/events/trigger.rb +6 -12
  22. data/lib/vedeu/geometry/grid.rb +0 -2
  23. data/lib/vedeu/geometry/position.rb +0 -2
  24. data/lib/vedeu/geometry/position_validator.rb +0 -14
  25. data/lib/vedeu/input/input.rb +0 -2
  26. data/lib/vedeu/models/collection.rb +0 -2
  27. data/lib/vedeu/models/focus.rb +0 -1
  28. data/lib/vedeu/models/geometry.rb +7 -3
  29. data/lib/vedeu/models/group.rb +0 -2
  30. data/lib/vedeu/models/menu.rb +23 -29
  31. data/lib/vedeu/models/model.rb +0 -2
  32. data/lib/vedeu/models/view/char.rb +14 -10
  33. data/lib/vedeu/models/view/composition.rb +7 -9
  34. data/lib/vedeu/models/view/interface.rb +0 -1
  35. data/lib/vedeu/models/view/line.rb +2 -3
  36. data/lib/vedeu/models/view/stream.rb +0 -3
  37. data/lib/vedeu/output/all.rb +1 -0
  38. data/lib/vedeu/output/background.rb +0 -2
  39. data/lib/vedeu/output/colour.rb +0 -2
  40. data/lib/vedeu/output/compositor.rb +0 -2
  41. data/lib/vedeu/output/foreground.rb +0 -2
  42. data/lib/vedeu/output/html_renderer.rb +6 -0
  43. data/lib/vedeu/output/index_position.rb +35 -0
  44. data/lib/vedeu/output/output.rb +3 -1
  45. data/lib/vedeu/output/position_index.rb +2 -2
  46. data/lib/vedeu/output/presentation.rb +0 -2
  47. data/lib/vedeu/output/style.rb +0 -1
  48. data/lib/vedeu/output/translator.rb +18 -20
  49. data/lib/vedeu/output/viewport.rb +76 -51
  50. data/lib/vedeu/output/virtual_terminal.rb +2 -1
  51. data/lib/vedeu/repositories/all.rb +4 -4
  52. data/lib/vedeu/repositories/repository.rb +0 -2
  53. data/lib/vedeu/support/coercions.rb +0 -2
  54. data/lib/vedeu/support/common.rb +0 -2
  55. data/lib/vedeu/support/esc.rb +0 -2
  56. data/lib/vedeu/support/log.rb +86 -3
  57. data/lib/vedeu/support/refresh.rb +0 -2
  58. data/lib/vedeu/support/sentence.rb +5 -9
  59. data/lib/vedeu/support/terminal.rb +0 -2
  60. data/lib/vedeu/support/trace.rb +0 -2
  61. data/lib/vedeu/support/visible.rb +1 -1
  62. data/test/lib/vedeu/configuration/api_test.rb +14 -0
  63. data/test/lib/vedeu/configuration/configuration_test.rb +10 -0
  64. data/test/lib/vedeu/distributed/server_test.rb +5 -0
  65. data/test/lib/vedeu/dsl/components/border_test.rb +7 -0
  66. data/test/lib/vedeu/dsl/components/geometry_test.rb +8 -3
  67. data/test/lib/vedeu/dsl/interface_test.rb +5 -0
  68. data/test/lib/vedeu/dsl/line_test.rb +4 -0
  69. data/test/lib/vedeu/dsl/shared/colour_test.rb +7 -7
  70. data/test/lib/vedeu/dsl/shared/style_test.rb +5 -2
  71. data/test/lib/vedeu/dsl/stream_test.rb +4 -1
  72. data/test/lib/vedeu/events/event_test.rb +6 -0
  73. data/test/lib/vedeu/geometry/bounding_area_test.rb +30 -30
  74. data/test/lib/vedeu/geometry/position_test.rb +5 -0
  75. data/test/lib/vedeu/models/view/char_test.rb +1 -14
  76. data/test/lib/vedeu/output/index_position_test.rb +64 -0
  77. data/test/lib/vedeu/output/style_test.rb +4 -0
  78. data/test/lib/vedeu/output/translator_test.rb +4 -0
  79. data/test/lib/vedeu/output/virtual_terminal_test.rb +2 -0
  80. data/test/lib/vedeu/output/wordwrap_test.rb +5 -0
  81. data/test/lib/vedeu/repositories/all_test.rb +3 -3
  82. data/test/lib/vedeu/repositories/repository_test.rb +8 -0
  83. data/test/lib/vedeu/support/console_test.rb +14 -0
  84. data/test/lib/vedeu/support/esc_test.rb +6 -0
  85. data/test/lib/vedeu/support/terminal_test.rb +13 -0
  86. data/vedeu.gemspec +4 -4
  87. metadata +12 -24
  88. data/test/integration/distributed_test.rb +0 -16
  89. data/test/integration/dsl/compositions_test.rb +0 -19
  90. data/test/integration/dsl/interfaces_test.rb +0 -193
  91. data/test/integration/dsl/keymaps_test.rb +0 -30
  92. data/test/integration/dsl/lines_test.rb +0 -104
  93. data/test/integration/dsl/menus_test.rb +0 -59
  94. data/test/integration/dsl/streams_test.rb +0 -103
  95. data/test/integration/dsl/views_test.rb +0 -45
@@ -4,9 +4,19 @@ module Vedeu
4
4
 
5
5
  describe Configuration do
6
6
 
7
+ let(:described) { Vedeu::Configuration }
8
+
7
9
  before { Configuration.reset! }
8
10
  after { test_configuration }
9
11
 
12
+ describe 'alias_methods' do
13
+ it { described.must_respond_to(:debug) }
14
+ it { described.must_respond_to(:drb) }
15
+ it { described.must_respond_to(:interactive) }
16
+ it { described.must_respond_to(:once) }
17
+ it { described.must_respond_to(:trace) }
18
+ end
19
+
10
20
  describe '.default_system_keys' do
11
21
  it 'returns the default system keys' do
12
22
  Configuration.default_system_keys.must_equal({
@@ -10,6 +10,11 @@ module Vedeu
10
10
  let(:instance) { described.instance }
11
11
  let(:configuration) {}
12
12
 
13
+ describe 'alias_methods' do
14
+ it { instance.must_respond_to(:read) }
15
+ it { instance.must_respond_to(:write) }
16
+ end
17
+
13
18
  describe '.input' do
14
19
  let(:data) {}
15
20
 
@@ -28,6 +28,13 @@ module Vedeu
28
28
  end
29
29
  end
30
30
 
31
+ describe 'alias methods' do
32
+ it { instance.must_respond_to(:show_bottom) }
33
+ it { instance.must_respond_to(:show_left) }
34
+ it { instance.must_respond_to(:show_right) }
35
+ it { instance.must_respond_to(:show_top) }
36
+ end
37
+
31
38
  describe '#initialize' do
32
39
  it { instance.must_be_instance_of(Vedeu::DSL::Border) }
33
40
  it { instance.instance_variable_get('@model').must_equal(model) }
@@ -6,12 +6,17 @@ module Vedeu
6
6
 
7
7
  describe Geometry do
8
8
 
9
- let(:described) { Vedeu::DSL::Geometry.new(model) }
9
+ let(:described) { Vedeu::DSL::Geometry }
10
+ let(:instance) { described.new(model) }
10
11
  let(:model) { Vedeu::Geometry.new }
11
12
 
13
+ describe 'alias methods' do
14
+ it { instance.must_respond_to(:centred!) }
15
+ end
16
+
12
17
  describe '#initialize' do
13
- it { described.must_be_instance_of(Vedeu::DSL::Geometry) }
14
- it { described.instance_variable_get('@model').must_equal(model) }
18
+ it { instance.must_be_instance_of(Vedeu::DSL::Geometry) }
19
+ it { instance.instance_variable_get('@model').must_equal(model) }
15
20
  end
16
21
 
17
22
  describe '#centred' do
@@ -17,6 +17,11 @@ module Vedeu
17
17
 
18
18
  before { Vedeu.interfaces.reset }
19
19
 
20
+ describe 'alias methods' do
21
+ it { instance.must_respond_to(:keys) }
22
+ it { instance.must_respond_to(:line) }
23
+ end
24
+
20
25
  describe '#initialize' do
21
26
  it { instance.must_be_instance_of(Vedeu::DSL::Interface) }
22
27
  it { instance.instance_variable_get('@model').must_equal(model) }
@@ -23,6 +23,10 @@ module Vedeu
23
23
  let(:colour) { Vedeu::Colour.new }
24
24
  let(:style) { Vedeu::Style.new }
25
25
 
26
+ describe 'alias methods' do
27
+ it { instance.must_respond_to(:stream) }
28
+ end
29
+
26
30
  describe '#initialize' do
27
31
  it { instance.must_be_instance_of(described) }
28
32
  it { instance.instance_variable_get('@model').must_equal(model) }
@@ -7,12 +7,18 @@ module Vedeu
7
7
  describe Colour do
8
8
 
9
9
  let(:described) { Vedeu::DSL::Colour }
10
-
11
10
  let(:dsl_klass) { Vedeu::DSL::Interface.new(model) }
12
11
  let(:model) { Vedeu::Interface.new }
13
12
  let(:background) { '#00ff00' }
14
13
  let(:foreground) { '#ff00ff' }
15
14
 
15
+ describe 'alias methods' do
16
+ it { dsl_klass.must_respond_to(:bg) }
17
+ it { dsl_klass.must_respond_to(:bgcolor) }
18
+ it { dsl_klass.must_respond_to(:fg) }
19
+ it { dsl_klass.must_respond_to(:fgcolor) }
20
+ end
21
+
16
22
  describe '#background' do
17
23
  subject { dsl_klass.background(background) }
18
24
 
@@ -23,9 +29,6 @@ module Vedeu
23
29
  { background: '#00ff00', foreground: '' }
24
30
  )
25
31
  end
26
-
27
- it { dsl_klass.must_respond_to(:bg) }
28
- it { dsl_klass.must_respond_to(:bgcolor) }
29
32
  end
30
33
 
31
34
  describe '#foreground' do
@@ -38,9 +41,6 @@ module Vedeu
38
41
  { background: '', foreground: '#ff00ff' }
39
42
  )
40
43
  end
41
-
42
- it { dsl_klass.must_respond_to(:fg) }
43
- it { dsl_klass.must_respond_to(:fgcolor) }
44
44
  end
45
45
 
46
46
  describe '#colour' do
@@ -6,11 +6,14 @@ module Vedeu
6
6
 
7
7
  describe Style do
8
8
 
9
+ let(:described) { Vedeu::DSL::Style }
10
+ let(:instance) { Vedeu::DSL::ModelTestClass.new(model) }
11
+ let(:model) { Vedeu::ModelTestClass.new({}) }
12
+
9
13
  describe '#style' do
10
- let(:model) { Vedeu::ModelTestClass.new({}) }
11
14
  let(:args) { :bold }
12
15
 
13
- subject { Vedeu::DSL::ModelTestClass.new(model).style(args) }
16
+ subject { instance.style(args) }
14
17
 
15
18
  it { subject.must_be_instance_of(Vedeu::Style) }
16
19
  end
@@ -8,8 +8,9 @@ module Vedeu
8
8
 
9
9
  let(:described) { Vedeu::DSL::Stream }
10
10
  let(:instance) { described.new(model) }
11
- let(:model) { Vedeu::Stream.new }
11
+ let(:model) { Vedeu::Stream.new({ parent: parent }) }
12
12
  let(:client) {}
13
+ let(:parent) { Vedeu::Line.new }
13
14
 
14
15
  describe '#initialize' do
15
16
  it { instance.must_be_instance_of(Vedeu::DSL::Stream) }
@@ -20,6 +21,8 @@ module Vedeu
20
21
  describe '#stream' do
21
22
  subject { instance.stream { } }
22
23
 
24
+ it { subject.must_be_instance_of(Vedeu::Streams) }
25
+
23
26
  context 'when the block is not given' do
24
27
  subject { instance.stream }
25
28
 
@@ -10,6 +10,12 @@ module Vedeu
10
10
  let(:options) { {} }
11
11
  let(:closure) { proc { :event_triggered } }
12
12
 
13
+ describe 'alias methods' do
14
+ it { described.must_respond_to(:event) }
15
+ it { described.must_respond_to(:register) }
16
+ it { described.must_respond_to(:unevent) }
17
+ end
18
+
13
19
  describe '.bind' do
14
20
  subject { described.bind(event_name, options) { :event_triggered } }
15
21
 
@@ -4,118 +4,118 @@ module Vedeu
4
4
 
5
5
  describe BoundingArea do
6
6
 
7
- let(:described) { BoundingArea.new(height, width) }
7
+ let(:described) { Vedeu::BoundingArea }
8
+ let(:instance) { described.new(height, width) }
8
9
  let(:height) { 15 }
9
10
  let(:width) { 40 }
10
11
 
12
+ describe 'alias methods' do
13
+ it { instance.must_respond_to(:y) }
14
+ it { instance.must_respond_to(:yn) }
15
+ it { instance.must_respond_to(:x) }
16
+ it { instance.must_respond_to(:xn) }
17
+ end
18
+
11
19
  describe '#initialize' do
12
- it { described.must_be_instance_of(BoundingArea) }
13
- it { described.instance_variable_get('@height').must_equal(height) }
14
- it { described.instance_variable_get('@width').must_equal(width) }
20
+ it { instance.must_be_instance_of(BoundingArea) }
21
+ it { instance.instance_variable_get('@height').must_equal(height) }
22
+ it { instance.instance_variable_get('@width').must_equal(width) }
15
23
  end
16
24
 
17
25
  describe '#height' do
18
26
  it 'returns the height' do
19
- described.height.must_equal(height)
27
+ instance.height.must_equal(height)
20
28
  end
21
29
  end
22
30
 
23
31
  describe '#width' do
24
32
  it 'returns the width' do
25
- described.width.must_equal(width)
33
+ instance.width.must_equal(width)
26
34
  end
27
35
  end
28
36
 
29
37
  describe '#top' do
30
38
  context 'when an offset is provided' do
31
39
  it 'returns the new top with the offset applied' do
32
- described.top(5).must_equal(6)
40
+ instance.top(5).must_equal(6)
33
41
  end
34
42
 
35
43
  context 'when the offset is greater or equal to the height' do
36
44
  it 'returns the height' do
37
- described.top(20).must_equal(15)
45
+ instance.top(20).must_equal(15)
38
46
  end
39
47
  end
40
48
 
41
49
  context 'when the offset is less than or equal to 1' do
42
- it { described.top(-1).must_equal(1) }
50
+ it { instance.top(-1).must_equal(1) }
43
51
  end
44
52
  end
45
53
 
46
54
  context 'when an offset is not provided' do
47
- it { described.top.must_equal(1) }
55
+ it { instance.top.must_equal(1) }
48
56
  end
49
-
50
- it { described.must_respond_to(:y) }
51
57
  end
52
58
 
53
59
  describe '#bottom' do
54
60
  context 'when an offset is provided' do
55
61
  it 'returns the new bottom with the offset applied' do
56
- described.bottom(5).must_equal(10)
62
+ instance.bottom(5).must_equal(10)
57
63
  end
58
64
 
59
65
  context 'when the offset is greater or equal to the height' do
60
- it { described.bottom(30).must_equal(1) }
66
+ it { instance.bottom(30).must_equal(1) }
61
67
  end
62
68
 
63
69
  context 'when the offset is less than 0' do
64
- it { described.bottom(-1).must_equal(height) }
70
+ it { instance.bottom(-1).must_equal(height) }
65
71
  end
66
72
  end
67
73
 
68
74
  context 'when an offset is not provided' do
69
- it { described.bottom.must_equal(15) }
75
+ it { instance.bottom.must_equal(15) }
70
76
  end
71
-
72
- it { described.must_respond_to(:yn) }
73
77
  end
74
78
 
75
79
  describe '#left' do
76
80
  context 'when an offset is provided' do
77
81
  it 'returns the new left with the offset applied' do
78
- described.left(5).must_equal(6)
82
+ instance.left(5).must_equal(6)
79
83
  end
80
84
 
81
85
  context 'when the offset is greater or equal to the width' do
82
86
  it 'returns the width' do
83
- described.left(50).must_equal(40)
87
+ instance.left(50).must_equal(40)
84
88
  end
85
89
  end
86
90
 
87
91
  context 'when the offset is less than or equal to 1' do
88
- it { described.left(-1).must_equal(1) }
92
+ it { instance.left(-1).must_equal(1) }
89
93
  end
90
94
  end
91
95
 
92
96
  context 'when an offset is not provided' do
93
- it { described.left.must_equal(1) }
97
+ it { instance.left.must_equal(1) }
94
98
  end
95
-
96
- it { described.must_respond_to(:x) }
97
99
  end
98
100
 
99
101
  describe '#right' do
100
102
  context 'when an offset is provided' do
101
103
  it 'returns the new right with the offset applied' do
102
- described.right(5).must_equal(35)
104
+ instance.right(5).must_equal(35)
103
105
  end
104
106
 
105
107
  context 'when the offset is greater or equal to the width' do
106
- it { described.right(50).must_equal(1) }
108
+ it { instance.right(50).must_equal(1) }
107
109
  end
108
110
 
109
111
  context 'when the offset is less than 0' do
110
- it { described.right(-1).must_equal(40) }
112
+ it { instance.right(-1).must_equal(40) }
111
113
  end
112
114
  end
113
115
 
114
116
  context 'when an offset is not provided' do
115
- it { described.right.must_equal(40) }
117
+ it { instance.right.must_equal(40) }
116
118
  end
117
-
118
- it { described.must_respond_to(:xn) }
119
119
  end
120
120
 
121
121
  end # BoundingArea
@@ -9,6 +9,11 @@ module Vedeu
9
9
  let(:y) { 12 }
10
10
  let(:x) { 19 }
11
11
 
12
+ describe 'alias methods' do
13
+ it { instance.must_respond_to(:first) }
14
+ it { instance.must_respond_to(:last) }
15
+ end
16
+
12
17
  describe '#initialize' do
13
18
  it { instance.must_be_instance_of(described) }
14
19
  it { instance.instance_variable_get('@y').must_equal(y) }
@@ -37,21 +37,8 @@ module Vedeu
37
37
  it { instance.instance_variable_get('@parent').must_equal(parent) }
38
38
  it { instance.instance_variable_get('@style').must_equal(style) }
39
39
  it { instance.instance_variable_get('@value').must_equal(value) }
40
- it { instance.instance_variable_get('@position').must_equal(position) }
41
- end
42
-
43
- describe '#value' do
44
- subject { instance.value }
45
-
46
- context 'when the value is not set' do
47
- let(:value) {}
48
40
 
49
- it { subject.must_equal('') }
50
- end
51
-
52
- context 'when the value is set' do
53
- it { subject.must_equal('a') }
54
- end
41
+ it { instance.must_respond_to(:value) }
55
42
  end
56
43
 
57
44
  describe '#to_html' do
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe IndexPosition do
6
+
7
+ let(:described) { Vedeu::IndexPosition }
8
+ let(:instance) { described.new(y, x) }
9
+ let(:y) { 6 }
10
+ let(:x) { 17 }
11
+
12
+ describe '#initialize' do
13
+ it { instance.must_be_instance_of(described) }
14
+ it { instance.instance_variable_get('@y').must_equal(7) }
15
+ it { instance.instance_variable_get('@x').must_equal(18) }
16
+
17
+ context 'when y is less than 0' do
18
+ let(:y) { -3 }
19
+
20
+ it { instance.instance_variable_get('@y').must_equal(1) }
21
+ end
22
+
23
+ context 'when x is less than 0' do
24
+ let(:x) { -9 }
25
+
26
+ it { instance.instance_variable_get('@x').must_equal(1) }
27
+ end
28
+ end
29
+
30
+ describe '.[]' do
31
+ subject { described[y, x] }
32
+
33
+ it { subject.must_be_instance_of(Array) }
34
+ it { subject.must_equal([7, 18]) }
35
+ end
36
+
37
+ describe '#[]' do
38
+ subject { instance.[] }
39
+
40
+ it { subject.must_be_instance_of(Array) }
41
+ it { subject.must_equal([7, 18]) }
42
+ end
43
+
44
+ describe 'attr_reader' do
45
+ context '#y' do
46
+ subject { instance.y }
47
+
48
+ it { subject.must_equal(7) }
49
+
50
+ it { instance.must_respond_to(:first) }
51
+ end
52
+
53
+ context '#x' do
54
+ subject { instance.x }
55
+
56
+ it { subject.must_equal(18) }
57
+
58
+ it { instance.must_respond_to(:last) }
59
+ end
60
+ end
61
+
62
+ end # IndexPosition
63
+
64
+ end # Vedeu
@@ -8,6 +8,10 @@ module Vedeu
8
8
  let(:instance) { described.new(value) }
9
9
  let(:value) { 'bold' }
10
10
 
11
+ describe 'alias methods' do
12
+ it { instance.must_respond_to(:escape_sequences) }
13
+ end
14
+
11
15
  describe '#initialize' do
12
16
  it { instance.must_be_instance_of(described) }
13
17
  it { instance.instance_variable_get('@value').must_equal('bold') }