Class: Nanoc::Core::ItemRepSelector::MicroGraph
- Inherits:
-
Object
- Object
- Nanoc::Core::ItemRepSelector::MicroGraph
- Defined in:
- lib/nanoc/core/item_rep_selector.rb
Instance Method Summary collapse
-
#initialize(reps) ⇒ MicroGraph
constructor
A new instance of MicroGraph.
- #mark_failed(dep) ⇒ Object
- #mark_ok ⇒ Object
- #next ⇒ Object
Constructor Details
#initialize(reps) ⇒ MicroGraph
Returns a new instance of MicroGraph.
12 13 14 15 |
# File 'lib/nanoc/core/item_rep_selector.rb', line 12 def initialize(reps) @reps = Set.new(reps) @stack = [] end |
Instance Method Details
#mark_failed(dep) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/nanoc/core/item_rep_selector.rb', line 34 def mark_failed(dep) if @stack.include?(dep) raise Nanoc::Core::Errors::DependencyCycle.new(@stack + [dep]) end @reps.delete(dep) @stack.push(dep) end |
#mark_ok ⇒ Object
30 31 32 |
# File 'lib/nanoc/core/item_rep_selector.rb', line 30 def mark_ok @stack.pop end |
#next ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/nanoc/core/item_rep_selector.rb', line 17 def next if @stack.any? @stack.last elsif @reps.any? @reps.each { |rep| break rep }.tap do |rep| @reps.delete(rep) @stack.push(rep) end else nil end end |