vedeu 0.4.46 → 0.4.47

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/lib/vedeu/api.rb +3 -3
  3. data/lib/vedeu/bindings/bindings.rb +14 -4
  4. data/lib/vedeu/bindings/drb.rb +2 -0
  5. data/lib/vedeu/bindings/menus.rb +2 -0
  6. data/lib/vedeu/bindings/movement.rb +2 -0
  7. data/lib/vedeu/bindings/visibility.rb +2 -0
  8. data/lib/vedeu/buffers/buffer.rb +1 -1
  9. data/lib/vedeu/cursor/cursor.rb +2 -2
  10. data/lib/vedeu/geometry/dimension.rb +16 -13
  11. data/lib/vedeu/geometry/geometry.rb +3 -1
  12. data/lib/vedeu/geometry/index_position.rb +1 -1
  13. data/lib/vedeu/geometry/position_index.rb +1 -1
  14. data/lib/vedeu/input/input.rb +2 -1
  15. data/lib/vedeu/input/keymap.rb +1 -0
  16. data/lib/vedeu/models/char.rb +7 -6
  17. data/lib/vedeu/models/interface.rb +2 -12
  18. data/lib/vedeu/models/line.rb +2 -2
  19. data/lib/vedeu/models/stream.rb +2 -2
  20. data/lib/vedeu/null/geometry.rb +3 -6
  21. data/lib/vedeu/output/all.rb +1 -1
  22. data/lib/vedeu/output/border.rb +5 -5
  23. data/lib/vedeu/output/clear/all.rb +2 -0
  24. data/lib/vedeu/output/clear/named_group.rb +52 -0
  25. data/lib/vedeu/output/clear/named_interface.rb +99 -0
  26. data/lib/vedeu/output/esc.rb +1 -1
  27. data/lib/vedeu/output/viewport.rb +10 -2
  28. data/lib/vedeu/repositories/registerable.rb +9 -1
  29. data/lib/vedeu/repositories/repositories/borders.rb +0 -11
  30. data/lib/vedeu/repositories/repositories/buffers.rb +0 -11
  31. data/lib/vedeu/repositories/repositories/cursors.rb +4 -11
  32. data/lib/vedeu/repositories/repositories/geometries.rb +0 -11
  33. data/lib/vedeu/repositories/repositories/groups.rb +4 -11
  34. data/lib/vedeu/repositories/repositories/interfaces.rb +0 -11
  35. data/lib/vedeu/repositories/repositories/keymaps.rb +4 -11
  36. data/lib/vedeu/repositories/repositories/menus.rb +4 -11
  37. data/lib/vedeu/repositories/repository.rb +1 -11
  38. data/lib/vedeu/storage/store.rb +15 -0
  39. data/lib/vedeu/support/log.rb +1 -0
  40. data/lib/vedeu/support/terminal.rb +1 -10
  41. data/lib/vedeu/support/visibility.rb +0 -1
  42. data/lib/vedeu/version.rb +1 -1
  43. data/test/lib/vedeu/geometry/geometry_test.rb +4 -0
  44. data/test/lib/vedeu/geometry/position_test.rb +25 -8
  45. data/test/lib/vedeu/models/char_test.rb +4 -4
  46. data/test/lib/vedeu/models/interface_test.rb +7 -2
  47. data/test/lib/vedeu/output/clear/named_group_test.rb +41 -0
  48. data/test/lib/vedeu/output/clear/named_interface_test.rb +68 -0
  49. data/test/lib/vedeu/output/render_border_test.rb +47 -5
  50. data/test/lib/vedeu/repositories/registerable_test.rb +30 -3
  51. data/test/lib/vedeu/repositories/repositories/borders_test.rb +0 -13
  52. data/test/lib/vedeu/repositories/repositories/buffers_test.rb +0 -11
  53. data/test/lib/vedeu/repositories/repositories/cursors_test.rb +0 -11
  54. data/test/lib/vedeu/repositories/repositories/geometries_test.rb +0 -11
  55. data/test/lib/vedeu/repositories/repositories/groups_test.rb +0 -11
  56. data/test/lib/vedeu/repositories/repositories/interfaces_test.rb +0 -11
  57. data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +0 -11
  58. data/test/lib/vedeu/repositories/repositories/menus_test.rb +0 -11
  59. data/test/lib/vedeu/repositories/repository_test.rb +0 -37
  60. data/test/lib/vedeu/storage/store_test.rb +41 -0
  61. data/test/test_helper.rb +3 -1
  62. metadata +9 -5
  63. data/lib/vedeu/output/clear.rb +0 -207
  64. data/test/lib/vedeu/output/clear_test.rb +0 -105
