vedeu 0.4.16 → 0.4.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/api.rb +7 -21
  3. data/lib/vedeu/bindings.rb +2 -6
  4. data/lib/vedeu/buffers/buffer.rb +29 -34
  5. data/lib/vedeu/cursor/cursor.rb +5 -2
  6. data/lib/vedeu/distributed/all.rb +5 -5
  7. data/lib/vedeu/distributed/server.rb +1 -1
  8. data/lib/vedeu/dsl/components/border.rb +1 -2
  9. data/lib/vedeu/dsl/components/geometry.rb +0 -47
  10. data/lib/vedeu/dsl/interface.rb +4 -11
  11. data/lib/vedeu/dsl/line.rb +1 -2
  12. data/lib/vedeu/dsl/shared/all.rb +1 -2
  13. data/lib/vedeu/dsl/shared/{colour.rb → presentation.rb} +27 -4
  14. data/lib/vedeu/dsl/shared/use.rb +50 -29
  15. data/lib/vedeu/dsl/stream.rb +1 -2
  16. data/lib/vedeu/geometry/geometry.rb +22 -11
  17. data/lib/vedeu/geometry/index_position.rb +0 -19
  18. data/lib/vedeu/geometry/position_validator.rb +8 -8
  19. data/lib/vedeu/models/interface.rb +34 -76
  20. data/lib/vedeu/models/null_interface.rb +5 -0
  21. data/lib/vedeu/models/stream.rb +1 -1
  22. data/lib/vedeu/output/border.rb +25 -41
  23. data/lib/vedeu/output/clear.rb +1 -7
  24. data/lib/vedeu/output/esc.rb +10 -10
  25. data/lib/vedeu/output/presentation.rb +2 -0
  26. data/lib/vedeu/output/renderers/escape_sequence_renderer.rb +3 -0
  27. data/lib/vedeu/repositories/model.rb +6 -0
  28. data/lib/vedeu/repositories/repositories/groups.rb +12 -0
  29. data/lib/vedeu/repositories/repository.rb +11 -8
  30. data/lib/vedeu/storage/all.rb +4 -4
  31. data/lib/vedeu/support/visibility.rb +8 -0
  32. data/test/lib/vedeu/buffers/buffer_test.rb +0 -2
  33. data/test/lib/vedeu/cursor/cursor_test.rb +14 -0
  34. data/test/lib/vedeu/dsl/components/border_test.rb +2 -2
  35. data/test/lib/vedeu/dsl/components/geometry_test.rb +63 -82
  36. data/test/lib/vedeu/dsl/components/keymap_test.rb +3 -3
  37. data/test/lib/vedeu/dsl/components/menu_test.rb +8 -8
  38. data/test/lib/vedeu/dsl/interface_test.rb +14 -22
  39. data/test/lib/vedeu/dsl/line_test.rb +4 -4
  40. data/test/lib/vedeu/dsl/shared/{colour_test.rb → presentation_test.rb} +19 -11
  41. data/test/lib/vedeu/dsl/shared/text_test.rb +15 -15
  42. data/test/lib/vedeu/dsl/shared/use_test.rb +24 -7
  43. data/test/lib/vedeu/geometry/geometry_test.rb +22 -19
  44. data/test/lib/vedeu/geometry/grid_test.rb +3 -3
  45. data/test/lib/vedeu/geometry/index_position_test.rb +0 -45
  46. data/test/lib/vedeu/geometry/position_test.rb +5 -5
  47. data/test/lib/vedeu/models/cell_test.rb +3 -3
  48. data/test/lib/vedeu/models/char_test.rb +5 -5
  49. data/test/lib/vedeu/models/interface_test.rb +7 -53
  50. data/test/lib/vedeu/models/null_test.rb +2 -2
  51. data/test/lib/vedeu/models/stream_test.rb +5 -5
  52. data/test/lib/vedeu/output/border_test.rb +1 -0
  53. data/test/lib/vedeu/output/colour_test.rb +16 -16
  54. data/test/lib/vedeu/output/esc_test.rb +15 -1
  55. data/test/lib/vedeu/output/html_char_test.rb +4 -4
  56. data/test/lib/vedeu/output/style_test.rb +15 -13
  57. data/test/lib/vedeu/output/text_test.rb +3 -3
  58. data/test/lib/vedeu/repositories/collection_test.rb +2 -2
  59. data/test/lib/vedeu/repositories/model_test.rb +19 -0
  60. data/test/lib/vedeu/repositories/repositories/groups_test.rb +22 -0
  61. data/test/lib/vedeu/repositories/repository_test.rb +50 -16
  62. data/test/lib/vedeu/support/common_test.rb +5 -5
  63. data/test/lib/vedeu/support/terminal_test.rb +3 -3
  64. data/test/lib/vedeu/support/visibility_test.rb +8 -0
  65. data/test/support/helpers/model_test_class.rb +18 -0
  66. data/test/test_helper.rb +1 -1
  67. data/vedeu.gemspec +2 -2
  68. metadata +7 -20
  69. data/lib/vedeu/dsl/shared/style.rb +0 -39
  70. data/test/lib/vedeu/dsl/shared/style_test.rb +0 -25
  71. data/test/support/helpers/all.rb +0 -5
  72. data/test/support/helpers/dsl_model_test_class.rb +0 -25
  73. data/test/support/helpers/helpers.rb +0 -17
  74. data/test/support/helpers/repositories.rb +0 -26
  75. data/test/support/helpers/repository_test_module.rb +0 -21
