Class: Nanoc::Core::PostCompileItemRepView

Inherits:
BasicItemRepView show all
Defined in:
lib/nanoc/core/post_compile_item_rep_view.rb

Instance Method Summary collapse

Methods inherited from BasicItemRepView

#==, #_unwrap, #binary?, #eql?, #hash, #initialize, #inspect, #item, #name, #path, #snapshot?

Methods inherited from View

#_context, #_unwrap, #frozen?, #initialize, #inspect

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

This class inherits a constructor from Nanoc::Core::BasicItemRepView

Instance Method Details

#compiled_content(snapshot: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nanoc/core/post_compile_item_rep_view.rb', line 10

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::Core::Errors::NoSuchSnapshot.new(_unwrap, snapshot_name)
  end

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

  content.string
end

#item_view_classObject



6
7
8
# File 'lib/nanoc/core/post_compile_item_rep_view.rb', line 6

def item_view_class
  Nanoc::Core::PostCompileItemView
end

#raw_path(snapshot: :last) ⇒ Object



28
29
30
# File 'lib/nanoc/core/post_compile_item_rep_view.rb', line 28

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