Class: Qa::Authorities::LinkedData::Config
- Inherits:
-
Object
- Object
- Qa::Authorities::LinkedData::Config
- Defined in:
- lib/qa/authorities/linked_data/config.rb
Instance Attribute Summary collapse
-
#authority_name ⇒ Object
readonly
Returns the value of attribute authority_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#authority_config ⇒ String
Return the full configuration for an authority.
- #authority_info ⇒ Object
- #config_version ⇒ Object
- #config_version?(version) ⇒ Boolean
-
#initialize(auth_name) ⇒ Qa::Authorities::LinkedData::Config
constructor
Initialize to hold the configuration for the specifed authority.
- #prefixes ⇒ Object
- #search ⇒ Object
- #service_uri ⇒ Object
- #term ⇒ Object
Constructor Details
#initialize(auth_name) ⇒ Qa::Authorities::LinkedData::Config
Initialize to hold the configuration for the specifed authority. Configurations are defined in config/authorities/linked_data. See README for more information.
25 26 27 28 |
# File 'lib/qa/authorities/linked_data/config.rb', line 25 def initialize(auth_name) @authority_name = auth_name end |
Instance Attribute Details
#authority_name ⇒ Object (readonly)
Returns the value of attribute authority_name.
20 21 22 |
# File 'lib/qa/authorities/linked_data/config.rb', line 20 def @authority_name end |
Class Method Details
.config_value(config, key) ⇒ Object
67 68 69 70 |
# 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 |
.predicate_uri(config, key) ⇒ Object
72 73 74 75 76 77 |
# 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 |
Instance Method Details
#authority_config ⇒ String
Return the full configuration for an authority
60 61 62 63 64 65 |
# File 'lib/qa/authorities/linked_data/config.rb', line 60 def @authority_config ||= Qa::LinkedData::AuthorityService.(@authority_name) raise Qa::InvalidLinkedDataAuthority, "Unable to initialize linked data authority '#{@authority_name}'" if @authority_config.nil? convert_1_0_to_2_0_version if @authority_config.fetch(:QA_CONFIG_VERSION, '1.0') == '1.0' @authority_config end |
#authority_info ⇒ Object
54 55 56 |
# File 'lib/qa/authorities/linked_data/config.rb', line 54 def search.info + term.info end |
#config_version ⇒ Object
46 47 48 |
# File 'lib/qa/authorities/linked_data/config.rb', line 46 def config_version @config_version ||= .fetch(:QA_CONFIG_VERSION, '1.0') end |
#config_version?(version) ⇒ Boolean
50 51 52 |
# File 'lib/qa/authorities/linked_data/config.rb', line 50 def config_version?(version) config_version == version end |
#prefixes ⇒ Object
38 39 40 |
# File 'lib/qa/authorities/linked_data/config.rb', line 38 def prefixes @prefixes ||= .fetch(:prefixes, {}) end |
#search ⇒ Object
30 31 32 |
# File 'lib/qa/authorities/linked_data/config.rb', line 30 def search @search ||= Qa::Authorities::LinkedData::SearchConfig.new(.fetch(:search), prefixes, self) end |
#service_uri ⇒ Object
42 43 44 |
# File 'lib/qa/authorities/linked_data/config.rb', line 42 def service_uri @service_uri ||= .fetch(:service_uri, nil) end |
#term ⇒ Object
34 35 36 |
# File 'lib/qa/authorities/linked_data/config.rb', line 34 def term @term ||= Qa::Authorities::LinkedData::TermConfig.new(.fetch(:term), prefixes, self) end |