lib/nanoc/base/result_data/item_rep.rb in nanoc-3.7.4 vs lib/nanoc/base/result_data/item_rep.rb in nanoc-3.7.5

- old
+ new

@@ -1,18 +1,15 @@ # encoding: utf-8 module Nanoc - # A single representation (rep) of an item ({Nanoc::Item}). An item can # have multiple representations. A representation has its own output file. # A single item can therefore have multiple output files, each run through # a different set of filters with a different layout. class ItemRep - # Contains all deprecated methods. Mixed into {Nanoc::ItemRep}. module Deprecated - # @deprecated Modify the {#raw_paths} attribute instead def raw_path=(raw_path) raw_paths[:last] = raw_path end @@ -21,11 +18,11 @@ paths[:last] = path end # @deprecated Use {Nanoc::ItemRep#compiled_content} instead. def content_at_snapshot(snapshot = :pre) - compiled_content(:snapshot => snapshot) + compiled_content(snapshot: snapshot) end # @deprecated def created raise NotImplementedError, 'Nanoc::ItemRep#created is no longer implemented' @@ -53,16 +50,14 @@ # @deprecated def written? raise NotImplementedError, 'Nanoc::ItemRep#written? is no longer implemented' end - end # Contains all private methods. Mixed into {Nanoc::ItemRep}. module Private - # @return [Hash] A hash containing the assigns that will be used in the # next filter or layout operation. The keys (symbols) will be made # available during the next operation. attr_accessor :assigns @@ -118,11 +113,11 @@ # @param [Symbol, nil] snapshot The name of the snapshot to write. # # @return [void] def write(snapshot = :last) # Get raw path - raw_path = self.raw_path(:snapshot => snapshot) + raw_path = self.raw_path(snapshot: snapshot) return if raw_path.nil? # Create parent directory FileUtils.mkdir_p(File.dirname(raw_path)) @@ -173,11 +168,10 @@ # # @return [Symbol] :item_rep def type :item_rep end - end include Deprecated include Private @@ -350,11 +344,11 @@ if self.binary? && !File.file?(filter.output_filename) raise "The #{filter_name.inspect} filter did not write anything to the required output file, #{filter.output_filename}." end # Create snapshot - snapshot(@content[:post] ? :post : :pre, :final => false) unless self.binary? + snapshot(@content[:post] ? :post : :pre, final: false) unless self.binary? ensure # Notify end Nanoc::NotificationCenter.post(:filtering_ended, self, filter_name) end end @@ -381,17 +375,17 @@ # Check whether item can be laid out raise Nanoc::Errors::CannotLayoutBinaryItem.new(self) if self.binary? # Create "pre" snapshot if @content[:post].nil? - snapshot(:pre, :final => true) + snapshot(:pre, final: true) end # Create filter klass = filter_named(filter_name) raise Nanoc::Errors::UnknownFilter.new(filter_name) if klass.nil? - filter = klass.new(assigns.merge({ :layout => layout })) + filter = klass.new(assigns.merge({ layout: layout })) # Visit Nanoc::NotificationCenter.post(:visit_started, layout) Nanoc::NotificationCenter.post(:visit_ended, layout) @@ -402,11 +396,11 @@ # Layout @content[:last] = filter.setup_and_run(layout.raw_content, filter_args) # Create "post" snapshot - snapshot(:post, :final => false) + snapshot(:post, final: false) ensure # Notify end Nanoc::NotificationCenter.post(:filtering_ended, self, filter_name) Nanoc::NotificationCenter.post(:processing_ended, layout) end @@ -468,21 +462,19 @@ private def initialize_content # Initialize content and filenames if self.binary? - @temporary_filenames = { :last => @item.raw_filename } + @temporary_filenames = { last: @item.raw_filename } @content = {} else - @content = { :last => @item.raw_content } + @content = { last: @item.raw_content } @content[:last].freeze @temporary_filenames = {} end end def filter_named(name) Nanoc::Filter.named(name) end - end - end