vedeu 0.6.34 → 0.6.35

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,14 @@ module Vedeu
7
7
  # :nocov:
8
8
  module Options
9
9
 
10
+ # @!attribute [w] options
11
+ # @return [Hash<Symbol => void>]
12
+ attr_writer :options
13
+
14
+ def compress?
15
+ options[:compression] || false
16
+ end
17
+
10
18
  private
11
19
 
12
20
  # Combines the options provided at instantiation with the
@@ -102,7 +102,7 @@ module Vedeu
102
102
  #
103
103
  # @return [void]
104
104
  def terminate!
105
- Vedeu.log(type: :info, message: 'Exiting gracefully.'.freeze)
105
+ Vedeu.log(message: 'Exiting gracefully.'.freeze)
106
106
 
107
107
  $stdin = STDIN
108
108
  $stdout = STDOUT
@@ -32,8 +32,7 @@ module Vedeu
32
32
  safe_exit_point!
33
33
  end
34
34
  rescue Vedeu::Error::Interrupt
35
- Vedeu.log(type: :info,
36
- message: 'Vedeu execution interrupted, exiting.'.freeze)
35
+ Vedeu.log(message: 'Vedeu execution interrupted, exiting.'.freeze)
37
36
  end
38
37
 
39
38
  # :nocov:
@@ -20,9 +20,9 @@ module Vedeu
20
20
  #
21
21
  # @return [Array<Array<Vedeu::Models::Cell>>]
22
22
  def buffer
23
- @output ||= Array.new(Vedeu.height) do |y|
24
- Array.new(Vedeu.width) do |x|
25
- Vedeu::Models::Cell.new(position: [y + 1, x + 1])
23
+ @output ||= Array.new(Vedeu.height + 1) do |y|
24
+ Array.new(Vedeu.width + 1) do |x|
25
+ Vedeu::Models::Cell.new(position: [y, x])
26
26
  end
27
27
  end
28
28
  end
@@ -77,9 +77,9 @@ module Vedeu
77
77
  #
78
78
  # @return [Array<Array<Vedeu::Models::Cell>>]
79
79
  def reset
80
- @output = Array.new(Vedeu.height) do |y|
81
- Array.new(Vedeu.width) do |x|
82
- Vedeu::Models::Cell.new(position: [y + 1, x + 1])
80
+ @output = Array.new(Vedeu.height + 1) do |y|
81
+ Array.new(Vedeu.width + 1) do |x|
82
+ Vedeu::Models::Cell.new(position: [y, x])
83
83
  end
84
84
  end
85
85
  end
@@ -75,7 +75,7 @@ module Vedeu
75
75
  # @param mode [Symbol]
76
76
  # @return [void]
77
77
  def initialize_screen(mode)
78
- Vedeu.log(type: :info, message: "Terminal entering '#{mode}' mode".freeze)
78
+ Vedeu.log(message: "Terminal entering '#{mode}' mode".freeze)
79
79
 
80
80
  output(Vedeu::EscapeSequences::Esc.string('screen_init'))
81
81
 
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.34'.freeze
4
+ VERSION = '0.6.35'.freeze
5
5
 
6
6
  end