@@ -165,6 +165,7 @@ module Vedeu
165
165
  info: [:white, :default],
166
166
  input: [:light_yellow, :yellow],
167
167
  output: [:light_green, :green],
168
+ reset: [:light_cyan, :cyan],
168
169
  store: [:light_cyan, :cyan],
169
170
  test: [:light_white, :white],
170
171
  timer: [:light_yellow, :yellow],
@@ -67,16 +67,7 @@ module Vedeu
67
67
  # @param streams [String|Array]
68
68
  # @return [Array]
69
69
  def output(*streams)
70
- streams.each do |stream|
71
- # Write the stream to the log file.
72
- # Vedeu.log(Esc.escape(stream))
73
-
74
- console.print(stream)
75
-
76
- # Vedeu::Console.write(stream)
77
- end
78
-
79
- streams
70
+ streams.each { |stream| console.print(stream) }
80
71
  end
81
72
  alias_method :write, :output
82
73
 
@@ -100,7 +100,6 @@ module Vedeu
100
100
  end
101
101
  end
102
102
 
103
-
104
103
  # @return [void]
105
104
  def toggle
106
105
  if model.visible?
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.4.46'
4
+ VERSION = '0.4.47'
5
5
 
6
6
  end
@@ -90,6 +90,8 @@ module Vedeu
90
90
  }
91
91
  }
92
92
 
93
+ before { Vedeu.stubs(:trigger) }
94
+
93
95
  subject { instance.maximise }
94
96
 
95
97
  it { subject.must_be_instance_of(described) }
@@ -107,6 +109,8 @@ module Vedeu
107
109
  }
108
110
  }
109
111
 
112
+ before { Vedeu.stubs(:trigger) }
113
+
110
114
  subject { instance.unmaximise }
111
115
 
112
116
  it { subject.must_be_instance_of(described) }
@@ -29,11 +29,27 @@ module Vedeu
29
29
  end
30
30
 
31
31
  describe '#<=>' do
32
- let(:other) {}
33
-
34
32
  subject { instance.<=>(other) }
35
33
 
36
- # it { skip }
34
+ context 'when y is the same as other.y' do
35
+ context 'when x is the same as other.x' do
36
+ let(:other) { described.new(12, 19) }
37
+
38
+ it { subject.must_equal(0) }
39
+ end
40
+
41
+ context 'when x is different to other.x' do
42
+ let(:other) { described.new(12, 21) }
43
+
44
+ it { subject.must_equal(-1) }
45
+ end
46
+ end
47
+
48
+ context 'when y is different to other.y' do
49
+ let(:other) { described.new(14, 19) }
50
+
51
+ it { subject.must_equal(-1) }
52
+ end
37
53
  end
38
54
 
39
55
  describe '.coerce' do
@@ -89,9 +105,10 @@ module Vedeu
89
105
  end
90
106
 
91
107
  describe '#to_position' do
92
- subject { Position.new }
108
+ subject { instance.to_position }
93
109
 
94
110
  it { subject.must_be_instance_of(Vedeu::Position) }
111
+ it { subject.must_equal(instance) }
95
112
  end
96
113
 
97
114
  describe '#to_s' do
@@ -102,7 +119,7 @@ module Vedeu
102
119
  end
103
120
 
104
121
  it 'returns an escape sequence when coordinates are provided' do
