Class: Qa::Authorities::LinkedData::TermConfig
- Inherits:
-
Object
- Object
- Qa::Authorities::LinkedData::TermConfig
- Defined in:
- lib/qa/authorities/linked_data/config/term_config.rb
Instance Attribute Summary collapse
-
#prefixes ⇒ Object
readonly
Returns the value of attribute prefixes.
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(config, prefixes = {}, full_config = nil) ⇒ TermConfig
constructor
A new instance of TermConfig.
-
#supports_language_parameter? ⇒ Boolean
True if supports language parameter; otherwise, false.
-
#supports_subauthorities? ⇒ Boolean
True if supports language parameter; otherwise, false.
-
#supports_term? ⇒ True|False
Does this authority configuration have term defined?.
-
#term_id_expects_id? ⇒ True|False
Is the term_id substitution expected to be an ID?.
-
#term_id_expects_uri? ⇒ True|False
Is the term_id substitution expected to be a URI?.
-
#term_language ⇒ Symbol
(also: #language)
Return the preferred language for literal value selection for term fetch.
-
#term_qa_replacement_patterns ⇒ Hash
(also: #qa_replacement_patterns)
Return parameters that are required for QA api.
-
#term_results ⇒ Hash
Return results ldpaths or predicates.
-
#term_results_altlabel_ldpath ⇒ String
Return results altlabel_ldpath.
-
#term_results_altlabel_predicate ⇒ String
Return results altlabel_predicate.
-
#term_results_broader_ldpath ⇒ String
Return results broader_ldpath.
-
#term_results_broader_predicate ⇒ String
Return results broader_predicate.
-
#term_results_id_ldpath ⇒ String
Return results id_ldpath.
-
#term_results_id_predicate ⇒ String
Return results id_predicate.
-
#term_results_label_ldpath ⇒ String
Return results label_ldpath.
-
#term_results_label_predicate ⇒ String
Return results label_predicate.
-
#term_results_narrower_ldpath ⇒ String
Return results narrower_ldpath.
-
#term_results_narrower_predicate ⇒ String
Return results narrower_predicate.
-
#term_results_sameas_ldpath ⇒ String
Return results sameas_ldpath.
-
#term_results_sameas_predicate ⇒ String
Return results sameas_predicate.
-
#term_subauthorities ⇒ Hash
(also: #subauthorities)
Return the list of subauthorities for term fetch.
-
#term_subauthorities? ⇒ True|False
(also: #subauthorities?)
Are there subauthorities configured for term fetch?.
-
#term_subauthority?(subauth_name) ⇒ True|False
Is a specific subauthority configured for term fetch?.
-
#term_subauthority_count ⇒ Integer
Return the number of subauthorities defined for term fetch.
-
#url_config ⇒ Qa::IriTemplate::UrlConfig
Return term url template defined in the configuration for this authority.
Constructor Details
#initialize(config, prefixes = {}, full_config = nil) ⇒ TermConfig
Returns a new instance of TermConfig.
16 17 18 19 20 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 16 def initialize(config, prefixes = {}, full_config = nil) @term_config = config @prefixes = prefixes @full_config = full_config end |
Instance Attribute Details
#prefixes ⇒ Object (readonly)
Returns the value of attribute prefixes.
8 9 10 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 8 def prefixes @prefixes end |
Instance Method Details
#info ⇒ Object
187 188 189 190 191 192 193 194 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 187 def info return [] unless supports_term? auth_name = .downcase.to_s language = Qa::LinkedData::LanguageService.preferred_language(authority_language: language).map(&:to_s) details = (auth_name, language) .keys { |subauth_name| details << (auth_name, subauth_name.downcase.to_s, language) } details end |
#supports_language_parameter? ⇒ Boolean
Returns true if supports language parameter; otherwise, false.
155 156 157 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 155 def supports_language_parameter? qa_replacement_patterns.key? :lang end |
#supports_subauthorities? ⇒ Boolean
Returns true if supports language parameter; otherwise, false.
150 151 152 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 150 def qa_replacement_patterns.key?(:subauth) && end |
#supports_term? ⇒ True|False
Does this authority configuration have term defined?
24 25 26 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 24 def supports_term? term_config.present? end |
#term_id_expects_id? ⇒ True|False
Is the term_id substitution expected to be an ID?
43 44 45 46 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 43 def term_id_expects_id? return false if term_config.nil? || !(term_config.key? :term_id) term_config[:term_id] == "ID" end |
#term_id_expects_uri? ⇒ True|False
Is the term_id substitution expected to be a URI?
36 37 38 39 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 36 def term_id_expects_uri? return false if term_config.nil? || !(term_config.key? :term_id) term_config[:term_id] == "URI" end |
#term_language ⇒ Symbol Also known as: language
Return the preferred language for literal value selection for term fetch. Only applies if the authority provides language encoded literals. This is the default used for this authority if the user does not pass in a language. Only applies if the authority provides language encoded literals.
52 53 54 55 56 57 58 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 52 def term_language return @term_language unless @term_language.nil? lang = Config.config_value(term_config, :language) return nil if lang.nil? lang = [lang] if lang.is_a? String @term_language = lang.collect(&:to_sym) end |
#term_qa_replacement_patterns ⇒ Hash Also known as: qa_replacement_patterns
Return parameters that are required for QA api
144 145 146 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 144 def term_qa_replacement_patterns term_config.fetch(:qa_replacement_patterns, {}) end |
#term_results ⇒ Hash
Return results ldpaths or predicates
63 64 65 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 63 def term_results Config.config_value(term_config, :results) end |
#term_results_altlabel_ldpath ⇒ String
Return results altlabel_ldpath
96 97 98 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 96 def term_results_altlabel_ldpath Config.config_value(term_results, :altlabel_ldpath) end |
#term_results_altlabel_predicate ⇒ String
Return results altlabel_predicate
102 103 104 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 102 def term_results_altlabel_predicate Config.predicate_uri(term_results, :altlabel_predicate) end |
#term_results_broader_ldpath ⇒ String
Return results broader_ldpath
108 109 110 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 108 def term_results_broader_ldpath Config.config_value(term_results, :broader_ldpath) end |
#term_results_broader_predicate ⇒ String
Return results broader_predicate
114 115 116 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 114 def term_results_broader_predicate Config.predicate_uri(term_results, :broader_predicate) end |
#term_results_id_ldpath ⇒ String
Return results id_ldpath
69 70 71 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 69 def term_results_id_ldpath Config.config_value(term_results, :id_ldpath) end |
#term_results_id_predicate ⇒ String
Return results id_predicate
75 76 77 78 79 80 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 75 def term_results_id_predicate return @pred_id unless @pred_id.blank? @pred_id = Config.predicate_uri(term_results, :id_predicate) return @pred_id unless @pred_id.blank? @pred_id = pred_id_from_ldpath end |
#term_results_label_ldpath ⇒ String
Return results label_ldpath
84 85 86 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 84 def term_results_label_ldpath Config.config_value(term_results, :label_ldpath) end |
#term_results_label_predicate ⇒ String
Return results label_predicate
90 91 92 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 90 def term_results_label_predicate Config.predicate_uri(term_results, :label_predicate) end |
#term_results_narrower_ldpath ⇒ String
Return results narrower_ldpath
120 121 122 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 120 def term_results_narrower_ldpath Config.config_value(term_results, :narrower_ldpath) end |
#term_results_narrower_predicate ⇒ String
Return results narrower_predicate
126 127 128 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 126 def term_results_narrower_predicate Config.predicate_uri(term_results, :narrower_predicate) end |
#term_results_sameas_ldpath ⇒ String
Return results sameas_ldpath
132 133 134 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 132 def term_results_sameas_ldpath Config.config_value(term_results, :sameas_ldpath) end |
#term_results_sameas_predicate ⇒ String
Return results sameas_predicate
138 139 140 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 138 def term_results_sameas_predicate Config.predicate_uri(term_results, :sameas_predicate) end |
#term_subauthorities ⇒ Hash Also known as:
Return the list of subauthorities for term fetch
181 182 183 184 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 181 def @term_subauthorities ||= {} if term_config.nil? || !(term_config.key? :subauthorities) @term_subauthorities ||= term_config[:subauthorities] end |
#term_subauthorities? ⇒ True|False Also known as:
Are there subauthorities configured for term fetch?
161 162 163 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 161 def .positive? end |
#term_subauthority?(subauth_name) ⇒ True|False
Is a specific subauthority configured for term fetch?
168 169 170 171 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 168 def (subauth_name) subauth_name = subauth_name.to_sym if subauth_name.is_a? String .key? subauth_name end |
#term_subauthority_count ⇒ Integer
Return the number of subauthorities defined for term fetch
175 176 177 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 175 def .size end |
#url_config ⇒ Qa::IriTemplate::UrlConfig
Return term url template defined in the configuration for this authority.
30 31 32 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 30 def url_config @url_config ||= Qa::IriTemplate::UrlConfig.new(term_config[:url]) if supports_term? end |