vedeu 0.8.22 → 0.8.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 317fd304eff7309a776c7520081310f4098f8d63
4
- data.tar.gz: 7cb42ff7dbc8b4945d5951cfff3a4030829b0ffc
3
+ metadata.gz: 23c1d81d7fc643062c5bfe739de370ff0e5dc948
4
+ data.tar.gz: 4083354c5c95d5828d7108d1f1870ddbf934f38c
5
5
  SHA512:
6
- metadata.gz: 7e4b571d22b599bcd5c977684c3e75862d5faaf740de1fe56db3588f64ba29b7a4873da43f02d7d169b8a9471f6ef505842eb62e6a243ee5ce5b5db2412ae5e1
7
- data.tar.gz: cdc5fbb14ae664528bd42214fd9e80c13418a20851b1a4aefc03937e67fa509275ea5c6c0f8559d931bc5c58cebd54ee567f10f35716002dba17f6ca3492d549
6
+ metadata.gz: 31993a416e19b815f8d471d0a23364918c07d070ae9823c17316393b1523f6a2a4780eff35ea05bef6c6ab1a82d61f7b2eabadcba074407874102a0dd574f416
7
+ data.tar.gz: b9b5bed7178bac6915911f7d4c0b19081a1c5c8094622d4d1e25e10dcbeab4c28b129188bed49487e03c20c1b1b108125d3bd2ca415a9e6533774366e94fd858
@@ -62,6 +62,9 @@ Style/ExtraSpacing:
62
62
  # - special_inside_parentheses
63
63
  # - consistent
64
64
 
65
+ Style/MultilineBlockChain:
66
+ Enabled: false
67
+
65
68
  Style/MultilineOperationIndentation:
66
69
  Enabled: false
67
70
 
@@ -16,15 +16,17 @@ class TestRunner
16
16
  # @return [TestRunner]
17
17
  def initialize(testcase, filename)
18
18
  @testcase = testcase
19
- @filename = filename
19
+ @filename = filename
20
20
  end
21
21
 
22
22
  # @return [void]
23
23
  def result
24
24
  print "\e[36m#{filename}: "
25
+
25
26
  if expected == actual
26
27
  print "\e[32mPassed.\e[39m\n"
27
28
  exit 0;
29
+
28
30
  else
29
31
  print "\e[31mFailed.\e[39m\n"
30
32
  puts "\e[33mExpected:\e[39m"
@@ -32,6 +34,7 @@ class TestRunner
32
34
  puts "\e[34mActual:\e[39m"
33
35
  puts actual.inspect
34
36
  exit 1;
37
+
35
38
  end
36
39
  end
37
40
 
@@ -57,7 +57,7 @@ module Vedeu
57
57
  def empty
58
58
  Array.new(height) do |h|
59
59
  Array.new(width) do |w|
60
- Vedeu::Cells::Empty.new(name: name, position: [(y + h), (x + w)])
60
+ Vedeu::Cells::Empty.new(name: name)
61
61
  end
62
62
  end
63
63
  end
@@ -10,7 +10,7 @@ module Vedeu
10
10
  #
11
11
  class Corner < Vedeu::Cells::Border
12
12
 
13
- # @return [Vedeu::Geometries::Position]
13
+ # @return [NilClass|Vedeu::Geometries::Position]
14
14
  def position
15
15
  @position = defaults[:position]
16
16
  end
@@ -88,6 +88,11 @@ module Vedeu
88
88
  :empty
89
89
  end
90
90
 
91
+ # @return [Boolean]
92
+ def value?
93
+ present?(value)
94
+ end
95
+
91
96
  private
92
97
 
93
98
  # @macro defaults_method
@@ -36,6 +36,52 @@ module Vedeu
36
36
  instance_eval(&block) if block_given?
37
37
  end
38
38
 