@@ -0,0 +1,100 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Geometry
6
+
7
+ describe Alignment do
8
+
9
+ let(:described) { Vedeu::Geometry::Alignment }
10
+ let(:instance) { described.new(_value) }
11
+ let(:_value) {}
12
+
13
+ describe '#initialize' do
14
+ it { instance.must_be_instance_of(described) }
15
+ it { instance.instance_variable_get('@value').must_equal(_value) }
16
+ end
17
+
18
+ describe '.align' do
19
+ subject { described.align(_value) }
20
+
21
+ context 'when the value is nil' do
22
+ it { subject.must_equal(:none) }
23
+ end
24
+
25
+ context 'when the value is not a Symbol' do
26
+ let(:_value) { 'invalid' }
27
+
28
+ it { subject.must_equal(:none) }
29
+ end
30
+
31
+ context 'when the value is :center' do
32
+ let(:_value) { :center }
33
+
34
+ it { subject.must_equal(:centre) }
35
+ end
36
+
37
+ context 'when the value is :centre' do
38
+ let(:_value) { :centre }
39
+
40
+ it { subject.must_equal(:centre) }
41
+ end
42
+
43
+ context 'when the value is :left' do
44
+ let(:_value) { :left }
45
+
46
+ it { subject.must_equal(:left) }
47
+ end
48
+
49
+ context 'when the value is :right' do
50
+ let(:_value) { :right }
51
+
52
+ it { subject.must_equal(:right) }
53
+ end
54
+
55
+ context 'when the value is :alignment' do
56
+ let(:_value) { :alignment }
57
+
58
+ it { subject.must_equal(:none) }
59
+ end
60
+
61
+ context 'when the value is :align_center' do
62
+ let(:_value) { :align_center }
63
+
64
+ it { subject.must_equal(:centre) }
65
+ end
66
+
67
+ context 'when the value is :align_centre' do
68
+ let(:_value) { :align_centre }
69
+
70
+ it { subject.must_equal(:centre) }
71
+ end
72
+
73
+ context 'when the value is :align_left' do
74
+ let(:_value) { :align_left }
75
+
76
+ it { subject.must_equal(:left) }
77
+ end
78
+
79
+ context 'when the value is :align_right' do
80
+ let(:_value) { :align_right }
81
+
82
+ it { subject.must_equal(:right) }
83
+ end
84
+
85
+ context 'when the value is :align_invalid' do
86
+ let(:_value) { :align_invalid }
87
+
88
+ it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
89
+ end
90
+ end
91
+
92
+ describe '#align' do
93
+ it { instance.must_respond_to(:align) }
94
+ end
95
+
96
+ end # Alignment
97
+
98
+ end # Geometry
99
+
100
+ end # Vedeu
@@ -48,6 +48,7 @@ module Vedeu
48
48
  x_default: x_default,
49
49
  maximised: maximised,
50
50
  centred: centred,
51
+ alignment: alignment,
51
52
  }
52
53
  }
53
54
  let(:y) {}
@@ -60,6 +61,7 @@ module Vedeu
60
61
  let(:x_default) {}
61
62
  let(:maximised) {}
62
63
  let(:centred) {}
64
+ let(:alignment) {}
63
65
 
64
66
  subject { described.from_attributes(attributes) }
65
67
 
@@ -16,6 +16,7 @@ module Vedeu
16
16
  default: default,
17
17
  maximised: maximised,
18
18
  centred: centred,
19
+ alignment: alignment,
19
20
  }
20
21
  }
21
22
  let(:d) {}
@@ -24,6 +25,7 @@ module Vedeu
24
25
  let(:default) {}
25
26
  let(:maximised) {}
26
27
  let(:centred) {}
28
+ let(:alignment) {}
27
29
 
28
30
  describe '#initialize' do
29
31
  it { instance.must_be_instance_of(described) }
@@ -33,6 +35,7 @@ module Vedeu
33
35
  it { instance.instance_variable_get('@default').must_equal(default) }
34
36
  it { instance.instance_variable_get('@maximised').must_equal(maximised) }
35
37
  it { instance.instance_variable_get('@centred').must_equal(centred) }
38
+ it { instance.instance_variable_get('@alignment').must_equal(alignment) }
36
39
  end
37
40
 
38
41
  describe '.pair' do
@@ -51,8 +54,64 @@ module Vedeu
51
54
  it { subject.must_equal([1, 80]) }
52
55
  end
53
56
 
