soundcloud-ruby-api-wrapper 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.html +5 -0
- data/Rakefile +10 -10
- data/VERSION.yml +3 -3
- data/lib/soundcloud.rb +6 -3
- data/lib/soundcloud/public_oauth_access_token.rb +36 -0
- data/lib/soundcloud/sc_oauth_active_resource.rb +30 -0
- data/soundcloud-ruby-api-wrapper.gemspec +9 -8
- data/spec/soundcloud_group_spec.rb +4 -4
- data/spec/soundcloud_spec.rb +22 -8
- data/spec/soundcloud_track_spec.rb +20 -17
- data/spec/soundcloud_user_spec.rb +9 -3
- data/spec/spec_helper.rb +15 -4
- metadata +7 -7
- data/lib/soundcloud/models/event.rb +0 -40
- data/ruby-api-wrapper.gemspec +0 -72
- data/spec/soundcloud_event_spec.rb +0 -34
data/README.html
CHANGED
@@ -6,6 +6,11 @@
|
|
6
6
|
|
7
7
|
<h3>News</h3>
|
8
8
|
|
9
|
+
<h4>May 18 2010</h4>
|
10
|
+
<p>Appending consumer_key param to all requests to public resources.</p>
|
11
|
+
|
12
|
+
<p>Removing Event model.</p>
|
13
|
+
|
9
14
|
19. November 2009
|
10
15
|
<p>With version 0.4.2 we switched back to the mojodna oauth gem, since the bug was finally fixed. We also had to switch to gemcutter.org to host our gems, since github doesn't support gem building and hosting anymore. By doing that we renamed jwagener-oauth-active-resource to oauth-active-resource.</p>
|
11
16
|
|
data/Rakefile
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
|
4
|
-
begin
|
4
|
+
begin
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name
|
8
|
-
gem.summary
|
9
|
-
gem.email
|
7
|
+
gem.name = "soundcloud-ruby-api-wrapper"
|
8
|
+
gem.summary = "A ruby wrapper for the SoundCloud API"
|
9
|
+
gem.email = "johannes@soundcloud.com"
|
10
10
|
gem.homepage = "http://github.com/soundcloud/ruby-api-wrapper"
|
11
|
-
gem.authors
|
12
|
-
|
13
|
-
gem.add_dependency "oauth", ">= 0.
|
14
|
-
|
11
|
+
gem.authors = [ "Johannes Wagener", "Thor Kell", "Hannes Tyden" ]
|
12
|
+
|
13
|
+
gem.add_dependency "oauth-active-resource", ">= 0.4.4"
|
14
|
+
gem.add_dependency "oauth", ">= 0.3.6"
|
15
|
+
end
|
15
16
|
rescue LoadError
|
16
|
-
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
17
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
20
|
require 'spec/rake/spectask'
|
21
21
|
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
22
|
spec.libs << 'lib' << 'spec'
|
data/VERSION.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
---
|
1
|
+
---
|
2
2
|
:major: 0
|
3
|
-
:minor: 4
|
4
|
-
:patch:
|
3
|
+
:minor: 4
|
4
|
+
:patch: 6
|
data/lib/soundcloud.rb
CHANGED
@@ -10,6 +10,7 @@ require 'oauth'
|
|
10
10
|
gem 'oauth-active-resource'
|
11
11
|
require 'oauth_active_resource'
|
12
12
|
|
13
|
+
|
13
14
|
module Soundcloud
|
14
15
|
# Will create an OAuth Consumer for you.
|
15
16
|
#
|
@@ -44,7 +45,10 @@ module Soundcloud
|
|
44
45
|
#
|
45
46
|
def self.register(options = {})
|
46
47
|
options[:site] = options[:site] || 'http://api.soundcloud.com'
|
47
|
-
|
48
|
+
if options[:consumer_key].nil? && options[:access_token].nil?
|
49
|
+
raise "Error: No consumer key or OAuth access token supplied."
|
50
|
+
end
|
51
|
+
mod = SCOAuthActiveResource.register(self.ancestors.first, self.ancestors.first.const_get('Models'),options)
|
48
52
|
add_resolver_to_mod(mod)
|
49
53
|
end
|
50
54
|
|
@@ -75,5 +79,4 @@ require 'soundcloud/models/event'
|
|
75
79
|
require 'soundcloud/models/playlist'
|
76
80
|
require 'soundcloud/models/track'
|
77
81
|
require 'soundcloud/models/group'
|
78
|
-
|
79
|
-
|
82
|
+
require File.expand_path('../soundcloud/sc_oauth_active_resource', __FILE__)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Soundcloud
|
2
|
+
|
3
|
+
# Subclass to force API users to pass a consumer key with each request.
|
4
|
+
class PublicOAuthAccessToken < OAuthActiveResource::FakeOAuthAccessToken
|
5
|
+
|
6
|
+
attr_accessor :token, :secret
|
7
|
+
def initialize(key)
|
8
|
+
@key = key
|
9
|
+
@token = "public #{key}"
|
10
|
+
@secret = 'Anonymous'
|
11
|
+
|
12
|
+
# ensure that keys are symbols
|
13
|
+
@options = @@default_options
|
14
|
+
end
|
15
|
+
def request(http_method, path, token = nil, request_options = {}, *arguments)
|
16
|
+
# Force a relative path from an absolute path
|
17
|
+
if path !~ /^\//
|
18
|
+
@http = create_http(path)
|
19
|
+
end
|
20
|
+
_uri = URI.parse(path)
|
21
|
+
|
22
|
+
# Append the consumer key to the request
|
23
|
+
if _uri.query.nil?
|
24
|
+
_uri.query = "consumer_key=#{@key}"
|
25
|
+
else
|
26
|
+
_uri.query += "&consumer_key=#{@key}"
|
27
|
+
end
|
28
|
+
|
29
|
+
path = "#{_uri.path}#{_uri.query ? "?#{_uri.query}" : ""}"
|
30
|
+
rsp = http.request(create_http_request(http_method, path, token, request_options, *arguments, @key))
|
31
|
+
|
32
|
+
rsp
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
gem 'activeresource'
|
4
|
+
require 'active_resource'
|
5
|
+
require 'digest/md5'
|
6
|
+
require File.expand_path('../public_oauth_access_token', __FILE__)
|
7
|
+
|
8
|
+
module SCOAuthActiveResource
|
9
|
+
|
10
|
+
# TODO check if klass has ancestor OAuthActiveResource
|
11
|
+
def self.register(add_to_module, model_module, options = {})
|
12
|
+
|
13
|
+
oauth_connection = options[:access_token]
|
14
|
+
|
15
|
+
if oauth_connection.nil?
|
16
|
+
oauth_connection = Soundcloud::PublicOAuthAccessToken.new(options[:consumer_key])
|
17
|
+
end
|
18
|
+
|
19
|
+
temp_hash = {:access_token => oauth_connection}
|
20
|
+
options.merge!(temp_hash)
|
21
|
+
|
22
|
+
mod = OAuthActiveResource.register(add_to_module, model_module, options)
|
23
|
+
return mod
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
require 'oauth_active_resource/connection'
|
29
|
+
require 'oauth_active_resource/resource'
|
30
|
+
require 'oauth_active_resource/unique_resource_array'
|
@@ -1,13 +1,16 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
7
|
s.name = %q{soundcloud-ruby-api-wrapper}
|
5
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.6"
|
6
9
|
|
7
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Johannes Wagener"]
|
9
|
-
s.date = %q{
|
10
|
-
s.email = %q{johannes@
|
11
|
+
s.authors = ["Johannes Wagener", "Thor Kell", "Hannes Tyden"]
|
12
|
+
s.date = %q{2010-05-18}
|
13
|
+
s.email = %q{johannes@soundcloud.com}
|
11
14
|
s.extra_rdoc_files = [
|
12
15
|
"LICENSE",
|
13
16
|
"README.html",
|
@@ -24,17 +27,16 @@ Gem::Specification.new do |s|
|
|
24
27
|
"lib/soundcloud.rb",
|
25
28
|
"lib/soundcloud/models/base.rb",
|
26
29
|
"lib/soundcloud/models/comment.rb",
|
27
|
-
"lib/soundcloud/models/event.rb",
|
28
30
|
"lib/soundcloud/models/group.rb",
|
29
31
|
"lib/soundcloud/models/playlist.rb",
|
30
32
|
"lib/soundcloud/models/track.rb",
|
31
33
|
"lib/soundcloud/models/user.rb",
|
32
|
-
"
|
34
|
+
"lib/soundcloud/public_oauth_access_token.rb",
|
35
|
+
"lib/soundcloud/sc_oauth_active_resource.rb",
|
33
36
|
"soundcloud-ruby-api-wrapper.gemspec",
|
34
37
|
"spec/fixtures/test_artwork.gif",
|
35
38
|
"spec/fixtures/test_track.mp3",
|
36
39
|
"spec/soundcloud_comment_spec.rb",
|
37
|
-
"spec/soundcloud_event_spec.rb",
|
38
40
|
"spec/soundcloud_group_spec.rb",
|
39
41
|
"spec/soundcloud_playlist_spec.rb",
|
40
42
|
"spec/soundcloud_spec.rb",
|
@@ -49,7 +51,6 @@ Gem::Specification.new do |s|
|
|
49
51
|
s.summary = %q{A ruby wrapper for the SoundCloud API}
|
50
52
|
s.test_files = [
|
51
53
|
"spec/soundcloud_comment_spec.rb",
|
52
|
-
"spec/soundcloud_event_spec.rb",
|
53
54
|
"spec/soundcloud_group_spec.rb",
|
54
55
|
"spec/soundcloud_playlist_spec.rb",
|
55
56
|
"spec/soundcloud_spec.rb",
|
@@ -9,7 +9,7 @@ describe "Soundcloud::Models::Group" do
|
|
9
9
|
@api_test_3 = @sc.User.find('api-test-3')
|
10
10
|
end
|
11
11
|
|
12
|
-
# static-test-group id =
|
12
|
+
# static-test-group id = 6635
|
13
13
|
# api_test_1 - creator
|
14
14
|
# api_test_3 - member
|
15
15
|
# api_test_2 track1 should be contributied
|
@@ -19,14 +19,14 @@ describe "Soundcloud::Models::Group" do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should get the fixture group' do
|
22
|
-
group = @sc.Group.find(
|
22
|
+
group = @sc.Group.find(6635)
|
23
23
|
group.name.should == "static-test-group"
|
24
24
|
end
|
25
25
|
|
26
26
|
|
27
27
|
describe 'users' do
|
28
28
|
before do
|
29
|
-
@group = @sc.Group.find(
|
29
|
+
@group = @sc.Group.find(6635)
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'should have the right creatotr api_test_1' do
|
@@ -42,7 +42,7 @@ describe "Soundcloud::Models::Group" do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should have a contributed track' do
|
45
|
-
@group.tracks.map(&:uri).should include('http://api.sandbox-soundcloud.com/tracks/
|
45
|
+
@group.tracks.map(&:uri).should include('http://api.sandbox-soundcloud.com/tracks/2096547')
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
data/spec/soundcloud_spec.rb
CHANGED
@@ -16,27 +16,41 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
16
16
|
# api-test-2 has 'static-test-playlist' with Track1, 2 and 3
|
17
17
|
#
|
18
18
|
# api-test-1 has Track "static-test-track" and user api-test-3 has not permissions for it
|
19
|
+
# "static-test-track" has a comment on it.
|
19
20
|
# api-test-1 has a playlist "my-static-playlist" with at least 2 tracks
|
20
21
|
|
21
|
-
|
22
|
-
|
23
22
|
describe "Soundcloud" do
|
24
|
-
before(:all) do
|
25
|
-
end
|
26
23
|
|
27
24
|
it 'should create an oauth consumer' do
|
28
|
-
Soundcloud.consumer(
|
25
|
+
Soundcloud.consumer(soundcloud_settings[:consumer_token], soundcloud_settings[:consumer_secret]).should be_an_instance_of OAuth::Consumer
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should fail to register a client with no API key, and no OAuth' do
|
29
|
+
lambda { sc = Soundcloud.register({:site => soundcloud_site})}.should raise_error RuntimeError
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should register a client with a bad API key, and no OAuth' do
|
33
|
+
sc = Soundcloud.register({:consumer_key=> soundcloud_settings[:bad_consumer_token], :site => soundcloud_site})
|
34
|
+
sc.to_s.should match(/Soundcloud::.+/)
|
35
|
+
lambda{ sc.Track.find(:all,:params => {:order => 'hotness', :limit => 1})}.should raise_error ActiveResource::UnauthorizedAccess
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should register a client with a good API key, but no OAuth, and be able to access public resources' do
|
39
|
+
sc = Soundcloud.register({:consumer_key => soundcloud_settings[:consumer_token], :site => soundcloud_site})
|
40
|
+
sc.to_s.should match(/Soundcloud::.+/)
|
41
|
+
lambda{ sc.Track.find(:all,:params => {:order => 'hotness', :limit => 1})}.should_not raise_error ActiveResource::UnauthorizedAccess
|
29
42
|
end
|
30
43
|
|
31
|
-
it 'should register a client
|
32
|
-
sc = Soundcloud.register({:site => soundcloud_site})
|
44
|
+
it 'should register a client with a good API key, but no OAuth, and fail to access private resources' do
|
45
|
+
sc = Soundcloud.register({:consumer_key=> soundcloud_settings[:consumer_token], :site => soundcloud_site})
|
33
46
|
sc.to_s.should match(/Soundcloud::.+/)
|
34
47
|
lambda{ sc.User.find(:one, :from => "/me")}.should raise_error ActiveResource::UnauthorizedAccess
|
35
48
|
end
|
36
49
|
|
37
|
-
it 'should register a client with
|
50
|
+
it 'should register a client with a valid oauth token, and be able to access public and private resources' do
|
38
51
|
sc = Soundcloud.register({:access_token=> valid_oauth_access_token, :site => soundcloud_site})
|
39
52
|
sc.to_s.should match(/Soundcloud::.+/)
|
53
|
+
lambda{ sc.Track.find(:all,:params => {:order => 'hotness', :limit => 1})}.should_not raise_error ActiveResource::UnauthorizedAccess
|
40
54
|
lambda{ sc.User.find(:one, :from => "/me")}.should_not raise_error ActiveResource::UnauthorizedAccess
|
41
55
|
end
|
42
56
|
end
|
@@ -133,21 +133,24 @@ describe "Soundcloud::Models::Track" do
|
|
133
133
|
# #tags.include? 'bla
|
134
134
|
#end
|
135
135
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
136
|
+
|
137
|
+
# App was changed, which causes this implementation to
|
138
|
+
# it 'should be able to add a user to permissions of a track and delete it again' do
|
139
|
+
# track = @sc.Track.find(:one, :from => '/users/api-test-1/tracks/static-test-track')
|
140
|
+
#
|
141
|
+
# old_count = track.permissions.length
|
142
|
+
#
|
143
|
+
# track.permissions << @api_test_3
|
144
|
+
# track.permissions.save
|
145
|
+
#
|
146
|
+
# track.permissions.length.should be(old_count+1)
|
147
|
+
#
|
148
|
+
# track.permissions.delete( @api_test_3 )
|
149
|
+
# track.permissions.save
|
150
|
+
#
|
151
|
+
# track.permissions.length.should be(old_count)
|
152
|
+
# end
|
140
153
|
|
141
|
-
track.permissions << @api_test_3
|
142
|
-
track.permissions.save
|
143
|
-
|
144
|
-
track.permissions.length.should be(old_count+1)
|
145
|
-
|
146
|
-
track.permissions.delete( @api_test_3 )
|
147
|
-
track.permissions.save
|
148
|
-
|
149
|
-
track.permissions.length.should be(old_count)
|
150
|
-
end
|
151
154
|
|
152
155
|
it 'should add, check and remove a favorite to "me"' do
|
153
156
|
@test_track_1.is_favorite?.should be false
|
@@ -158,13 +161,13 @@ describe "Soundcloud::Models::Track" do
|
|
158
161
|
end
|
159
162
|
|
160
163
|
it 'should be able to download a private track' do
|
161
|
-
track = @sc.Track.find(
|
164
|
+
track = @sc.Track.find(2096549)
|
162
165
|
track.download_url
|
163
166
|
end
|
164
167
|
|
165
168
|
it 'should be able to download a public track (unauthenticated)' do
|
166
|
-
usc = Soundcloud.register({:site => soundcloud_site})
|
167
|
-
track = usc.Track.find(:one, :from => '/users/api-test-2/tracks/
|
169
|
+
usc = Soundcloud.register({:consumer_key => soundcloud_settings[:consumer_token], :site => soundcloud_site})
|
170
|
+
track = usc.Track.find(:one, :from => '/users/api-test-2/tracks/test-track')
|
168
171
|
track.download_url
|
169
172
|
end
|
170
173
|
|
@@ -22,11 +22,14 @@ describe "Soundcloud::Models::User" do
|
|
22
22
|
user.username.should == test_for
|
23
23
|
end
|
24
24
|
|
25
|
+
# Search index not updated? a SOLR issue;
|
26
|
+
=begin
|
25
27
|
it 'should find all api-test users' do
|
26
28
|
test_for = 'api-test'
|
27
29
|
users = @sc.User.find(:all , :params => {:q => test_for})
|
28
30
|
users.length.should be >= 3
|
29
31
|
end
|
32
|
+
=end
|
30
33
|
|
31
34
|
it 'should check if a user has a contact' do
|
32
35
|
@api_test_2.has_contact?(@api_test_3).should be true
|
@@ -41,13 +44,16 @@ describe "Soundcloud::Models::User" do
|
|
41
44
|
@api_test_3.remove_contact!
|
42
45
|
end
|
43
46
|
|
47
|
+
# Favoriting not coming through -
|
48
|
+
|
44
49
|
it 'should check if a user has a favorite' do
|
45
|
-
track1 = @sc.Track.find(:one, :from => '/
|
46
|
-
track2 = @sc.Track.find(:one, :from => '/users/api-test-2/tracks/
|
50
|
+
track1 = @sc.Track.find(:one, :from => '/tracks/2096549')
|
51
|
+
track2 = @sc.Track.find(:one, :from => '/users/api-test-2/tracks/test-track')
|
47
52
|
@api_test_2.has_favorite?(track1).should be true
|
48
53
|
@api_test_2.has_favorite?(track1.id).should be true
|
49
54
|
@api_test_2.has_favorite?(track2).should be false
|
50
|
-
end
|
55
|
+
end
|
56
|
+
|
51
57
|
|
52
58
|
it 'should find the logged in user' do
|
53
59
|
my_user = @sc.User.find_me
|
data/spec/spec_helper.rb
CHANGED
@@ -14,11 +14,22 @@ def soundcloud_site
|
|
14
14
|
'http://api.sandbox-soundcloud.com'
|
15
15
|
end
|
16
16
|
|
17
|
+
def soundcloud_settings
|
18
|
+
return {
|
19
|
+
:access_token => 'your_access_token_here',
|
20
|
+
:access_secret => 'your_access_secret_here',
|
21
|
+
:consumer_token => 'your_consumer_token_here',
|
22
|
+
:consumer_secret => 'your_consumer_secret_here',
|
23
|
+
:bad_consumer_token => '98ydfg',
|
24
|
+
:bad_consumer_secret => 'Sp9p1FTU0hhLBNXY'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
17
28
|
def valid_oauth_access_token
|
18
|
-
access_token =
|
19
|
-
access_secret =
|
20
|
-
consumer_token =
|
21
|
-
consumer_secret =
|
29
|
+
access_token = soundcloud_settings[:access_token]
|
30
|
+
access_secret = soundcloud_settings[:access_secret]
|
31
|
+
consumer_token = soundcloud_settings[:consumer_token]
|
32
|
+
consumer_secret = soundcloud_settings[:consumer_secret]
|
22
33
|
|
23
34
|
sc_consumer = Soundcloud.consumer(consumer_token,consumer_secret,soundcloud_site)
|
24
35
|
return OAuth::AccessToken.new(sc_consumer, access_token, access_secret)
|
metadata
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soundcloud-ruby-api-wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Wagener
|
8
|
+
- Thor Kell
|
9
|
+
- Hannes Tyden
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
13
|
|
12
|
-
date:
|
14
|
+
date: 2010-05-18 00:00:00 +02:00
|
13
15
|
default_executable:
|
14
16
|
dependencies:
|
15
17
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +35,7 @@ dependencies:
|
|
33
35
|
version: 0.3.6
|
34
36
|
version:
|
35
37
|
description:
|
36
|
-
email: johannes@
|
38
|
+
email: johannes@soundcloud.com
|
37
39
|
executables: []
|
38
40
|
|
39
41
|
extensions: []
|
@@ -53,17 +55,16 @@ files:
|
|
53
55
|
- lib/soundcloud.rb
|
54
56
|
- lib/soundcloud/models/base.rb
|
55
57
|
- lib/soundcloud/models/comment.rb
|
56
|
-
- lib/soundcloud/models/event.rb
|
57
58
|
- lib/soundcloud/models/group.rb
|
58
59
|
- lib/soundcloud/models/playlist.rb
|
59
60
|
- lib/soundcloud/models/track.rb
|
60
61
|
- lib/soundcloud/models/user.rb
|
61
|
-
-
|
62
|
+
- lib/soundcloud/public_oauth_access_token.rb
|
63
|
+
- lib/soundcloud/sc_oauth_active_resource.rb
|
62
64
|
- soundcloud-ruby-api-wrapper.gemspec
|
63
65
|
- spec/fixtures/test_artwork.gif
|
64
66
|
- spec/fixtures/test_track.mp3
|
65
67
|
- spec/soundcloud_comment_spec.rb
|
66
|
-
- spec/soundcloud_event_spec.rb
|
67
68
|
- spec/soundcloud_group_spec.rb
|
68
69
|
- spec/soundcloud_playlist_spec.rb
|
69
70
|
- spec/soundcloud_spec.rb
|
@@ -100,7 +101,6 @@ specification_version: 3
|
|
100
101
|
summary: A ruby wrapper for the SoundCloud API
|
101
102
|
test_files:
|
102
103
|
- spec/soundcloud_comment_spec.rb
|
103
|
-
- spec/soundcloud_event_spec.rb
|
104
104
|
- spec/soundcloud_group_spec.rb
|
105
105
|
- spec/soundcloud_playlist_spec.rb
|
106
106
|
- spec/soundcloud_spec.rb
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Soundcloud
|
2
|
-
module Models
|
3
|
-
#
|
4
|
-
# SC API Attributes (as of 26/05/09):
|
5
|
-
# * type
|
6
|
-
# * id
|
7
|
-
# * created_at
|
8
|
-
# * resource_id
|
9
|
-
# * comment/track/user (embedded resource, depending on type)
|
10
|
-
#
|
11
|
-
# Custom Wrapper Attribute:
|
12
|
-
# * event_type (access to type attribute, since 'type' is a ruby keyword)
|
13
|
-
#
|
14
|
-
# Look up the resource attributes and filtering usage here:
|
15
|
-
#
|
16
|
-
# http://wiki.github.com/soundcloud/api/documentation#event
|
17
|
-
#
|
18
|
-
# Examples:
|
19
|
-
#
|
20
|
-
# # find the last 50 (default soundcloud limit) dropbox events and display the titles of the dropped tracks
|
21
|
-
# dropbox_events = sc_client.Event.find(:all,:params => {:filter => 'drop'})
|
22
|
-
#
|
23
|
-
# dropbox_events.each do |event|
|
24
|
-
# p event.track.title
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
# # find the last 50 (default soundcloud limit) events
|
28
|
-
# sc_client.Event.find(:all)
|
29
|
-
#
|
30
|
-
class Event < Base
|
31
|
-
cattr_accessor :element_name
|
32
|
-
self.element_name = 'event'
|
33
|
-
|
34
|
-
|
35
|
-
def event_type
|
36
|
-
return attributes['type']
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/ruby-api-wrapper.gemspec
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{ruby-api-wrapper}
|
5
|
-
s.version = "0.4.1"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Johannes Wagener"]
|
9
|
-
s.date = %q{2009-09-03}
|
10
|
-
s.email = %q{johannes@wagener.cc}
|
11
|
-
s.extra_rdoc_files = [
|
12
|
-
"LICENSE",
|
13
|
-
"README.html",
|
14
|
-
"README.rdoc"
|
15
|
-
]
|
16
|
-
s.files = [
|
17
|
-
".document",
|
18
|
-
".gitignore",
|
19
|
-
"LICENSE",
|
20
|
-
"README.html",
|
21
|
-
"README.rdoc",
|
22
|
-
"Rakefile",
|
23
|
-
"VERSION.yml",
|
24
|
-
"lib/soundcloud.rb",
|
25
|
-
"lib/soundcloud/models/base.rb",
|
26
|
-
"lib/soundcloud/models/comment.rb",
|
27
|
-
"lib/soundcloud/models/event.rb",
|
28
|
-
"lib/soundcloud/models/playlist.rb",
|
29
|
-
"lib/soundcloud/models/track.rb",
|
30
|
-
"lib/soundcloud/models/user.rb",
|
31
|
-
"ruby-api-wrapper.gemspec",
|
32
|
-
"spec/fixtures/test_artwork.gif",
|
33
|
-
"spec/fixtures/test_track.mp3",
|
34
|
-
"spec/soundcloud_comment_spec.rb",
|
35
|
-
"spec/soundcloud_event_spec.rb",
|
36
|
-
"spec/soundcloud_playlist_spec.rb",
|
37
|
-
"spec/soundcloud_spec.rb",
|
38
|
-
"spec/soundcloud_track_spec.rb",
|
39
|
-
"spec/soundcloud_user_spec.rb",
|
40
|
-
"spec/spec_helper.rb"
|
41
|
-
]
|
42
|
-
s.homepage = %q{http://github.com/soundcloud/ruby-api-wrapper}
|
43
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
44
|
-
s.require_paths = ["lib"]
|
45
|
-
s.rubygems_version = %q{1.3.4}
|
46
|
-
s.summary = %q{TODO}
|
47
|
-
s.test_files = [
|
48
|
-
"spec/soundcloud_comment_spec.rb",
|
49
|
-
"spec/soundcloud_event_spec.rb",
|
50
|
-
"spec/soundcloud_playlist_spec.rb",
|
51
|
-
"spec/soundcloud_spec.rb",
|
52
|
-
"spec/soundcloud_track_spec.rb",
|
53
|
-
"spec/soundcloud_user_spec.rb",
|
54
|
-
"spec/spec_helper.rb"
|
55
|
-
]
|
56
|
-
|
57
|
-
if s.respond_to? :specification_version then
|
58
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
59
|
-
s.specification_version = 3
|
60
|
-
|
61
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
62
|
-
s.add_runtime_dependency(%q<jwagener-oauth-active-resource>, [">= 0"])
|
63
|
-
s.add_runtime_dependency(%q<pelle-oauth>, [">= 0"])
|
64
|
-
else
|
65
|
-
s.add_dependency(%q<jwagener-oauth-active-resource>, [">= 0"])
|
66
|
-
s.add_dependency(%q<pelle-oauth>, [">= 0"])
|
67
|
-
end
|
68
|
-
else
|
69
|
-
s.add_dependency(%q<jwagener-oauth-active-resource>, [">= 0"])
|
70
|
-
s.add_dependency(%q<pelle-oauth>, [">= 0"])
|
71
|
-
end
|
72
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe 'Soundcloud::Models::Event' do
|
4
|
-
before(:all) do
|
5
|
-
@sc = Soundcloud.register({:access_token=> valid_oauth_access_token, :site => soundcloud_site})
|
6
|
-
# @api_test_1 = @sc.User.find('api-test-1')
|
7
|
-
# @api_test_2 = @sc.User.find('api-test-2')
|
8
|
-
# @api_test_3 = @sc.User.find('api-test-3')
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should get the last events' do
|
12
|
-
events = @sc.Event.find(:all)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should get fan events and they should provide the user resource' do
|
16
|
-
fan_events = @sc.Event.find(:all,:params => {:filter => 'fan'})
|
17
|
-
fan_events.each do |event|
|
18
|
-
event.event_type.should == "Fan"
|
19
|
-
event.user.username.should_not be nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should get track events and they should provide the track resource' do
|
24
|
-
events = @sc.Event.find(:all,:params => {:filter => 'track'})
|
25
|
-
events.each do |event|
|
26
|
-
|
27
|
-
#Temporary Fix because of the API
|
28
|
-
["Track", "Playlist"].should include(event.event_type)
|
29
|
-
|
30
|
-
#event.event_type.should == "Track"
|
31
|
-
#event.track.title.should_not be nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|