nanoc-core 4.12.11 → 4.12.12
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/lib/nanoc/core/errors.rb +1 -4
- data/lib/nanoc/core/item_rep_selector.rb +27 -12
- data/lib/nanoc/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f5cba2759d0a1a3fed3b3ecd60b4d48fe74e4e47d9855f585731a52436b407c
|
4
|
+
data.tar.gz: cbe6128977455e8109c3991059521a6f97053eda60eccaa4597637c680f89a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 488a4b2b75e2a0a49f1a66f810003f5f11961e156013852cd97e1495bc1b66a0906b7efe1816a760127ed4759cd8926426d0dccc9776d12bb159ac15be3eabc6
|
7
|
+
data.tar.gz: 32cc8224e2aaf4abff07af2fb0401211f927bfa1e057c3641acdf043097df4554f4a70142cfcbac37f791f54dfefd196d10e0f48c7637d2692a94134b4850658
|
data/lib/nanoc/core/errors.rb
CHANGED
@@ -72,10 +72,7 @@ module Nanoc
|
|
72
72
|
# Error that is raised during site compilation when an item (directly or
|
73
73
|
# indirectly) includes its own item content, leading to endless recursion.
|
74
74
|
class DependencyCycle < ::Nanoc::Core::Error
|
75
|
-
def initialize(
|
76
|
-
start_idx = stack.index(stack.last)
|
77
|
-
cycle = stack[start_idx..-2]
|
78
|
-
|
75
|
+
def initialize(cycle)
|
79
76
|
msg_bits = []
|
80
77
|
msg_bits << 'The site cannot be compiled because there is a dependency cycle:'
|
81
78
|
msg_bits << ''
|
@@ -31,35 +31,31 @@ module Nanoc
|
|
31
31
|
@prio_b = ItemRepIgnorableIterator.new(reps)
|
32
32
|
@prio_c = []
|
33
33
|
|
34
|
-
# Stack of things that depend on each other. This is used for
|
35
|
-
# detecting and reporting circular dependencies.
|
36
|
-
@stack = []
|
37
|
-
|
38
34
|
# List of reps that we’ve already seen. Reps from `reps` will end up
|
39
35
|
# in here. Reps can end up in here even *before* they come from
|
40
36
|
# `reps`, when they are part of a dependency.
|
41
37
|
@seen = Set.new
|
38
|
+
|
39
|
+
# Record (hard) dependencies. Used for detecting cycles.
|
40
|
+
@dependencies = Hash.new { |hash, key| hash[key] = Set.new }
|
42
41
|
end
|
43
42
|
|
44
43
|
def next
|
45
44
|
# Read prio A
|
46
45
|
@this = @prio_a.pop
|
47
46
|
if @this
|
48
|
-
@stack.push(@this)
|
49
47
|
return @this
|
50
48
|
end
|
51
49
|
|
52
50
|
# Read prio B
|
53
51
|
@this = @prio_b.next_ignoring(@seen)
|
54
52
|
if @this
|
55
|
-
@stack.push(@this)
|
56
53
|
return @this
|
57
54
|
end
|
58
55
|
|
59
56
|
# Read prio C
|
60
57
|
@this = @prio_c.pop
|
61
58
|
if @this
|
62
|
-
@stack.push(@this)
|
63
59
|
return @this
|
64
60
|
end
|
65
61
|
|
@@ -67,20 +63,18 @@ module Nanoc
|
|
67
63
|
end
|
68
64
|
|
69
65
|
def mark_ok
|
70
|
-
|
66
|
+
# Nothing to do
|
71
67
|
end
|
72
68
|
|
73
69
|
def mark_failed(dep)
|
74
|
-
|
75
|
-
raise Nanoc::Core::Errors::DependencyCycle.new(@stack + [dep])
|
76
|
-
end
|
70
|
+
record_dependency(dep)
|
77
71
|
|
78
72
|
# `@this` depends on `dep`, so `dep` has to be compiled first. Thus,
|
79
73
|
# move `@this` into priority C, and `dep` into priority A.
|
80
74
|
|
81
75
|
# Put `@this` (item rep that needs `dep` to be compiled first) into
|
82
76
|
# priority C (lowest prio).
|
83
|
-
@prio_c.push(@this)
|
77
|
+
@prio_c.push(@this) unless @prio_c.include?(@this)
|
84
78
|
|
85
79
|
# Put `dep` (item rep that needs to be compiled first, before
|
86
80
|
# `@this`) into priority A (highest prio).
|
@@ -91,6 +85,27 @@ module Nanoc
|
|
91
85
|
# it then.
|
92
86
|
@seen << dep
|
93
87
|
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def record_dependency(dep)
|
92
|
+
@dependencies[@this] << dep
|
93
|
+
|
94
|
+
find_cycle(@this, [@this])
|
95
|
+
end
|
96
|
+
|
97
|
+
def find_cycle(dep, path)
|
98
|
+
@dependencies[dep].each do |dep1|
|
99
|
+
# Check whether this dependency path ends in `@this` again. If it
|
100
|
+
# does, we have a cycle (because we started from `@this`).
|
101
|
+
if dep1 == @this
|
102
|
+
raise Nanoc::Core::Errors::DependencyCycle.new(path)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Continue checking, starting from `dep1` this time.
|
106
|
+
find_cycle(dep1, [*path, dep1])
|
107
|
+
end
|
108
|
+
end
|
94
109
|
end
|
95
110
|
|
96
111
|
def each
|
data/lib/nanoc/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.12.
|
4
|
+
version: 4.12.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|