vedeu 0.6.34 → 0.6.35
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 +4 -4
- data/docs/api.md +5 -0
- data/docs/dsl.md +4 -0
- data/docs/geometry.md +3 -0
- data/examples/alignment.rb +183 -0
- data/lib/vedeu/cursors/cursor.rb +1 -1
- data/lib/vedeu/geometry/alignment.rb +87 -0
- data/lib/vedeu/geometry/all.rb +1 -0
- data/lib/vedeu/geometry/area.rb +5 -1
- data/lib/vedeu/geometry/dimension.rb +109 -11
- data/lib/vedeu/geometry/dsl.rb +96 -1
- data/lib/vedeu/geometry/geometry.rb +13 -3
- data/lib/vedeu/input/translator.rb +91 -140
- data/lib/vedeu/models/focus.rb +18 -18
- data/lib/vedeu/output/renderers/options.rb +8 -0
- data/lib/vedeu/runtime/launcher.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +1 -2
- data/lib/vedeu/terminal/buffer.rb +6 -6
- data/lib/vedeu/terminal/terminal.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/geometry/alignment_test.rb +100 -0
- data/test/lib/vedeu/geometry/area_test.rb +2 -0
- data/test/lib/vedeu/geometry/dimension_test.rb +136 -75
- data/test/lib/vedeu/geometry/dsl_test.rb +96 -0
- data/test/lib/vedeu/geometry/geometry_test.rb +14 -1
- data/test/lib/vedeu/output/renderers/options_test.rb +43 -0
- data/test/support/ttyrec.rb +35 -0
- data/vedeu.gemspec +1 -1
- metadata +10 -4
@@ -14,6 +14,102 @@ module Vedeu
|
|
14
14
|
it { described.must_respond_to(:geometry) }
|
15
15
|
end
|
16
16
|
|
17
|
+
describe '#alignment' do
|
18
|
+
let(:_value) { :none }
|
19
|
+
let(:width) { 20 }
|
20
|
+
|
21
|
+
subject { instance.alignment(_value, width) }
|
22
|
+
|
23
|
+
context 'when a value and width is given' do
|
24
|
+
it { subject.must_be_instance_of(Vedeu::Geometry::Geometry) }
|
25
|
+
|
26
|
+
context 'when the value is :center' do
|
27
|
+
let(:_value) { :center }
|
28
|
+
|
29
|
+
it { subject.alignment.must_equal(:centre) }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when the value is :centre' do
|
33
|
+
let(:_value) { :centre }
|
34
|
+
|
35
|
+
it { subject.alignment.must_equal(:centre) }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when the value is :left' do
|
39
|
+
let(:_value) { :left }
|
40
|
+
|
41
|
+
it { subject.alignment.must_equal(:left) }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when the value is :right' do
|
45
|
+
let(:_value) { :right }
|
46
|
+
|
47
|
+
it { subject.alignment.must_equal(:right) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when a value is not given' do
|
52
|
+
let(:_value) {}
|
53
|
+
|
54
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when a width is not given' do
|
58
|
+
let(:_value) { :none }
|
59
|
+
let(:width) {}
|
60
|
+
|
61
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#align_centre' do
|
66
|
+
let(:width) { 20 }
|
67
|
+
|
68
|
+
subject { instance.align_centre(width) }
|
69
|
+
|
70
|
+
it { instance.must_respond_to(:align_center) }
|
71
|
+
|
72
|
+
context 'when a width is given' do
|
73
|
+
it { subject.must_be_instance_of(Vedeu::Geometry::Geometry) }
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when a width is not given' do
|
77
|
+
let(:width) {}
|
78
|
+
|
79
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#align_left' do
|
84
|
+
let(:width) { 20 }
|
85
|
+
|
86
|
+
subject { instance.align_left(width) }
|
87
|
+
|
88
|
+
context 'when a width is given' do
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'when a width is not given' do
|
92
|
+
let(:width) {}
|
93
|
+
|
94
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#align_right' do
|
99
|
+
let(:width) { 20 }
|
100
|
+
|
101
|
+
subject { instance.align_right(width) }
|
102
|
+
|
103
|
+
context 'when a width is given' do
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when a width is not given' do
|
107
|
+
let(:width) {}
|
108
|
+
|
109
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
17
113
|
describe '#centred' do
|
18
114
|
subject { instance.centred(true) }
|
19
115
|
|
@@ -10,6 +10,7 @@ module Vedeu
|
|
10
10
|
let(:instance) { described.new(attributes) }
|
11
11
|
let(:attributes) {
|
12
12
|
{
|
13
|
+
alignment: alignment,
|
13
14
|
centred: centred,
|
14
15
|
client: client,
|
15
16
|
height: height,
|
@@ -23,6 +24,7 @@ module Vedeu
|
|
23
24
|
yn: yn,
|
24
25
|
}
|
25
26
|
}
|
27
|
+
let(:alignment) {}
|
26
28
|
let(:centred) { false }
|
27
29
|
let(:client) {}
|
28
30
|
let(:height) {}
|
@@ -38,6 +40,7 @@ module Vedeu
|
|
38
40
|
|
39
41
|
describe '#initialize' do
|
40
42
|
it { instance.must_be_instance_of(described) }
|
43
|
+
it { instance.instance_variable_get('@alignment').must_equal(alignment) }
|
41
44
|
it { instance.instance_variable_get('@centred').must_equal(centred) }
|
42
45
|
it { instance.instance_variable_get('@client').must_equal(client) }
|
43
46
|
it { instance.instance_variable_get('@height').must_equal(height) }
|
@@ -56,9 +59,10 @@ module Vedeu
|
|
56
59
|
|
57
60
|
describe 'accessors' do
|
58
61
|
it {
|
62
|
+
instance.must_respond_to(:alignment)
|
63
|
+
instance.must_respond_to(:alignment=)
|
59
64
|
instance.must_respond_to(:centred)
|
60
65
|
instance.must_respond_to(:centred=)
|
61
|
-
instance.must_respond_to(:attributes)
|
62
66
|
instance.must_respond_to(:name)
|
63
67
|
instance.must_respond_to(:name=)
|
64
68
|
instance.must_respond_to(:height=)
|
@@ -79,6 +83,15 @@ module Vedeu
|
|
79
83
|
it { subject.must_equal(instance) }
|
80
84
|
end
|
81
85
|
|
86
|
+
describe '#attributes' do
|
87
|
+
subject { instance.attributes }
|
88
|
+
|
89
|
+
it { subject.must_be_instance_of(Hash) }
|
90
|
+
|
91
|
+
# @todo Add more tests.
|
92
|
+
# it { skip }
|
93
|
+
end
|
94
|
+
|
82
95
|
describe '#eql?' do
|
83
96
|
let(:other) { instance }
|
84
97
|
|
@@ -4,8 +4,51 @@ module Vedeu
|
|
4
4
|
|
5
5
|
module Renderers
|
6
6
|
|
7
|
+
class RenderersTestClass
|
8
|
+
include Vedeu::Renderers::Options
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@options = options || {}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
describe Options do
|
8
16
|
|
17
|
+
let(:described) { Vedeu::Renderers::Options }
|
18
|
+
let(:instance) { RenderersTestClass.new(options) }
|
19
|
+
let(:options) {
|
20
|
+
{
|
21
|
+
compression: compression,
|
22
|
+
}
|
23
|
+
}
|
24
|
+
let(:compression) { false }
|
25
|
+
|
26
|
+
describe 'accessors' do
|
27
|
+
it { instance.must_respond_to(:options=) }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#compress?' do
|
31
|
+
subject { instance.compress? }
|
32
|
+
|
33
|
+
context 'when the option is not set' do
|
34
|
+
before { options.tap { |o| o.delete(:compression) } }
|
35
|
+
|
36
|
+
it { subject.must_equal(false) }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when the option is set and is false' do
|
40
|
+
let(:compression) { false }
|
41
|
+
|
42
|
+
it { subject.must_equal(false) }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when the option is set and is true' do
|
46
|
+
let(:compression) { true }
|
47
|
+
|
48
|
+
it { subject.must_equal(true) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
9
52
|
# @todo Add more tests.
|
10
53
|
# it { skip }
|
11
54
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# ttyrec -a -e ./material_colours_app.rb /tmp/ttyrecord
|
5
|
+
#
|
6
|
+
|
7
|
+
ttyrecord = File.binread('/tmp/ttyrecord')
|
8
|
+
ttyrecord.force_encoding('BINARY') if ttyrecord.respond_to?(:force_encoding)
|
9
|
+
|
10
|
+
offset = 0
|
11
|
+
chunks = []
|
12
|
+
|
13
|
+
while offset < ttyrecord.size
|
14
|
+
hash = {}
|
15
|
+
|
16
|
+
data_start = offset + 12
|
17
|
+
data_length = ttyrecord[offset..(data_start)].unpack('VVV')[2]
|
18
|
+
data_end = data_start + data_length
|
19
|
+
|
20
|
+
hash[:offset] = offset
|
21
|
+
hash[:data_start] = data_start
|
22
|
+
hash[:data_length] = data_length
|
23
|
+
hash[:data] = ttyrecord[(data_start)...(data_end)]
|
24
|
+
hash[:data_end] = data_end
|
25
|
+
|
26
|
+
chunks << hash
|
27
|
+
|
28
|
+
offset = data_start + data_length
|
29
|
+
end
|
30
|
+
|
31
|
+
File.open('/tmp/ttyrecord_decoded', 'w') do |file|
|
32
|
+
chunks.each do |chunk|
|
33
|
+
file.write("---\n" + chunk[:data] + "\n")
|
34
|
+
end
|
35
|
+
end
|
data/vedeu.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'guard-minitest', '2.4.4'
|
25
25
|
spec.add_development_dependency 'guard-rubocop', '1.2.0'
|
26
26
|
spec.add_development_dependency 'minitest', '5.8.1'
|
27
|
-
spec.add_development_dependency 'minitest-reporters', '1.1.
|
27
|
+
spec.add_development_dependency 'minitest-reporters', '1.1.4'
|
28
28
|
spec.add_development_dependency 'mocha', '1.1.0'
|
29
29
|
spec.add_development_dependency 'pry', '0.10.3'
|
30
30
|
spec.add_development_dependency 'rubocop', '0.34.2'
|
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.6.
|
4
|
+
version: 0.6.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.1.
|
75
|
+
version: 1.1.4
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.1.
|
82
|
+
version: 1.1.4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mocha
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -286,6 +286,7 @@ files:
|
|
286
286
|
- docs/keymaps.md
|
287
287
|
- docs/object_graph.md
|
288
288
|
- docs/view.md
|
289
|
+
- examples/alignment.rb
|
289
290
|
- examples/demo_groups.rb
|
290
291
|
- examples/hello_worlds.rb
|
291
292
|
- lib/vedeu.rb
|
@@ -370,6 +371,7 @@ files:
|
|
370
371
|
- lib/vedeu/events/event.rb
|
371
372
|
- lib/vedeu/events/repository.rb
|
372
373
|
- lib/vedeu/events/trigger.rb
|
374
|
+
- lib/vedeu/geometry/alignment.rb
|
373
375
|
- lib/vedeu/geometry/all.rb
|
374
376
|
- lib/vedeu/geometry/area.rb
|
375
377
|
- lib/vedeu/geometry/coordinate.rb
|
@@ -541,6 +543,7 @@ files:
|
|
541
543
|
- test/lib/vedeu/events/event_test.rb
|
542
544
|
- test/lib/vedeu/events/repository_test.rb
|
543
545
|
- test/lib/vedeu/events/trigger_test.rb
|
546
|
+
- test/lib/vedeu/geometry/alignment_test.rb
|
544
547
|
- test/lib/vedeu/geometry/area_test.rb
|
545
548
|
- test/lib/vedeu/geometry/coordinate.rb
|
546
549
|
- test/lib/vedeu/geometry/dimension_test.rb
|
@@ -650,6 +653,7 @@ files:
|
|
650
653
|
- test/support/helpers/model_test_class.rb
|
651
654
|
- test/support/stats.sh
|
652
655
|
- test/support/templates/html_renderer.vedeu
|
656
|
+
- test/support/ttyrec.rb
|
653
657
|
- test/support/who.rb
|
654
658
|
- test/test_helper.rb
|
655
659
|
- vedeu.gemspec
|
@@ -739,6 +743,7 @@ test_files:
|
|
739
743
|
- test/lib/vedeu/events/event_test.rb
|
740
744
|
- test/lib/vedeu/events/repository_test.rb
|
741
745
|
- test/lib/vedeu/events/trigger_test.rb
|
746
|
+
- test/lib/vedeu/geometry/alignment_test.rb
|
742
747
|
- test/lib/vedeu/geometry/area_test.rb
|
743
748
|
- test/lib/vedeu/geometry/coordinate.rb
|
744
749
|
- test/lib/vedeu/geometry/dimension_test.rb
|
@@ -848,6 +853,7 @@ test_files:
|
|
848
853
|
- test/support/helpers/model_test_class.rb
|
849
854
|
- test/support/stats.sh
|
850
855
|
- test/support/templates/html_renderer.vedeu
|
856
|
+
- test/support/ttyrec.rb
|
851
857
|
- test/support/who.rb
|
852
858
|
- test/test_helper.rb
|
853
859
|
has_rdoc:
|