lib/chronicle/etl/oauth_authorizer.rb in chronicle-etl-0.5.5 vs lib/chronicle/etl/oauth_authorizer.rb in chronicle-etl-0.6.1
- old
+ new
@@ -47,18 +47,18 @@
# Start up an authorization server and handle the oauth flow
def authorize!
associate_oauth_credentials
@server = load_server
- spinner = TTY::Spinner.new(":spinner :title", format: :dots_2)
+ spinner = TTY::Spinner.new(':spinner :title', format: :dots_2)
spinner.auto_spin
- spinner.update(title: "Starting temporary authorization server on port #{@port}""")
+ spinner.update(title: "Starting temporary authorization server on port #{@port}"'')
server_thread = start_authorization_server(port: @port)
start_oauth_flow
- spinner.update(title: "Waiting for authorization to complete in your browser")
+ spinner.update(title: 'Waiting for authorization to complete in your browser')
sleep 0.1 while authorization_pending?(server_thread)
@server.quit!
server_thread.join
spinner.success("(#{'successful'.green})")
@@ -83,11 +83,11 @@
end
def load_server
# Load at runtime so that we can set omniauth strategies based on
# which chronicle plugin has been loaded.
- require_relative './authorization_server'
+ require_relative 'authorization_server'
Chronicle::ETL::AuthorizationServer
end
def start_authorization_server(port:)
@server.settings.port = port
@@ -95,11 +95,11 @@
Thread.abort_on_exception = true
Thread.report_on_exception = false
Thread.new do
@server.run!({ port: @port }) do |s|
- s.silent = true if s.class.to_s == "Thin::Server"
+ s.silent = true if defined?(::Thin::Server) && s.instance_of?(::Thin::Server)
end
end
end
def start_oauth_flow
@@ -115,21 +115,21 @@
:server_settings,
{
AccessLog: [],
# TODO: make this windows friendly
# https://github.com/winton/stasis/commit/77da36f43285fda129300e382f18dfaff48571b0
- Logger: WEBrick::Log::new("/dev/null")
+ Logger: WEBrick::Log.new('/dev/null')
}
)
rescue LoadError
# no worries if we're not using WEBrick
end
def extract_secrets(authorization:, pluck_values:)
return authorization unless pluck_values&.any?
- pluck_values.each_with_object({}) do |(key, identifiers), secrets|
- secrets[key] = authorization.dig(*identifiers)
+ pluck_values.transform_values do |identifiers|
+ authorization.dig(*identifiers)
end
end
def omniauth_strategy
self.class.strategy