@@ -17,14 +17,14 @@ module Vedeu
17
17
  describe Grid do
18
18
 
19
19
  let(:described) { Vedeu::Grid }
20
- let(:instance) { described.new(value) }
21
- let(:value) { 2 }
20
+ let(:instance) { described.new(_value) }
21
+ let(:_value) { 2 }
22
22
 
23
23
  before { IO.console.stubs(:winsize).returns([25, 80]) }
24
24
 
25
25
  describe '#initialize' do
26
26
  it { instance.must_be_instance_of(Grid) }
27
- it { instance.instance_variable_get('@value').must_equal(value) }
27
+ it { instance.instance_variable_get('@value').must_equal(_value) }
28
28
  end
29
29
 
30
30
  describe '.columns' do
@@ -30,51 +30,6 @@ module Vedeu
30
30
  it { subject.must_be_instance_of(Vedeu::Position) }
31
31
  end
32
32
 
33
- describe '.from_interface' do
34
- let(:ix) { 3 }
35
- let(:iy) { 3 }
36
- let(:_name) { 'IndexPosition.from_interface' }
37
-
38
- before do
39
- Vedeu.borders.reset
40
- Vedeu.interfaces.reset
41
- Vedeu.interface('IndexPosition.from_interface') do
42
- geometry do
43
- x 4
44
- y 6
45
- xn 10
46
- yn 12
47
- end
48
- end
49
- end
50
- after { Vedeu.interfaces.reset }
51
-
52
- subject { described.from_interface(_name, iy, ix) }
53
-
54
- it { subject.must_be_instance_of(Vedeu::Position) }
55
-
56
- context 'when the interface is registered' do
57
- context 'when the interface has a border' do
58
- before { Vedeu.border('IndexPosition.from_interface') {} }
59
-
60
- it { subject.x.must_equal(8) }
61
- it { subject.y.must_equal(10) }
62
- end
63
-
64
- context 'when the interface does not have a border' do
65
- it { subject.x.must_equal(7) }
66
- it { subject.y.must_equal(9) }
67
- end
68
- end
69
-
70
- context 'when the interface is not registered' do
71
- before { Vedeu.interfaces.reset }
72
-
73
- it { subject.x.must_equal(4) }
74
- it { subject.y.must_equal(4) }
75
- end
76
- end
77
-
78
33
  describe '#[]' do
79
34
  subject { instance.[] }
80
35
 
@@ -27,18 +27,18 @@ module Vedeu
27
27
  end
28
28
 
29
29
  describe '.coerce' do
30
- let(:value) {}
30
+ let(:_value) {}
31
31
 
32
- subject { described.coerce(value) }
32
+ subject { described.coerce(_value) }
33
33
 
34
34
  context 'when the value is already a Position' do
35
- let(:value) { instance }
35
+ let(:_value) { instance }
36
36
 
37
37
  it { subject.must_equal(instance) }
38
38
  end
39
39
 
40
40
  context 'when the value is an Array' do
41
- let(:value) { [2, 8] }
41
+ let(:_value) { [2, 8] }
42
42
 
43
43
  it { subject.must_be_instance_of(described) }
44
44
  it { subject.y.must_equal(2) }
@@ -46,7 +46,7 @@ module Vedeu
46
46
  end
47
47
 
48
48
  context 'when the value is a Hash' do
49
- let(:value) { { y: 3, x: 9 } }
49
+ let(:_value) { { y: 3, x: 9 } }
50
50
 