54
- context 'when centred and a length can be determined' do
55
- let(:centred) { true }
57
+ context 'when left aligned' do
58
+ let(:alignment) { :left }
59
+ let(:default) { 80 }
60
+
61
+ context 'when a width (d_dn) is set' do
62
+ let(:d_dn) { 20 }
63
+
64
+ it { subject.must_equal([1, 20]) }
65
+
66
+ context 'when the width is greater than the terminal width' do
67
+ let(:d_dn) { 100 }
68
+
69
+ it { subject.must_equal([1, 80]) }
70
+ end
71
+ end
72
+
73
+ context 'when a dn is set' do
74
+ it { subject.must_equal([1, 38]) }
75
+ end
76
+
77
+ context 'when neither width nor dn is set' do
78
+ let(:dn) {}
79
+
80
+ it { subject.must_equal([1, 80]) }
81
+ end
82
+ end
83
+
84
+ context 'when right aligned' do
85
+ let(:alignment) { :right }
86
+ let(:default) { 80 }
87
+
88
+ context 'when a width (d_dn) is set' do
89
+ let(:d_dn) { 20 }
90
+
91
+ it { subject.must_equal([60, 80]) }
92
+
93
+ context 'when the width is greater than the terminal width' do
94
+ let(:d_dn) { 100 }
95
+
96
+ it { subject.must_equal([1, 80]) }
97
+ end
98
+ end
99
+
100
+ context 'when a d is set' do
101
+ let(:d) { 58 }
102
+
103
+ it { subject.must_equal([58, 80]) }
104
+ end
105
+
106
+ context 'when neither width nor d is set' do
107
+ let(:d) {}
108
+
109
+ it { subject.must_equal([1, 80]) }
110
+ end
111
+ end
112
+
113
+ context 'when centre aligned' do
114
+ let(:alignment) { :centre }
56
115
  let(:default) { 80 }
57
116
 
58
117
  context 'when d and dn are given' do
@@ -79,110 +138,112 @@ module Vedeu
79
138
 
80
139
  it { subject.must_be_instance_of(Fixnum) }
81
140
 
82
- context 'when not centred and/or a length cannot be determined' do
83
- context 'when d is given' do
84
- let(:d) { 5 }
141
+ # context 'when not centred and/or a length cannot be determined' do
142
+ # context 'when d is given' do
143
+ # let(:d) { 5 }
85
144
 
86
- it { subject.must_equal(5) }
87
- end
145
+ # it { subject.must_equal(5) }
146
+ # end
88
147
 
89
- context 'when d is not given' do
90
- it { subject.must_equal(1) }
91
- end
92
- end
148
+ # context 'when d is not given' do
149
+ # it { subject.must_equal(1) }
150
+ # end
151
+ # end
93
152
 
94
- context 'when centred and a length can be determined' do
95
- let(:centred) { true }
96
- let(:default) { 80 }
153
+ # context 'when centred and a length can be determined' do
154
+ # let(:centred) { true }
155
+ # let(:default) { 80 }
97
156
 
98
- context 'when d and dn are given' do
99
- let(:d) { 7 }
100
- let(:dn) { 47 }
157
+ # context 'when d and dn are given' do
158
+ # let(:d) { 7 }
159
+ # let(:dn) { 47 }
101
160
 
102
- it { subject.must_equal(20) }
103
- end
161
+ # it { subject.must_equal(20) }
162
+ # end
104
163
 
105
- context 'when only a d_dn is given' do
106
- let(:d_dn) { 30 }
164
+ # context 'when only a d_dn is given' do
165
+ # let(:d_dn) { 30 }
107
166
 
108
- it { subject.must_equal(25) }
109
- end
167
+ # it { subject.must_equal(25) }
168
+ # end
110
169
 
111
- context 'when only a default is given' do
112
- it { subject.must_equal(1) }
113
- end
114
- end
170
+ # context 'when only a default is given' do
171
+ # it { subject.must_equal(1) }
172
+ # end
173
+ # end
115
174
  end
116
175
 
117
176
  describe '#d2' do
118
177
  subject { instance.d2 }
