Class: BerkeleyLibrary::AV::Config
- Inherits:
-
Object
- Object
- BerkeleyLibrary::AV::Config
- Extended by:
- Util
- Defined in:
- lib/berkeley_library/av/config.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- REQUIRED_SETTINGS =
%i[ avplayer_base_uri alma_sru_host alma_primo_host alma_institution_code alma_permalink_key tind_base_uri wowza_base_uri ].freeze
Class Method Summary collapse
-
.alma_institution_code ⇒ Object
Alma institution code, e.g.
-
.alma_institution_code=(inst_code) ⇒ String
Sets the Alma SRU institution code.
- .alma_permalink_base_uri ⇒ Object
-
.alma_permalink_key ⇒ Object
View state key to use when generating Alma permalinks, e.g.
-
.alma_permalink_key=(permalink_key) ⇒ String
Sets the Alma permalink key.
-
.alma_primo_host ⇒ Object
Alma Primo host, e.g.
-
.alma_primo_host=(hostname) ⇒ String
Sets the Alma Primo hostname.
- .alma_sru_base_uri ⇒ Object
-
.alma_sru_host ⇒ Object
Alma SRU hostname, e.g.
-
.alma_sru_host=(hostname) ⇒ String
Sets the Alma SRU hostname.
- .avplayer_base_uri ⇒ Object
-
.avplayer_base_uri=(uri) ⇒ URI
Sets the AV Player base URI.
- .ensure_configured(*settings) ⇒ Object
-
.log_settings!(to_logger: BerkeleyLibrary::Logging.logger) ⇒ Object
Logs settings to the specified logger, or to the default logger.
-
.missing(*settings) ⇒ Array<Symbol>
Returns the list of missing required settings.
- .tind_base_uri ⇒ Object
-
.tind_base_uri=(uri) ⇒ URI
Sets the TIND base URI.
- .wowza_base_uri ⇒ Object
-
.wowza_base_uri=(uri) ⇒ URI
Sets the Wowza base URI.
Class Method Details
.alma_institution_code ⇒ Object
Alma institution code, e.g. UC Berkeley = 01UCS_BER
27 28 29 |
# File 'lib/berkeley_library/av/config.rb', line 27 def alma_institution_code @alma_institution_code ||= value_from_rails_config(:alma_institution_code) end |
.alma_institution_code=(inst_code) ⇒ String
Sets the Alma SRU institution code
109 110 111 112 113 114 |
# File 'lib/berkeley_library/av/config.rb', line 109 def alma_institution_code=(inst_code) raise ArgumentError, "Invalid institution code: #{inst_code.inspect}" if inst_code.nil? || inst_code.empty? sru_uri = sru_base_uri_for('example.org', inst_code) # Catch bad URIs early @alma_institution_code = sru_uri.path.split('/').last end |
.alma_permalink_base_uri ⇒ Object
50 51 52 53 54 |
# File 'lib/berkeley_library/av/config.rb', line 50 def alma_permalink_base_uri ensure_configured(:alma_primo_host, :alma_institution_code, :alma_permalink_key) primo_permalink_base_uri_for(alma_primo_host, alma_institution_code, alma_permalink_key) end |
.alma_permalink_key ⇒ Object
View state key to use when generating Alma permalinks, e.g. ‘iqob43`; see knowledge.exlibrisgroup.com/Primo/Knowledge_Articles/What_is_the_key_in_short_permalinks%3F
Note that despite the name ‘key’, this is not a secret.
40 41 42 |
# File 'lib/berkeley_library/av/config.rb', line 40 def alma_permalink_key @alma_permalink_key ||= value_from_rails_config(:alma_permalink_key) end |
.alma_permalink_key=(permalink_key) ⇒ String
Sets the Alma permalink key
122 123 124 125 126 127 |
# File 'lib/berkeley_library/av/config.rb', line 122 def alma_permalink_key=(permalink_key) raise ArgumentError, "Invalid permalink key: #{permalink_key.inspect}" if permalink_key.nil? || permalink_key.empty? sru_uri = primo_permalink_base_uri_for('example.org', 'XXX', permalink_key) # Catch bad URIs early @alma_permalink_key = sru_uri.path.split('/').last end |
.alma_primo_host ⇒ Object
Alma Primo host, e.g. UC Berkeley = search.library.berkeley.edu
32 33 34 |
# File 'lib/berkeley_library/av/config.rb', line 32 def alma_primo_host @alma_primo_host ||= value_from_rails_config(:alma_primo_host) end |
.alma_primo_host=(hostname) ⇒ String
Sets the Alma Primo hostname
96 97 98 99 100 101 |
# File 'lib/berkeley_library/av/config.rb', line 96 def alma_primo_host=(hostname) raise ArgumentError, "Invalid hostname: #{hostname.inspect}" if hostname.nil? || hostname.empty? primo_uri = primo_permalink_base_uri_for(hostname, 'XXX', 'abc123') # Catch bad URIs early @alma_primo_host = primo_uri.host end |
.alma_sru_base_uri ⇒ Object
44 45 46 47 48 |
# File 'lib/berkeley_library/av/config.rb', line 44 def alma_sru_base_uri ensure_configured(:alma_sru_host, :alma_institution_code) sru_base_uri_for(alma_sru_host, alma_institution_code) end |
.alma_sru_host ⇒ Object
Alma SRU hostname, e.g. UC Berkeley = berkeley.alma.exlibrisgroup.com
22 23 24 |
# File 'lib/berkeley_library/av/config.rb', line 22 def alma_sru_host @alma_sru_host ||= value_from_rails_config(:alma_sru_host) end |
.alma_sru_host=(hostname) ⇒ String
Sets the Alma SRU hostname
83 84 85 86 87 88 |
# File 'lib/berkeley_library/av/config.rb', line 83 def alma_sru_host=(hostname) raise ArgumentError, "Invalid hostname: #{hostname.inspect}" if hostname.nil? || hostname.empty? sru_uri = sru_base_uri_for(hostname, '') # Catch bad URIs early @alma_sru_host = sru_uri.host end |
.avplayer_base_uri ⇒ Object
56 57 58 |
# File 'lib/berkeley_library/av/config.rb', line 56 def avplayer_base_uri @avplayer_base_uri ||= uri_from_rails_config(:avplayer_base_uri) end |
.avplayer_base_uri=(uri) ⇒ URI
Sets the AV Player base URI
73 74 75 |
# File 'lib/berkeley_library/av/config.rb', line 73 def avplayer_base_uri=(uri) @avplayer_base_uri = clean_uri(uri) end |
.ensure_configured(*settings) ⇒ Object
158 159 160 161 162 |
# File 'lib/berkeley_library/av/config.rb', line 158 def ensure_configured(*settings) return if (missing_settings = missing(*settings)).empty? raise ArgumentError, "Missing AV configuration settings: #{missing_settings.join(', ')}" end |
.log_settings!(to_logger: BerkeleyLibrary::Logging.logger) ⇒ Object
Logs settings to the specified logger, or to the default logger.
166 167 168 169 |
# File 'lib/berkeley_library/av/config.rb', line 166 def log_settings!(to_logger: BerkeleyLibrary::Logging.logger) settings = REQUIRED_SETTINGS.to_h { |attr| [attr, loggable_value(send(attr))] } to_logger.info("#{name} settings:", settings:) end |
.missing(*settings) ⇒ Array<Symbol>
Returns the list of missing required settings.
149 150 151 152 153 154 155 156 |
# File 'lib/berkeley_library/av/config.rb', line 149 def missing(*settings) settings = REQUIRED_SETTINGS if settings.empty? [].tap do |unset| settings.each do |setting| unset << setting unless set?(setting) end end end |
.tind_base_uri ⇒ Object
60 61 62 |
# File 'lib/berkeley_library/av/config.rb', line 60 def tind_base_uri @tind_base_uri ||= uri_from_rails_config(:tind_base_uri) end |
.tind_base_uri=(uri) ⇒ URI
Sets the TIND base URI
134 135 136 |
# File 'lib/berkeley_library/av/config.rb', line 134 def tind_base_uri=(uri) @tind_base_uri = clean_uri(uri) end |
.wowza_base_uri ⇒ Object
64 65 66 |
# File 'lib/berkeley_library/av/config.rb', line 64 def wowza_base_uri @wowza_base_uri ||= uri_from_rails_config(:wowza_base_uri) end |
.wowza_base_uri=(uri) ⇒ URI
Sets the Wowza base URI
143 144 145 |
# File 'lib/berkeley_library/av/config.rb', line 143 def wowza_base_uri=(uri) @wowza_base_uri = clean_uri(uri) end |