39
+ # {include:file:docs/configuration/background.md}
40
+ # @param value [String]
41
+ # @return [Vedeu::Colours::Background]
42
+ def background(value = nil)
43
+ return options[:background] unless value
44
+
45
+ options[:background] = value
46
+ end
47
+
48
+ # {include:file:docs/configuration/base_path.md}
49
+ # @param path [String]
50
+ # @return [String]
51
+ def base_path(path = nil)
52
+ options[:base_path] = path
53
+ end
54
+
55
+ # {include:file:docs/configuration/colour.md}
56
+ # @param attrs [Hash<Symbol => String>]
57
+ # @return [Hash<Symbol => void>]
58
+ def colour(attrs = {})
59
+ options[:background] = attrs[:background] if attrs.key?(:background)
60
+ options[:foreground] = attrs[:foreground] if attrs.key?(:foreground)
61
+ options
62
+ end
63
+
64
+ # {include:file:docs/configuration/colour_mode.md}
65
+ # @param value [Fixnum]
66
+ # @macro raise_invalid_syntax
67
+ # @return [Boolean]
68
+ def colour_mode(value = nil)
69
+ unless valid_colour_mode?(value)
70
+ raise Vedeu::Error::InvalidSyntax,
71
+ '`colour_mode` must be `8`, `16`, `256`, `16777216`.'
72
+ end
73
+
74
+ options[:colour_mode] = value
75
+ end
76
+
77
+ # {include:file:docs/configuration/compression.md}
78
+ # @param value [Boolean]
79
+ # @return [Boolean]
80
+ def compression(value = true)
81
+ options[:compression] = value
82
+ end
83
+ alias compression! compression
84
+
39
85
  # Returns the configuration options set up by the API DSL.
40
86
  #
41
87
  # @return [Hash<Symbol => Boolean, Fixnum, String>]
@@ -58,29 +104,20 @@ module Vedeu
58
104
  options
59
105
  end
60
106
 
61
- # {include:file:docs/configuration/interactive.md}
62
- # @param value [Boolean]
63
- # @return [Boolean]
64
- def interactive!(value = true)
65
- options[:interactive] = value
66
- end
67
- alias interactive interactive!
68
-
69
- # {include:file:docs/configuration/standalone.md}
70
- # @param value [Boolean]
107
+ # {include:file:docs/configuration/cooked.md}
71
108
  # @return [Boolean]
72
- def standalone!(value = true)
73
- options[:interactive] = !value
109
+ def cooked!
110
+ options[:terminal_mode] = :cooked
74
111
  end
75
- alias standalone standalone!
112
+ alias cooked cooked!
76
113
 
77
- # {include:file:docs/configuration/run_once.md}
114
+ # {include:file:docs/configuration/debug.md}
78
115
  # @param value [Boolean]
79
116
  # @return [Boolean]
80
- def run_once!(value = true)
81
- options[:once] = value
117
+ def debug!(value = true)
118
+ options[:debug] = value
82
119
  end
83
- alias run_once run_once!
120
+ alias debug debug!
84
121
 
85
122
  # {include:file:docs/configuration/drb.md}
86
123
  # @param value [Boolean]
@@ -90,6 +127,13 @@ module Vedeu
90
127
  end
91
128
  alias drb drb!
92
129
 
130
+ # {include:file:docs/configuration/drb_height.md}
131
+ # @param height [Fixnum]
132
+ # @return [Fixnum]
133
+ def drb_height(height = 25)
134
+ options[:drb_height] = height
135
+ end
136
+
93
137
  # {include:file:docs/configuration/drb_host.md}
94
138
  # @param hostname [String]
95
139
  # @return [String]
@@ -104,13 +148,6 @@ module Vedeu
104
148
  options[:drb_port] = port
105
149
  end
106
150
 
107
- # {include:file:docs/configuration/drb_height.md}
108
- # @param height [Fixnum]
109
- # @return [Fixnum]
110
- def drb_height(height = 25)
111
- options[:drb_height] = height
112
- end
113
-
114
151
  # {include:file:docs/configuration/drb_width.md}
