class Luban::Deployment::Package::DependencySet
Public Class Methods
new()
click to toggle source
# File lib/luban/deployment/cli/package/dependency_set.rb, line 5 def initialize @dependencies = {} @ctx = {} end
Public Instance Methods
after_install(&blk)
click to toggle source
# File lib/luban/deployment/cli/package/dependency_set.rb, line 25 def after_install(&blk) if @ctx[:version_requirement].nil? raise RuntimeError, 'Please call #apply_to prior to #after_install.' end @ctx[:type] = :after_install instance_eval(&blk) if block_given? end
after_install_dependencies_for(version)
click to toggle source
# File lib/luban/deployment/cli/package/dependency_set.rb, line 65 def after_install_dependencies_for(version) dependencies_for(version, type: :after_install) end
apply_to(version_requirement, &blk)
click to toggle source
# File lib/luban/deployment/cli/package/dependency_set.rb, line 10 def apply_to(version_requirement, &blk) @ctx = { version_requirement: version_requirement } instance_eval(&blk) if block_given? ensure @ctx = {} end
before_install(&blk)
click to toggle source
# File lib/luban/deployment/cli/package/dependency_set.rb, line 17 def before_install(&blk) if @ctx[:version_requirement].nil? raise RuntimeError, 'Please call #apply_to prior to #before_install.' end @ctx[:type] = :before_install instance_eval(&blk) if block_given? end
before_install_dependencies_for(version)
click to toggle source
# File lib/luban/deployment/cli/package/dependency_set.rb, line 61 def before_install_dependencies_for(version) dependencies_for(version, type: :before_install) end
depend_on(name, version:, **opts)
click to toggle source
# File lib/luban/deployment/cli/package/dependency_set.rb, line 33 def depend_on(name, version:, **opts) if @ctx[:type].nil? raise RuntimeError, 'Please call #before_install or #after_install prior to #depend_on.' end requirement = @ctx[:version_requirement] type = @ctx[:type] dependency = Dependency.new(requirement, type, name, version, **opts) unless @dependencies.has_key?(requirement) @dependencies[requirement] = { before_install: [], after_install: [] } end @dependencies[requirement][type] << dependency end
dependencies_for(version, type: nil)
click to toggle source
# File lib/luban/deployment/cli/package/dependency_set.rb, line 47 def dependencies_for(version, type: nil) types = *type types = DependencyTypes if types.empty? deps = { before_install: [], after_install: [] } @dependencies.each_pair do |r, d| types.each do |t| next if d[t].empty? deps[t] |= d[t] if d[t].first.applicable_to?(version) end end deps end