Class: Cul::Fedora::Connector
- Inherits:
-
Object
- Object
- Cul::Fedora::Connector
- Defined in:
- lib/cul/fedora/connector.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #apim_call(method, *args) ⇒ Object
- #apim_interface ⇒ Object
- #config_for(interface, value) ⇒ Object
-
#initialize(config) ⇒ Connector
constructor
A new instance of Connector.
- #protocol_for(interface) ⇒ Object
- #rest_interface {|http| ... } ⇒ Object
- #rest_location ⇒ Object
- #url_builder(interface, url) ⇒ Object
Constructor Details
#initialize(config) ⇒ Connector
Returns a new instance of Connector.
16 17 18 |
# File 'lib/cul/fedora/connector.rb', line 16 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/cul/fedora/connector.rb', line 4 def config @config end |
Class Method Details
Instance Method Details
#apim_call(method, *args) ⇒ Object
57 58 59 60 |
# File 'lib/cul/fedora/connector.rb', line 57 def apim_call(method, *args) = args. apim_interface.method(method).call() end |
#apim_interface ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cul/fedora/connector.rb', line 42 def apim_interface() wsdl = url_builder(:admin, "fedora/wsdl?api=API-M") driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver if config_for(:admin, :ssl_verify) raise "SSL verification not currently supported. Please specify ssl_verify: false" else driver.['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE end driver.["protocol.http.basic_auth"] << [url_builder(:admin,"fedora/services/management"), config_for(:admin,:user), config_for(:admin,:password)] driver end |
#config_for(interface, value) ⇒ Object
34 35 36 |
# File 'lib/cul/fedora/connector.rb', line 34 def config_for(interface, value) (@config[interface.to_s] && @config[interface.to_s][value.to_s]) || @config[value.to_s] end |
#protocol_for(interface) ⇒ Object
30 31 32 |
# File 'lib/cul/fedora/connector.rb', line 30 def protocol_for(interface) config_for(interface.to_s,"ssl") == true ? "https" : "http" end |
#rest_interface {|http| ... } ⇒ Object
20 21 22 23 24 |
# File 'lib/cul/fedora/connector.rb', line 20 def rest_interface() http = Net::HTTP.start(config_for(:rest, :host),config_for(:rest, :port)) yield http http.finish() end |
#rest_location ⇒ Object
26 27 28 |
# File 'lib/cul/fedora/connector.rb', line 26 def rest_location() url_builder(:rest, "") end |
#url_builder(interface, url) ⇒ Object
38 39 40 |
# File 'lib/cul/fedora/connector.rb', line 38 def url_builder(interface, url) "#{protocol_for(interface)}://#{config_for(interface,:host)}:#{config_for(interface,:port)}/#{url}" end |