Class: Qa::Authorities::LinkedData::AuthorityService

Inherits:
Object
  • Object
show all
Defined in:
lib/qa/authorities/linked_data/authority_service.rb

Class Method Summary collapse

Class Method Details

.authority_config(authname) ⇒ Array<String>

Get the configuration for an authority

Parameters:

  • name (String)

    of the authority

Returns:

  • (Array<String>)

    configuration for the specified authority



36
37
38
# File 'lib/qa/authorities/linked_data/authority_service.rb', line 36

def self.authority_config(authname)
  authority_configs[authname]
end

.authority_configsArray<String>

Get the list of names of the loaded authorities

Returns:

  • (Array<String>)

    all loaded authority configurations



29
30
31
# File 'lib/qa/authorities/linked_data/authority_service.rb', line 29

def self.authority_configs
  Qa.config.linked_data_authority_configs
end

.authority_namesArray<String>

Get the list of names of the loaded authorities

Returns:

  • (Array<String>)

    names of the authority config files that are currently loaded



42
43
44
# File 'lib/qa/authorities/linked_data/authority_service.rb', line 42

def self.authority_names
  authority_configs.keys.sort
end

.load_authoritiesObject

Load or reload the linked data configuration files



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/qa/authorities/linked_data/authority_service.rb', line 7

def self.load_authorities
  auth_cfg = {}
  # load QA configured linked data authorities
  Dir[File.join(Qa::Engine.root, 'config', 'authorities', 'linked_data', '*.json')].each do |fn|
    auth = File.basename(fn, '.json').upcase.to_sym
    json = File.read(File.expand_path(fn, __FILE__))
    cfg = JSON.parse(json).deep_symbolize_keys
    auth_cfg[auth] = cfg
  end

  # load app configured linked data authorities and overrides
  Dir[Rails.root.join('config', 'authorities', 'linked_data', '*.json')].each do |fn|
    auth = File.basename(fn, '.json').upcase.to_sym
    json = File.read(File.expand_path(fn, __FILE__))
    cfg = JSON.parse(json).deep_symbolize_keys
    auth_cfg[auth] = cfg
  end
  Qa.config.linked_data_authority_configs = auth_cfg
end