119
178
 
120
- context 'when not centred and/or a length cannot be determined' do
121
- context 'when d and dn are given' do
122
- let(:d) { 5 }
123
- let(:dn) { 8 }
179
+ it { subject.must_be_instance_of(Fixnum) }
124
180
 
125
- it { subject.must_equal(8) }
126
- end
181
+ # context 'when not centred and/or a length cannot be determined' do
182
+ # context 'when d and dn are given' do
183
+ # let(:d) { 5 }
184
+ # let(:dn) { 8 }
127
185
 
128
- context 'when d and d_dn are given' do
129
- let(:d) { 5 }
130
- let(:d_dn) { 2 }
186
+ # it { subject.must_equal(8) }
187
+ # end
131
188
 
132
- it { subject.must_equal(6) }
133
- end
189
+ # context 'when d and d_dn are given' do
190
+ # let(:d) { 5 }
191
+ # let(:d_dn) { 2 }
134
192
 
135
- context 'when only d_dn is given' do
136
- let(:d_dn) { 6 }
193
+ # it { subject.must_equal(6) }
194
+ # end
137
195
 
138
- it { subject.must_equal(6) }
139
- end
196
+ # context 'when only d_dn is given' do
197
+ # let(:d_dn) { 6 }
140
198
 
141
- context 'when only dn is given' do
142
- let(:dn) { 8 }
199
+ # it { subject.must_equal(6) }
200
+ # end
143
201
 
144
- it { subject.must_equal(8) }
145
- end
202
+ # context 'when only dn is given' do
203
+ # let(:dn) { 8 }
146
204
 
147
- context 'when d and a default is given' do
148
- let(:d) { 1 }
149
- let(:default) { 40 }
205
+ # it { subject.must_equal(8) }
206
+ # end
150
207
 
151
- it { subject.must_equal(40) }
152
- end
208
+ # context 'when d and a default is given' do
209
+ # let(:d) { 1 }
210
+ # let(:default) { 40 }
153
211
 
154
- context 'when only a default is given' do
155
- let(:default) { 25 }
212
+ # it { subject.must_equal(40) }
213
+ # end
156
214
 
157
- it { subject.must_equal(25) }
158
- end
215
+ # context 'when only a default is given' do
216
+ # let(:default) { 25 }
159
217
 
160
- context 'when no default is given' do
161
- it { subject.must_equal(nil) }
162
- end
163
- end
218
+ # it { subject.must_equal(25) }
219
+ # end
164
220
 
165
- context 'when centred and a length can be determined' do
166
- let(:centred) { true }
167
- let(:default) { 80 }
221
+ # context 'when no default is given' do
222
+ # it { subject.must_equal(nil) }
223
+ # end
224
+ # end
168
225
 
169
- context 'when d and dn are given' do
170
- let(:d) { 7 }
171
- let(:dn) { 47 }
226
+ # context 'when centred and a length can be determined' do
227
+ # let(:centred) { true }
228
+ # let(:default) { 80 }
172
229
 
173
- it { subject.must_equal(60) }
174
- end
230
+ # context 'when d and dn are given' do
231
+ # let(:d) { 7 }
232
+ # let(:dn) { 47 }
175
233
 
176
- context 'when only a d_dn is given' do
177
- let(:d_dn) { 30 }
234
+ # it { subject.must_equal(60) }
235
+ # end
178
236
 
179
- it { subject.must_equal(55) }
180
- end
237
+ # context 'when only a d_dn is given' do
238
+ # let(:d_dn) { 30 }
181
239
 
182
- context 'when only a default is given' do
183
- it { subject.must_equal(80) }
184
- end
185
- end
240
+ # it { subject.must_equal(55) }
241
+ # end
242
+
243
+ # context 'when only a default is given' do
244
+ # it { subject.must_equal(80) }
245
+ # end
246
+ # end
186
247
  end
187
248
 
188
249
  end # Dimension