115
152
  # @param width [Fixnum]
116
153
  # @return [Fixnum]
@@ -118,13 +155,6 @@ module Vedeu
118
155
  options[:drb_width] = width
119
156
  end
120
157
 
121
- # {include:file:docs/configuration/cooked.md}
122
- # @return [Boolean]
123
- def cooked!
124
- options[:terminal_mode] = :cooked
125
- end
126
- alias cooked cooked!
127
-
128
158
  # {include:file:docs/configuration/fake.md}
129
159
  # @return [Boolean]
130
160
  def fake!
@@ -132,32 +162,13 @@ module Vedeu
132
162
  end
133
163
  alias fake fake!
134
164
 
135
- # {include:file:docs/configuration/raw.md}
136
- # @return [Boolean]
137
- def raw!
138
- options[:terminal_mode] = :raw
139
- end
140
- alias raw raw!
141
-
142
- # {include:file:docs/configuration/debug.md}
143
- # @param value [Boolean]
144
- # @return [Boolean]
145
- def debug!(value = true)
146
- options[:debug] = value
147
- end
148
- alias debug debug!
149
-
150
- # {include:file:docs/configuration/colour_mode.md}
151
- # @param value [Fixnum]
152
- # @macro raise_invalid_syntax
153
- # @return [Boolean]
154
- def colour_mode(value = nil)
155
- unless valid_colour_mode?(value)
156
- raise Vedeu::Error::InvalidSyntax,
157
- '`colour_mode` must be `8`, `16`, `256`, `16777216`.'
158
- end
165
+ # {include:file:docs/configuration/foreground.md}
166
+ # @param value [String]
167
+ # @return [Vedeu::Colours::Foreground]
168
+ def foreground(value = nil)
169
+ return options[:foreground] unless value
159
170
 
160
- options[:colour_mode] = value
171
+ options[:foreground] = value
161
172
  end
162
173
 
163
174
  # {include:file:docs/configuration/height.md}
@@ -168,6 +179,14 @@ module Vedeu
168
179
  end
169
180
  alias height= height
170
181
 
182
+ # {include:file:docs/configuration/interactive.md}
183
+ # @param value [Boolean]
184
+ # @return [Boolean]
185
+ def interactive!(value = true)
186
+ options[:interactive] = value
187
+ end
188
+ alias interactive interactive!
189
+
171
190
  # {include:file:docs/configuration/log.md}
172
191
  # @param filename_or_false [FalseClass|String]
173
192
  # @return [NilClass|String]
@@ -199,6 +218,14 @@ module Vedeu
199
218
  options[:log_only] = types.flatten
200
219
  end
201
220
 
221
+ # {include:file:docs/configuration/mouse.md}
222
+ # @param value [Boolean]
223
+ # @return [Boolean]
224
+ def mouse!(value = true)
225
+ options[:mouse] = value
226
+ end
227
+ alias mouse mouse!
228
+
202
229
  # {include:file:docs/configuration/profile.md}
203
230
  # @param value [Boolean]
204
231
  # @return [Boolean]
@@ -207,6 +234,13 @@ module Vedeu
207
234
  end
208
235
  alias profile profile!
209
236
 
237
+ # {include:file:docs/configuration/raw.md}
238
+ # @return [Boolean]
239
+ def raw!
240
+ options[:terminal_mode] = :raw
241
+ end
242
+ alias raw raw!
243
+
210
244
  # {include:file:docs/configuration/renderer.md}
211
245
  # @param renderer [Array<Class>|Class]
212
246
  # @return [Array<Class>]
@@ -215,13 +249,6 @@ module Vedeu
215
249
  end
216
250
  alias renderers renderer
217
251
 
218
- # {include:file:docs/configuration/base_path.md}
219
- # @param path [String]
220
- # @return [String]
221
- def base_path(path = nil)
222
- options[:base_path] = path
223
- end
224
-
225
252
  # {include:file:docs/configuration/root.md}
226
253
  # @param args [Array<Symbol|void>]