105
- Position.new(12, 19).to_s.must_equal("\e[12;19H")
122
+ Position[12, 19].to_s.must_equal("\e[12;19H")
106
123
  end
107
124
 
108
125
  it 'returns an escape sequence if a coordinate is missing' do
@@ -110,15 +127,15 @@ module Vedeu
110
127
  end
111
128
 
112
129
  it 'returns an escape sequence if the x coordinate is negative' do
113
- Position.new(12, -5).to_s.must_equal("\e[12;1H")
130
+ Position[12, -5].to_s.must_equal("\e[12;1H")
114
131
  end
115
132
 
116
133
  it 'returns an escape sequence if the y coordinate is negative' do
117
- Position.new(-12, 5).to_s.must_equal("\e[1;5H")
134
+ Position[-12, 5].to_s.must_equal("\e[1;5H")
118
135
  end
119
136
 
120
137
  it 'resets to starting position when a block is given' do
121
- Position.new(4, 9).to_s { 'test' }.must_equal("\e[4;9Htest\e[4;9H")
138
+ Position[4, 9].to_s { 'test' }.must_equal("\e[4;9Htest\e[4;9H")
122
139
  end
123
140
  end
124
141
 
@@ -74,7 +74,7 @@ module Vedeu
74
74
  describe '#inspect' do
75
75
  let(:colour) { Vedeu::Colour.new(foreground: '#00ff00',
76
76
  background: '#005500') }
77
- let(:position) { Vedeu::Position.new(17, 2) }
77
+ let(:position) { Vedeu::Position[17, 2] }
78
78
  let(:style) { Vedeu::Style.new('underline') }
79
79
 
80
80
 
@@ -136,7 +136,7 @@ module Vedeu
136
136
  it { subject.must_be_instance_of(String) }
137
137
 
138
138
  context 'when a position is specified' do
139
- let(:position) { Vedeu::Position.new(17, 2) }
139
+ let(:position) { Vedeu::Position[17, 2] }
140
140
 
141
141
  it { subject.must_equal("\e[17;2Ha\e[17;2H") }
142
142
  end
@@ -218,7 +218,7 @@ module Vedeu
218
218
  end
219
219
 
220
220
  describe '#x' do
221
- let(:position) { Vedeu::Position.new(17, 2) }
221
+ let(:position) { Vedeu::Position[17, 2] }
222
222
 
223
223
  subject { instance.x }
224
224
 
@@ -234,7 +234,7 @@ module Vedeu
234
234
  end
235
235
 
236
236
  describe '#y' do
237
- let(:position) { Vedeu::Position.new(17, 2) }
237
+ let(:position) { Vedeu::Position[17, 2] }
238
238
 
239
239
  subject { instance.y }
240
240
 
@@ -107,8 +107,8 @@ module Vedeu
107
107
  let(:view) { mock('Vedeu::Viewport') }
108
108
 
109
109
  before do
110
- Vedeu::Clear.stubs(:new).returns(clear)
111
- clear.stubs(:render).returns(:clear)
110
+ Vedeu::Clear::NamedInterface.stubs(:render).returns(:clear)
111
+
112
112
  Vedeu.borders.stubs(:by_name).returns(border)
113
113
  border.stubs(:render).returns(:border)
114
114
  Vedeu::Viewport.stubs(:new).returns(view)
@@ -120,6 +120,11 @@ module Vedeu
120
120
  it { subject.must_be_instance_of(Array) }
121
121
 
122
122
  context 'when the interface is visible' do
123
+ it {
124
+ Vedeu::Clear::NamedInterface.expects(:render).with(_name)
125
+ subject
126
+ }
127
+
123
128
  it { subject.must_equal([:clear, :border, :view]) }
124
129
  end
125
130
 
