lib/nanoc/base/compilation/compiler.rb in nanoc-4.0.0b3 vs lib/nanoc/base/compilation/compiler.rb in nanoc-4.0.0b4
- old
+ new
@@ -89,11 +89,11 @@
store
ensure
Nanoc::Int::TempFilenameFactory.instance.cleanup(
Nanoc::Filter::TMP_BINARY_ITEMS_DIR)
Nanoc::Int::TempFilenameFactory.instance.cleanup(
- Nanoc::Int::ItemRep::TMP_TEXT_ITEMS_DIR)
+ Nanoc::Int::ItemRepWriter::TMP_TEXT_ITEMS_DIR)
end
# @group Private instance methods
# @return [Nanoc::Int::RulesCollection] The collection of rules to be used
@@ -161,11 +161,11 @@
rule_memory_store[obj] = rule_memory_calculator[obj]
end
# Calculate checksums
objects.each do |obj|
- checksum_store[obj] = obj.__nanoc_checksum
+ checksum_store[obj] = Nanoc::Int::Checksummer.calc(obj)
end
# Store
stores.each(&:store)
end
@@ -226,11 +226,11 @@
rules = rules_collection.routing_rules_for(rep)
raise Nanoc::Int::Errors::NoMatchingRoutingRuleFound.new(rep) if rules[:last].nil?
rules.each_pair do |snapshot, rule|
# Get basic path by applying matching rule
- basic_path = rule.apply_to(rep, compiler: self)
+ basic_path = rule.apply_to(rep, executor: nil, compiler: self)
next if basic_path.nil?
if basic_path !~ %r{^/}
raise "The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash."
end
@@ -258,13 +258,13 @@
# operation
#
# @api private
def assigns_for(rep)
if rep.binary?
- content_or_filename_assigns = { filename: rep.temporary_filenames[:last] }
+ content_or_filename_assigns = { filename: rep.content_snapshots[:last].filename }
else
- content_or_filename_assigns = { content: rep.content[:last] }
+ content_or_filename_assigns = { content: rep.content_snapshots[:last].string }
end
# TODO: Do not expose @site (necessary for captures store though…)
content_or_filename_assigns.merge({
item: Nanoc::ItemView.new(rep.item),
@@ -359,31 +359,33 @@
#
# @param [Nanoc::Int::ItemRep] rep The rep that is to be compiled
#
# @return [void]
def compile_rep(rep)
+ executor = Nanoc::Int::Executor.new(self)
+
Nanoc::Int::NotificationCenter.post(:compilation_started, rep)
Nanoc::Int::NotificationCenter.post(:processing_started, rep)
Nanoc::Int::NotificationCenter.post(:visit_started, rep.item)
# Calculate rule memory if we haven’t yet done do
rules_collection.new_rule_memory_for_rep(rep)
if !rep.item.forced_outdated? && !outdatedness_checker.outdated?(rep) && compiled_content_cache[rep]
# Reuse content
Nanoc::Int::NotificationCenter.post(:cached_content_used, rep)
- rep.content = compiled_content_cache[rep]
+ rep.content_snapshots = compiled_content_cache[rep]
else
# Recalculate content
- rep.snapshot(:raw)
- rep.snapshot(:pre, final: false)
- rules_collection.compilation_rule_for(rep).apply_to(rep, compiler: self)
- rep.snapshot(:post) if rep.has_snapshot?(:post)
- rep.snapshot(:last)
+ executor.snapshot(rep, :raw)
+ executor.snapshot(rep, :pre, final: false)
+ rules_collection.compilation_rule_for(rep).apply_to(rep, executor: executor, compiler: self)
+ executor.snapshot(rep, :post) if rep.has_snapshot?(:post)
+ executor.snapshot(rep, :last)
end
rep.compiled = true
- compiled_content_cache[rep] = rep.content
+ compiled_content_cache[rep] = rep.content_snapshots
Nanoc::Int::NotificationCenter.post(:processing_ended, rep)
Nanoc::Int::NotificationCenter.post(:compilation_ended, rep)
rescue => e
rep.forget_progress