227
254
  # @return [Class]
@@ -229,6 +256,22 @@ module Vedeu
229
256
  options[:root] = args
230
257
  end
231
258
 
259
+ # {include:file:docs/configuration/run_once.md}
260
+ # @param value [Boolean]
261
+ # @return [Boolean]
262
+ def run_once!(value = true)
263
+ options[:once] = value
264
+ end
265
+ alias run_once run_once!
266
+
267
+ # {include:file:docs/configuration/standalone.md}
268
+ # @param value [Boolean]
269
+ # @return [Boolean]
270
+ def standalone!(value = true)
271
+ options[:interactive] = !value
272
+ end
273
+ alias standalone standalone!
274
+
232
275
  # {include:file:docs/configuration/stdin.md}
233
276
  # @param io [File|IO]
234
277
  # @return [File|IO]
@@ -250,14 +293,6 @@ module Vedeu
250
293
  options[:stderr] = io
251
294
  end
252
295
 
253
- # {include:file:docs/configuration/compression.md}
254
- # @param value [Boolean]
255
- # @return [Boolean]
256
- def compression(value = true)
257
- options[:compression] = value
258
- end
259
- alias compression! compression
260
-
261
296
  # {include:file:docs/configuration/terminal_mode.md}
262
297
  # @param mode [Symbol] Either ':cooked', ':fake' or ':raw'.
263
298
  # @macro raise_invalid_syntax
@@ -288,41 +323,6 @@ module Vedeu
288
323
  end
289
324
  alias width= width
290
325
 
291
- # {include:file:docs/configuration/background.md}
292
- # @param value [String]
293
- # @return [Vedeu::Colours::Background]
294
- def background(value = nil)
295
- return options[:background] unless value
296
-
297
- options[:background] = value
298
- end
299
-
300
- # {include:file:docs/configuration/foreground.md}
301
- # @param value [String]
302
- # @return [Vedeu::Colours::Foreground]
303
- def foreground(value = nil)
304
- return options[:foreground] unless value
305
-
306
- options[:foreground] = value
307
- end
308
-
309
- # {include:file:docs/configuration/colour.md}
310
- # @param attrs [Hash<Symbol => String>]
311
- # @return [Hash<Symbol => void>]
312
- def colour(attrs = {})
313
- options[:background] = attrs[:background] if attrs.key?(:background)
314
- options[:foreground] = attrs[:foreground] if attrs.key?(:foreground)
315
- options
316
- end
317
-
318
- # {include:file:docs/configuration/mouse.md}
319
- # @param value [Boolean]
320
- # @return [Boolean]
321
- def mouse!(value = true)
322
- options[:mouse] = value
323
- end
324
- alias mouse mouse!
325
-
326
326
  protected
327
327
 
328
328
  # @!attribute [r] default
@@ -76,14 +76,15 @@ module Vedeu
76
76
 
77
77
  private
78
78
 
79
- # Returns the visible lines.
79
+ # Returns the visible lines and their respective content,
80
+ # determined by the offsets 'ox' and 'oy'.
80
81
  #
81
82
  # @note If there are no lines of content, we return an empty
82
83
  # array. If there are any empty lines, then they are discarded.
83
84
  #
84
85
  # @return [Array<void>]
85
86
  def visible
86
- lines.map { |line| columns(line) }
87
+ lines.map { |line| line[ox...(ox + bordered_width)] || '' }
87
88
  end
88
89
 
89
90
  # Return a range of visible lines.
@@ -93,13 +94,6 @@ module Vedeu
93
94
  @lines[oy...(oy + bordered_height)] || []
94
95
  end
95
96
 
96
- # Return a range of visible characters from each line.
97
- #
98
- # @return [String]
99
- def columns(line)
100
- line[ox...(ox + bordered_width)] || ''
101
- end
102
-
103
97
  # @macro geometry_by_name
104
98
  def geometry
105
99
  @_geometry ||= Vedeu.geometries.by_name(name)
