vedeu 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu.rb +43 -17
- data/lib/vedeu/api/api.rb +21 -0
- data/lib/vedeu/api/base.rb +7 -15
- data/lib/vedeu/api/events.rb +5 -10
- data/lib/vedeu/api/grid.rb +0 -2
- data/lib/vedeu/api/interface.rb +15 -37
- data/lib/vedeu/api/line.rb +0 -3
- data/lib/vedeu/{instrumentation.rb → api/log.rb} +2 -5
- data/lib/vedeu/api/store.rb +3 -9
- data/lib/vedeu/api/stream.rb +0 -2
- data/lib/vedeu/api/view.rb +4 -15
- data/lib/vedeu/application.rb +1 -5
- data/lib/vedeu/configuration.rb +0 -2
- data/lib/vedeu/launcher.rb +0 -3
- data/lib/vedeu/models/attributes/background.rb +0 -4
- data/lib/vedeu/models/attributes/foreground.rb +0 -4
- data/lib/vedeu/models/attributes/interface_collection.rb +3 -8
- data/lib/vedeu/models/attributes/line_collection.rb +0 -5
- data/lib/vedeu/models/attributes/stream_collection.rb +0 -5
- data/lib/vedeu/models/colour.rb +0 -5
- data/lib/vedeu/models/composition.rb +0 -15
- data/lib/vedeu/models/geometry.rb +0 -5
- data/lib/vedeu/models/interface.rb +0 -14
- data/lib/vedeu/models/line.rb +0 -6
- data/lib/vedeu/models/stream.rb +0 -5
- data/lib/vedeu/models/style.rb +0 -4
- data/lib/vedeu/output/buffers.rb +13 -4
- data/lib/vedeu/output/render.rb +1 -4
- data/lib/vedeu/output/view.rb +7 -3
- data/lib/vedeu/support/input.rb +0 -3
- data/lib/vedeu/support/menu.rb +0 -5
- data/lib/vedeu/support/terminal.rb +0 -4
- data/test/lib/vedeu/api/events_test.rb +0 -1
- data/test/lib/vedeu/api/grid_test.rb +0 -2
- data/test/lib/vedeu/api/interface_test.rb +0 -1
- data/test/lib/vedeu/api/store_test.rb +0 -1
- data/test/lib/vedeu/api/view_test.rb +1 -4
- data/test/lib/vedeu/configuration_test.rb +0 -1
- data/test/lib/vedeu/models/attributes/collection_test.rb +0 -1
- data/test/lib/vedeu/models/attributes/interface_collection_test.rb +0 -5
- data/test/lib/vedeu/models/attributes/line_collection_test.rb +0 -2
- data/test/lib/vedeu/models/attributes/stream_collection_test.rb +0 -2
- data/test/lib/vedeu/models/colour_test.rb +0 -1
- data/test/lib/vedeu/models/composition_test.rb +14 -34
- data/test/lib/vedeu/models/geometry_test.rb +0 -1
- data/test/lib/vedeu/models/interface_test.rb +0 -1
- data/test/lib/vedeu/models/line_test.rb +0 -1
- data/test/lib/vedeu/models/stream_test.rb +0 -1
- data/test/lib/vedeu/models/style_test.rb +0 -1
- data/test/lib/vedeu/output/buffers_test.rb +0 -2
- data/test/lib/vedeu/output/clear_test.rb +0 -3
- data/test/lib/vedeu/output/render_test.rb +0 -3
- data/test/lib/vedeu/support/esc_test.rb +0 -1
- data/test/lib/vedeu/support/input_test.rb +0 -1
- data/test/lib/vedeu/support/menu_test.rb +0 -1
- data/test/lib/vedeu/support/terminal_test.rb +0 -1
- data/test/support/model_test_data.json +437 -0
- data/test/test_helper.rb +4 -2
- data/vedeu.gemspec +1 -1
- metadata +6 -44
- data/lib/vedeu/support/wordwrap.rb +0 -88
- data/test/lib/vedeu/api/base_test.rb +0 -12
- data/test/lib/vedeu/api/line_test.rb +0 -10
- data/test/lib/vedeu/api/stream_test.rb +0 -12
- data/test/lib/vedeu/application_test.rb +0 -10
- data/test/lib/vedeu/launcher_test.rb +0 -7
- data/test/lib/vedeu/models/attributes/background_test.rb +0 -8
- data/test/lib/vedeu/models/attributes/foreground_test.rb +0 -8
- data/test/lib/vedeu/output/view_test.rb +0 -9
- data/test/lib/vedeu/support/wordwrap_test.rb +0 -56
- data/test/lib/vedeu_test.rb +0 -10
- data/test/support/json/int1_lin1_str1.json +0 -10
- data/test/support/json/int1_lin1_str3.json +0 -18
- data/test/support/json/int1_lin2_str1.json +0 -17
- data/test/support/json/int1_lin2_str3.json +0 -33
- data/test/support/json/int1_lin2_str3_styles.json +0 -43
- data/test/support/json/int2_lin1_str1.json +0 -20
- data/test/support/json/int2_lin1_str3.json +0 -36
- data/test/support/json/int2_lin2_str1.json +0 -34
- data/test/support/json/int2_lin2_str3.json +0 -66
- data/test/support/json/int2_lin2_str3_styles.json +0 -158
data/test/test_helper.rb
CHANGED
@@ -13,6 +13,8 @@ require 'mocha/setup'
|
|
13
13
|
|
14
14
|
GC.disable
|
15
15
|
|
16
|
+
require 'vedeu'
|
17
|
+
|
16
18
|
# commented out by default (makes tests slower)
|
17
19
|
# require 'minitest/reporters'
|
18
20
|
# Minitest::Reporters.use!(
|
@@ -21,5 +23,5 @@ GC.disable
|
|
21
23
|
# )
|
22
24
|
|
23
25
|
# trace method execution with (optionally) local variables
|
24
|
-
# require 'vedeu/
|
25
|
-
# Vedeu::
|
26
|
+
# require 'vedeu/api/log'
|
27
|
+
# Vedeu::Log::Trace.call({ watched: 'call', klass: /^Vedeu/ })
|
data/vedeu.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'vedeu'
|
7
|
-
spec.version = '0.1.
|
7
|
+
spec.version = '0.1.10'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{A terminal case of wonderland.}
|
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.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -184,17 +184,18 @@ files:
|
|
184
184
|
- bin/log
|
185
185
|
- bin/vedeu
|
186
186
|
- lib/vedeu.rb
|
187
|
+
- lib/vedeu/api/api.rb
|
187
188
|
- lib/vedeu/api/base.rb
|
188
189
|
- lib/vedeu/api/events.rb
|
189
190
|
- lib/vedeu/api/grid.rb
|
190
191
|
- lib/vedeu/api/interface.rb
|
191
192
|
- lib/vedeu/api/line.rb
|
193
|
+
- lib/vedeu/api/log.rb
|
192
194
|
- lib/vedeu/api/store.rb
|
193
195
|
- lib/vedeu/api/stream.rb
|
194
196
|
- lib/vedeu/api/view.rb
|
195
197
|
- lib/vedeu/application.rb
|
196
198
|
- lib/vedeu/configuration.rb
|
197
|
-
- lib/vedeu/instrumentation.rb
|
198
199
|
- lib/vedeu/launcher.rb
|
199
200
|
- lib/vedeu/models/attributes/background.rb
|
200
201
|
- lib/vedeu/models/attributes/collection.rb
|
@@ -218,23 +219,15 @@ files:
|
|
218
219
|
- lib/vedeu/support/input.rb
|
219
220
|
- lib/vedeu/support/menu.rb
|
220
221
|
- lib/vedeu/support/terminal.rb
|
221
|
-
- lib/vedeu/support/wordwrap.rb
|
222
222
|
- logs/.gitkeep
|
223
|
-
- test/lib/vedeu/api/base_test.rb
|
224
223
|
- test/lib/vedeu/api/events_test.rb
|
225
224
|
- test/lib/vedeu/api/grid_test.rb
|
226
225
|
- test/lib/vedeu/api/interface_test.rb
|
227
|
-
- test/lib/vedeu/api/line_test.rb
|
228
226
|
- test/lib/vedeu/api/store_test.rb
|
229
|
-
- test/lib/vedeu/api/stream_test.rb
|
230
227
|
- test/lib/vedeu/api/view_test.rb
|
231
|
-
- test/lib/vedeu/application_test.rb
|
232
228
|
- test/lib/vedeu/configuration_test.rb
|
233
|
-
- test/lib/vedeu/launcher_test.rb
|
234
|
-
- test/lib/vedeu/models/attributes/background_test.rb
|
235
229
|
- test/lib/vedeu/models/attributes/collection_test.rb
|
236
230
|
- test/lib/vedeu/models/attributes/colour_translator_test.rb
|
237
|
-
- test/lib/vedeu/models/attributes/foreground_test.rb
|
238
231
|
- test/lib/vedeu/models/attributes/interface_collection_test.rb
|
239
232
|
- test/lib/vedeu/models/attributes/line_collection_test.rb
|
240
233
|
- test/lib/vedeu/models/attributes/stream_collection_test.rb
|
@@ -248,26 +241,14 @@ files:
|
|
248
241
|
- test/lib/vedeu/output/buffers_test.rb
|
249
242
|
- test/lib/vedeu/output/clear_test.rb
|
250
243
|
- test/lib/vedeu/output/render_test.rb
|
251
|
-
- test/lib/vedeu/output/view_test.rb
|
252
244
|
- test/lib/vedeu/support/esc_test.rb
|
253
245
|
- test/lib/vedeu/support/input_test.rb
|
254
246
|
- test/lib/vedeu/support/menu_test.rb
|
255
247
|
- test/lib/vedeu/support/terminal_test.rb
|
256
|
-
- test/lib/vedeu/support/wordwrap_test.rb
|
257
|
-
- test/lib/vedeu_test.rb
|
258
248
|
- test/stats.sh
|
259
249
|
- test/support/bench.rb
|
260
250
|
- test/support/colours.rb
|
261
|
-
- test/support/
|
262
|
-
- test/support/json/int1_lin1_str3.json
|
263
|
-
- test/support/json/int1_lin2_str1.json
|
264
|
-
- test/support/json/int1_lin2_str3.json
|
265
|
-
- test/support/json/int1_lin2_str3_styles.json
|
266
|
-
- test/support/json/int2_lin1_str1.json
|
267
|
-
- test/support/json/int2_lin1_str3.json
|
268
|
-
- test/support/json/int2_lin2_str1.json
|
269
|
-
- test/support/json/int2_lin2_str3.json
|
270
|
-
- test/support/json/int2_lin2_str3_styles.json
|
251
|
+
- test/support/model_test_data.json
|
271
252
|
- test/test_helper.rb
|
272
253
|
- vedeu.gemspec
|
273
254
|
homepage: https://github.com/gavinlaking/vedeu
|
@@ -295,21 +276,14 @@ signing_key:
|
|
295
276
|
specification_version: 4
|
296
277
|
summary: A terminal case of wonderland.
|
297
278
|
test_files:
|
298
|
-
- test/lib/vedeu/api/base_test.rb
|
299
279
|
- test/lib/vedeu/api/events_test.rb
|
300
280
|
- test/lib/vedeu/api/grid_test.rb
|
301
281
|
- test/lib/vedeu/api/interface_test.rb
|
302
|
-
- test/lib/vedeu/api/line_test.rb
|
303
282
|
- test/lib/vedeu/api/store_test.rb
|
304
|
-
- test/lib/vedeu/api/stream_test.rb
|
305
283
|
- test/lib/vedeu/api/view_test.rb
|
306
|
-
- test/lib/vedeu/application_test.rb
|
307
284
|
- test/lib/vedeu/configuration_test.rb
|
308
|
-
- test/lib/vedeu/launcher_test.rb
|
309
|
-
- test/lib/vedeu/models/attributes/background_test.rb
|
310
285
|
- test/lib/vedeu/models/attributes/collection_test.rb
|
311
286
|
- test/lib/vedeu/models/attributes/colour_translator_test.rb
|
312
|
-
- test/lib/vedeu/models/attributes/foreground_test.rb
|
313
287
|
- test/lib/vedeu/models/attributes/interface_collection_test.rb
|
314
288
|
- test/lib/vedeu/models/attributes/line_collection_test.rb
|
315
289
|
- test/lib/vedeu/models/attributes/stream_collection_test.rb
|
@@ -323,24 +297,12 @@ test_files:
|
|
323
297
|
- test/lib/vedeu/output/buffers_test.rb
|
324
298
|
- test/lib/vedeu/output/clear_test.rb
|
325
299
|
- test/lib/vedeu/output/render_test.rb
|
326
|
-
- test/lib/vedeu/output/view_test.rb
|
327
300
|
- test/lib/vedeu/support/esc_test.rb
|
328
301
|
- test/lib/vedeu/support/input_test.rb
|
329
302
|
- test/lib/vedeu/support/menu_test.rb
|
330
303
|
- test/lib/vedeu/support/terminal_test.rb
|
331
|
-
- test/lib/vedeu/support/wordwrap_test.rb
|
332
|
-
- test/lib/vedeu_test.rb
|
333
304
|
- test/stats.sh
|
334
305
|
- test/support/bench.rb
|
335
306
|
- test/support/colours.rb
|
336
|
-
- test/support/
|
337
|
-
- test/support/json/int1_lin1_str3.json
|
338
|
-
- test/support/json/int1_lin2_str1.json
|
339
|
-
- test/support/json/int1_lin2_str3.json
|
340
|
-
- test/support/json/int1_lin2_str3_styles.json
|
341
|
-
- test/support/json/int2_lin1_str1.json
|
342
|
-
- test/support/json/int2_lin1_str3.json
|
343
|
-
- test/support/json/int2_lin2_str1.json
|
344
|
-
- test/support/json/int2_lin2_str3.json
|
345
|
-
- test/support/json/int2_lin2_str3_styles.json
|
307
|
+
- test/support/model_test_data.json
|
346
308
|
- test/test_helper.rb
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
class Wordwrap
|
3
|
-
def self.this(value, options = {})
|
4
|
-
new(value, options).reformat
|
5
|
-
end
|
6
|
-
|
7
|
-
def initialize(value, options = {})
|
8
|
-
@value = value
|
9
|
-
@options = options || {}
|
10
|
-
end
|
11
|
-
|
12
|
-
def reformat
|
13
|
-
return pruned if prune?
|
14
|
-
|
15
|
-
wordwrapped
|
16
|
-
end
|
17
|
-
|
18
|
-
def wordwrapped
|
19
|
-
processed = []
|
20
|
-
value.split(/\n/).map do |unprocessed|
|
21
|
-
line_length = 0
|
22
|
-
reformatted = []
|
23
|
-
|
24
|
-
unprocessed.split(/\s/).map do |word|
|
25
|
-
word_length = word.length + 1
|
26
|
-
|
27
|
-
if (line_length += word_length) >= maximum_width
|
28
|
-
line_length = word_length
|
29
|
-
processed << reformatted
|
30
|
-
reformatted = []
|
31
|
-
end
|
32
|
-
|
33
|
-
reformatted << word
|
34
|
-
end
|
35
|
-
|
36
|
-
processed << reformatted
|
37
|
-
end
|
38
|
-
|
39
|
-
output(processed)
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
attr_reader :value, :options
|
45
|
-
|
46
|
-
def output(paragraph)
|
47
|
-
paragraph.reduce([]) do |output, line|
|
48
|
-
output << line.join(' ')
|
49
|
-
end.join("\n")
|
50
|
-
end
|
51
|
-
|
52
|
-
def pruned
|
53
|
-
if value.size <= pruned_width
|
54
|
-
value
|
55
|
-
|
56
|
-
else
|
57
|
-
[
|
58
|
-
value.chomp.slice(0..pruned_width),
|
59
|
-
'...'
|
60
|
-
].join
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def pruned_width
|
66
|
-
maximum_width - 3
|
67
|
-
end
|
68
|
-
|
69
|
-
def prune?
|
70
|
-
options.fetch(:prune)
|
71
|
-
end
|
72
|
-
|
73
|
-
def maximum_width
|
74
|
-
options.fetch(:width)
|
75
|
-
end
|
76
|
-
|
77
|
-
def options
|
78
|
-
defaults.merge!(@options)
|
79
|
-
end
|
80
|
-
|
81
|
-
def defaults
|
82
|
-
{
|
83
|
-
width: 70,
|
84
|
-
prune: false
|
85
|
-
}
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'vedeu/support/wordwrap'
|
3
|
-
|
4
|
-
module Vedeu
|
5
|
-
describe Wordwrap do
|
6
|
-
describe '#wordwrap' do
|
7
|
-
let(:formatted_value) {
|
8
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \
|
9
|
-
"Curabitur\naliquet turpis id dui condimentum elementum.\n" \
|
10
|
-
'Pellentesque blandit vulputate imperdiet. Quisque ut arcu ' \
|
11
|
-
"dolor.\nMorbi nec vulputate purus.\n\nQuisque porta " \
|
12
|
-
"feugiat egestas. Aenean ac ipsum varius, lobortis\nlacus " \
|
13
|
-
"at, mattis est.\nQuisque viverra facilisis tortor, id " \
|
14
|
-
"convallis metus laoreet quis.\nCurabitur auctor nunc " \
|
15
|
-
"blandit enim volutpat hendrerit. Phasellus\naccumsan " \
|
16
|
-
'tempor iaculis. Ut in semper massa. Cras quis viverra ' \
|
17
|
-
"elit.\n\nInteger vitae mattis est. Cras id nisl porttitor " \
|
18
|
-
"lectus placerat\ngravida sit amet quis diam.\n\nDonec " \
|
19
|
-
'mollis, nisi sit amet congue sagittis, sapien magna ' \
|
20
|
-
"rhoncus\njusto, vel molestie metus sapien eget libero."
|
21
|
-
}
|
22
|
-
|
23
|
-
it 'returns formatted text' do
|
24
|
-
value =
|
25
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \
|
26
|
-
"Curabitur aliquet turpis id dui condimentum elementum.\n" \
|
27
|
-
'Pellentesque blandit vulputate imperdiet. Quisque ut arcu ' \
|
28
|
-
"dolor. Morbi nec vulputate purus.\n\nQuisque porta feugiat " \
|
29
|
-
'egestas. Aenean ac ipsum varius, lobortis lacus at, mattis ' \
|
30
|
-
"est.\nQuisque viverra facilisis tortor, id convallis metus " \
|
31
|
-
'laoreet quis. Curabitur auctor nunc blandit enim volutpat ' \
|
32
|
-
'hendrerit. Phasellus accumsan tempor iaculis. Ut in semper ' \
|
33
|
-
"massa. Cras quis viverra elit.\n\nInteger vitae mattis est." \
|
34
|
-
' Cras id nisl porttitor lectus placerat gravida sit amet ' \
|
35
|
-
"quis diam.\n\nDonec mollis, nisi sit amet congue sagittis, " \
|
36
|
-
'sapien magna rhoncus justo, vel molestie metus sapien eget ' \
|
37
|
-
"libero.\n\n\n"
|
38
|
-
Wordwrap.this(value, {}).must_equal(formatted_value)
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'returns formatted text when the content should be pruned' do
|
42
|
-
value = 'Lorem ipsum dolor sit amet, consectetur ' \
|
43
|
-
'adipiscing elit. Curabitur aviverra facil tortor.'
|
44
|
-
result = 'Lorem ipsum dolor sit amet, consectetur ' \
|
45
|
-
'adipiscing elit. Curabitur a...'
|
46
|
-
Wordwrap.this(value, { width: 70, prune: true })
|
47
|
-
.must_equal(result)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'returns formatted text when the content is less than the prune size' do
|
51
|
-
Wordwrap.this('Wordwrap.this', { width: 70, prune: true })
|
52
|
-
.must_equal('Wordwrap.this')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/test/lib/vedeu_test.rb
DELETED