lib/nanoc/base/compilation/compiler.rb in nanoc-4.3.7 vs lib/nanoc/base/compilation/compiler.rb in nanoc-4.3.8
- old
+ new
@@ -181,11 +181,11 @@
private
def prune
if site.config[:prune][:auto_prune]
- Nanoc::Extra::Pruner.new(site, exclude: prune_config_exclude).run
+ Nanoc::Pruner.new(site.config, reps, exclude: prune_config_exclude).run
end
end
def prune_config
site.config[:prune] || {}
@@ -225,33 +225,47 @@
#
# @param [Nanoc::Int::ItemRep] rep The rep that is to be compiled
#
# @return [void]
def compile_rep(rep)
- dependency_tracker = Nanoc::Int::DependencyTracker.new(@dependency_store)
+ @fibers ||= {}
+ @fibers[rep] ||=
+ Fiber.new do
+ begin
+ dependency_tracker = Nanoc::Int::DependencyTracker.new(@dependency_store)
+ dependency_tracker.enter(rep.item)
- Nanoc::Int::NotificationCenter.post(:compilation_started, rep)
- Nanoc::Int::NotificationCenter.post(:processing_started, rep)
- dependency_tracker.enter(rep.item)
+ if can_reuse_content_for_rep?(rep)
+ Nanoc::Int::NotificationCenter.post(:cached_content_used, rep)
+ rep.snapshot_contents = compiled_content_cache[rep]
+ else
+ recalculate_content_for_rep(rep, dependency_tracker)
+ end
- if can_reuse_content_for_rep?(rep)
- Nanoc::Int::NotificationCenter.post(:cached_content_used, rep)
- rep.snapshot_contents = compiled_content_cache[rep]
- else
- recalculate_content_for_rep(rep, dependency_tracker)
- end
+ rep.compiled = true
+ compiled_content_cache[rep] = rep.snapshot_contents
- rep.compiled = true
- compiled_content_cache[rep] = rep.snapshot_contents
+ @fibers.delete(rep)
+ ensure
+ dependency_tracker.exit(rep.item)
+ end
+ end
- Nanoc::Int::NotificationCenter.post(:processing_ended, rep)
+ fiber = @fibers[rep]
+ while fiber.alive?
+ Nanoc::Int::NotificationCenter.post(:processing_started, rep)
+ Nanoc::Int::NotificationCenter.post(:compilation_started, rep)
+ res = fiber.resume
+
+ if res.is_a?(Nanoc::Int::Errors::UnmetDependency)
+ Nanoc::Int::NotificationCenter.post(:compilation_suspended, rep, res)
+ Nanoc::Int::NotificationCenter.post(:processing_ended, rep)
+ raise(res)
+ end
+ end
+
Nanoc::Int::NotificationCenter.post(:compilation_ended, rep)
- rescue => e
- rep.forget_progress
- Nanoc::Int::NotificationCenter.post(:compilation_failed, rep, e)
- raise e
- ensure
- dependency_tracker.exit(rep.item)
+ Nanoc::Int::NotificationCenter.post(:processing_ended, rep)
end
# @return [Boolean]
def can_reuse_content_for_rep?(rep)
!outdatedness_checker.outdated?(rep) && compiled_content_cache[rep]