51
51
  it { subject.must_be_instance_of(described) }
52
52
  it { subject.y.must_equal(3) }
@@ -10,14 +10,14 @@ module Vedeu
10
10
  {
11
11
  colour: colour,
12
12
  style: style,
13
- value: value,
13
+ value: _value,
14
14
  x: x,
15
15
  y: y,
16
16
  }
17
17
  }
18
18
  let(:colour) { Colour.new(background: '#000000') }
19
19
  let(:style) {}
20
- let(:value) {}
20
+ let(:_value) {}
21
21
  let(:x) {}
22
22
  let(:y) {}
23
23
 
@@ -27,7 +27,7 @@ module Vedeu
27
27
  it { subject.must_be_instance_of(described) }
28
28
  it { subject.instance_variable_get('@colour').must_equal(colour) }
29
29
  it { subject.instance_variable_get('@style').must_equal(style) }
30
- it { subject.instance_variable_get('@value').must_equal(value) }
30
+ it { subject.instance_variable_get('@value').must_equal(_value) }
31
31
  it { subject.instance_variable_get('@x').must_equal(x) }
32
32
  it { subject.instance_variable_get('@y').must_equal(y) }
33
33
  end
@@ -13,10 +13,10 @@ module Vedeu
13
13
  parent: parent,
14
14
  position: position,
15
15
  style: style,
16
- value: value,
16
+ value: _value,
17
17
  }
18
18
  }
19
- let(:value) { 'a' }
19
+ let(:_value) { 'a' }
20
20
  let(:parent) { Vedeu::Line.new(parent_attributes) }
