Class: Dor::Configuration
- Inherits:
-
Confstruct::Configuration
- Object
- Confstruct::Configuration
- Dor::Configuration
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- lib/dor/config.rb
Instance Method Summary collapse
- #autoconfigure(url, cert_file = Config.ssl.cert_file, key_file = Config.ssl.key_file, key_pass = Config.ssl.key_pass) ⇒ Object
- #configure(*args) ⇒ Object
- #fedora_config ⇒ Object
-
#init(*args) ⇒ Object
Act like an ActiveFedora.configurator.
-
#initialize(*args) ⇒ Configuration
constructor
A new instance of Configuration.
- #make_rest_client(url, cert = Config.ssl.cert_file, key = Config.ssl.key_file, pass = Config.ssl.key_pass) ⇒ Object
- #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.
12 13 14 15 |
# File 'lib/dor/config.rb', line 12 def initialize(*args) super *args run_callbacks(:initialize) { } end |
Instance Method Details
#autoconfigure(url, cert_file = Config.ssl.cert_file, key_file = Config.ssl.key_file, key_pass = Config.ssl.key_pass) ⇒ Object
31 32 33 34 35 |
# File 'lib/dor/config.rb', line 31 def autoconfigure(url, cert_file = Config.ssl.cert_file, key_file = Config.ssl.key_file, key_pass = Config.ssl.key_pass) client = make_rest_client(url, cert_file, key_file, key_pass) config = Confstruct::Configuration.symbolize_hash JSON.parse(client.get(accept: 'application/json')) configure(config) end |
#configure(*args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dor/config.rb', line 17 def configure(*args) result = self temp_v = $-v $-v = nil begin run_callbacks :configure do result = super(*args) end ensure $-v = temp_v end result end |
#fedora_config ⇒ Object
129 130 131 132 133 134 135 |
# File 'lib/dor/config.rb', line 129 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 end |
#init(*args) ⇒ Object
Act like an ActiveFedora.configurator
127 |
# File 'lib/dor/config.rb', line 127 def init(*args); end |
#make_rest_client(url, cert = Config.ssl.cert_file, key = Config.ssl.key_file, pass = Config.ssl.key_pass) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/dor/config.rb', line 41 def make_rest_client(url, cert = Config.ssl.cert_file, key = Config.ssl.key_file, pass = Config.ssl.key_pass) params = {} params[:ssl_client_cert] = OpenSSL::X509::Certificate.new(File.read(cert)) if cert params[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(key), pass) if key RestClient::Resource.new(url, params) end |
#make_solr_connection(add_opts = {}) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/dor/config.rb', line 48 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
141 142 143 |
# File 'lib/dor/config.rb', line 141 def predicate_config YAML.load(File.read(File.('../../../config/predicate_mappings.yml', __FILE__))) end |
#sanitize ⇒ Object
37 38 39 |
# File 'lib/dor/config.rb', line 37 def sanitize dup end |
#solr_config ⇒ Object
137 138 139 |
# File 'lib/dor/config.rb', line 137 def solr_config { :url => solr.url } end |