Class: Qa::LinkedData::AuthorityService
- Inherits:
-
Object
- Object
- Qa::LinkedData::AuthorityService
- Defined in:
- lib/qa/linked_data/authority_service.rb
Class Method Summary collapse
-
.authority_config(authname) ⇒ Hash
Get the configuration for an authority.
-
.authority_configs ⇒ Array<String>
Get the list of names of the loaded authorities.
-
.authority_details ⇒ Array<String>
Get the list of names and details of the loaded authorities.
-
.authority_names ⇒ Array<String>
Get the list of names of the loaded authorities.
-
.load_assign_fast_config ⇒ Object
similar to the above; these settings are for getting (non-linked-data) FAST subject headings from OCLC.
- .load_authorities ⇒ Object
-
.load_linked_data_config ⇒ Object
Load or reload the linked data configuration files.
-
.process_config_file(file_path:, config_hash:) ⇒ Object
load settings into a configuration hash:.
Class Method Details
.authority_config(authname) ⇒ Hash
Get the configuration for an authority
55 56 57 |
# File 'lib/qa/linked_data/authority_service.rb', line 55 def self.(authname) [authname] end |
.authority_configs ⇒ Array<String>
Get the list of names of the loaded authorities
48 49 50 |
# File 'lib/qa/linked_data/authority_service.rb', line 48 def self. Qa.config. end |
.authority_details ⇒ Array<String>
Get the list of names and details of the loaded authorities
67 68 69 70 71 |
# File 'lib/qa/linked_data/authority_service.rb', line 67 def self. details = [] .each { |auth_name| details << Qa::Authorities::LinkedData::Config.new(auth_name). } details.flatten end |
.authority_names ⇒ Array<String>
Get the list of names of the loaded authorities
61 62 63 |
# File 'lib/qa/linked_data/authority_service.rb', line 61 def self. .keys.sort end |
.load_assign_fast_config ⇒ Object
similar to the above; these settings are for getting (non-linked-data) FAST subject headings from OCLC.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/qa/linked_data/authority_service.rb', line 25 def self.load_assign_fast_config assign_fast_auth_cfg = {} # assign_fast settings Dir[File.join(Qa::Engine.root, 'config', 'authorities', 'assign_fast', '*.json')].each do |fn| process_config_file(file_path: fn, config_hash: assign_fast_auth_cfg) end # Optional local (app) assign_fast settings overrides Dir[Rails.root.join('config', 'authorities', 'assign_fast', '*.json')].each do |fn| process_config_file(file_path: fn, config_hash: assign_fast_auth_cfg) end Qa.config. = assign_fast_auth_cfg end |
.load_authorities ⇒ Object
5 6 7 8 |
# File 'lib/qa/linked_data/authority_service.rb', line 5 def self. load_linked_data_config load_assign_fast_config end |
.load_linked_data_config ⇒ Object
Load or reload the linked data configuration files
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/qa/linked_data/authority_service.rb', line 11 def self.load_linked_data_config ld_auth_cfg = {} # Linked data settings Dir[File.join(Qa::Engine.root, 'config', 'authorities', 'linked_data', '*.json')].each do |fn| process_config_file(file_path: fn, config_hash: ld_auth_cfg) end # Optional local (app) linked data settings overrides Dir[Rails.root.join('config', 'authorities', 'linked_data', '*.json')].each do |fn| process_config_file(file_path: fn, config_hash: ld_auth_cfg) end Qa.config. = ld_auth_cfg end |
.process_config_file(file_path:, config_hash:) ⇒ Object
load settings into a configuration hash:
39 40 41 42 43 44 |
# File 'lib/qa/linked_data/authority_service.rb', line 39 def self.process_config_file(file_path:, config_hash:) file_key = File.basename(file_path, '.json').upcase.to_sym json = File.read(File.(file_path, __FILE__)) cfg = JSON.parse(json).deep_symbolize_keys config_hash[file_key] = cfg end |