21
21
  let(:parent_attributes) {
22
22
  {
@@ -37,7 +37,7 @@ module Vedeu
37
37
  it { instance.must_be_instance_of(described) }
38
38
  it { instance.instance_variable_get('@border').must_equal(border) }
39
39
  it { instance.instance_variable_get('@parent').must_equal(parent) }
40
- it { instance.instance_variable_get('@value').must_equal(value) }
40
+ it { instance.instance_variable_get('@value').must_equal(_value) }
41
41
 
42
42
  it { instance.must_respond_to(:value) }
43
43
  end
@@ -183,7 +183,7 @@ module Vedeu
183
183
  end
184
184
 
185
185
  context 'when the value is nil' do
186
- let(:value) {}
186
+ let(:_value) {}
187
187
 
188
188
  it { subject.must_equal('') }
189
189
  end
@@ -196,7 +196,7 @@ module Vedeu
196
196
 
197
197
  context 'when the border attribute is defined' do
198
198
  let(:border) { :top_left }
199
- let(:value) { "\x6C" }
199
+ let(:_value) { "\x6C" }
200
200
 
201
201
  it { subject.must_equal("\e(0l\e(B") }
202
202
  end
@@ -8,6 +8,7 @@ module Vedeu
8
8
  let(:instance) { described.new(attributes) }
9
9
  let(:attributes) {
10
10
  {
11
+ client: client,
11
12
  name: _name,
12
13
  lines: lines,
13
14
  parent: parent,
@@ -16,6 +17,7 @@ module Vedeu
16
17
  visible: visible,
17
18
  }
18
19
  }
20
+ let(:client) {}
19
21
  let(:_name) { 'hydrogen' }
20
22
  let(:lines) { [] }
21
23
  let(:parent) {}
@@ -27,47 +29,14 @@ module Vedeu
27
29
  describe '#initialize' do
28
30
  subject { instance }
29
31
 
30
- it { subject.instance_variable_get('@name').must_equal(_name) }
31
- it { subject.instance_variable_get('@lines').must_equal(lines) }
32
- it { subject.instance_variable_get('@parent').must_equal(parent) }
33
- it { subject.instance_variable_get('@visible').must_equal(visible) }
34
- it { subject.instance_variable_get('@border').must_equal(nil) }
32
+ it { subject.instance_variable_get('@client').must_equal(client) }
35
33
  it { subject.instance_variable_get('@delay').must_equal(0.0) }
36
- it { subject.instance_variable_get('@geometry').must_equal(nil) }
37
34
  it { subject.instance_variable_get('@group').must_equal('') }
35
+ it { subject.instance_variable_get('@lines').must_equal(lines) }
36
+ it { subject.instance_variable_get('@name').must_equal(_name) }
37
+ it { subject.instance_variable_get('@parent').must_equal(parent) }
38
38
  it { subject.instance_variable_get('@repository').must_equal(repository) }
39
- end
40
-
41
- describe '#border' do
42
- subject { instance.border }
43
-
44
- context 'when the interface has a border' do
45
- before { Vedeu.border('hydrogen') { } }
46
- after { Vedeu.borders.reset }
47
-
48
- it { subject.must_be_instance_of(Vedeu::Border) }
49
- end
50
-
51
- context 'when the interface does not have a border' do
52
- before do
53
- Vedeu.interface 'hydrogen' do
54
- end
55
-
56
- Vedeu.borders.reset
57
- end
58
- after { Vedeu.interfaces.reset }
59
-
60
- it { subject.must_be_instance_of(Vedeu::NullBorder) }
61
- end
62
- end
63
-
64
- describe '#clear' do
65
- subject { instance.clear }
66
-
67
- it {
68
- Vedeu::Clear.expects(:new).with(instance)
69
- subject
70
- }
39
+ it { subject.instance_variable_get('@visible').must_equal(visible) }
71
40
  end
72
41
 
73
42
  describe '#lines?' do
@@ -84,12 +53,6 @@ module Vedeu
84
53
  end
85
54
  end
86
55
 
87
- describe '#cursor' do
88
- subject { instance.cursor }
89
-
90
- it { subject.must_be_instance_of(Vedeu::Cursor) }
91
- end
92
-
93
56
  describe '#render' do
94
57
  subject { instance.render }
95
58
 
@@ -115,15 +78,6 @@ module Vedeu
115
78
  end
116
79
  end
117
80
 
118
- describe '#viewport' do
119
- subject { instance.viewport }
120
-
121
- it {
122
- Vedeu::Viewport.expects(:new).with(instance)
123
- subject
124
- }
125
- end
126
-
127
81
  end # Interface
128
82
 
129
83
  end # Vedeu
@@ -52,9 +52,9 @@ module Vedeu
52
52
  end
53
53
 
54
54
  describe '#visible=' do
55
- let(:value) { :ignored }
55
+ let(:_value) { :ignored }
56
56
 
57
- subject { instance.visible = (value) }
57
+ subject { instance.visible = (_value) }
58
58
 
59
59
  # This should be FalseClass, I'm explicitly returning false in the method.
60
60
  it { subject.must_be_instance_of(Symbol) }
@@ -8,13 +8,13 @@ module Vedeu
8
8
  let(:instance) { described.new(attributes) }
9
9
  let(:attributes) {
10
10
  {
11
- value: value,
11
+ value: _value,
12
12
  parent: parent,
13
13
  colour: colour,
14
14
  style: style
15
15
  }
16
16
  }
17
- let(:value) { 'Some text' }
17
+ let(:_value) { 'Some text' }
18
18
  let(:parent) {
19
19
  Line.new(streams: [],
20
20
  parent: line_parent,
@@ -32,7 +32,7 @@ module Vedeu
32
32
 
33
33
  describe '#initialize' do
34
34
  it { instance.must_be_instance_of(described) }
35
- it { instance.instance_variable_get('@value').must_equal(value) }
35
+ it { instance.instance_variable_get('@value').must_equal(_value) }
36
36
  it { instance.instance_variable_get('@parent').must_equal(parent) }
37
37
  end
38
38
 
@@ -54,7 +54,7 @@ module Vedeu
54
54
  end
55
55
 
56
56
  context 'when there is no content' do
57
- let(:value) { '' }
57
+ let(:_value) { '' }
58
58
 
59
59
  it 'returns an empty collection' do
60
60
  subject.must_equal([])
@@ -66,7 +66,7 @@ module Vedeu
66
66
  subject { instance.empty? }
67
67
 
68
68
  context 'when there is no content' do
69
- let(:value) { '' }
69
+ let(:_value) { '' }
70
70
 
71
71
  it { subject.must_equal(true) }
72
72
  end
@@ -51,6 +51,7 @@ module Vedeu
51
51
  enabled: false,
52
52
  horizontal: 'q',
53
53
  name: 'borders',
54
+ repository: Vedeu.borders,
54
55
  show_bottom: true,
55
56
  show_left: true,
56
57
  show_right: true,
@@ -21,9 +21,9 @@ module Vedeu
21
21
  end
22
22
 
23
23
  describe '.coerce' do
24
- let(:value) {}
24
+ let(:_value) {}
25
25
 
26
- subject { described.coerce(value) }
26
+ subject { described.coerce(_value) }
27
27
 
28
28
  it { subject.must_be_instance_of(described) }
29
29
 
@@ -39,7 +39,7 @@ module Vedeu
39
39
  foreground: '#220022',
40
40
  }
41
41
  }
42
- let(:value) { Vedeu::Colour.new(attributes) }
42
+ let(:_value) { Vedeu::Colour.new(attributes) }
43
43
 
44
44
  it { subject.must_be_instance_of(described) }
45
45
  it { subject.attributes.must_equal(attributes) }
@@ -54,7 +54,7 @@ module Vedeu
54
54
  foreground: '#00ff00',
55
55
  }
56
56
  }
