Class: Mudguard::Domain::Policies

Inherits:
Object
  • Object
show all
Includes:
Texts
Defined in:
lib/mudguard/domain/policies.rb

Overview

Contains the policies to be enforced

Instance Method Summary collapse

Methods included from Texts

#dependency_allowed, #dependency_not_allowed, #dependency_summary, #summary

Constructor Details

#initialize(source_policies: []) ⇒ Policies

Returns a new instance of Policies.



13
14
15
# File 'lib/mudguard/domain/policies.rb', line 13

def initialize(source_policies: [])
  @source_policies = source_policies
end

Instance Method Details

#check(notification) ⇒ Object



17
18
19
20
21
22
23
24
25
# 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


27
28
29
30
31
32
33
34
# 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