nanoc-core 4.14.0 → 4.14.1
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/compilation_item_rep_view.rb +1 -1
- data/lib/nanoc/core/compilation_phases/notify.rb +3 -0
- data/lib/nanoc/core/compilation_phases/recalculate.rb +16 -3
- data/lib/nanoc/core/compilation_stages/compile_reps.rb +1 -5
- data/lib/nanoc/core/compiled_content_store.rb +2 -3
- data/lib/nanoc/core/directed_graph.rb +7 -3
- data/lib/nanoc/core/filter.rb +0 -5
- data/lib/nanoc/core/notification_center.rb +5 -54
- data/lib/nanoc/core/version.rb +1 -1
- metadata +2 -3
- data/lib/nanoc/core/compilation_phases/resume.rb +0 -52
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5de89d113517fc4b36e407d4e143a8cf715a976403a88ebccd7b835657d0fe7c
|
|
4
|
+
data.tar.gz: fa356053ac5f68c8000fe8f33d5c04441e866921905f9b360a0f55c16897e3ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c6ee804845d8df4865282f5844d9d04005efd6b72235a8d1c145308d9df521f1340852934564b34163623da8809abbde7c003dfc04cea8865dd30139898db2ed
|
|
7
|
+
data.tar.gz: aff44bee226c1edbf815cb9f459a2ab6a59729f0ffd520a771e101f1b92aa11a3adcbf447547a61a147aee7d032ed0849326d65f59c7e6f36a77886791b45ee9
|
|
@@ -27,7 +27,7 @@ module Nanoc
|
|
|
27
27
|
res = @item_rep.raw_path(snapshot:)
|
|
28
28
|
|
|
29
29
|
unless @item_rep.compiled?
|
|
30
|
-
|
|
30
|
+
raise Nanoc::Core::Errors::UnmetDependency.new(@item_rep, snapshot)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Wait for file to exist
|
|
@@ -12,6 +12,9 @@ module Nanoc
|
|
|
12
12
|
Nanoc::Core::NotificationCenter.post(:compilation_started, rep)
|
|
13
13
|
yield
|
|
14
14
|
Nanoc::Core::NotificationCenter.post(:compilation_ended, rep)
|
|
15
|
+
rescue Nanoc::Core::Errors::UnmetDependency
|
|
16
|
+
Nanoc::Core::NotificationCenter.post(:compilation_suspended, rep)
|
|
17
|
+
raise
|
|
15
18
|
end
|
|
16
19
|
end
|
|
17
20
|
end
|
|
@@ -23,10 +23,16 @@ module Nanoc
|
|
|
23
23
|
|
|
24
24
|
executor = Nanoc::Core::Executor.new(rep, @compilation_context, dependency_tracker)
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
# Set initial content, if not already present
|
|
27
|
+
compiled_content_store = @compilation_context.compiled_content_store
|
|
28
|
+
unless compiled_content_store.get_current(rep)
|
|
29
|
+
compiled_content_store.set_current(rep, rep.item.content)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
actions = pending_action_sequence_for(rep:)
|
|
33
|
+
until actions.empty?
|
|
34
|
+
action = actions.first
|
|
27
35
|
|
|
28
|
-
actions = @action_sequences[rep]
|
|
29
|
-
actions.each do |action|
|
|
30
36
|
case action
|
|
31
37
|
when Nanoc::Core::ProcessingActions::Filter
|
|
32
38
|
executor.filter(action.filter_name, action.params)
|
|
@@ -39,10 +45,17 @@ module Nanoc
|
|
|
39
45
|
else
|
|
40
46
|
raise Nanoc::Core::Errors::InternalInconsistency, "unknown action #{action.inspect}"
|
|
41
47
|
end
|
|
48
|
+
|
|
49
|
+
actions.shift
|
|
42
50
|
end
|
|
43
51
|
ensure
|
|
44
52
|
dependency_tracker.exit
|
|
45
53
|
end
|
|
54
|
+
|
|
55
|
+
def pending_action_sequence_for(rep:)
|
|
56
|
+
@_pending_action_sequences ||= {}
|
|
57
|
+
@_pending_action_sequences[rep] ||= @action_sequences[rep].to_a
|
|
58
|
+
end
|
|
46
59
|
end
|
|
47
60
|
end
|
|
48
61
|
end
|
|
@@ -87,13 +87,9 @@ module Nanoc
|
|
|
87
87
|
wrapped: recalculate_phase,
|
|
88
88
|
)
|
|
89
89
|
|
|
90
|
-
resume_phase = Nanoc::Core::CompilationPhases::Resume.new(
|
|
91
|
-
wrapped: cache_phase,
|
|
92
|
-
)
|
|
93
|
-
|
|
94
90
|
write_phase = Nanoc::Core::CompilationPhases::Write.new(
|
|
95
91
|
compiled_content_store: @compilation_context.compiled_content_store,
|
|
96
|
-
wrapped:
|
|
92
|
+
wrapped: cache_phase,
|
|
97
93
|
)
|
|
98
94
|
|
|
99
95
|
mark_done_phase = Nanoc::Core::CompilationPhases::MarkDone.new(
|
|
@@ -57,9 +57,8 @@ module Nanoc
|
|
|
57
57
|
content = get(rep, snapshot_name)
|
|
58
58
|
return content if content
|
|
59
59
|
|
|
60
|
-
# Content is unavailable
|
|
61
|
-
|
|
62
|
-
get(rep, snapshot_name)
|
|
60
|
+
# Content is unavailable
|
|
61
|
+
raise Nanoc::Core::Errors::UnmetDependency.new(rep, snapshot_name)
|
|
63
62
|
end
|
|
64
63
|
|
|
65
64
|
contract C::KeywordArgs[rep: Nanoc::Core::ItemRep, snapshot: C::Optional[C::Maybe[Symbol]]] => String
|
|
@@ -33,6 +33,8 @@ module Nanoc
|
|
|
33
33
|
# graph.predecessors_of('e').sort
|
|
34
34
|
# # => %w( c d )
|
|
35
35
|
class DirectedGraph
|
|
36
|
+
EMPTY_SET = Set.new.freeze
|
|
37
|
+
|
|
36
38
|
# @group Creating a graph
|
|
37
39
|
|
|
38
40
|
# Creates a new directed graph with the given vertices.
|
|
@@ -40,7 +42,8 @@ module Nanoc
|
|
|
40
42
|
@vertices = {}
|
|
41
43
|
@next_vertex_idx = 0
|
|
42
44
|
vertices.each do |v|
|
|
43
|
-
@vertices[v] = @next_vertex_idx
|
|
45
|
+
@vertices[v] = @next_vertex_idx
|
|
46
|
+
@next_vertex_idx += 1
|
|
44
47
|
end
|
|
45
48
|
|
|
46
49
|
@to_graph = {}
|
|
@@ -93,7 +96,8 @@ module Nanoc
|
|
|
93
96
|
def add_vertex(vertex)
|
|
94
97
|
return if @vertices.key?(vertex)
|
|
95
98
|
|
|
96
|
-
@vertices[vertex] = @next_vertex_idx
|
|
99
|
+
@vertices[vertex] = @next_vertex_idx
|
|
100
|
+
@next_vertex_idx += 1
|
|
97
101
|
end
|
|
98
102
|
|
|
99
103
|
# Deletes all edges going to the given vertex.
|
|
@@ -121,7 +125,7 @@ module Nanoc
|
|
|
121
125
|
#
|
|
122
126
|
# @return [Array] Direct predecessors of the given vertex
|
|
123
127
|
def direct_predecessors_of(to)
|
|
124
|
-
@to_graph.fetch(to,
|
|
128
|
+
@to_graph.fetch(to, EMPTY_SET)
|
|
125
129
|
end
|
|
126
130
|
|
|
127
131
|
# Returns the predecessors of the given vertex, i.e. the vertices x for
|
data/lib/nanoc/core/filter.rb
CHANGED
|
@@ -249,11 +249,6 @@ module Nanoc
|
|
|
249
249
|
end
|
|
250
250
|
end
|
|
251
251
|
|
|
252
|
-
# @api private
|
|
253
|
-
def on_main_fiber(&block)
|
|
254
|
-
Fiber.yield(block)
|
|
255
|
-
end
|
|
256
|
-
|
|
257
252
|
contract C::ArrayOf[C::Named['Nanoc::Core::BasicItemView']] => C::Any
|
|
258
253
|
# Creates a dependency from the item that is currently being filtered onto
|
|
259
254
|
# the given collection of items. In other words, require the given items
|
|
@@ -10,46 +10,9 @@ module Nanoc
|
|
|
10
10
|
# table of subscribers is not stored in the observable object itself, but in
|
|
11
11
|
# the notification center.
|
|
12
12
|
class NotificationCenter
|
|
13
|
-
DONE = Object.new
|
|
14
|
-
SYNC = Object.new
|
|
15
|
-
|
|
16
13
|
def initialize
|
|
17
|
-
@thread = nil
|
|
18
|
-
|
|
19
14
|
# name => observers dictionary
|
|
20
15
|
@notifications = Hash.new { |hash, name| hash[name] = [] }
|
|
21
|
-
|
|
22
|
-
@queue = Queue.new
|
|
23
|
-
|
|
24
|
-
@sync_queue = Queue.new
|
|
25
|
-
on(SYNC, self) { @sync_queue << true }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def start
|
|
29
|
-
@thread ||= Thread.new do # rubocop:disable Naming/MemoizedInstanceVariableName
|
|
30
|
-
Thread.current.abort_on_exception = true
|
|
31
|
-
|
|
32
|
-
loop do
|
|
33
|
-
elem = @queue.pop
|
|
34
|
-
break if DONE.equal?(elem)
|
|
35
|
-
|
|
36
|
-
name = elem[0]
|
|
37
|
-
args = elem[1]
|
|
38
|
-
|
|
39
|
-
@notifications[name].each do |observer|
|
|
40
|
-
observer[:block].call(*args)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def stop
|
|
47
|
-
@queue << DONE
|
|
48
|
-
@thread.join
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def force_stop
|
|
52
|
-
@queue << DONE
|
|
53
16
|
end
|
|
54
17
|
|
|
55
18
|
def on(name, id = nil, &block)
|
|
@@ -61,18 +24,16 @@ module Nanoc
|
|
|
61
24
|
end
|
|
62
25
|
|
|
63
26
|
def post(name, *args)
|
|
64
|
-
@
|
|
65
|
-
|
|
66
|
-
|
|
27
|
+
@notifications[name].each do |observer|
|
|
28
|
+
observer[:block].call(*args)
|
|
29
|
+
end
|
|
67
30
|
|
|
68
|
-
|
|
69
|
-
post(SYNC)
|
|
70
|
-
@sync_queue.pop
|
|
31
|
+
self
|
|
71
32
|
end
|
|
72
33
|
|
|
73
34
|
class << self
|
|
74
35
|
def instance
|
|
75
|
-
@_instance ||= new
|
|
36
|
+
@_instance ||= new
|
|
76
37
|
end
|
|
77
38
|
|
|
78
39
|
def on(name, id = nil, &)
|
|
@@ -88,18 +49,8 @@ module Nanoc
|
|
|
88
49
|
end
|
|
89
50
|
|
|
90
51
|
def reset
|
|
91
|
-
instance.stop
|
|
92
52
|
@_instance = nil
|
|
93
53
|
end
|
|
94
|
-
|
|
95
|
-
def force_reset
|
|
96
|
-
instance.force_stop
|
|
97
|
-
@_instance = nil
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def sync
|
|
101
|
-
instance.sync
|
|
102
|
-
end
|
|
103
54
|
end
|
|
104
55
|
end
|
|
105
56
|
end
|
data/lib/nanoc/core/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nanoc-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.14.
|
|
4
|
+
version: 4.14.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denis Defreyne
|
|
@@ -185,7 +185,6 @@ files:
|
|
|
185
185
|
- lib/nanoc/core/compilation_phases/mark_done.rb
|
|
186
186
|
- lib/nanoc/core/compilation_phases/notify.rb
|
|
187
187
|
- lib/nanoc/core/compilation_phases/recalculate.rb
|
|
188
|
-
- lib/nanoc/core/compilation_phases/resume.rb
|
|
189
188
|
- lib/nanoc/core/compilation_phases/write.rb
|
|
190
189
|
- lib/nanoc/core/compilation_stage.rb
|
|
191
190
|
- lib/nanoc/core/compilation_stages/build_reps.rb
|
|
@@ -304,7 +303,7 @@ licenses:
|
|
|
304
303
|
- MIT
|
|
305
304
|
metadata:
|
|
306
305
|
rubygems_mfa_required: 'true'
|
|
307
|
-
source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-core-v4.14.
|
|
306
|
+
source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-core-v4.14.1/nanoc-core
|
|
308
307
|
rdoc_options: []
|
|
309
308
|
require_paths:
|
|
310
309
|
- lib
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Nanoc
|
|
4
|
-
module Core
|
|
5
|
-
module CompilationPhases
|
|
6
|
-
# Provides functionality for suspending and resuming item rep compilation (using fibers).
|
|
7
|
-
class Resume < Abstract
|
|
8
|
-
include Nanoc::Core::ContractsSupport
|
|
9
|
-
|
|
10
|
-
DONE = Object.new
|
|
11
|
-
|
|
12
|
-
contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
|
13
|
-
def run(rep, is_outdated:, &)
|
|
14
|
-
fiber = fiber_for(rep, is_outdated:, &)
|
|
15
|
-
while fiber.alive?
|
|
16
|
-
res = fiber.resume
|
|
17
|
-
|
|
18
|
-
case res
|
|
19
|
-
when Nanoc::Core::Errors::UnmetDependency
|
|
20
|
-
Nanoc::Core::NotificationCenter.post(:compilation_suspended, rep, res.rep, res.snapshot_name)
|
|
21
|
-
raise(res)
|
|
22
|
-
when Proc
|
|
23
|
-
fiber.resume(res.call)
|
|
24
|
-
when DONE
|
|
25
|
-
# ignore
|
|
26
|
-
else
|
|
27
|
-
raise Nanoc::Core::Errors::InternalInconsistency.new(
|
|
28
|
-
"Fiber yielded object of unexpected type #{res.class}",
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => Fiber
|
|
37
|
-
def fiber_for(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
|
|
38
|
-
@fibers ||= {}
|
|
39
|
-
|
|
40
|
-
@fibers[rep] ||=
|
|
41
|
-
Fiber.new do
|
|
42
|
-
yield
|
|
43
|
-
@fibers.delete(rep)
|
|
44
|
-
DONE
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
@fibers[rep]
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|