lib/redd.rb in redd-0.8.8 vs lib/redd.rb in redd-0.9.0.pre.1
- old
+ new
@@ -6,10 +6,12 @@
require_relative 'redd/version'
# Models
Dir[File.join(__dir__, 'redd', 'models', '*.rb')].each { |f| require f }
# Authentication Clients
Dir[File.join(__dir__, 'redd', 'auth_strategies', '*.rb')].each { |f| require f }
+# Error Classes
+require_relative 'redd/errors'
# Regular Client
require_relative 'redd/api_client'
# Redd is a simple and intuitive API wrapper.
module Redd
@@ -86,32 +88,32 @@
end
private
def filter_auth(opts)
- opts.select { |k| %i(client_id secret username password redirect_uri user_agent).include?(k) }
+ opts.select { |k| %i[client_id secret username password redirect_uri user_agent].include?(k) }
end
def filter_api(opts)
- opts.select { |k| %i(user_agent limit_time max_retries auto_refresh).include?(k) }
+ opts.select { |k| %i[user_agent limit_time max_retries auto_refresh].include?(k) }
end
def script(opts = {})
- return unless %i(client_id secret username password).all? { |o| opts.include?(o) }
+ return unless %i[client_id secret username password].all? { |o| opts.include?(o) }
auth = AuthStrategies::Script.new(filter_auth(opts))
api = APIClient.new(auth, **filter_api(opts))
api.tap(&:authenticate)
end
def web(opts = {})
- return unless %i(client_id redirect_uri code).all? { |o| opts.include?(o) }
+ return unless %i[client_id redirect_uri code].all? { |o| opts.include?(o) }
auth = AuthStrategies::Web.new(**filter_auth(opts))
api = APIClient.new(auth, **filter_api(opts))
api.tap { |c| c.authenticate(opts[:code]) }
end
def userless(opts = {})
- return unless %i(client_id secret).all? { |o| opts.include?(o) }
+ return unless %i[client_id secret].all? { |o| opts.include?(o) }
auth = AuthStrategies::Userless.new(filter_auth(opts))
api = APIClient.new(auth, **filter_api(opts))
api.tap(&:authenticate)
end
end