Class: Nanoc::Core::ItemRepBuilder Private

Inherits:
Object
  • Object
show all
Includes:
ContractsSupport
Defined in:
lib/nanoc/core/item_rep_builder.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

#initialize(site, action_provider, reps) ⇒ ItemRepBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ItemRepBuilder.



12
13
14
15
16
# File 'lib/nanoc/core/item_rep_builder.rb', line 12

def initialize(site, action_provider, reps)
  @site = site
  @action_provider = action_provider
  @reps = reps
end

Instance Attribute Details

#repsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/nanoc/core/item_rep_builder.rb', line 9

def reps
  @reps
end

Class Method Details

.snapshot_defs_for(action_sequence) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nanoc/core/item_rep_builder.rb', line 35

def self.snapshot_defs_for(action_sequence)
  is_binary = action_sequence.item_rep.item.content.binary?
  snapshot_defs = []

  action_sequence.each do |action|
    case action
    when Nanoc::Core::ProcessingActions::Snapshot
      action.snapshot_names.each do |snapshot_name|
        snapshot_defs << Nanoc::Core::SnapshotDef.new(snapshot_name, binary: is_binary)
      end
    when Nanoc::Core::ProcessingActions::Filter
      is_binary = Nanoc::Core::Filter.named!(action.filter_name).to_binary?
    end
  end

  snapshot_defs
end

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nanoc/core/item_rep_builder.rb', line 18

def run
  @site.items.each do |item|
    @action_provider.rep_names_for(item).each do |rep_name|
      @reps << Nanoc::Core::ItemRep.new(item, rep_name)
    end
  end

  action_sequences = Nanoc::Core::ItemRepRouter.new(@reps, @action_provider, @site).run

  @reps.each do |rep|
    rep.snapshot_defs = self.class.snapshot_defs_for(action_sequences[rep])
  end

  action_sequences
end