57
- let(:value) {
57
+ let(:_value) {
58
58
  {
59
59
  colour: Vedeu::Colour.new(attributes),
60
60
  }
@@ -66,7 +66,7 @@ module Vedeu
66
66
 
67
67
  context 'when the value of :colour is a Hash' do
68
68
  context 'and a :background is defined' do
69
- let(:value) {
69
+ let(:_value) {
70
70
  {
71
71
  colour: {
72
72
  background: '#7700ff'
@@ -82,7 +82,7 @@ module Vedeu
82
82
  end
83
83
 
84
84
  context 'and a :foreground is defined' do
85
- let(:value) {
85
+ let(:_value) {
86
86
  {
87
87
  colour: {
88
88
  foreground: '#220077'
@@ -98,7 +98,7 @@ module Vedeu
98
98
  end
99
99
 
100
100
  context 'and neither a :background or :foreground is defined' do
101
- let(:value) {
101
+ let(:_value) {
102
102
  {
103
103
  colour: 'wrong'
104
104
  }
@@ -115,7 +115,7 @@ module Vedeu
115
115
 
116
116
  context 'when the hash does not have a :colour defined' do
117
117
  context 'when the hash has a :background defined' do
118
- let(:value) {
118
+ let(:_value) {
119
119
  {
120
120
  background: '#000022'
121
121
  }
@@ -129,7 +129,7 @@ module Vedeu
129
129
  end
130
130
 
131
131
  context 'when the hash has a :foreground defined' do
132
- let(:value) {
132
+ let(:_value) {
133
133
  {
134
134
  foreground: '#aadd00'
135
135
  }
@@ -143,7 +143,7 @@ module Vedeu
143
143
  end
144
144
 
145
145
  context 'when neither a :background or :foreground is defined' do
146
- let(:value) {
146
+ let(:_value) {
147
147
  {
148
148
  irrelevant: true
149
149
  }
@@ -184,11 +184,11 @@ module Vedeu
184
184
  end
185
185
 
186
186
  describe '#background=' do
187
- let(:value) { '#000000' }
187
+ let(:_value) { '#000000' }
188
188
 
189
- subject { instance.background = (value) }
189
+ subject { instance.background = (_value) }
190
190
 
191
- it { subject.must_equal(value) }
191
+ it { subject.must_equal(_value) }
192
192
  end
193
193
 
194
194
  describe '#eql?' do
@@ -230,11 +230,11 @@ module Vedeu
230
230
  end
231
231
 
232
232
  describe '#foreground=' do
233
- let(:value) { '#ff0000' }
233
+ let(:_value) { '#ff0000' }
234
234
 
235
- subject { instance.foreground = (value) }
235
+ subject { instance.foreground = (_value) }
236
236
 
237
- it { subject.must_equal(value) }
237
+ it { subject.must_equal(_value) }
238
238
  end
239
239
 
240
240
  describe '#to_s' do
@@ -48,10 +48,24 @@ module Vedeu
48
48
  context 'when a stream is not given' do
49
49
  let(:stream) { '' }
50
50
 
51
- it { Esc.escape(stream).must_equal('') }
51
+ it { subject.must_equal('') }
52
52
  end
53
53
  end
54
54
 
55
+ describe '.hide_cursor' do
56
+ subject { described.hide_cursor }
57
+
58
+ it { subject.must_be_instance_of(String) }
59
+ it { subject.must_equal("\e[?25l") }
60
+ end
61
+
62
+ describe '.show_cursor' do
63
+ subject { described.show_cursor }
64
+
65
+ it { subject.must_be_instance_of(String) }
66
+ it { subject.must_equal("\e[?25h") }
67
+ end
68
+
55
69
  describe '.string' do
56
70
  it 'returns an empty string when the style is not provided' do
57
71
  Esc.string.must_equal('')