@@ -0,0 +1,41 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Clear
6
+
7
+ describe NamedGroup do
8
+
9
+ let(:described) { Vedeu::Clear::NamedGroup }
10
+ let(:instance) { described.new(_name) }
11
+ let(:_name) { 'Vedeu::Clear::NamedGroup' }
12
+
13
+ describe '#initialize' do
14
+ it { instance.must_be_instance_of(described) }
15
+ it { instance.instance_variable_get('@name').must_equal(_name) }
16
+ end
17
+
18
+ describe '.render' do
19
+ it { described.must_respond_to(:by_group) }
20
+ it { described.must_respond_to(:clear_by_group) }
21
+ it { described.must_respond_to(:render) }
22
+ end
23
+
24
+ describe '#render' do
25
+ let(:group) { Vedeu::Group.new(members: [_name]) }
26
+
27
+ before { Vedeu.groups.stubs(:by_name).returns(group) }
28
+
29
+ subject { instance.render }
30
+
31
+ it {
32
+ Vedeu::Clear::NamedInterface.expects(:render).with(_name)
33
+ subject
34
+ }
35
+ end
36
+
37
+ end # NamedGroup
38
+
39
+ end # Clear
40
+
41
+ end # Vedeu
@@ -0,0 +1,68 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Clear
6
+
7
+ describe NamedInterface do
8
+
9
+ let(:described) { Vedeu::Clear::NamedInterface }
10
+ let(:instance) { described.new(_name) }
11
+ let(:_name) { 'Vedeu::Clear::NamedInterface' }
12
+
13
+ describe '#initialize' do
14
+ it { instance.must_be_instance_of(described) }
15
+ it { instance.instance_variable_get('@name').must_equal(_name) }
16
+ end
17
+
18
+ describe '.render' do
19
+ it { described.must_respond_to(:by_name) }
20
+ it { described.must_respond_to(:clear_by_name) }
21
+ it { described.must_respond_to(:render) }
22
+ end
23
+
24
+ describe '#render' do
25
+ let(:interface) { Vedeu::Interface.new(name: _name, visible: visible) }
26
+ let(:visible) { true }
27
+ let(:geometry) {
28
+ Vedeu::Geometry.new(name: _name, x: 1, y: 1, xn: 2, yn: 2)
29
+ }
30
+
31
+ before do
32
+ Vedeu.interfaces.stubs(:by_name).returns(interface)
33
+ Vedeu.geometries.stubs(:by_name).returns(geometry)
34
+ end
35
+
36
+ subject { instance.render }
37
+
38
+ context 'when the interface is visible' do
39
+ let(:output) {
40
+ [
41
+ [
42
+ Vedeu::Char.new(value: ' ', position: [1, 1]),
43
+ Vedeu::Char.new(value: ' ', position: [1, 2]),
44
+
45
+ ], [
46
+ Vedeu::Char.new(value: ' ', position: [2, 1]),
47
+ Vedeu::Char.new(value: ' ', position: [2, 2]),
48
+
49
+ ]
50
+ ]
51
+ }
52
+
53
+ it { subject.must_equal(output) }
54
+ end
55
+
56
+ context 'when the interface is not visible' do
57
+ let(:visible) { false }
58
+
59
+ it { subject.must_equal([]) }
60
+ end
61
+
62
+ end
63
+
64
+ end # NamedInterface
65
+
66
+ end # Clear
67
+
68
+ end # Vedeu
@@ -4,12 +4,54 @@ module Vedeu
4
4
 
5
5
  describe RenderBorder do
6
6
 
