Sha256: 92bcc395469ffee9927456c20d00f74a4a9a6329d0c08989d2114b3e2e071062
Contents?: true
Size: 1.17 KB
Versions: 12
Compression:
Stored size: 1.17 KB
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 => e handle_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_error(e, rep, graph) actual_error = if e.is_a?(Nanoc::Int::Errors::CompilationError) e.unwrap else e end if actual_error.is_a?(Nanoc::Int::Errors::UnmetDependency) handle_dependency_error(actual_error, rep, graph) else raise(e) 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
12 entries across 12 versions & 1 rubygems