Sha256: 25f5c1ada11a60afbc5e61c891e6ec89a927abcf11259acaf514564587d14856

Contents?: true

Size: 857 Bytes

Versions: 11

Compression:

Stored size: 857 Bytes

Contents

# frozen_string_literal: true

module Nanoc
  class PostCompileItemRepView < ::Nanoc::BasicItemRepView
    def item_view_class
      Nanoc::PostCompileItemView
    end

    def compiled_content(snapshot: nil)
      compilation_context = @context.compilation_context
      snapshot_contents = compilation_context.compiled_content_cache[_unwrap] || {}

      snapshot_name = snapshot || (snapshot_contents[:pre] ? :pre : :last)

      unless snapshot_contents[snapshot_name]
        raise Nanoc::Int::Errors::NoSuchSnapshot.new(_unwrap, snapshot_name)
      end

      content = snapshot_contents[snapshot_name]
      if content.binary?
        raise Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem.new(_unwrap)
      end

      content.string
    end

    def raw_path(snapshot: :last)
      @item_rep.raw_path(snapshot: snapshot)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
nanoc-4.11.12 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.11 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.10 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.9 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.8 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.7 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.6 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.5 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.4 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.3 lib/nanoc/base/views/post_compile_item_rep_view.rb
nanoc-4.11.2 lib/nanoc/base/views/post_compile_item_rep_view.rb