Class: Inferno::TerminologyConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/terminology/terminology_configuration.rb

Class Method Summary collapse

Class Method Details

.allowed_systems_metadataObject



15
16
17
18
19
# File 'lib/inferno/terminology/terminology_configuration.rb', line 15

def 
  @allowed_systems_metadata ||=
    Terminology.
      .select { |url, | system_allowed?(url) }
end

.configObject



6
7
8
9
10
11
12
13
# File 'lib/inferno/terminology/terminology_configuration.rb', line 6

def config
  @config =
    if File.file? File.join('config', 'terminology_config.yml')
      YAML.load_file(File.join('config', 'terminology_config.yml')).presence || {}
    else
      {}
    end
end

.explicitly_allowed_systemsObject



32
33
34
# File 'lib/inferno/terminology/terminology_configuration.rb', line 32

def explicitly_allowed_systems
  config[:include] || []
end

.explicitly_prohibited_systemsObject



36
37
38
# File 'lib/inferno/terminology/terminology_configuration.rb', line 36

def explicitly_prohibited_systems
  config[:exclude] || []
end

.prohibited_license_restriction_levelsObject



28
29
30
# File 'lib/inferno/terminology/terminology_configuration.rb', line 28

def prohibited_license_restriction_levels
  config[:exclude_license_restriction_levels] || []
end

.prohibited_systemsObject



21
22
23
24
25
26
# File 'lib/inferno/terminology/terminology_configuration.rb', line 21

def prohibited_systems
  @prohibited_systems ||=
    Terminology.
      .reject { |url, | system_allowed?(url) }
      .keys
end

.system_allowed?(url) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
# File 'lib/inferno/terminology/terminology_configuration.rb', line 40

def system_allowed?(url)
  return true if explicitly_allowed_systems.include?(url)
  return false if explicitly_prohibited_systems.include?(url)

  !prohibited_license_restriction_levels.include?(Terminology..dig(url, :restriction_level))
end

.system_prohibited?(url) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/inferno/terminology/terminology_configuration.rb', line 47

def system_prohibited?(url)
  !system_allowed?(url)
end