Class: Nanoc::Core::ItemRepSelector

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/core/item_rep_selector.rb

Overview

Yields item reps to compile.

Defined Under Namespace

Classes: MicroGraph

Instance Method Summary collapse

Constructor Details

#initialize(reps) ⇒ ItemRepSelector

Returns a new instance of ItemRepSelector.



7
8
9
# File 'lib/nanoc/core/item_rep_selector.rb', line 7

def initialize(reps)
  @reps = reps
end

Instance Method Details

#eachObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/nanoc/core/item_rep_selector.rb', line 44

def each
  mg = MicroGraph.new(@reps)

  loop do
    rep = mg.next
    break if rep.nil?

    begin
      yield(rep)
      mg.mark_ok
    rescue => e
      actual_error = e.is_a?(Nanoc::Core::Errors::CompilationError) ? e.unwrap : e

      if actual_error.is_a?(Nanoc::Core::Errors::UnmetDependency)
        mg.mark_failed(actual_error.rep)
      else
        raise(e)
      end
    end
  end
end