Sha256: 8475a3980a3b409b824fc7578d2cb364c750cba4bff5652e73724cbf2333ebbc

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 Bytes

Contents

module SoundcloudAuth
  class Error < StandardError; end

  def self.config(environment=RAILS_ENV)
    @config ||= {}
    @config[environment] ||= YAML.load(File.open(RAILS_ROOT + '/config/soundcloud_auth.yml').read)[environment]
  end
  
  def self.base_url
    config['base_url'] || 'http://api.soundcloud.com'    
  end

  def self.path_prefix
    URI.parse(base_url).path
  end

  def self.oauth_callback?
    config.key?('oauth_callback')
  end

  def self.oauth_callback
    config['oauth_callback']
  end

  def self.remember_for
    (config['remember_for'] || 14).to_i
  end
  
  def self.consumer
    
    options = {
      :site => SoundcloudAuth.base_url,
      :request_token_path => "/oauth/request_token",
      :access_token_path => "/oauth/access_token",
      :authorize_path => "/oauth/authorize"
    }
    
    OAuth::Consumer.new(
      config['key'],
      config['secret'],
      options
    )
    
  end
  
end

require 'soundcloud_auth/controller_extensions'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
soundcloud-auth-0.2.0 lib/soundcloud_auth.rb
soundcloud-auth-0.1.2 lib/soundcloud_auth.rb