Class: Mudguard::Infrastructure::Persistence::ProjectRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/mudguard/infrastructure/persistence/project_repository.rb

Overview

Provides access to the persisted source and policies

Class Method Summary collapse

Class Method Details

.load_source_policies(project_path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/mudguard/infrastructure/persistence/project_repository.rb', line 13

def load_source_policies(project_path)
  file = PolicyFile.read(project_path)
  scopes = file.flat_map do |patterns, policies|
    build_scope(patterns, policies, project_path)
  end

  sources = scopes.group_by { |e| e[:source] }

  sources.map(&method(:build_policies))
end