Class: Qa::LinkedData::AuthorityService

Inherits:
Object
  • Object
show all
Defined in:
app/services/qa/linked_data/authority_service.rb

Class Method Summary collapse

Class Method Details

.authority_config(authname) ⇒ Hash

Get the configuration for an authority

Parameters:

  • name (String)

    of the authority

Returns:

  • (Hash)

    configuration for the specified authority



35
36
37
# File 'app/services/qa/linked_data/authority_service.rb', line 35

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



28
29
30
# File 'app/services/qa/linked_data/authority_service.rb', line 28

def self.authority_configs
  Qa.config.linked_data_authority_configs
end

.authority_detailsArray<String>

Get the list of names and details of the loaded authorities

Returns:

  • (Array<String>)

    names of the authority config files that are currently loaded



47
48
49
50
51
# File 'app/services/qa/linked_data/authority_service.rb', line 47

def self.authority_details
  details = []
  authority_names.each { |auth_name| details << Qa::Authorities::LinkedData::Config.new(auth_name).authority_info }
  details.flatten
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



41
42
43
# File 'app/services/qa/linked_data/authority_service.rb', line 41

def self.authority_names
  authority_configs.keys.sort
end

.load_authoritiesObject

Load or reload the linked data configuration files



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

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