lib/nanoc3/base/item_rep.rb in nanoc3-3.1.1 vs lib/nanoc3/base/item_rep.rb in nanoc3-3.1.2
- old
+ new
@@ -93,24 +93,11 @@
# Set binary
@binary = @item.binary?
# Initialize content and filenames
- if self.binary?
- @filenames = {
- :raw => @item.raw_filename,
- :last => @item.raw_filename
- }
- @content = {}
- else
- @content = {
- :raw => @item.raw_content,
- :last => @item.raw_content,
- :pre => @item.raw_content
- }
- @filenames = {}
- end
+ initialize_content
@old_content = nil
# Reset flags
@compiled = false
@modified = false
@@ -246,10 +233,19 @@
# @deprecated Use {Nanoc3::ItemRep#compiled_content} instead.
def content_at_snapshot(snapshot=:pre)
compiled_content(:snapshot => snapshot)
end
+ # Resets the compilation progress for this item representation. This is
+ # necessary when an unmet dependency is detected during compilation.
+ # This method should probably not be called directly.
+ #
+ # @return [void]
+ def forget_progress
+ initialize_content
+ end
+
# Runs the item content through the given filter with the given arguments.
# This method will replace the content of the `:last` snapshot with the
# filtered content of the last snapshot.
#
# This method is supposed to be called only in a compilation rule block
@@ -407,9 +403,27 @@
def inspect
"<#{self.class}:0x#{self.object_id.to_s(16)} name=#{self.name} binary=#{self.binary?} raw_path=#{self.raw_path} item.identifier=#{self.item.identifier}>"
end
private
+
+ def initialize_content
+ # Initialize content and filenames
+ if self.binary?
+ @filenames = {
+ :raw => @item.raw_filename,
+ :last => @item.raw_filename
+ }
+ @content = {}
+ else
+ @content = {
+ :raw => @item.raw_content,
+ :last => @item.raw_content,
+ :pre => @item.raw_content
+ }
+ @filenames = {}
+ end
+ end
def filter_named(name)
Nanoc3::Filter.named(name)
end