@@ -43,7 +43,7 @@ module Vedeu
43
43
  #
44
44
  # @param attributes [Hash<Symbol => Fixnum|String|Symbol>]
45
45
  # @option attributes y [Fixnum] The current line.
46
- # @option attributes x [Fixnum] The current character with the
46
+ # @option attributes x [Fixnum] The current character within the
47
47
  # line.
48
48
  # @option attributes name [String|Symbol]
49
49
  # @option attributes oy [Fixnum]
@@ -67,7 +67,9 @@ module Vedeu
67
67
 
68
68
  # Move the virtual cursor down by one line.
69
69
  #
70
- # @param size [Fixnum]
70
+ # @param size [Fixnum] The number of characters on the next
71
+ # line. The cursor is placed at the end of this next line if
72
+ # the x coordinate is greater than the next line length.
71
73
  # @return [Vedeu::Editor::Cursor]
72
74
  def down(size = nil)
73
75
  @y += 1
@@ -93,7 +95,7 @@ module Vedeu
93
95
  # @return [Vedeu::Editor::Cursor]
94
96
  # @todo Should ox/oy be 0; or set to @ox/@oy? (GL: 2015-10-02)
95
97
  def refresh
96
- Vedeu::Cursors::Cursor.store(refresh_attributes)
98
+ Vedeu::Cursors::Cursor.store(new_attributes)
97
99
 
98
100
  Vedeu.trigger(:_refresh_cursor_, name)
99
101
 
@@ -132,7 +134,9 @@ module Vedeu
132
134
 
133
135
  # Move the virtual cursor up by one line.
134
136
  #
135
- # @param size [Fixnum]
137
+ # @param size [Fixnum] The number of characters on the next
138
+ # line. The cursor is placed at the end of this next line if
139
+ # the x coordinate is greater than the next line length.
136
140
  # @return [Vedeu::Editor::Cursor]
137
141
  def up(size = nil)
138
142
  @oy -= 1 unless @oy == 0
@@ -191,14 +195,14 @@ module Vedeu
191
195
  end
192
196
 
193
197
  # @return [Hash<Symbol => Fixnum, String, Symbol>]
194
- def refresh_attributes
198
+ def new_attributes
195
199
  {
196
200
  name: name,
197
201
  x: real_x,
198
202
  y: real_y,
199
203
  ox: 0,
200
204
  oy: 0,
201
- visible: true
205
+ visible: true,
202
206
  }
203
207
  end
204
208
 
@@ -27,26 +27,22 @@ module Vedeu
27
27
  @style = ''
28
28
  end
29
29
 
30
+ # Process the content as a stream; for each sequence with the
31
+ # same position take the first sequence and ignore the rest.
32
+ #
30
33
  # @return [String]
31
34
  def with
32
35
  @same = ''
33
36
  @compress ||= Vedeu.timer(message) do
34
37
  content.map do |cell|
