class Mudguard::Domain::Policies
Contains the policies to be enforced
Public Class Methods
new(source_policies: [])
click to toggle source
# File lib/mudguard/domain/policies.rb, line 13 def initialize(source_policies: []) @source_policies = source_policies end
Public Instance Methods
check(notification)
click to toggle source
# File lib/mudguard/domain/policies.rb, line 17 def check(notification) result = analyse(:check, notification) count = result[:sources_count] violations = result[:analyser_count] notification.add(nil, summary(count, violations)) violations.zero? end
print_allowed_dependencies(notification)
click to toggle source
# File lib/mudguard/domain/policies.rb, line 27 def print_allowed_dependencies(notification) result = analyse(:print_allowed, notification) count = result[:sources_count] violations = result[:analyser_count] notification.add(nil, dependency_summary(count, violations)) end
Private Instance Methods
analyse(method, notification)
click to toggle source
# File lib/mudguard/domain/policies.rb, line 38 def analyse(method, notification) consts = Consts.new(sources: @source_policies.map(&:source)) @source_policies.each_with_object(sources_count: 0, analyser_count: 0) do |sp, result| analyser = Dependencies.new(policies: sp.policies, notification: notification) dependencies = sp.source.find_mod_dependencies(consts) result[:sources_count] += 1 result[:analyser_count] += analyser.send(method, dependencies) end end