class Qa::Authorities::LinkedData::Config
Attributes
Public Class Methods
config_value(config, key)
click to toggle source
# File lib/qa/authorities/linked_data/config.rb, line 67 def self.config_value(config, key) return nil if config.nil? || !(config.key? key) config[key] end
new(auth_name)
click to toggle source
Initialize to hold the configuration for the specifed authority. Configurations are defined in config/authorities/linked_data. See README for more information. @param [String] the name of the configuration file for the authority @return [Qa::Authorities::LinkedData::Config] instance of this class
# File lib/qa/authorities/linked_data/config.rb, line 25 def initialize(auth_name) @authority_name = auth_name authority_config end
predicate_uri(config, key)
click to toggle source
# File lib/qa/authorities/linked_data/config.rb, line 72 def self.predicate_uri(config, key) pred = config_value(config, key) pred_uri = nil pred_uri = RDF::URI(pred) unless pred.nil? || pred.length <= 0 pred_uri end
Public Instance Methods
config_version()
click to toggle source
# File lib/qa/authorities/linked_data/config.rb, line 46 def config_version @config_version ||= authority_config.fetch(:QA_CONFIG_VERSION, '1.0') end
config_version?(version)
click to toggle source
# File lib/qa/authorities/linked_data/config.rb, line 50 def config_version?(version) config_version == version end
prefixes()
click to toggle source
# File lib/qa/authorities/linked_data/config.rb, line 38 def prefixes @prefixes ||= authority_config.fetch(:prefixes, {}) end
search()
click to toggle source
# File lib/qa/authorities/linked_data/config.rb, line 30 def search @search ||= Qa::Authorities::LinkedData::SearchConfig.new(authority_config.fetch(:search), prefixes, self) end
service_uri()
click to toggle source
# File lib/qa/authorities/linked_data/config.rb, line 42 def service_uri @service_uri ||= authority_config.fetch(:service_uri, nil) end
term()
click to toggle source
# File lib/qa/authorities/linked_data/config.rb, line 34 def term @term ||= Qa::Authorities::LinkedData::TermConfig.new(authority_config.fetch(:term), prefixes, self) end
Private Instance Methods
convert_1_0_to_2_0_version()
click to toggle source
# File lib/qa/authorities/linked_data/config.rb, line 81 def convert_1_0_to_2_0_version convert_1_0_url_to_2_0_url(:search) convert_1_0_url_to_2_0_url(:term) end
convert_1_0_url_to_2_0_url(action_key)
click to toggle source
@deprecated Update to linked data config version 2.0 instead
# File lib/qa/authorities/linked_data/config.rb, line 87 def convert_1_0_url_to_2_0_url(action_key) url_template = @authority_config.fetch(action_key, {}).fetch(:url, {}).fetch(:template, "") return if url_template.blank? Qa.deprecation_warning(msg: "Linked data configuration #{authority_name} has 1.0 version format which is deprecated; update to version 2.0 configuration.") @authority_config[action_key][:url][:template] = url_template.gsub("{?", "{") end