Class: Qa::Authorities::LinkedData::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/qa/authorities/linked_data/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • the (String)

    name of the configuration file for the authority



25
26
27
28
# File 'lib/qa/authorities/linked_data/config.rb', line 25

def initialize(auth_name)
  @authority_name = auth_name
  authority_config
end

Instance Attribute Details

#authority_nameObject (readonly)

Returns the value of attribute authority_name.



20
21
22
# File 'lib/qa/authorities/linked_data/config.rb', line 20

def authority_name
  @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_configString

Return the full configuration for an authority

Returns:

  • (String)

    the authority configuration

Raises:



60
61
62
63
64
65
# File 'lib/qa/authorities/linked_data/config.rb', line 60

def authority_config
  @authority_config ||= Qa::LinkedData::AuthorityService.authority_config(@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_infoObject



54
55
56
# File 'lib/qa/authorities/linked_data/config.rb', line 54

def authority_info
  search.info + term.info
end

#config_versionObject



46
47
48
# 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) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/qa/authorities/linked_data/config.rb', line 50

def config_version?(version)
  config_version == version
end

#prefixesObject



38
39
40
# File 'lib/qa/authorities/linked_data/config.rb', line 38

def prefixes
  @prefixes ||= authority_config.fetch(:prefixes, {})
end

#searchObject



30
31
32
# 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_uriObject



42
43
44
# File 'lib/qa/authorities/linked_data/config.rb', line 42

def service_uri
  @service_uri ||= authority_config.fetch(:service_uri, nil)
end

#termObject



34
35
36
# 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