5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 17:26:21 +00:00
panel/app/models/site/deploy_dependencies.rb

31 lines
800 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rgl/adjacency'
class Site
module DeployDependencies
extend ActiveSupport::Concern
included do
# Genera un grafo dirigido de todos los métodos de publicación
#
# @return [RGL::DirectedAdjacencyGraph]
def deployment_graph
@deployment_graph ||= RGL::DirectedAdjacencyGraph.new.tap do |graph|
deploys.each do |deploy|
graph.add_vertex deploy
end
deploys.each do |deploy|
deploy.class::DEPENDENCIES.each do |dependency|
deploys.where(type: "Deploy#{dependency.to_s.classify}").each do |deploy_dependency|
graph.add_edge deploy_dependency, deploy
end
end
end
end
end
end
end
end