Class: Mudguard::Domain::Dependencies

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

Overview

Executes operation on a set of dependencies

Instance Method Summary collapse

Methods included from Texts

#dependency_allowed, #dependency_not_allowed, #dependency_summary, #summary

Constructor Details

#initialize(policies:, notification:) ⇒ Dependencies

Returns a new instance of Dependencies.



11
12
13
14
# File 'lib/mudguard/domain/dependencies.rb', line 11

def initialize(policies:, notification:)
  @policies = policies.map { |p| /^#{p}/x }
  @notification = notification
end

Instance Method Details

#check(dependencies) ⇒ Object



16
17
18
19
20
21
# File 'lib/mudguard/domain/dependencies.rb', line 16

def check(dependencies)
  select_dependencies(dependencies) do |dependency, is_allowed|
    add_message(dependency, dependency_not_allowed(dependency.dependency)) unless is_allowed
    !is_allowed
  end
end


23
24
25
26
27
28
# File 'lib/mudguard/domain/dependencies.rb', line 23

def print_allowed(dependencies)
  select_dependencies(dependencies) do |dependency, is_allowed|
    add_message(dependency, dependency_allowed(dependency.dependency)) if is_allowed
    is_allowed
  end
end