7
- let(:described) { Vedeu::RenderBorder }
8
- let(:instance) { described.new(border) }
9
- let(:border) {
10
- Vedeu.border 'Vedeu::RenderBorder' do
11
- end
7
+ let(:described) { Vedeu::RenderBorder }
8
+ let(:instance) { described.new(border) }
9
+ let(:border) {
10
+ Vedeu::Border.new(enabled: enabled,
11
+ name: _name).store
12
12
  }
13
+ let(:visible) { false }
14
+ let(:enabled) { false }
15
+ let(:_name) { 'Vedeu::RenderBorder' }
16
+
17
+ it { described.must_respond_to(:with) }
18
+
19
+ describe '#initialize' do
20
+ it { instance.must_be_instance_of(described) }
21
+ it { instance.instance_variable_get('@border').must_equal(border) }
22
+ end
23
+
24
+ describe '#render' do
25
+ before do
26
+ Vedeu::Geometry.new(name: _name, x: 1, xn: 3, y: 1, yn: 3).store
27
+ Vedeu::Interface.new(name: _name, visible: visible).store
28
+ end
29
+ after do
30
+ Vedeu.geometries.reset!
31
+ Vedeu.interfaces.reset!
32
+ Vedeu.borders.reset!
33
+ end
34
+
35
+ subject { instance.render }
36
+
37
+ context 'when the interface is not visible' do
38
+ it { subject.must_equal([]) }
39
+ end
40
+
41
+ context 'when the interface is visible' do
42
+ let(:visible) { true }
43
+
44
+ context 'when the border is not enabled' do
45
+ it { subject.must_equal([]) }
46
+ end
47
+
48
+ context 'when the border is enabled' do
49
+ let(:enabled) { true }
50
+
51
+ # it { skip }
52
+ end
53
+ end
54
+ end
13
55
 
14
56
  end # RenderBorder
15
57
 
@@ -9,20 +9,47 @@ module Vedeu
9
9
  include Vedeu::Registerable
10
10
 
11
11
  null Vedeu::ModelTestClass
12
+ real Vedeu::ModelTestClass
12
13
 
13
14
  end
14
15
 
15
- describe '.included' do
16
- it { RegisterableTestClass.must_respond_to(:null) }
17
- end
16
+ let(:described) { Vedeu::Registerable }
17
+
18
+ it { RegisterableTestClass.must_respond_to(:repository) }
19
+ it { RegisterableTestClass.must_respond_to(:register) }
18
20
 
19
21
  describe '.null' do
20
22
  subject { RegisterableTestClass.new }
21
23
 
24
+ it { RegisterableTestClass.must_respond_to(:null) }
25
+
22
26
  it { subject.must_respond_to(:null_model) }
23
27
  it { subject.null_model.must_equal(Vedeu::ModelTestClass) }
24
28
  end
25
29
 
30
+ describe '.real' do
31
+ subject { RegisterableTestClass.new }
32
+
33
+ it { RegisterableTestClass.must_respond_to(:real) }
34
+
35
+ it { subject.must_respond_to(:model) }
36
+ it { subject.model.must_equal(Vedeu::ModelTestClass) }
37
+ end
38
+
39
+ describe '.reset' do
40
+ subject { RegisterableTestClass.reset! }
41
+
42
+ before { RegisterableTestClass.stubs(:register) }
43
+
44
+ it { RegisterableTestClass.must_respond_to(:reset!) }
45
+ it { RegisterableTestClass.must_respond_to(:reset) }
46
+
47
+ it {
48
+ RegisterableTestClass.expects(:register)
49
+ subject
50
+ }
51
+ end
52
+
26
53
  end # Registerable
27
54
 
28
55
  end # Vedeu
@@ -10,19 +10,6 @@ module Vedeu
10
10
 
11
11
  it { described.must_respond_to(:borders) }
12
12
 
13
- describe '.reset!' do
14
- subject { described.reset! }
15
-
16
- before { described.stubs(:register) }
17
-
18
- it { described.must_respond_to(:reset) }
19
-
20
- it {
21
- described.expects(:register).with(Vedeu::Border)
22
- subject
23
- }
24
- end
25
-
26
13
  end # Borders
27
14
 
28
15
  end # Vedeu
@@ -9,17 +9,6 @@ module Vedeu
9
9
 
10
10
  it { described.must_respond_to(:buffers) }
11
11
 
12
- describe '#reset!' do
13
- subject { described.reset! }
14
-
15
- it { described.must_respond_to(:reset) }
16
-
17
- it {
18
- described.expects(:register).with(Vedeu::Buffer)
19
- subject
20
- }
21
- end
22
-
23
12
  end # Buffers
24
13
 
25
14
  end # Vedeu