nanoc 4.4.6 → 4.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +11 -13
- data/LICENSE +1 -1
- data/NEWS.md +11 -0
- data/README.md +1 -1
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base/repos.rb +1 -0
- data/lib/nanoc/base/repos/outdatedness_store.rb +49 -0
- data/lib/nanoc/base/services/compiler.rb +286 -152
- data/lib/nanoc/base/services/compiler_loader.rb +4 -0
- data/lib/nanoc/base/services/outdatedness_checker.rb +2 -6
- data/lib/nanoc/checking/checks/external_links.rb +0 -2
- data/lib/nanoc/data_sources/filesystem.rb +13 -4
- data/lib/nanoc/version.rb +1 -1
- data/spec/nanoc/base/compiler_spec.rb +54 -14
- data/spec/nanoc/base/repos/outdatedness_store_spec.rb +100 -0
- data/spec/nanoc/base/services/outdatedness_checker_spec.rb +15 -6
- data/spec/nanoc/base/services/outdatedness_rules_spec.rb +12 -4
- data/spec/nanoc/cli/commands/view_spec.rb +2 -0
- data/spec/nanoc/data_sources/filesystem_spec.rb +13 -1
- data/spec/nanoc/extra/parallel_collection_spec.rb +2 -2
- data/spec/nanoc/integration/outdatedness_integration_spec.rb +8 -0
- data/spec/nanoc/integration/partial_recompilation_spec.rb +48 -0
- data/spec/nanoc/regressions/gh_1045_spec.rb +48 -0
- data/spec/nanoc/regressions/gh_1047_spec.rb +28 -0
- data/test/base/test_compiler.rb +1 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz: '
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0167178257988b6aaf09493db7ca9913b18d2961'
|
4
|
+
data.tar.gz: ff4d70d12e3e147010857f60f216d102f17e5ba3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 561f6907b5ae8fe75ac79038a9ca563846c6015b83c78bce7e20f2fdbdcd63f9d9df8d0d052f3810b49be3fa388fa56ec47a52c285ba86312bc5fb8506e64a67
|
7
|
+
data.tar.gz: d28b4eb99ca9dba7e154018201a19f3cef48d6aa0af69e671324e9b5548c675eade4549a9b9d81ef7257c958e3f79a5b6a5986bfbfdf3e8f09ac15aa6cfbccee
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/bbatsov/rubocop.git
|
3
|
-
revision:
|
3
|
+
revision: 7c95534e1906539e53341cd53265fadfc0aba0e2
|
4
4
|
specs:
|
5
5
|
rubocop (0.46.0)
|
6
6
|
parser (>= 2.3.3.1, < 3.0)
|
@@ -11,23 +11,23 @@ GIT
|
|
11
11
|
|
12
12
|
GIT
|
13
13
|
remote: git://github.com/cowboyd/therubyracer.git
|
14
|
-
revision:
|
14
|
+
revision: a635aee79b2057c396f8af92417cadf93415c275
|
15
15
|
specs:
|
16
|
-
therubyracer (0.12.
|
16
|
+
therubyracer (0.12.3)
|
17
17
|
libv8 (~> 3.16.14.15)
|
18
18
|
ref
|
19
19
|
|
20
20
|
GIT
|
21
21
|
remote: git://github.com/tmm1/pygments.rb.git
|
22
|
-
revision:
|
22
|
+
revision: cf50cbeda48e8a242ef9cba9467e092935730f66
|
23
23
|
specs:
|
24
|
-
pygments.rb (1.1.
|
24
|
+
pygments.rb (1.1.1)
|
25
25
|
multi_json (>= 1.0.0)
|
26
26
|
|
27
27
|
PATH
|
28
28
|
remote: .
|
29
29
|
specs:
|
30
|
-
nanoc (4.4.
|
30
|
+
nanoc (4.4.7)
|
31
31
|
cri (~> 2.3)
|
32
32
|
hamster (~> 3.0)
|
33
33
|
ref (~> 2.0)
|
@@ -204,7 +204,7 @@ GEM
|
|
204
204
|
fog-voxel (0.1.0)
|
205
205
|
fog-core
|
206
206
|
fog-xml
|
207
|
-
fog-vsphere (1.
|
207
|
+
fog-vsphere (1.6.0)
|
208
208
|
fog-core
|
209
209
|
rbvmomi (~> 1.9)
|
210
210
|
fog-xenserver (0.2.3)
|
@@ -268,13 +268,12 @@ GEM
|
|
268
268
|
multi_json (1.12.1)
|
269
269
|
mustache (1.0.3)
|
270
270
|
nenv (0.3.0)
|
271
|
-
nokogiri (1.7.0)
|
271
|
+
nokogiri (1.7.0.1)
|
272
272
|
mini_portile2 (~> 2.1.0)
|
273
273
|
notiffany (0.1.1)
|
274
274
|
nenv (~> 0.1)
|
275
275
|
shellany (~> 0.0)
|
276
276
|
pandoc-ruby (2.0.1)
|
277
|
-
parallel (1.10.0)
|
278
277
|
parser (2.3.3.1)
|
279
278
|
ast (~> 2.2)
|
280
279
|
powerpack (0.1.1)
|
@@ -282,9 +281,9 @@ GEM
|
|
282
281
|
coderay (~> 1.1.0)
|
283
282
|
method_source (~> 0.8.1)
|
284
283
|
slop (~> 3.4)
|
285
|
-
public_suffix (2.0.
|
284
|
+
public_suffix (2.0.5)
|
286
285
|
rack (2.0.1)
|
287
|
-
rainbow (2.2.
|
286
|
+
rainbow (2.2.1)
|
288
287
|
rainpress (1.0)
|
289
288
|
rake (12.0.0)
|
290
289
|
rb-fsevent (0.9.8)
|
@@ -348,7 +347,7 @@ GEM
|
|
348
347
|
w3c_validators (1.3.1)
|
349
348
|
json (~> 2.0)
|
350
349
|
nokogiri (~> 1.6)
|
351
|
-
webmock (2.3.
|
350
|
+
webmock (2.3.2)
|
352
351
|
addressable (>= 2.3.6)
|
353
352
|
crack (>= 0.3.2)
|
354
353
|
hashdiff
|
@@ -394,7 +393,6 @@ DEPENDENCIES
|
|
394
393
|
nanoc!
|
395
394
|
nokogiri (~> 1.6)
|
396
395
|
pandoc-ruby
|
397
|
-
parallel
|
398
396
|
pry
|
399
397
|
pygments.rb!
|
400
398
|
rack
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2007-
|
1
|
+
Copyright (c) 2007-2017 Denis Defreyne and contributors
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
data/NEWS.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Nanoc news
|
2
2
|
|
3
|
+
## 4.4.7 (2017-01-05)
|
4
|
+
|
5
|
+
Fixes:
|
6
|
+
|
7
|
+
* Fixed issue that caused an item not to be considered outdated when only the mtime has changed (#1046)
|
8
|
+
* Removed stray `require 'parallel'` which could break the `external_links` check (#1051) [Cédric Boutillier]
|
9
|
+
|
10
|
+
Enhancements:
|
11
|
+
|
12
|
+
* Made Nanoc not recompile compiled items after an exception occurs (#1044)
|
13
|
+
|
3
14
|
## 4.4.6 (2016-12-28)
|
4
15
|
|
5
16
|
Fixes:
|
data/README.md
CHANGED
@@ -19,4 +19,4 @@ Contributions are greatly appreciated! Consult the [Development guidelines](http
|
|
19
19
|
|
20
20
|
Many thanks to everyone who has contributed to Nanoc in one way or another:
|
21
21
|
|
22
|
-
Ale Muñoz, Alexander Mankuta, Andy Drop, Arnau Siches, Ben Armston, Bil Bas, Brian Candler, Bruno Dufour, Chris Chapman, Chris Eppstein, Christian Plessl, Colin Barrett, Colin Seymour, Croath Liu, Damien Pollet, Dan Callahan, Daniel Hofstetter, Daniel Mendler, Daniel Wollschlaeger, David Alexander, David Everitt, Denis Defreyne, Dennis Sutch, Devon Luke Buchanan, Dmitry Bilunov, Eric Sunshine, Erik Hollensbe, Fabian Buch, Felix Hanley, Garen Torikian, Go Maeda, Grégory Karékinian, Gregory Pakosz, Guilherme Garnier, Jack Chu, Jake Benilov, Jasper Van der Jeugt, Jeff Forcier, Jim Mendenhall, John Nishinaga, Justin Clift, Justin Hileman, Kevin Lynagh, Lorin Werthen, Louis T., Lucas Vuotto, Mathias Bynens, Matt Keveney, Matthew Frazier, Matthias Beyer, Matthias Reitinger, Matthias Vallentin, Micha Rosenbaum, Michal Cichra, Michal Papis, Mike Pennisi, Nelson Chen, Nicky Peeters, Nikhil Marathe, Oliver Byford, Paul Boone, Peter Aronoff, Raphael von der Grün, Rémi Barraquand, Remko Tronçon, Riley Goodside, Ruben Verborgh, Scott Vokes, Šime Ramov, Simon South, Spencer Whitt, Stanley Rost, Starr Horne, Stefan Bühler, Stuart Montgomery, Takashi Uchibe, Toon Willems, Tuomas Kareinen, Ursula Kallio, Vincent Driessen, Vlatko Kosturjak, whitequark, Xavier Shay, Yannick Ihmels, Zaiste de Grengolada
|
22
|
+
Ale Muñoz, Alexander Mankuta, Andy Drop, Arnau Siches, Ben Armston, Bil Bas, Brian Candler, Bruno Dufour, Cédric Boutillier, Chris Chapman, Chris Eppstein, Christian Plessl, Colin Barrett, Colin Seymour, Croath Liu, Damien Pollet, Dan Callahan, Daniel Hofstetter, Daniel Mendler, Daniel Wollschlaeger, David Alexander, David Everitt, Denis Defreyne, Dennis Sutch, Devon Luke Buchanan, Dmitry Bilunov, Eric Sunshine, Erik Hollensbe, Fabian Buch, Felix Hanley, Garen Torikian, Go Maeda, Grégory Karékinian, Gregory Pakosz, Guilherme Garnier, Jack Chu, Jake Benilov, Jasper Van der Jeugt, Jeff Forcier, Jim Mendenhall, John Nishinaga, Justin Clift, Justin Hileman, Kevin Lynagh, Lorin Werthen, Louis T., Lucas Vuotto, Mathias Bynens, Matt Keveney, Matthew Frazier, Matthias Beyer, Matthias Reitinger, Matthias Vallentin, Micha Rosenbaum, Michal Cichra, Michal Papis, Mike Pennisi, Nelson Chen, Nicky Peeters, Nikhil Marathe, Oliver Byford, Paul Boone, Peter Aronoff, Raphael von der Grün, Rémi Barraquand, Remko Tronçon, Riley Goodside, Ruben Verborgh, Scott Vokes, Šime Ramov, Simon South, Spencer Whitt, Stanley Rost, Starr Horne, Stefan Bühler, Stuart Montgomery, Takashi Uchibe, Toon Willems, Tuomas Kareinen, Ursula Kallio, Vincent Driessen, Vlatko Kosturjak, whitequark, Xavier Shay, Yannick Ihmels, Zaiste de Grengolada
|
data/lib/nanoc.rb
CHANGED
@@ -7,7 +7,7 @@ module Nanoc
|
|
7
7
|
gem_info = defined?(Gem) ? "with RubyGems #{Gem::VERSION}" : 'without RubyGems'
|
8
8
|
engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
9
9
|
res = ''
|
10
|
-
res << "Nanoc #{Nanoc::VERSION} © 2007-
|
10
|
+
res << "Nanoc #{Nanoc::VERSION} © 2007-2017 Denis Defreyne.\n"
|
11
11
|
res << "Running #{engine} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) on #{RUBY_PLATFORM} #{gem_info}.\n"
|
12
12
|
res
|
13
13
|
end
|
data/lib/nanoc/base/repos.rb
CHANGED
@@ -6,5 +6,6 @@ require_relative 'repos/config_loader'
|
|
6
6
|
require_relative 'repos/data_source'
|
7
7
|
require_relative 'repos/dependency_store'
|
8
8
|
require_relative 'repos/item_rep_repo'
|
9
|
+
require_relative 'repos/outdatedness_store'
|
9
10
|
require_relative 'repos/rule_memory_store'
|
10
11
|
require_relative 'repos/site_loader'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Nanoc::Int
|
2
|
+
# @api private
|
3
|
+
class OutdatednessStore < ::Nanoc::Int::Store
|
4
|
+
include Nanoc::Int::ContractsSupport
|
5
|
+
|
6
|
+
contract C::KeywordArgs[site: C::Maybe[Nanoc::Int::Site], reps: Nanoc::Int::ItemRepRepo] => C::Any
|
7
|
+
def initialize(site: nil, reps:)
|
8
|
+
super(Nanoc::Int::Store.tmp_path_for(env_name: (site.config.env_name if site), store_name: 'outdatedness'), 1)
|
9
|
+
|
10
|
+
@outdated_reps = Set.new
|
11
|
+
@all_reps = reps
|
12
|
+
end
|
13
|
+
|
14
|
+
contract Nanoc::Int::ItemRep => C::Bool
|
15
|
+
def include?(obj)
|
16
|
+
@outdated_reps.include?(obj)
|
17
|
+
end
|
18
|
+
|
19
|
+
contract Nanoc::Int::ItemRep => self
|
20
|
+
def add(obj)
|
21
|
+
@outdated_reps << obj
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
contract Nanoc::Int::ItemRep => self
|
26
|
+
def remove(obj)
|
27
|
+
@outdated_reps.delete(obj)
|
28
|
+
self
|
29
|
+
end
|
30
|
+
|
31
|
+
contract C::None => C::ArrayOf[Nanoc::Int::ItemRep]
|
32
|
+
def to_a
|
33
|
+
@outdated_reps.to_a
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
def data
|
39
|
+
@outdated_reps.map(&:reference)
|
40
|
+
end
|
41
|
+
|
42
|
+
def data=(new_data)
|
43
|
+
outdated_refs = Set.new(new_data)
|
44
|
+
all_reps = Set.new(@all_reps)
|
45
|
+
|
46
|
+
@outdated_reps = Set.new(all_reps.select { |rep| outdated_refs.include?(rep.reference) })
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -73,128 +73,272 @@ module Nanoc::Int
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
#
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
# All phases for the compilation of a single item rep. Phases will be repeated for every rep.
|
77
|
+
module Phases
|
78
|
+
# Provides functionality for (re)calculating the content of an item rep, without caching or
|
79
|
+
# outdatedness checking.
|
80
|
+
class Recalculate
|
81
|
+
include Nanoc::Int::ContractsSupport
|
82
|
+
|
83
|
+
def initialize(action_provider:, dependency_store:, compilation_context:)
|
84
|
+
@action_provider = action_provider
|
85
|
+
@dependency_store = dependency_store
|
86
|
+
@compilation_context = compilation_context
|
87
|
+
end
|
80
88
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
89
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
90
|
+
def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
|
91
|
+
dependency_tracker = Nanoc::Int::DependencyTracker.new(@dependency_store)
|
92
|
+
dependency_tracker.enter(rep.item)
|
93
|
+
|
94
|
+
executor = Nanoc::Int::Executor.new(rep, @compilation_context, dependency_tracker)
|
95
|
+
|
96
|
+
@action_provider.memory_for(rep).each do |action|
|
97
|
+
case action
|
98
|
+
when Nanoc::Int::ProcessingActions::Filter
|
99
|
+
executor.filter(action.filter_name, action.params)
|
100
|
+
when Nanoc::Int::ProcessingActions::Layout
|
101
|
+
executor.layout(action.layout_identifier, action.params)
|
102
|
+
when Nanoc::Int::ProcessingActions::Snapshot
|
103
|
+
executor.snapshot(action.snapshot_name)
|
104
|
+
else
|
105
|
+
raise Nanoc::Int::Errors::InternalInconsistency, "unknown action #{action.inspect}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
ensure
|
109
|
+
dependency_tracker.exit
|
110
|
+
end
|
85
111
|
end
|
86
112
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
113
|
+
# Provides functionality for (re)calculating the content of an item rep, with caching or
|
114
|
+
# outdatedness checking. Delegates to s::Recalculate if outdated or no cache available.
|
115
|
+
class Cache
|
116
|
+
include Nanoc::Int::ContractsSupport
|
117
|
+
|
118
|
+
def initialize(compiled_content_cache:, wrapped:)
|
119
|
+
@compiled_content_cache = compiled_content_cache
|
120
|
+
@wrapped = wrapped
|
121
|
+
end
|
122
|
+
|
123
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
124
|
+
def run(rep, is_outdated:)
|
125
|
+
if can_reuse_content_for_rep?(rep, is_outdated: is_outdated)
|
126
|
+
Nanoc::Int::NotificationCenter.post(:cached_content_used, rep)
|
127
|
+
rep.snapshot_contents = @compiled_content_cache[rep]
|
102
128
|
else
|
103
|
-
|
129
|
+
@wrapped.run(rep, is_outdated: is_outdated)
|
104
130
|
end
|
131
|
+
|
132
|
+
rep.compiled = true
|
133
|
+
@compiled_content_cache[rep] = rep.snapshot_contents
|
134
|
+
end
|
135
|
+
|
136
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Bool
|
137
|
+
def can_reuse_content_for_rep?(rep, is_outdated:)
|
138
|
+
!is_outdated && !@compiled_content_cache[rep].nil?
|
105
139
|
end
|
106
|
-
ensure
|
107
|
-
dependency_tracker.exit
|
108
140
|
end
|
109
|
-
end
|
110
141
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
include Nanoc::Int::ContractsSupport
|
142
|
+
# Provides functionality for suspending and resuming item rep compilation (using fibers).
|
143
|
+
class Resume
|
144
|
+
include Nanoc::Int::ContractsSupport
|
115
145
|
|
116
|
-
|
117
|
-
|
118
|
-
|
146
|
+
def initialize(wrapped:)
|
147
|
+
@wrapped = wrapped
|
148
|
+
end
|
149
|
+
|
150
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
151
|
+
def run(rep, is_outdated:)
|
152
|
+
fiber = fiber_for(rep, is_outdated: is_outdated)
|
153
|
+
while fiber.alive?
|
154
|
+
Nanoc::Int::NotificationCenter.post(:compilation_started, rep)
|
155
|
+
res = fiber.resume
|
156
|
+
|
157
|
+
case res
|
158
|
+
when Nanoc::Int::Errors::UnmetDependency
|
159
|
+
Nanoc::Int::NotificationCenter.post(:compilation_suspended, rep, res)
|
160
|
+
raise(res)
|
161
|
+
when Proc
|
162
|
+
fiber.resume(res.call)
|
163
|
+
else
|
164
|
+
# TODO: raise
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
Nanoc::Int::NotificationCenter.post(:compilation_ended, rep)
|
169
|
+
end
|
170
|
+
|
171
|
+
private
|
172
|
+
|
173
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => Fiber
|
174
|
+
def fiber_for(rep, is_outdated:)
|
175
|
+
@fibers ||= {}
|
176
|
+
|
177
|
+
@fibers[rep] ||=
|
178
|
+
Fiber.new do
|
179
|
+
@wrapped.run(rep, is_outdated: is_outdated)
|
180
|
+
@fibers.delete(rep)
|
181
|
+
end
|
182
|
+
|
183
|
+
@fibers[rep]
|
184
|
+
end
|
119
185
|
end
|
120
186
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
else
|
127
|
-
@wrapped.run(rep, is_outdated: is_outdated)
|
187
|
+
class Write
|
188
|
+
include Nanoc::Int::ContractsSupport
|
189
|
+
|
190
|
+
def initialize(wrapped:)
|
191
|
+
@wrapped = wrapped
|
128
192
|
end
|
129
193
|
|
130
|
-
|
131
|
-
|
194
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
195
|
+
def run(rep, is_outdated:)
|
196
|
+
@wrapped.run(rep, is_outdated: is_outdated)
|
197
|
+
|
198
|
+
rep.snapshot_defs.each do |sdef|
|
199
|
+
ItemRepWriter.new.write(rep, sdef.name)
|
200
|
+
end
|
201
|
+
end
|
132
202
|
end
|
133
203
|
|
134
|
-
|
135
|
-
|
136
|
-
|
204
|
+
class MarkDone
|
205
|
+
include Nanoc::Int::ContractsSupport
|
206
|
+
|
207
|
+
def initialize(wrapped:, outdatedness_store:)
|
208
|
+
@wrapped = wrapped
|
209
|
+
@outdatedness_store = outdatedness_store
|
210
|
+
end
|
211
|
+
|
212
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
213
|
+
def run(rep, is_outdated:)
|
214
|
+
@wrapped.run(rep, is_outdated: is_outdated)
|
215
|
+
@outdatedness_store.remove(rep)
|
216
|
+
end
|
137
217
|
end
|
138
218
|
end
|
139
219
|
|
140
|
-
|
141
|
-
|
142
|
-
|
220
|
+
module Stages
|
221
|
+
class Preprocess
|
222
|
+
def initialize(action_provider:, site:, dependency_store:, checksum_store:)
|
223
|
+
@action_provider = action_provider
|
224
|
+
@site = site
|
225
|
+
@dependency_store = dependency_store
|
226
|
+
@checksum_store = checksum_store
|
227
|
+
end
|
228
|
+
|
229
|
+
def run
|
230
|
+
@action_provider.preprocess(@site)
|
143
231
|
|
144
|
-
|
145
|
-
|
232
|
+
@dependency_store.objects = @site.items.to_a + @site.layouts.to_a
|
233
|
+
@checksum_store.objects = @site.items.to_a + @site.layouts.to_a + @site.code_snippets + [@site.config]
|
234
|
+
|
235
|
+
@site.freeze
|
236
|
+
end
|
146
237
|
end
|
147
238
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
Nanoc::Int::NotificationCenter.post(:compilation_suspended, rep, res)
|
158
|
-
raise(res)
|
159
|
-
when Proc
|
160
|
-
fiber.resume(res.call)
|
161
|
-
else
|
162
|
-
# TODO: raise
|
239
|
+
class Prune
|
240
|
+
def initialize(config:, reps:)
|
241
|
+
@config = config
|
242
|
+
@reps = reps
|
243
|
+
end
|
244
|
+
|
245
|
+
def run
|
246
|
+
if @config[:prune][:auto_prune]
|
247
|
+
Nanoc::Pruner.new(@config, @reps, exclude: prune_config_exclude).run
|
163
248
|
end
|
164
249
|
end
|
165
250
|
|
166
|
-
|
167
|
-
end
|
251
|
+
private
|
168
252
|
|
169
|
-
|
253
|
+
def prune_config
|
254
|
+
@config[:prune] || {}
|
255
|
+
end
|
170
256
|
|
171
|
-
|
172
|
-
|
173
|
-
|
257
|
+
def prune_config_exclude
|
258
|
+
prune_config[:exclude] || {}
|
259
|
+
end
|
260
|
+
end
|
174
261
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
262
|
+
class DetermineOutdatedness
|
263
|
+
def initialize(reps:, outdatedness_checker:, outdatedness_store:)
|
264
|
+
@reps = reps
|
265
|
+
@outdatedness_checker = outdatedness_checker
|
266
|
+
@outdatedness_store = outdatedness_store
|
267
|
+
end
|
268
|
+
|
269
|
+
def run
|
270
|
+
outdated_reps_tmp = @reps.select do |r|
|
271
|
+
@outdatedness_store.include?(r) || @outdatedness_checker.outdated?(r)
|
179
272
|
end
|
180
273
|
|
181
|
-
|
182
|
-
|
183
|
-
end
|
274
|
+
outdated_items = outdated_reps_tmp.map(&:item).uniq
|
275
|
+
outdated_reps = Set.new(outdated_items.flat_map { |i| @reps[i] })
|
184
276
|
|
185
|
-
|
186
|
-
include Nanoc::Int::ContractsSupport
|
277
|
+
outdated_reps.each { |r| @outdatedness_store.add(r) }
|
187
278
|
|
188
|
-
|
189
|
-
|
279
|
+
yield(outdated_items)
|
280
|
+
end
|
190
281
|
end
|
191
282
|
|
192
|
-
|
193
|
-
|
194
|
-
|
283
|
+
class CompileReps
|
284
|
+
def initialize(outdatedness_store:, dependency_store:, action_provider:, compilation_context:, compiled_content_cache:)
|
285
|
+
@outdatedness_store = outdatedness_store
|
286
|
+
@dependency_store = dependency_store
|
287
|
+
@action_provider = action_provider
|
288
|
+
@compilation_context = compilation_context
|
289
|
+
@compiled_content_cache = compiled_content_cache
|
290
|
+
end
|
291
|
+
|
292
|
+
def run
|
293
|
+
selector = Nanoc::Int::ItemRepSelector.new(@outdatedness_store.to_a)
|
294
|
+
selector.each do |rep|
|
295
|
+
handle_errors_while(rep) { compile_rep(rep, is_outdated: @outdatedness_store.include?(rep)) }
|
296
|
+
end
|
297
|
+
ensure
|
298
|
+
@outdatedness_store.store
|
299
|
+
@compiled_content_cache.store
|
300
|
+
end
|
301
|
+
|
302
|
+
private
|
303
|
+
|
304
|
+
def handle_errors_while(item_rep)
|
305
|
+
yield
|
306
|
+
rescue => e
|
307
|
+
raise Nanoc::Int::Errors::CompilationError.new(e, item_rep)
|
308
|
+
end
|
309
|
+
|
310
|
+
def compile_rep(rep, is_outdated:)
|
311
|
+
item_rep_compiler.run(rep, is_outdated: is_outdated)
|
312
|
+
end
|
195
313
|
|
196
|
-
|
197
|
-
|
314
|
+
def item_rep_compiler
|
315
|
+
@_item_rep_compiler ||= begin
|
316
|
+
recalculate_phase = Phases::Recalculate.new(
|
317
|
+
action_provider: @action_provider,
|
318
|
+
dependency_store: @dependency_store,
|
319
|
+
compilation_context: @compilation_context,
|
320
|
+
)
|
321
|
+
|
322
|
+
cache_phase = Phases::Cache.new(
|
323
|
+
compiled_content_cache: @compiled_content_cache,
|
324
|
+
wrapped: recalculate_phase,
|
325
|
+
)
|
326
|
+
|
327
|
+
resume_phase = Phases::Resume.new(
|
328
|
+
wrapped: cache_phase,
|
329
|
+
)
|
330
|
+
|
331
|
+
write_phase = Phases::Write.new(
|
332
|
+
wrapped: resume_phase,
|
333
|
+
)
|
334
|
+
|
335
|
+
mark_done_phase = Phases::MarkDone.new(
|
336
|
+
wrapped: write_phase,
|
337
|
+
outdatedness_store: @outdatedness_store,
|
338
|
+
)
|
339
|
+
|
340
|
+
mark_done_phase
|
341
|
+
end
|
198
342
|
end
|
199
343
|
end
|
200
344
|
end
|
@@ -225,7 +369,10 @@ module Nanoc::Int
|
|
225
369
|
# @api private
|
226
370
|
attr_reader :reps
|
227
371
|
|
228
|
-
|
372
|
+
# @api private
|
373
|
+
attr_reader :outdatedness_store
|
374
|
+
|
375
|
+
def initialize(site, compiled_content_cache:, checksum_store:, rule_memory_store:, action_provider:, dependency_store:, outdatedness_checker:, reps:, outdatedness_store:)
|
229
376
|
@site = site
|
230
377
|
|
231
378
|
@compiled_content_cache = compiled_content_cache
|
@@ -235,22 +382,20 @@ module Nanoc::Int
|
|
235
382
|
@outdatedness_checker = outdatedness_checker
|
236
383
|
@reps = reps
|
237
384
|
@action_provider = action_provider
|
385
|
+
@outdatedness_store = outdatedness_store
|
238
386
|
end
|
239
387
|
|
240
388
|
def run_all
|
241
|
-
|
389
|
+
preprocess_stage.run
|
242
390
|
build_reps
|
243
|
-
|
244
|
-
run
|
245
|
-
@action_provider.postprocess(@site, @reps)
|
246
|
-
end
|
247
|
-
|
248
|
-
def run
|
391
|
+
prune_stage.run
|
249
392
|
load_stores
|
250
|
-
|
251
|
-
|
252
|
-
compile_reps
|
393
|
+
determine_outdatedness
|
394
|
+
forget_dependencies_if_needed
|
253
395
|
store
|
396
|
+
compile_reps
|
397
|
+
store_output_state
|
398
|
+
@action_provider.postprocess(@site, @reps)
|
254
399
|
ensure
|
255
400
|
Nanoc::Int::TempFilenameFactory.instance.cleanup(
|
256
401
|
Nanoc::Filter::TMP_BINARY_ITEMS_DIR,
|
@@ -261,17 +406,10 @@ module Nanoc::Int
|
|
261
406
|
end
|
262
407
|
|
263
408
|
def load_stores
|
264
|
-
# FIXME: icky hack to update the dependency/checksum store’s list of objects
|
265
|
-
# (does not include preprocessed objects otherwise)
|
266
|
-
dependency_store.objects = site.items.to_a + site.layouts.to_a
|
267
|
-
checksum_store.objects = site.items.to_a + site.layouts.to_a + site.code_snippets + [site.config]
|
268
|
-
|
269
409
|
stores.each(&:load)
|
270
410
|
end
|
271
411
|
|
272
|
-
#
|
273
|
-
#
|
274
|
-
# @return [void]
|
412
|
+
# TODO: rename to store_preprocessed_state
|
275
413
|
def store
|
276
414
|
# Calculate rule memory
|
277
415
|
(@reps.to_a + @site.layouts.to_a).each do |obj|
|
@@ -284,7 +422,12 @@ module Nanoc::Int
|
|
284
422
|
objects_to_checksum.each { |obj| checksum_store.add(obj) }
|
285
423
|
|
286
424
|
# Store
|
287
|
-
|
425
|
+
checksum_store.store
|
426
|
+
rule_memory_store.store
|
427
|
+
end
|
428
|
+
|
429
|
+
def store_output_state
|
430
|
+
@dependency_store.store
|
288
431
|
end
|
289
432
|
|
290
433
|
def build_reps
|
@@ -305,62 +448,52 @@ module Nanoc::Int
|
|
305
448
|
|
306
449
|
private
|
307
450
|
|
308
|
-
def
|
309
|
-
|
310
|
-
|
311
|
-
|
451
|
+
def preprocess_stage
|
452
|
+
@_preprocess_stage ||= Stages::Preprocess.new(
|
453
|
+
action_provider: action_provider,
|
454
|
+
site: site,
|
455
|
+
dependency_store: dependency_store,
|
456
|
+
checksum_store: checksum_store,
|
457
|
+
)
|
312
458
|
end
|
313
459
|
|
314
|
-
def
|
315
|
-
|
460
|
+
def prune_stage
|
461
|
+
@_prune_stage ||= Stages::Prune.new(
|
462
|
+
config: site.config,
|
463
|
+
reps: reps,
|
464
|
+
)
|
316
465
|
end
|
317
466
|
|
318
|
-
def
|
319
|
-
|
467
|
+
def determine_outdatedness_stage
|
468
|
+
@_determine_outdatedness_stage ||= Stages::DetermineOutdatedness.new(
|
469
|
+
reps: reps,
|
470
|
+
outdatedness_checker: outdatedness_checker,
|
471
|
+
outdatedness_store: outdatedness_store,
|
472
|
+
)
|
320
473
|
end
|
321
474
|
|
322
|
-
def
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
end
|
475
|
+
def compile_reps_stage
|
476
|
+
@_compile_reps_stage ||= Stages::CompileReps.new(
|
477
|
+
outdatedness_store: @outdatedness_store,
|
478
|
+
dependency_store: @dependency_store,
|
479
|
+
action_provider: action_provider,
|
480
|
+
compilation_context: compilation_context,
|
481
|
+
compiled_content_cache: compiled_content_cache,
|
482
|
+
)
|
331
483
|
end
|
332
484
|
|
333
|
-
def
|
334
|
-
|
335
|
-
|
336
|
-
|
485
|
+
def determine_outdatedness
|
486
|
+
determine_outdatedness_stage.run do |outdated_items|
|
487
|
+
@outdated_items = outdated_items
|
488
|
+
end
|
337
489
|
end
|
338
490
|
|
339
|
-
def
|
340
|
-
|
491
|
+
def forget_dependencies_if_needed
|
492
|
+
@outdated_items.each { |i| @dependency_store.forget_dependencies_for(i) }
|
341
493
|
end
|
342
494
|
|
343
|
-
def
|
344
|
-
|
345
|
-
recalculate_phase = RecalculatePhase.new(
|
346
|
-
action_provider: action_provider,
|
347
|
-
dependency_store: @dependency_store,
|
348
|
-
compilation_context: compilation_context,
|
349
|
-
)
|
350
|
-
|
351
|
-
cache_phase = CachePhase.new(
|
352
|
-
compiled_content_cache: compiled_content_cache,
|
353
|
-
wrapped: recalculate_phase,
|
354
|
-
)
|
355
|
-
|
356
|
-
resume_phase = ResumePhase.new(
|
357
|
-
wrapped: cache_phase,
|
358
|
-
)
|
359
|
-
|
360
|
-
WritePhase.new(
|
361
|
-
wrapped: resume_phase,
|
362
|
-
)
|
363
|
-
end
|
495
|
+
def compile_reps
|
496
|
+
compile_reps_stage.run
|
364
497
|
end
|
365
498
|
|
366
499
|
# Returns all stores that can load/store data that can be used for
|
@@ -371,6 +504,7 @@ module Nanoc::Int
|
|
371
504
|
compiled_content_cache,
|
372
505
|
@dependency_store,
|
373
506
|
rule_memory_store,
|
507
|
+
@outdatedness_store,
|
374
508
|
]
|
375
509
|
end
|
376
510
|
end
|