35
- rendered = [
36
- cell.position.to_s,
38
+ character = [
39
+ position_for(cell),
37
40
  colour_for(cell),
38
41
  style_for(cell),
39
- cell.value,
42
+ value_for(cell),
40
43
  ].join
41
44
 
42
- if @same == rendered
43
- next
44
-
45
- else
46
- @same = rendered
47
- @same
48
-
49
- end
45
+ character == @same ? next : @same = character
50
46
  end.join.tap do |out|
51
47
  Vedeu.log(type: :compress,
52
48
  message: "#{message} -> #{out.size} characters")
@@ -85,6 +81,14 @@ module Vedeu
85
81
  content.size
86
82
  end
87
83
 
84
+ # @param char [Vedeu::Cells::Char]
85
+ # @return [String]
86
+ def position_for(char)
87
+ return '' unless char.position?
88
+
89
+ char.position.to_s
90
+ end
91
+
88
92
  # Compress by not repeatedly sending the same style(s) for each
89
93
  # character which has the same style(s) as the last character
90
94
  # output.
@@ -98,6 +102,14 @@ module Vedeu
98
102
  @style.to_s
99
103
  end
100
104
 
105
+ # @param char [Vedeu::Cells::Char]
106
+ # @return [String]
107
+ def value_for(char)
108
+ return '' unless char.value?
109
+
110
+ char.value
111
+ end
112
+
101
113
  end # Character
102
114
 
103
115
  end # Compressors
@@ -46,7 +46,7 @@ module Vedeu
46
46
  nil
47
47
  end
48
48
 
49
- # @return [Vedeu::Geometries::Position]
49
+ # @return [NilClass|Vedeu::Geometries::Position]
50
50
  def position(pos = position_start)
51
51
  Vedeu::Geometries::Position.coerce(pos)
52
52
  end
@@ -12,7 +12,7 @@ module Vedeu
12
12
 
13
13
  # Gets the position.
14
14
  #
15
- # @return [Vedeu::Geometries::Position]
15
+ # @return [NilClass|Vedeu::Geometries::Position]
16
16
  def position
17
17
  Vedeu::Geometries::Position.coerce(@position)
18
18
  end
@@ -21,7 +21,7 @@ module Vedeu
21
21
  #
22
22
  # @param value [Array<void>|Hash<void>|
23
23
  # Vedeu::Geometries::Position]
24
- # @return [Vedeu::Geometries::Position]
24
+ # @return [NilClass|Vedeu::Geometries::Position]
25
25
  def position=(value)
26
26
  @position = Vedeu::Geometries::Position.coerce(value)
27
27
  end
@@ -3,6 +3,6 @@
3
3
  module Vedeu
4
4
 
5
5
  # The current version of Vedeu.
6
- VERSION = '0.8.22'
6
+ VERSION = '0.8.23'
7
7
 
8
8
  end
@@ -92,7 +92,6 @@ module Vedeu
92
92
 
93
93
  it { subject.size.must_equal(height + 1) }
94
94
  it { subject.first.size.must_equal(width + 1) }
95
- it { subject.first.first.position.must_equal(position) }
96
95
  end
97
96
 
98
97
  describe '#height' do
@@ -35,10 +35,6 @@ module Vedeu
35
35
  it { instance.must_respond_to(:name) }
36
36
  end
37
37
 
38
- describe '#value' do
39
- it { instance.must_respond_to(:value) }
40
- end
41
-
42
38
  describe '#eql?' do
43
39
  let(:other) { instance }
44
40
 
@@ -188,6 +184,24 @@ module Vedeu
188
184
  it { subject.must_equal(:empty) }
189
185
  end
190
186
 
187
+ describe '#value' do
188
+ it { instance.must_respond_to(:value) }
189
+ end
190
+
191
+ describe '#value?' do
192
+ subject { instance.value? }
193
+
194
+ context 'when a value exists' do
195
+ let(:_value) { "\e[0m" }
196
+
197
+ it { subject.must_equal(true) }
198
+ end
199
+
200
+ context 'when a value does not exist' do
201
+ it { subject.must_equal(false) }
202
+ end
203
+ end
204
+
191
205
  end # Empty
192
206
 
193
207
  end # Cells
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'minitest', '5.8.4'
28
28
  spec.add_development_dependency 'minitest-reporters', '1.1.8'
29
29
  spec.add_development_dependency 'mocha', '1.1.0'
30
- spec.add_development_dependency 'rubocop', '0.38.0'
30
+ spec.add_development_dependency 'rubocop', '0.39.0'
31
31
  spec.add_development_dependency 'simplecov', '0.11.2'
32
32
  spec.add_development_dependency 'simplecov-console', '0.3.0'
33
33
  spec.add_development_dependency 'yard', '0.8.7.6'
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.8.22
4
+ version: 0.8.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-27 00:00:00.000000000 Z
11
+ date: 2016-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.38.0
103
+ version: 0.39.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 0.38.0
110
+ version: 0.39.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement