Sha256: 9284238c269bbabea3b340e6a3a3cdf641f78241da1a22dd7dad21c8b61d9ffd
Contents?: true
Size: 905 Bytes
Versions: 28
Compression:
Stored size: 905 Bytes
Contents
module Nanoc::Int # Yields item reps to compile. # # @api private class ItemRepSelector def initialize(reps) @reps = reps end def each graph = Nanoc::Int::DirectedGraph.new(@reps) loop do break if graph.roots.empty? rep = graph.roots.each { |e| break e } begin yield(rep) graph.delete_vertex(rep) rescue Nanoc::Int::Errors::UnmetDependency => e handle_dependency_error(e, rep, graph) end end # Check whether everything was compiled unless graph.vertices.empty? raise Nanoc::Int::Errors::RecursiveCompilation.new(graph.vertices) end end def handle_dependency_error(e, rep, graph) other_rep = e.rep graph.add_edge(other_rep, rep) unless graph.vertices.include?(other_rep) graph.add_vertex(other_rep) end end end end
Version data entries
28 entries across 28 versions & 1 rubygems