lib/dor/services/client.rb in dor-services-client-1.8.0 vs lib/dor/services/client.rb in dor-services-client-1.9.0
- old
+ new
@@ -1,18 +1,29 @@
# frozen_string_literal: true
-require 'dor/services/client/version'
-require 'singleton'
-require 'faraday'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/module/delegation'
-require 'dor/services/client/versioned_service'
-require 'dor/services/client/object'
-require 'dor/services/client/objects'
-require 'dor/services/client/workflows'
-require 'dor/services/client/error_faraday_middleware'
+require 'faraday'
+require 'singleton'
+require 'zeitwerk'
+class DorServicesClientInflector < Zeitwerk::Inflector
+ def camelize(basename, _abspath)
+ case basename
+ when 'sdr'
+ 'SDR'
+ else
+ super
+ end
+ end
+end
+
+loader = Zeitwerk::Loader.new
+loader.inflector = DorServicesClientInflector.new
+loader.push_dir('lib')
+loader.setup
+
module Dor
module Services
class Client
class Error < StandardError; end
@@ -86,10 +97,11 @@
def url
@url || raise(Error, 'url has not yet been configured')
end
+ # rubocop:disable Metrics/AbcSize
def connection
@connection ||= Faraday.new(url) do |conn|
conn.use ErrorFaradayMiddleware
# @note when username & password are nil, this line is required else
@@ -99,9 +111,10 @@
conn.basic_auth username, password if username && password
conn.headers[:user_agent] = user_agent
conn.headers[token_header] = "Bearer #{token}" if token
end
end
+ # rubocop:enable Metrics/AbcSize
def user_agent
"dor-services-client #{Dor::Services::Client::VERSION}"
end
end