Sha256: 0fcdbf38911409cd331950251f84270d03dd770eb260edf40face45108b074cc

Contents?: true

Size: 809 Bytes

Versions: 6

Compression:

Stored size: 809 Bytes

Contents

class LuxOauth
  class_attribute :local_path, 'callback'

  class << self
    def get target
      "LuxOauth::#{target.to_s.classify}".constantize.new
    end

    def login target
      get(target).login
    end
  end

  ###

  def initialize
    @target = self.class.to_s.split('::').last.downcase.to_sym
    @opts   = opts_loader

    raise ArgumentError, 'Host is invalid' unless host =~ /^https?:/

    for el in %i[key secret]
      raise ArgumentError.new('OAUTH %s needed for %s' % [el, @target]) unless @opts.send(el)
    end
  end

  def redirect_url
    [host, LuxOauth.local_path, @target].join('/')
  end

  private

  def opts_loader
    Lux.secrets.send(@target).oauth
  rescue
    raise "Can't load Oauth secrets for #{@target}: #{$!.message}"
  end

  def host
    Lux.config(:host)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lux-fw-0.5.37 ./plugins/oauth/oauth.rb
lux-fw-0.5.36 ./plugins/oauth/oauth.rb
lux-fw-0.5.35 ./plugins/oauth/oauth.rb
lux-fw-0.5.34 ./plugins/oauth/oauth.rb
lux-fw-0.5.33 ./plugins/oauth/oauth.rb
lux-fw-0.5.32 ./plugins/oauth/oauth.rb