mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 16:31:41 +00:00
feat: usar un grafo dirigido para ordenar las dependencias #10464
This commit is contained in:
parent
4f8ea0d9a7
commit
db25750ab0
3 changed files with 38 additions and 0 deletions
1
Gemfile
1
Gemfile
|
@ -23,6 +23,7 @@ if ENV['RAILS_GROUPS']&.split(',')&.include? 'assets'
|
|||
end
|
||||
|
||||
gem 'nokogiri'
|
||||
gem 'rgl'
|
||||
|
||||
# Turbolinks makes navigating your web application faster. Read more:
|
||||
# https://github.com/turbolinks/turbolinks
|
||||
|
|
|
@ -353,6 +353,7 @@ GEM
|
|||
mini_portile2 (~> 2.6.1)
|
||||
racc (~> 1.4)
|
||||
orm_adapter (0.5.0)
|
||||
pairing_heap (3.0.0)
|
||||
parallel (1.21.0)
|
||||
parser (3.0.2.0)
|
||||
ast (~> 2.4.1)
|
||||
|
@ -443,6 +444,10 @@ GEM
|
|||
actionpack (>= 5.0)
|
||||
railties (>= 5.0)
|
||||
rexml (3.2.5)
|
||||
rgl (0.6.2)
|
||||
pairing_heap (>= 0.3.0)
|
||||
rexml (~> 3.2, >= 3.2.4)
|
||||
stream (~> 0.5.3)
|
||||
rouge (3.26.1)
|
||||
rubocop (1.23.0)
|
||||
parallel (~> 1.10)
|
||||
|
@ -510,6 +515,7 @@ GEM
|
|||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.4.2-x86_64-linux-musl)
|
||||
stackprof (0.2.17-x86_64-linux-musl)
|
||||
stream (0.5.5)
|
||||
sucker_punch (3.0.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
sutty-archives (2.5.4)
|
||||
|
@ -626,6 +632,7 @@ DEPENDENCIES
|
|||
rails_warden
|
||||
redis
|
||||
redis-rails
|
||||
rgl
|
||||
rollups!
|
||||
rubocop-rails
|
||||
rubyzip
|
||||
|
|
30
app/models/site/deploy_dependencies.rb
Normal file
30
app/models/site/deploy_dependencies.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# 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
|
Loading…
Reference in a new issue