squib 0.0.3 → 0.0.4
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/.gitignore +29 -29
- data/.travis.yml +6 -6
- data/.yardopts +7 -7
- data/CHANGELOG.md +19 -0
- data/Gemfile +2 -2
- data/LICENSE.txt +22 -22
- data/README.md +256 -244
- data/Rakefile +11 -11
- data/bin/squib +18 -18
- data/lib/squib.rb +31 -31
- data/lib/squib/api/background.rb +18 -18
- data/lib/squib/api/data.rb +52 -52
- data/lib/squib/api/image.rb +66 -66
- data/lib/squib/api/save.rb +43 -43
- data/lib/squib/api/settings.rb +37 -38
- data/lib/squib/api/shapes.rb +116 -116
- data/lib/squib/api/text.rb +53 -50
- data/lib/squib/api/units.rb +16 -16
- data/lib/squib/card.rb +41 -41
- data/lib/squib/commands/new.rb +43 -43
- data/lib/squib/constants.rb +108 -104
- data/lib/squib/deck.rb +170 -116
- data/lib/squib/graphics/background.rb +13 -13
- data/lib/squib/graphics/image.rb +47 -47
- data/lib/squib/graphics/save_doc.rb +54 -54
- data/lib/squib/graphics/save_images.rb +32 -32
- data/lib/squib/graphics/shapes.rb +59 -59
- data/lib/squib/graphics/text.rb +116 -113
- data/lib/squib/input_helpers.rb +193 -193
- data/lib/squib/progress.rb +37 -37
- data/lib/squib/project_template/.gitignore +4 -4
- data/lib/squib/project_template/ABOUT.md +19 -19
- data/lib/squib/project_template/Gemfile +2 -2
- data/lib/squib/project_template/PNP NOTES.md +3 -3
- data/lib/squib/project_template/config.yml +19 -19
- data/lib/squib/project_template/deck.rb +5 -5
- data/lib/squib/version.rb +6 -6
- data/samples/autoscale_font.rb +27 -0
- data/samples/basic.rb +19 -19
- data/samples/colors.rb +15 -15
- data/samples/custom-config.yml +5 -5
- data/samples/custom-layout.yml +59 -39
- data/samples/custom_config.rb +18 -18
- data/samples/customconfig-imgdir/spanner2.svg +91 -91
- data/samples/draw_shapes.rb +18 -18
- data/samples/excel.rb +19 -19
- data/samples/hello_world.rb +6 -6
- data/samples/load_images.rb +29 -29
- data/samples/offset.svg +71 -71
- data/samples/portrait-landscape.rb +22 -22
- data/samples/ranges.rb +55 -55
- data/samples/save_pdf.rb +14 -14
- data/samples/spanner.svg +91 -91
- data/samples/text_options.rb +67 -60
- data/samples/tgc_proofs.rb +19 -19
- data/samples/units.rb +12 -12
- data/samples/use_layout.rb +33 -28
- data/spec/api/api_text_spec.rb +43 -43
- data/spec/commands/new_spec.rb +47 -47
- data/spec/data/easy-circular-extends.yml +6 -0
- data/spec/data/hard-circular-extends.yml +9 -0
- data/spec/data/multi-extends-single-entry.yml +14 -13
- data/spec/data/multi-level-extends.yml +9 -9
- data/spec/data/no-extends.yml +5 -5
- data/spec/data/pre-extends.yml +7 -0
- data/spec/data/self-circular-extends.yml +3 -0
- data/spec/data/single-extends.yml +7 -7
- data/spec/data/single-level-multi-extends.yml +11 -11
- data/spec/deck_spec.rb +188 -147
- data/spec/input_helpers_spec.rb +116 -116
- data/spec/samples_run_spec.rb +19 -19
- data/squib.gemspec +46 -46
- metadata +17 -7
data/spec/api/api_text_spec.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib'
|
3
|
-
|
4
|
-
describe Squib::Deck, '#text' do
|
5
|
-
|
6
|
-
context "fonts" do
|
7
|
-
it "should use the default font when #text and #set_font don't specify" do
|
8
|
-
card = instance_double(Squib::Card)
|
9
|
-
expect(card).to receive(:text).with('a', 'Arial 36',
|
10
|
-
anything, anything, anything,
|
11
|
-
).once
|
12
|
-
Squib::Deck.new do
|
13
|
-
@cards = [card]
|
14
|
-
text str: 'a'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should use the #set_font when #text doesn't specify" do
|
19
|
-
card = instance_double(Squib::Card)
|
20
|
-
expect(card).to receive(:text).with('a', 'Times New Roman 16',
|
21
|
-
anything, anything, anything, anything,anything, anything, anything, anything,anything, anything, anything, anything, anything
|
22
|
-
).once
|
23
|
-
Squib::Deck.new do
|
24
|
-
@cards = [card]
|
25
|
-
set font: 'Times New Roman 16'
|
26
|
-
text str: 'a'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should use the specified font no matter what" do
|
31
|
-
card = instance_double(Squib::Card)
|
32
|
-
expect(card).to receive(:text).with('a', 'Arial 18',
|
33
|
-
anything, anything, anything, anything,anything,
|
34
|
-
).once
|
35
|
-
Squib::Deck.new do
|
36
|
-
@cards = [card]
|
37
|
-
set font: 'Times New Roman 16'
|
38
|
-
text str: 'a', font: 'Arial 18'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib'
|
3
|
+
|
4
|
+
describe Squib::Deck, '#text' do
|
5
|
+
|
6
|
+
context "fonts" do
|
7
|
+
it "should use the default font when #text and #set_font don't specify" do
|
8
|
+
card = instance_double(Squib::Card)
|
9
|
+
expect(card).to receive(:text).with('a', 'Arial 36',
|
10
|
+
anything, anything, anything,anything,anything,anything, anything, anything, anything,anything, anything, anything, anything, anything, anything
|
11
|
+
).once
|
12
|
+
Squib::Deck.new do
|
13
|
+
@cards = [card]
|
14
|
+
text str: 'a'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should use the #set_font when #text doesn't specify" do
|
19
|
+
card = instance_double(Squib::Card)
|
20
|
+
expect(card).to receive(:text).with('a', 'Times New Roman 16',
|
21
|
+
anything, anything, anything, anything,anything,anything, anything, anything, anything,anything, anything, anything, anything, anything, anything
|
22
|
+
).once
|
23
|
+
Squib::Deck.new do
|
24
|
+
@cards = [card]
|
25
|
+
set font: 'Times New Roman 16'
|
26
|
+
text str: 'a'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should use the specified font no matter what" do
|
31
|
+
card = instance_double(Squib::Card)
|
32
|
+
expect(card).to receive(:text).with('a', 'Arial 18',
|
33
|
+
anything, anything, anything, anything,anything,anything,anything, anything, anything,anything, anything, anything, anything, anything, anything
|
34
|
+
).once
|
35
|
+
Squib::Deck.new do
|
36
|
+
@cards = [card]
|
37
|
+
set font: 'Times New Roman 16'
|
38
|
+
text str: 'a', font: 'Arial 18'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/spec/commands/new_spec.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib'
|
3
|
-
|
4
|
-
describe Squib::Commands::New do
|
5
|
-
|
6
|
-
describe "#process" do
|
7
|
-
before(:all) do
|
8
|
-
@old_stderr = $stderr
|
9
|
-
$stderr = StringIO.new
|
10
|
-
@oldpwd = Dir.pwd
|
11
|
-
Dir.chdir(File.expand_path('../../samples/_output', File.dirname(__FILE__)))
|
12
|
-
end
|
13
|
-
|
14
|
-
before(:each) do
|
15
|
-
FileUtils.rm_rf('foo', secure: true)
|
16
|
-
@cmd = Squib::Commands::New.new
|
17
|
-
end
|
18
|
-
|
19
|
-
it "raises an error if no directory was specified" do
|
20
|
-
expect{@cmd.process([])}.to raise_error(ArgumentError, 'Please specify a path.')
|
21
|
-
end
|
22
|
-
|
23
|
-
it "creates a new template on an fresh directory" do
|
24
|
-
@cmd.process(['foo'])
|
25
|
-
expect(File.exists?('foo/deck.rb')).to be true
|
26
|
-
end
|
27
|
-
|
28
|
-
it "creates a new template on an empty directory" do
|
29
|
-
Dir.mkdir('foo')
|
30
|
-
@cmd.process(['foo'])
|
31
|
-
expect(File.exists?('foo/deck.rb')).to be true
|
32
|
-
end
|
33
|
-
|
34
|
-
it "does not create a new template on an empty " do
|
35
|
-
Dir.mkdir('foo')
|
36
|
-
File.new('foo/somefile.txt', 'w+')
|
37
|
-
@cmd.process(['foo'])
|
38
|
-
$stderr.rewind
|
39
|
-
expect($stderr.string.chomp).to end_with " exists and is not empty. Doing nothing and quitting."
|
40
|
-
end
|
41
|
-
|
42
|
-
after(:all) do
|
43
|
-
$stderr = @old_stderr
|
44
|
-
Dir.chdir(@oldpwd)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib'
|
3
|
+
|
4
|
+
describe Squib::Commands::New do
|
5
|
+
|
6
|
+
describe "#process" do
|
7
|
+
before(:all) do
|
8
|
+
@old_stderr = $stderr
|
9
|
+
$stderr = StringIO.new
|
10
|
+
@oldpwd = Dir.pwd
|
11
|
+
Dir.chdir(File.expand_path('../../samples/_output', File.dirname(__FILE__)))
|
12
|
+
end
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
FileUtils.rm_rf('foo', secure: true)
|
16
|
+
@cmd = Squib::Commands::New.new
|
17
|
+
end
|
18
|
+
|
19
|
+
it "raises an error if no directory was specified" do
|
20
|
+
expect{@cmd.process([])}.to raise_error(ArgumentError, 'Please specify a path.')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "creates a new template on an fresh directory" do
|
24
|
+
@cmd.process(['foo'])
|
25
|
+
expect(File.exists?('foo/deck.rb')).to be true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "creates a new template on an empty directory" do
|
29
|
+
Dir.mkdir('foo')
|
30
|
+
@cmd.process(['foo'])
|
31
|
+
expect(File.exists?('foo/deck.rb')).to be true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "does not create a new template on an empty " do
|
35
|
+
Dir.mkdir('foo')
|
36
|
+
File.new('foo/somefile.txt', 'w+')
|
37
|
+
@cmd.process(['foo'])
|
38
|
+
$stderr.rewind
|
39
|
+
expect($stderr.string.chomp).to end_with " exists and is not empty. Doing nothing and quitting."
|
40
|
+
end
|
41
|
+
|
42
|
+
after(:all) do
|
43
|
+
$stderr = @old_stderr
|
44
|
+
Dir.chdir(@oldpwd)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
48
|
end
|
@@ -1,13 +1,14 @@
|
|
1
|
-
aunt:
|
2
|
-
a: 101
|
3
|
-
b: 102
|
4
|
-
c: 103
|
5
|
-
uncle:
|
6
|
-
x: 104
|
7
|
-
y: 105
|
8
|
-
b: 106
|
9
|
-
child:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
aunt:
|
2
|
+
a: 101
|
3
|
+
b: 102
|
4
|
+
c: 103
|
5
|
+
uncle:
|
6
|
+
x: 104
|
7
|
+
y: 105
|
8
|
+
b: 106
|
9
|
+
child:
|
10
|
+
extends:
|
11
|
+
- uncle
|
12
|
+
- aunt
|
13
|
+
a: 107
|
14
|
+
x: 108
|
@@ -1,10 +1,10 @@
|
|
1
|
-
frame:
|
2
|
-
x: 38
|
3
|
-
y: 38
|
4
|
-
title:
|
5
|
-
|
6
|
-
y: 50
|
7
|
-
width: 100
|
8
|
-
subtitle:
|
9
|
-
|
1
|
+
frame:
|
2
|
+
x: 38
|
3
|
+
y: 38
|
4
|
+
title:
|
5
|
+
extends: frame
|
6
|
+
y: 50
|
7
|
+
width: 100
|
8
|
+
subtitle:
|
9
|
+
extends: title
|
10
10
|
y: 150
|
data/spec/data/no-extends.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
frame:
|
2
|
-
x: 38
|
3
|
-
valign: !ruby/symbol middle
|
4
|
-
str: "blah"
|
5
|
-
font: Mr. Font
|
1
|
+
frame:
|
2
|
+
x: 38
|
3
|
+
valign: !ruby/symbol middle
|
4
|
+
str: "blah"
|
5
|
+
font: Mr. Font
|
@@ -1,7 +1,7 @@
|
|
1
|
-
frame:
|
2
|
-
x: 38
|
3
|
-
y: 38
|
4
|
-
title:
|
5
|
-
|
6
|
-
y: 50
|
7
|
-
width: 100
|
1
|
+
frame:
|
2
|
+
x: 38
|
3
|
+
y: 38
|
4
|
+
title:
|
5
|
+
extends: frame
|
6
|
+
y: 50
|
7
|
+
width: 100
|
@@ -1,12 +1,12 @@
|
|
1
|
-
frame:
|
2
|
-
x: 38
|
3
|
-
y: 38
|
4
|
-
title:
|
5
|
-
|
6
|
-
y: 50
|
7
|
-
width: 100
|
8
|
-
title2:
|
9
|
-
|
10
|
-
x: 75
|
11
|
-
y: 150
|
1
|
+
frame:
|
2
|
+
x: 38
|
3
|
+
y: 38
|
4
|
+
title:
|
5
|
+
extends: frame
|
6
|
+
y: 50
|
7
|
+
width: 100
|
8
|
+
title2:
|
9
|
+
extends: frame
|
10
|
+
x: 75
|
11
|
+
y: 150
|
12
12
|
width: 150
|
data/spec/deck_spec.rb
CHANGED
@@ -1,147 +1,188 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/deck'
|
3
|
-
|
4
|
-
describe Squib::Deck do
|
5
|
-
|
6
|
-
it "initializes with default parameters" do
|
7
|
-
d = Squib::Deck.new
|
8
|
-
expect(d.width).to eq(825)
|
9
|
-
expect(d.height).to eq(1125)
|
10
|
-
expect(d.cards.size).to eq(1)
|
11
|
-
end
|
12
|
-
|
13
|
-
context "in dealing with ranges" do
|
14
|
-
it "calls text on all cards by default" do
|
15
|
-
card1 = instance_double(Squib::Card)
|
16
|
-
card2 = instance_double(Squib::Card)
|
17
|
-
expect(card1).to receive(:text).once
|
18
|
-
expect(card2).to receive(:text).once
|
19
|
-
Squib::Deck.new do
|
20
|
-
@cards = [card1, card2]
|
21
|
-
text str: 'blah'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it "calls text on some cards with an integer" do
|
26
|
-
card1 = instance_double(Squib::Card)
|
27
|
-
card2 = instance_double(Squib::Card)
|
28
|
-
expect(card2).to receive(:text).once
|
29
|
-
Squib::Deck.new do
|
30
|
-
@cards = [card1, card2]
|
31
|
-
text range: 1, str: 'blah'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "calls text with ranges" do
|
36
|
-
card1 = instance_double(Squib::Card)
|
37
|
-
card2 = instance_double(Squib::Card)
|
38
|
-
card3 = instance_double(Squib::Card)
|
39
|
-
expect(card1).to receive(:text).once
|
40
|
-
expect(card2).to receive(:text).once
|
41
|
-
Squib::Deck.new do
|
42
|
-
@cards = [card1, card2, card3]
|
43
|
-
text range: 0..1, str: 'blah'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "#load_layout" do
|
49
|
-
|
50
|
-
it "loads a normal layout with no extends" do
|
51
|
-
d = Squib::Deck.new(layout: test_file('no-extends.yml'))
|
52
|
-
expect(d.layout).to \
|
53
|
-
eq({'frame' => {
|
54
|
-
'x' => 38,
|
55
|
-
'valign' => :middle,
|
56
|
-
'str' => "blah",
|
57
|
-
'font' => "Mr. Font",
|
58
|
-
}
|
59
|
-
}
|
60
|
-
)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "loads with a single extends" do
|
64
|
-
d = Squib::Deck.new(layout: test_file('single-extends.yml'))
|
65
|
-
expect(d.layout).to \
|
66
|
-
eq({'frame' => {
|
67
|
-
'x' => 38,
|
68
|
-
'y' => 38,
|
69
|
-
},
|
70
|
-
'title' => {
|
71
|
-
'
|
72
|
-
'
|
73
|
-
'
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
'
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
'
|
89
|
-
'
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
'
|
106
|
-
'
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
'
|
112
|
-
|
113
|
-
|
114
|
-
'
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
'
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
'
|
135
|
-
|
136
|
-
|
137
|
-
'
|
138
|
-
'
|
139
|
-
'
|
140
|
-
},
|
141
|
-
}
|
142
|
-
)
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/deck'
|
3
|
+
|
4
|
+
describe Squib::Deck do
|
5
|
+
|
6
|
+
it "initializes with default parameters" do
|
7
|
+
d = Squib::Deck.new
|
8
|
+
expect(d.width).to eq(825)
|
9
|
+
expect(d.height).to eq(1125)
|
10
|
+
expect(d.cards.size).to eq(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "in dealing with ranges" do
|
14
|
+
it "calls text on all cards by default" do
|
15
|
+
card1 = instance_double(Squib::Card)
|
16
|
+
card2 = instance_double(Squib::Card)
|
17
|
+
expect(card1).to receive(:text).once
|
18
|
+
expect(card2).to receive(:text).once
|
19
|
+
Squib::Deck.new do
|
20
|
+
@cards = [card1, card2]
|
21
|
+
text str: 'blah'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "calls text on some cards with an integer" do
|
26
|
+
card1 = instance_double(Squib::Card)
|
27
|
+
card2 = instance_double(Squib::Card)
|
28
|
+
expect(card2).to receive(:text).once
|
29
|
+
Squib::Deck.new do
|
30
|
+
@cards = [card1, card2]
|
31
|
+
text range: 1, str: 'blah'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "calls text with ranges" do
|
36
|
+
card1 = instance_double(Squib::Card)
|
37
|
+
card2 = instance_double(Squib::Card)
|
38
|
+
card3 = instance_double(Squib::Card)
|
39
|
+
expect(card1).to receive(:text).once
|
40
|
+
expect(card2).to receive(:text).once
|
41
|
+
Squib::Deck.new do
|
42
|
+
@cards = [card1, card2, card3]
|
43
|
+
text range: 0..1, str: 'blah'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "#load_layout" do
|
49
|
+
|
50
|
+
it "loads a normal layout with no extends" do
|
51
|
+
d = Squib::Deck.new(layout: test_file('no-extends.yml'))
|
52
|
+
expect(d.layout).to \
|
53
|
+
eq({'frame' => {
|
54
|
+
'x' => 38,
|
55
|
+
'valign' => :middle,
|
56
|
+
'str' => "blah",
|
57
|
+
'font' => "Mr. Font",
|
58
|
+
}
|
59
|
+
}
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "loads with a single extends" do
|
64
|
+
d = Squib::Deck.new(layout: test_file('single-extends.yml'))
|
65
|
+
expect(d.layout).to \
|
66
|
+
eq({'frame' => {
|
67
|
+
'x' => 38,
|
68
|
+
'y' => 38,
|
69
|
+
},
|
70
|
+
'title' => {
|
71
|
+
'extends' => 'frame',
|
72
|
+
'x' => 38,
|
73
|
+
'y' => 50,
|
74
|
+
'width' => 100,
|
75
|
+
}
|
76
|
+
}
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "applies the extends regardless of order" do
|
81
|
+
d = Squib::Deck.new(layout: test_file('pre-extends.yml'))
|
82
|
+
expect(d.layout).to \
|
83
|
+
eq({'frame' => {
|
84
|
+
'x' => 38,
|
85
|
+
'y' => 38,
|
86
|
+
},
|
87
|
+
'title' => {
|
88
|
+
'extends' => 'frame',
|
89
|
+
'x' => 38,
|
90
|
+
'y' => 50,
|
91
|
+
'width' => 100,
|
92
|
+
}
|
93
|
+
}
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "applies the single-level extends multiple times" do
|
98
|
+
d = Squib::Deck.new(layout: test_file('single-level-multi-extends.yml'))
|
99
|
+
expect(d.layout).to \
|
100
|
+
eq({'frame' => {
|
101
|
+
'x' => 38,
|
102
|
+
'y' => 38,
|
103
|
+
},
|
104
|
+
'title' => {
|
105
|
+
'extends' => 'frame',
|
106
|
+
'x' => 38,
|
107
|
+
'y' => 50,
|
108
|
+
'width' => 100,
|
109
|
+
},
|
110
|
+
'title2' => {
|
111
|
+
'extends' => 'frame',
|
112
|
+
'x' => 75,
|
113
|
+
'y' => 150,
|
114
|
+
'width' => 150,
|
115
|
+
},
|
116
|
+
}
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "applies multiple extends in a single rule" do
|
121
|
+
d = Squib::Deck.new(layout: test_file('multi-extends-single-entry.yml'))
|
122
|
+
expect(d.layout).to \
|
123
|
+
eq({'aunt' => {
|
124
|
+
'a' => 101,
|
125
|
+
'b' => 102,
|
126
|
+
'c' => 103,
|
127
|
+
},
|
128
|
+
'uncle' => {
|
129
|
+
'x' => 104,
|
130
|
+
'y' => 105,
|
131
|
+
'b' => 106,
|
132
|
+
},
|
133
|
+
'child' => {
|
134
|
+
'extends' => ['uncle','aunt'],
|
135
|
+
'a' => 107, # my own
|
136
|
+
'b' => 102, # from the younger aunt
|
137
|
+
'c' => 103, # from aunt
|
138
|
+
'x' => 108, # my own
|
139
|
+
'y' => 105, # from uncle
|
140
|
+
},
|
141
|
+
}
|
142
|
+
)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "applies multi-level extends" do
|
146
|
+
d = Squib::Deck.new(layout: test_file('multi-level-extends.yml'))
|
147
|
+
expect(d.layout).to \
|
148
|
+
eq({'frame' => {
|
149
|
+
'x' => 38,
|
150
|
+
'y' => 38,
|
151
|
+
},
|
152
|
+
'title' => {
|
153
|
+
'extends' => 'frame',
|
154
|
+
'x' => 38,
|
155
|
+
'y' => 50,
|
156
|
+
'width' => 100,
|
157
|
+
},
|
158
|
+
'subtitle' => {
|
159
|
+
'extends' => 'title',
|
160
|
+
'x' => 38,
|
161
|
+
'y' => 150,
|
162
|
+
'width' => 100,
|
163
|
+
},
|
164
|
+
}
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "fails on a self-circular extends" do
|
169
|
+
file = test_file('self-circular-extends.yml')
|
170
|
+
expect { Squib::Deck.new(layout: file) }.to \
|
171
|
+
raise_error(RuntimeError, "Invalid layout: circular extends with 'a'")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "fails on a easy-circular extends" do
|
175
|
+
file = test_file('easy-circular-extends.yml')
|
176
|
+
expect { Squib::Deck.new(layout: file) }.to \
|
177
|
+
raise_error(RuntimeError, "Invalid layout: circular extends with 'a'")
|
178
|
+
end
|
179
|
+
|
180
|
+
it "hard on a easy-circular extends" do
|
181
|
+
file = test_file('hard-circular-extends.yml')
|
182
|
+
expect { Squib::Deck.new(layout: file) }.to \
|
183
|
+
raise_error(RuntimeError, "Invalid layout: circular extends with 'a'")
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|