Class: Dor::Configuration
- Inherits:
-
Confstruct::Configuration
- Object
- Confstruct::Configuration
- Dor::Configuration
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- lib/dor/config.rb
Instance Method Summary collapse
-
#configure(*args) ⇒ Object
Call the super method with callbacks and with $VERBOSE temporarily disabled.
- #configure_client!(config) ⇒ Object
- #default_ssl_cert_store ⇒ Object
- #fedora_config ⇒ Object
-
#init(*args) ⇒ Object
Act like an ActiveFedora.configurator.
-
#initialize(*args) ⇒ Configuration
constructor
A new instance of Configuration.
- #make_solr_connection(add_opts = {}) ⇒ Object
- #predicate_config ⇒ Object
- #sanitize ⇒ Object
- #solr_config ⇒ Object
Constructor Details
#initialize(*args) ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 |
# File 'lib/dor/config.rb', line 15 def initialize(*args) super *args run_callbacks(:initialize) {} end |
Instance Method Details
#configure(*args) ⇒ Object
Call the super method with callbacks and with $VERBOSE temporarily disabled
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dor/config.rb', line 21 def configure(*args) result = self temp_verbose = $VERBOSE $VERBOSE = nil begin run_callbacks :configure do result = super(*args) end ensure $VERBOSE = temp_verbose end result end |
#configure_client!(config) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/dor/config.rb', line 91 def configure_client!(config) # Do not configure client if URL not specified return if config.dor_services&.url.blank? params = { url: config.dor_services.url } params[:username] = config.dor_services.user if config.dor_services&.user.present? params[:password] = config.dor_services.pass if config.dor_services&.pass.present? Dor::Services::Client.configure(params) end |
#default_ssl_cert_store ⇒ Object
124 125 126 |
# File 'lib/dor/config.rb', line 124 def default_ssl_cert_store @default_ssl_cert_store ||= RestClient::Request.default_ssl_cert_store end |
#fedora_config ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'lib/dor/config.rb', line 107 def fedora_config fedora_uri = URI.parse(fedora.url) connection_opts = { url: fedora.safeurl, user: fedora_uri.user, password: fedora_uri.password } connection_opts[:ssl_client_cert] = OpenSSL::X509::Certificate.new(File.read(ssl.cert_file)) if ssl.cert_file.present? connection_opts[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(ssl.key_file), ssl.key_pass) if ssl.key_file.present? connection_opts[:ssl_cert_store] = default_ssl_cert_store connection_opts end |
#init(*args) ⇒ Object
Act like an ActiveFedora.configurator
105 |
# File 'lib/dor/config.rb', line 105 def init(*args); end |
#make_solr_connection(add_opts = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/dor/config.rb', line 39 def make_solr_connection(add_opts = {}) opts = Dor::Config.solr.opts.merge(add_opts).merge( url: Dor::Config.solr.url ) ::RSolr.connect(opts) end |
#predicate_config ⇒ Object
120 121 122 |
# File 'lib/dor/config.rb', line 120 def predicate_config YAML.load(File.read(File.('../../config/predicate_mappings.yml', __dir__))) end |
#sanitize ⇒ Object
35 36 37 |
# File 'lib/dor/config.rb', line 35 def sanitize dup end |
#solr_config ⇒ Object
116 117 118 |
# File 'lib/dor/config.rb', line 116 def solr_config { url: solr.url } end |