nanoc 4.7.13 → 4.7.14
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/NEWS.md +6 -0
- data/bin/nanoc +7 -0
- data/lib/nanoc/base/entities/code_snippet.rb +1 -1
- data/lib/nanoc/base/entities/configuration.rb +1 -1
- data/lib/nanoc/base/entities/directed_graph.rb +18 -119
- data/lib/nanoc/base/entities/item.rb +1 -1
- data/lib/nanoc/base/entities/item_collection.rb +1 -1
- data/lib/nanoc/base/entities/item_rep.rb +1 -1
- data/lib/nanoc/base/entities/layout.rb +1 -1
- data/lib/nanoc/base/entities/layout_collection.rb +1 -1
- data/lib/nanoc/base/errors.rb +4 -3
- data/lib/nanoc/base/services/item_rep_selector.rb +40 -61
- data/lib/nanoc/data_sources/filesystem.rb +1 -1
- data/lib/nanoc/rule_dsl/rules_collection.rb +1 -1
- data/lib/nanoc/version.rb +1 -1
- data/spec/nanoc/base/directed_graph_spec.rb +123 -296
- data/spec/nanoc/base/entities/identifiable_collection_spec.rb +2 -2
- data/spec/nanoc/base/entities/item_spec.rb +1 -1
- data/spec/nanoc/base/entities/layout_spec.rb +1 -1
- data/spec/nanoc/base/errors/dependency_cycle_spec.rb +14 -13
- data/spec/nanoc/base/services/item_rep_selector_spec.rb +41 -0
- data/test/base/test_directed_graph.rb +0 -256
- metadata +2 -2
@@ -139,12 +139,12 @@ describe Nanoc::Int::IdentifiableCollection do
|
|
139
139
|
end
|
140
140
|
|
141
141
|
describe Nanoc::Int::ItemCollection do
|
142
|
-
let(:expected_reference) {
|
142
|
+
let(:expected_reference) { 'items' }
|
143
143
|
it_behaves_like 'a generic identifiable collection'
|
144
144
|
end
|
145
145
|
|
146
146
|
describe Nanoc::Int::LayoutCollection do
|
147
|
-
let(:expected_reference) {
|
147
|
+
let(:expected_reference) { 'layouts' }
|
148
148
|
it_behaves_like 'a generic identifiable collection'
|
149
149
|
end
|
150
150
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe Nanoc::Int::Errors::DependencyCycle do
|
4
|
-
subject(:error) { described_class.new(
|
4
|
+
subject(:error) { described_class.new(stack) }
|
5
5
|
|
6
|
-
let(:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
let(:stack) do
|
7
|
+
[
|
8
|
+
rep_a,
|
9
|
+
rep_b,
|
10
|
+
rep_c,
|
11
|
+
rep_d,
|
12
|
+
rep_e,
|
13
|
+
rep_b,
|
14
|
+
]
|
14
15
|
end
|
15
16
|
|
16
17
|
let(:rep_a) { Nanoc::Int::ItemRep.new(Nanoc::Int::Item.new('a', {}, '/a.md'), :default) }
|
@@ -23,10 +24,10 @@ describe Nanoc::Int::Errors::DependencyCycle do
|
|
23
24
|
expected = <<~EOS
|
24
25
|
The site cannot be compiled because there is a dependency cycle:
|
25
26
|
|
26
|
-
(1) item /
|
27
|
-
(2) item /
|
28
|
-
(3) item /
|
29
|
-
(4) item /
|
27
|
+
(1) item /b.md, rep :default, uses compiled content of
|
28
|
+
(2) item /c.md, rep :default, uses compiled content of
|
29
|
+
(3) item /d.md, rep :default, uses compiled content of
|
30
|
+
(4) item /e.md, rep :default, uses compiled content of (1)
|
30
31
|
EOS
|
31
32
|
|
32
33
|
expect(error.message).to eql(expected)
|
@@ -111,6 +111,47 @@ describe Nanoc::Int::ItemRepSelector do
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
describe 'cycle' do
|
115
|
+
context 'dependency on self' do
|
116
|
+
subject do
|
117
|
+
selector.each { |r| raise Nanoc::Int::Errors::UnmetDependency.new(r) }
|
118
|
+
end
|
119
|
+
|
120
|
+
example do
|
121
|
+
expect { subject }.to raise_error(Nanoc::Int::Errors::DependencyCycle, <<~EOS)
|
122
|
+
The site cannot be compiled because there is a dependency cycle:
|
123
|
+
|
124
|
+
(1) item /foo.md, rep :a, uses compiled content of (1)
|
125
|
+
EOS
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context 'cycle with three dependencies' do
|
130
|
+
subject do
|
131
|
+
selector.each do |r|
|
132
|
+
case r
|
133
|
+
when reps_array[0]
|
134
|
+
raise Nanoc::Int::Errors::UnmetDependency.new(reps_array[1])
|
135
|
+
when reps_array[1]
|
136
|
+
raise Nanoc::Int::Errors::UnmetDependency.new(reps_array[2])
|
137
|
+
when reps_array[2]
|
138
|
+
raise Nanoc::Int::Errors::UnmetDependency.new(reps_array[0])
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
example do
|
144
|
+
expect { subject }.to raise_error(Nanoc::Int::Errors::DependencyCycle, <<~EOS)
|
145
|
+
The site cannot be compiled because there is a dependency cycle:
|
146
|
+
|
147
|
+
(1) item /foo.md, rep :a, uses compiled content of
|
148
|
+
(2) item /foo.md, rep :b, uses compiled content of
|
149
|
+
(3) item /foo.md, rep :c, uses compiled content of (1)
|
150
|
+
EOS
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
114
155
|
describe 'yield order' do
|
115
156
|
context 'linear dependencies' do
|
116
157
|
let(:dependencies) do
|
@@ -3,108 +3,6 @@
|
|
3
3
|
require 'helper'
|
4
4
|
|
5
5
|
class Nanoc::Int::DirectedGraphTest < Nanoc::TestCase
|
6
|
-
def test_direct_predecessors
|
7
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
8
|
-
graph.add_edge(1, 2)
|
9
|
-
graph.add_edge(2, 3)
|
10
|
-
|
11
|
-
assert_equal [], graph.direct_predecessors_of(1)
|
12
|
-
assert_equal [1], graph.direct_predecessors_of(2)
|
13
|
-
assert_equal [2], graph.direct_predecessors_of(3)
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_predecessors
|
17
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
18
|
-
graph.add_edge(1, 2)
|
19
|
-
graph.add_edge(2, 3)
|
20
|
-
|
21
|
-
assert_equal [], graph.predecessors_of(1).sort
|
22
|
-
assert_equal [1], graph.predecessors_of(2).sort
|
23
|
-
assert_equal [1, 2], graph.predecessors_of(3).sort
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_direct_successors
|
27
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
28
|
-
graph.add_edge(1, 2)
|
29
|
-
graph.add_edge(2, 3)
|
30
|
-
|
31
|
-
assert_equal [2], graph.direct_successors_of(1)
|
32
|
-
assert_equal [3], graph.direct_successors_of(2)
|
33
|
-
assert_equal [], graph.direct_successors_of(3)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_successors
|
37
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
38
|
-
graph.add_edge(1, 2)
|
39
|
-
graph.add_edge(2, 3)
|
40
|
-
|
41
|
-
assert_equal [2, 3], graph.successors_of(1).sort
|
42
|
-
assert_equal [3], graph.successors_of(2).sort
|
43
|
-
assert_equal [], graph.successors_of(3).sort
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_edges
|
47
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
48
|
-
graph.add_edge(1, 2)
|
49
|
-
graph.add_edge(2, 3)
|
50
|
-
|
51
|
-
assert_equal [[0, 1, nil], [1, 2, nil]], graph.edges.sort
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_edges_with_new_vertices
|
55
|
-
graph = Nanoc::Int::DirectedGraph.new([1])
|
56
|
-
assert_equal [1], graph.vertices
|
57
|
-
graph.add_edge(1, 2)
|
58
|
-
assert_equal [1, 2], graph.vertices
|
59
|
-
graph.add_edge(3, 2)
|
60
|
-
assert_equal [1, 2, 3], graph.vertices
|
61
|
-
|
62
|
-
assert_equal [[0, 1, nil], [2, 1, nil]], graph.edges.sort
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_edge_with_props
|
66
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
67
|
-
graph.add_edge(1, 2, props: { donkey: 14 })
|
68
|
-
graph.add_edge(2, 3, props: { giraffe: 3 })
|
69
|
-
|
70
|
-
assert_equal [[0, 1, { donkey: 14 }], [1, 2, { giraffe: 3 }]], graph.edges.sort
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_props_for
|
74
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3, 4])
|
75
|
-
graph.add_edge(1, 2, props: { donkey: 14 })
|
76
|
-
graph.add_edge(2, 3, props: { giraffe: 3 })
|
77
|
-
graph.add_edge(3, 4)
|
78
|
-
|
79
|
-
assert_equal({ donkey: 14 }, graph.props_for(1, 2))
|
80
|
-
assert_equal({ giraffe: 3 }, graph.props_for(2, 3))
|
81
|
-
assert_equal(nil, graph.props_for(3, 4))
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_props_for_with_deleted_edge
|
85
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2])
|
86
|
-
graph.add_edge(1, 2, props: { donkey: 14 })
|
87
|
-
graph.delete_edge(1, 2)
|
88
|
-
|
89
|
-
assert_equal(nil, graph.props_for(1, 2))
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_props_for_with_deleted_edges_from
|
93
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2])
|
94
|
-
graph.add_edge(1, 2, props: { donkey: 14 })
|
95
|
-
graph.delete_edges_from(1)
|
96
|
-
|
97
|
-
assert_equal(nil, graph.props_for(1, 2))
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_props_for_with_deleted_edges_to
|
101
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2])
|
102
|
-
graph.add_edge(1, 2, props: { donkey: 14 })
|
103
|
-
graph.delete_edges_to(2)
|
104
|
-
|
105
|
-
assert_equal(nil, graph.props_for(1, 2))
|
106
|
-
end
|
107
|
-
|
108
6
|
def test_add_edge
|
109
7
|
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
110
8
|
|
@@ -126,58 +24,6 @@ class Nanoc::Int::DirectedGraphTest < Nanoc::TestCase
|
|
126
24
|
assert graph.vertices.include?(3)
|
127
25
|
end
|
128
26
|
|
129
|
-
def test_delete_edge
|
130
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
131
|
-
graph.add_edge(1, 2)
|
132
|
-
|
133
|
-
assert_equal [2], graph.successors_of(1)
|
134
|
-
assert_equal [1], graph.predecessors_of(2)
|
135
|
-
|
136
|
-
graph.delete_edge(1, 2)
|
137
|
-
|
138
|
-
assert_equal [], graph.successors_of(1)
|
139
|
-
assert_equal [], graph.predecessors_of(2)
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_delete_edges_from
|
143
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
144
|
-
|
145
|
-
graph.add_edge(1, 2)
|
146
|
-
graph.add_edge(2, 1)
|
147
|
-
graph.add_edge(2, 3)
|
148
|
-
graph.add_edge(3, 2)
|
149
|
-
graph.add_edge(1, 3)
|
150
|
-
graph.add_edge(3, 1)
|
151
|
-
|
152
|
-
assert_equal [2, 3], graph.direct_predecessors_of(1).sort
|
153
|
-
assert_equal [2, 3], graph.direct_successors_of(1).sort
|
154
|
-
assert_equal [1, 3], graph.direct_predecessors_of(2).sort
|
155
|
-
assert_equal [1, 3], graph.direct_successors_of(2).sort
|
156
|
-
assert_equal [1, 2], graph.direct_predecessors_of(3).sort
|
157
|
-
assert_equal [1, 2], graph.direct_successors_of(3).sort
|
158
|
-
assert_equal Set.new([]), graph.roots
|
159
|
-
|
160
|
-
graph.delete_edges_from(1)
|
161
|
-
|
162
|
-
assert_equal [2, 3], graph.direct_predecessors_of(1).sort
|
163
|
-
assert_equal [], graph.direct_successors_of(1).sort
|
164
|
-
assert_equal [3], graph.direct_predecessors_of(2).sort
|
165
|
-
assert_equal [1, 3], graph.direct_successors_of(2).sort
|
166
|
-
assert_equal [2], graph.direct_predecessors_of(3).sort
|
167
|
-
assert_equal [1, 2], graph.direct_successors_of(3).sort
|
168
|
-
assert_equal Set.new([]), graph.roots
|
169
|
-
|
170
|
-
graph.delete_edges_from(2)
|
171
|
-
|
172
|
-
assert_equal [3], graph.direct_predecessors_of(1).sort
|
173
|
-
assert_equal [], graph.direct_successors_of(1).sort
|
174
|
-
assert_equal [3], graph.direct_predecessors_of(2).sort
|
175
|
-
assert_equal [], graph.direct_successors_of(2).sort
|
176
|
-
assert_equal [], graph.direct_predecessors_of(3).sort
|
177
|
-
assert_equal [1, 2], graph.direct_successors_of(3).sort
|
178
|
-
assert_equal Set.new([3]), graph.roots
|
179
|
-
end
|
180
|
-
|
181
27
|
def test_delete_edges_to
|
182
28
|
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
183
29
|
|
@@ -194,7 +40,6 @@ class Nanoc::Int::DirectedGraphTest < Nanoc::TestCase
|
|
194
40
|
assert_equal [1, 3], graph.direct_successors_of(2).sort
|
195
41
|
assert_equal [1, 2], graph.direct_predecessors_of(3).sort
|
196
42
|
assert_equal [1, 2], graph.direct_successors_of(3).sort
|
197
|
-
assert_equal Set.new([]), graph.roots
|
198
43
|
|
199
44
|
graph.delete_edges_to(1)
|
200
45
|
|
@@ -204,7 +49,6 @@ class Nanoc::Int::DirectedGraphTest < Nanoc::TestCase
|
|
204
49
|
assert_equal [3], graph.direct_successors_of(2).sort
|
205
50
|
assert_equal [1, 2], graph.direct_predecessors_of(3).sort
|
206
51
|
assert_equal [2], graph.direct_successors_of(3).sort
|
207
|
-
assert_equal Set.new([1]), graph.roots
|
208
52
|
|
209
53
|
graph.delete_edges_to(2)
|
210
54
|
|
@@ -214,38 +58,6 @@ class Nanoc::Int::DirectedGraphTest < Nanoc::TestCase
|
|
214
58
|
assert_equal [3], graph.direct_successors_of(2).sort
|
215
59
|
assert_equal [1, 2], graph.direct_predecessors_of(3).sort
|
216
60
|
assert_equal [], graph.direct_successors_of(3).sort
|
217
|
-
assert_equal Set.new([1, 2]), graph.roots
|
218
|
-
end
|
219
|
-
|
220
|
-
def test_delete_vertex
|
221
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
222
|
-
|
223
|
-
graph.add_edge(1, 2)
|
224
|
-
graph.add_edge(2, 1)
|
225
|
-
graph.add_edge(2, 3)
|
226
|
-
graph.add_edge(3, 2)
|
227
|
-
graph.add_edge(1, 3)
|
228
|
-
graph.add_edge(3, 1)
|
229
|
-
|
230
|
-
graph.delete_vertex(2)
|
231
|
-
|
232
|
-
assert_equal [3], graph.direct_predecessors_of(1).sort
|
233
|
-
assert_equal [3], graph.direct_successors_of(1).sort
|
234
|
-
assert_equal [1], graph.direct_predecessors_of(3).sort
|
235
|
-
assert_equal [1], graph.direct_successors_of(3).sort
|
236
|
-
assert_equal Set.new([]), graph.roots
|
237
|
-
end
|
238
|
-
|
239
|
-
def test_delete_vertex_resulting_roots
|
240
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
241
|
-
assert_equal Set.new([1, 2, 3]), graph.roots
|
242
|
-
|
243
|
-
graph.add_edge(1, 2)
|
244
|
-
graph.add_edge(2, 3)
|
245
|
-
assert_equal Set.new([1]), graph.roots
|
246
|
-
|
247
|
-
graph.delete_vertex(2)
|
248
|
-
assert_equal Set.new([1, 3]), graph.roots
|
249
61
|
end
|
250
62
|
|
251
63
|
def test_should_return_empty_array_for_nonexistant_vertices
|
@@ -257,74 +69,6 @@ class Nanoc::Int::DirectedGraphTest < Nanoc::TestCase
|
|
257
69
|
assert_equal [], graph.successors_of(4)
|
258
70
|
end
|
259
71
|
|
260
|
-
def test_roots_after_init
|
261
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
262
|
-
|
263
|
-
assert_equal Set.new([1, 2, 3]), graph.roots
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_roots_after_adding_edge
|
267
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
268
|
-
graph.add_edge(1, 2)
|
269
|
-
assert_equal Set.new([1, 3]), graph.roots
|
270
|
-
|
271
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
272
|
-
graph.add_edge(1, 3)
|
273
|
-
assert_equal Set.new([1, 2]), graph.roots
|
274
|
-
|
275
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
276
|
-
graph.add_edge(2, 1)
|
277
|
-
assert_equal Set.new([2, 3]), graph.roots
|
278
|
-
|
279
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
280
|
-
graph.add_edge(1, 2)
|
281
|
-
graph.add_edge(2, 3)
|
282
|
-
assert_equal Set.new([1]), graph.roots
|
283
|
-
|
284
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
285
|
-
graph.add_edge(1, 2)
|
286
|
-
graph.add_edge(2, 3)
|
287
|
-
graph.add_edge(3, 1)
|
288
|
-
assert_equal Set.new([]), graph.roots
|
289
|
-
end
|
290
|
-
|
291
|
-
def test_roots_after_removing_edge
|
292
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
293
|
-
graph.add_edge(1, 2)
|
294
|
-
graph.delete_edge(1, 2)
|
295
|
-
assert_equal Set.new([1, 2, 3]), graph.roots
|
296
|
-
|
297
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
298
|
-
graph.add_edge(1, 3)
|
299
|
-
assert_equal Set.new([1, 2]), graph.roots
|
300
|
-
graph.delete_edge(1, 2) # no such edge
|
301
|
-
assert_equal Set.new([1, 2]), graph.roots
|
302
|
-
|
303
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
304
|
-
graph.add_edge(2, 1)
|
305
|
-
graph.delete_edge(2, 1)
|
306
|
-
assert_equal Set.new([1, 2, 3]), graph.roots
|
307
|
-
|
308
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
309
|
-
graph.add_edge(1, 2)
|
310
|
-
graph.add_edge(2, 3)
|
311
|
-
graph.delete_edge(1, 2)
|
312
|
-
assert_equal Set.new([1, 2]), graph.roots
|
313
|
-
graph.delete_edge(2, 3)
|
314
|
-
assert_equal Set.new([1, 2, 3]), graph.roots
|
315
|
-
|
316
|
-
graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
|
317
|
-
graph.add_edge(1, 2)
|
318
|
-
graph.add_edge(2, 3)
|
319
|
-
graph.add_edge(3, 1)
|
320
|
-
graph.delete_edge(1, 2)
|
321
|
-
assert_equal Set.new([2]), graph.roots
|
322
|
-
graph.delete_edge(2, 3)
|
323
|
-
assert_equal Set.new([2, 3]), graph.roots
|
324
|
-
graph.delete_edge(3, 1)
|
325
|
-
assert_equal Set.new([1, 2, 3]), graph.roots
|
326
|
-
end
|
327
|
-
|
328
72
|
def test_example
|
329
73
|
YARD.parse(LIB_DIR + '/nanoc/base/entities/directed_graph.rb')
|
330
74
|
assert_examples_correct 'Nanoc::Int::DirectedGraph'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.7.
|
4
|
+
version: 4.7.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|