soundcloud-auth 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/**/*
data/README.markdown CHANGED
@@ -1,16 +1,16 @@
1
- SoundcloudAuth
1
+ SoundCloudAuth
2
2
  ===========
3
3
 
4
- SoundcloudAuth aims to provide a complete authentication and API access solution for creating SoundCloud applications in Rails. It provides a generator and all of the necessary components to use Soundcloud as the sole authentication provider for an application using OAuth.
4
+ SoundCloudAuth aims to provide a complete authentication and API access solution for creating SoundCloud applications in Rails. It provides a generator and all of the necessary components to use Soundcloud as the sole authentication provider for an application using OAuth.
5
5
 
6
6
  ### Major Props
7
7
 
8
- SoundcloudAuth is largely influenced and in a lot of ways identical to [Michael Bleigh's](http://github.com/mbleigh) amazing [TwitterAuth](http://github.com/mbleigh/twitter-auth) plugin. I've used TwitterAuth so many times on my Twitter app development that I found it sorely missed when I tried to tackle the SoundCloud platform. All props and donations should be forwarded to Michael.
8
+ SoundCloudAuth is largely influenced and in a lot of ways identical to [Michael Bleigh's](http://github.com/mbleigh) amazing [TwitterAuth](http://github.com/mbleigh/twitter-auth) plugin. I've used TwitterAuth so many times on my Twitter app development that I found it sorely missed when I tried to tackle the SoundCloud platform. All props and donations should be forwarded to Michael.
9
9
 
10
10
  Installation
11
11
  ============
12
12
 
13
- You can include SoundcloudAuth as a gem in your project like so:
13
+ You can include SoundCloudAuth as a gem in your project like so:
14
14
 
15
15
  config.gem `soundcloud-auth`, :lib => `soundcloud_auth`
16
16
 
@@ -18,23 +18,23 @@ Or you can install it as a traditional Rails plugin:
18
18
 
19
19
  script/plugin install git://github.com/leemartin/soundcloud-auth.git
20
20
 
21
- Note that because SoundcloudAuth utilizes Rails Engines functionality introduced in Rails 2.3, it will not work with earlier versions of Rails.
21
+ Note that because SoundCloudAuth utilizes Rails Engines functionality introduced in Rails 2.3, it will not work with earlier versions of Rails.
22
22
 
23
23
  Usage
24
24
  =====
25
25
 
26
- To utilize SoundcloudAuth in your application you will need to run the generator:
26
+ To utilize SoundCloudAuth in your application you will need to run the generator:
27
27
 
28
28
  script/generate soundcloud_auth
29
29
 
30
- This will generate a migration as well as set up the stubs needed to use the Rails Engines controllers and models set up by SoundcloudAuth. It will also create a User class that inherits from SoundcloudUser, abstracting away all of the SoundCloud authentication functionality and leaving you a blank slate to work with for your application.
30
+ This will generate a migration as well as set up the stubs needed to use the Rails Engines controllers and models set up by SoundCloudAuth. It will also create a User class that inherits from SoundcloudUser, abstracting away all of the SoundCloud authentication functionality and leaving you a blank slate to work with for your application.
31
31
 
32
32
  Finally, it will create a configuration file in `config/soundcloud_auth.yml` in which you should input your OAuth consumer key and secret as well as a custom callback for development (the 'oauth_callback' option is where SoundCloud will send the browser after authentication is complete).
33
33
 
34
34
  Usage Basics
35
35
  ------------
36
36
 
37
- SoundcloudAuth borrows heavily from [Restful Authentication](http://github.com/technoweenie/restful-authentication) for its API because it's simple and well-known. Here are some of the familiar methods that are available:
37
+ SoundCloudAuth borrows heavily from [Restful Authentication](http://github.com/technoweenie/restful-authentication) for its API because it's simple and well-known. Here are some of the familiar methods that are available:
38
38
 
39
39
  * `login_required`: a before filter that can be added to a controller to require that a user logs in before he/she can view the page.
40
40
  * `current_user`: returns the logged in user if one exists, otherwise returns `nil`.
@@ -46,24 +46,20 @@ SoundcloudAuth borrows heavily from [Restful Authentication](http://github.com/t
46
46
  Accessing the SoundCloud API
47
47
  -------------------------
48
48
 
49
- The `User` class will have a `soundcloud` method that provides a generic dispatcher with HTTP verb commands available (`get`, `put`, `post`, and `delete`). These are automatically initialized to the `base_url` you specified in the `twitter_auth.yml` file, so you need only specify a path. Additionally, it will automatically append a .json extension and parse the JSON if you don't provide.
49
+ The `User` class will have a `soundcloud` method that interfaces with the [SoundCloud Ruby API Wrapper](http://wiki.github.com/soundcloud/ruby-api-wrapper/) allowing you to easily access the [SoundCloud API](http://wiki.github.com/soundcloud/api/). Check out the [Wiki](http://wiki.github.com/soundcloud/ruby-api-wrapper/getting-started) for more info.
50
50
 
51
- user.soundcloud.get('/me')
52
- # => {'username' => 'leemartin', 'full_name' => 'Lee Martin' ... }
51
+ user.soundcloud.User.find_me
53
52
 
54
- user.soundcloud.put('/me', 'user[website]=http://lee.ma/rtin')
55
- # => {'username' => 'leemartin', 'website' => 'http://lee.ma/rtin'}
53
+ user.soundcloud.Track.find(:all)
56
54
 
57
- If SoundCloud returns something other than a 200 response code, SoundcloudAuth will catch it and try to raise a salient error message. The exception class is `SoundcloudAuth::Dispatcher::Error`.
58
-
59
- Customizing SoundcloudAuth
55
+ Customizing SoundCloudAuth
60
56
  -----------------------
61
57
 
62
- There are a number of hooks to extend the functionality of SoundcloudAuth. Here is a brief description of each of them.
58
+ There are a number of hooks to extend the functionality of SoundCloudAuth. Here is a brief description of each of them.
63
59
 
64
60
  ### Controller Methods
65
61
 
66
- SoundcloudAuth provides some default controller methods that may be overridden in your `ApplicationController` to behave differently.
62
+ SoundCloudAuth provides some default controller methods that may be overridden in your `ApplicationController` to behave differently.
67
63
 
68
64
  * `authentication_failed(message)`: called when SoundCloud authorization has failed during the process. By default, simply redirects to the site root and sets the `flash[:error]`.
69
65
  * `authentication_succeeded(message=default)`: called when SoundCloud authorization has completed successfully. By default, simply redirects to the site root and sets the `flash[:notice]`.
@@ -72,4 +68,4 @@ SoundcloudAuth provides some default controller methods that may be overridden i
72
68
  Copyright
73
69
  ---------
74
70
 
75
- **SoundcloudAuth** is Copyright (c) 2010 [Lee Martin](http://lee.ma/rtin), released under the MIT License.
71
+ **SoundCloudAuth** is Copyright (c) 2010 [Lee Martin](http://lee.ma/rtin), released under the MIT License.
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gemspec.homepage = "http://github.com/leemartin/soundcloud-auth"
12
12
  gemspec.authors = ["Lee Martin"]
13
13
  gemspec.add_dependency('oauth', '>= 0.3.1')
14
+ gemspec.add_dependency('soundcloud-ruby-api-wrapper')
14
15
  end
15
16
  Jeweler::GemcutterTasks.new
16
17
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -89,13 +89,17 @@ module SoundcloudAuth
89
89
  user.save
90
90
  user
91
91
  end
92
+
93
+ def token
94
+ OAuth::AccessToken.new(SoundcloudAuth.consumer, access_token, access_secret)
95
+ end
92
96
 
93
97
  def utilize_default_validations
94
98
  true
95
99
  end
96
100
 
97
101
  def soundcloud
98
- SoundcloudAuth::Dispatcher::Oauth.new(self)
102
+ Soundcloud.register({:access_token => token})
99
103
  end
100
104
 
101
105
  def remember_me
@@ -45,12 +45,4 @@ module SoundcloudAuth
45
45
 
46
46
  end
47
47
 
48
- require 'soundcloud_auth/controller_extensions'
49
- require 'soundcloud_auth/dispatcher/oauth'
50
-
51
- module SoundcloudAuth
52
- module Dispatcher
53
- class Error < StandardError; end
54
- class Unauthorized < Error; end
55
- end
56
- end
48
+ require 'soundcloud_auth/controller_extensions'
data/rails/init.rb CHANGED
@@ -1,6 +1,7 @@
1
- # Gem Dependencies
2
- config.gem 'oauth'
1
+ gem 'oauth'
2
+ gem 'soundcloud-ruby-api-wrapper'
3
3
 
4
+ require 'soundcloud'
4
5
  require 'json'
5
6
  require 'soundcloud_auth'
6
7
 
@@ -5,18 +5,19 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{soundcloud-auth}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lee Martin"]
12
- s.date = %q{2010-06-25}
12
+ s.date = %q{2010-06-27}
13
13
  s.description = %q{SoundcloudAuth is a Rails plugin gem that provides Single Sign-On capabilities for Rails applications via SoundCloud.}
14
14
  s.email = %q{lee@soundcloud.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.markdown"
17
17
  ]
18
18
  s.files = [
19
- "README.markdown",
19
+ ".gitignore",
20
+ "README.markdown",
20
21
  "Rakefile",
21
22
  "VERSION",
22
23
  "app/controllers/sessions_controller.rb",
@@ -30,8 +31,6 @@ Gem::Specification.new do |s|
30
31
  "init.rb",
31
32
  "lib/soundcloud_auth.rb",
32
33
  "lib/soundcloud_auth/controller_extensions.rb",
33
- "lib/soundcloud_auth/dispatcher/oauth.rb",
34
- "pkg/soundcloud-auth-0.1.0.gem",
35
34
  "rails/init.rb",
36
35
  "soundcloud-auth.gemspec"
37
36
  ]
@@ -47,10 +46,13 @@ Gem::Specification.new do |s|
47
46
 
48
47
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
48
  s.add_runtime_dependency(%q<oauth>, [">= 0.3.1"])
49
+ s.add_runtime_dependency(%q<soundcloud-ruby-api-wrapper>, [">= 0"])
50
50
  else
51
51
  s.add_dependency(%q<oauth>, [">= 0.3.1"])
52
+ s.add_dependency(%q<soundcloud-ruby-api-wrapper>, [">= 0"])
52
53
  end
53
54
  else
54
55
  s.add_dependency(%q<oauth>, [">= 0.3.1"])
56
+ s.add_dependency(%q<soundcloud-ruby-api-wrapper>, [">= 0"])
55
57
  end
56
58
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soundcloud-auth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lee Martin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-25 00:00:00 -07:00
18
+ date: 2010-06-27 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -34,6 +34,20 @@ dependencies:
34
34
  version: 0.3.1
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: soundcloud-ruby-api-wrapper
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :runtime
50
+ version_requirements: *id002
37
51
  description: SoundcloudAuth is a Rails plugin gem that provides Single Sign-On capabilities for Rails applications via SoundCloud.
38
52
  email: lee@soundcloud.com
39
53
  executables: []
@@ -43,6 +57,7 @@ extensions: []
43
57
  extra_rdoc_files:
44
58
  - README.markdown
45
59
  files:
60
+ - .gitignore
46
61
  - README.markdown
47
62
  - Rakefile
48
63
  - VERSION
@@ -57,8 +72,6 @@ files:
57
72
  - init.rb
58
73
  - lib/soundcloud_auth.rb
59
74
  - lib/soundcloud_auth/controller_extensions.rb
60
- - lib/soundcloud_auth/dispatcher/oauth.rb
61
- - pkg/soundcloud-auth-0.1.0.gem
62
75
  - rails/init.rb
63
76
  - soundcloud-auth.gemspec
64
77
  has_rdoc: true
@@ -1,56 +0,0 @@
1
- require 'oauth'
2
-
3
- module SoundcloudAuth
4
- module Dispatcher
5
- class Oauth < OAuth::AccessToken
6
-
7
- attr_accessor :user
8
-
9
- def append_extension_to(path)
10
- path, query_string = *(path.split("?"))
11
- path << '.json' unless path.match(/\.(:?xml|json)\z/i)
12
- "#{path}#{"?#{query_string}" if query_string}"
13
- end
14
-
15
- def handle_response(response)
16
- case response
17
- when Net::HTTPOK
18
- begin
19
- JSON.parse(response.body)
20
- rescue JSON::ParserError
21
- response.body
22
- end
23
- when Net::HTTPUnauthorized
24
- raise SoundcloudAuth::Dispatcher::Unauthorized, 'The credentials provided did not authorize the user.'
25
- else
26
- message = begin
27
- JSON.parse(response.body)['error']
28
- rescue JSON::ParserError
29
- if match = response.body.match(/<error>(.*)<\/error>/)
30
- match[1]
31
- else
32
- 'An error occurred processing your SoundCloud request.'
33
- end
34
- end
35
-
36
- raise SoundcloudAuth::Dispatcher::Error, message
37
- end
38
- end
39
-
40
- def initialize(user)
41
- self.user = user
42
- super(SoundcloudAuth.consumer, user.access_token, user.access_secret)
43
- end
44
-
45
- def request(http_method, path, *arguments)
46
- path = SoundcloudAuth.path_prefix + path
47
- path = append_extension_to(path)
48
-
49
- response = super
50
-
51
- handle_response(response)
52
- end
53
-
54
- end
55
- end
56
- end
Binary file