soundcloud-ruby-api-wrapper 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/lib/soundcloud.rb +23 -1
- data/lib/soundcloud/models/group.rb +24 -0
- data/lib/soundcloud/models/user.rb +13 -1
- data/soundcloud-ruby-api-wrapper.gemspec +5 -2
- data/spec/soundcloud_group_spec.rb +50 -0
- data/spec/soundcloud_spec.rb +1 -2
- data/spec/soundcloud_track_spec.rb +3 -0
- metadata +5 -2
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "soundcloud-ruby-api-wrapper"
|
8
|
-
gem.summary =
|
8
|
+
gem.summary = "A ruby wrapper for the SoundCloud API"
|
9
9
|
gem.email = "johannes@wagener.cc"
|
10
10
|
gem.homepage = "http://github.com/soundcloud/ruby-api-wrapper"
|
11
11
|
gem.authors = ["Johannes Wagener"]
|
data/VERSION.yml
CHANGED
data/lib/soundcloud.rb
CHANGED
@@ -44,7 +44,27 @@ module Soundcloud
|
|
44
44
|
#
|
45
45
|
def self.register(options = {})
|
46
46
|
options[:site] = options[:site] || 'http://api.soundcloud.com'
|
47
|
-
OAuthActiveResource.register(self.ancestors.first, self.ancestors.first.const_get('Models'), options)
|
47
|
+
mod = OAuthActiveResource.register(self.ancestors.first, self.ancestors.first.const_get('Models'), options)
|
48
|
+
add_resolver_to_mod(mod)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# Quick hack to add support api.soundcloud.com/resolve . TODO jw cleanup :)
|
53
|
+
def self.add_resolver_to_mod(mod)
|
54
|
+
mod.module_eval do
|
55
|
+
def self.resolve(url)
|
56
|
+
base = self.const_get('Base')
|
57
|
+
response = base.oauth_connection.get("/resolve?url=#{url}")
|
58
|
+
if response.code == "302"
|
59
|
+
path = URI.parse(response.header['Location']).path
|
60
|
+
resource_class = base.new.send(:find_or_create_resource_for_collection, path.split('/')[-2])
|
61
|
+
resource_class.find(:one, :from => path)
|
62
|
+
else
|
63
|
+
raise ActiveResource::ResourceNotFound.new(response)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
mod
|
48
68
|
end
|
49
69
|
end
|
50
70
|
|
@@ -54,4 +74,6 @@ require 'soundcloud/models/comment'
|
|
54
74
|
require 'soundcloud/models/event'
|
55
75
|
require 'soundcloud/models/playlist'
|
56
76
|
require 'soundcloud/models/track'
|
77
|
+
require 'soundcloud/models/group'
|
78
|
+
|
57
79
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Soundcloud
|
2
|
+
module Models
|
3
|
+
# Look up the resource attributes and filtering usage here:
|
4
|
+
#
|
5
|
+
# SC API Attributes (as of 26/05/09):
|
6
|
+
# ......
|
7
|
+
# * users (array)
|
8
|
+
# * moderators (array)
|
9
|
+
# * members (array)
|
10
|
+
# * contributors (array)
|
11
|
+
# * tracks (array)
|
12
|
+
|
13
|
+
class Group < Base
|
14
|
+
has_many :users, :moderators, :members, :contributors, :tracks
|
15
|
+
|
16
|
+
# NOT IMPLEMENTED ON THE API YET
|
17
|
+
#cattr_accessor :data_attributes
|
18
|
+
#self.data_attributes = ['artwork_data']
|
19
|
+
|
20
|
+
cattr_accessor :element_name
|
21
|
+
self.element_name = 'group'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -97,7 +97,19 @@ module Soundcloud
|
|
97
97
|
end
|
98
98
|
|
99
99
|
class Fan < User #:nodoc:
|
100
|
-
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class Creator < User #:nodoc:
|
103
|
+
end
|
104
|
+
|
105
|
+
class Contributor < User
|
106
|
+
end
|
107
|
+
|
108
|
+
class Member < User #:nodoc:
|
109
|
+
end
|
110
|
+
|
111
|
+
class Moderator < User #:nodoc:
|
112
|
+
end
|
101
113
|
end
|
102
114
|
end
|
103
115
|
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{soundcloud-ruby-api-wrapper}
|
5
|
-
s.version = "0.4.
|
5
|
+
s.version = "0.4.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Johannes Wagener"]
|
9
|
-
s.date = %q{2009-11-
|
9
|
+
s.date = %q{2009-11-21}
|
10
10
|
s.email = %q{johannes@wagener.cc}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"lib/soundcloud/models/base.rb",
|
26
26
|
"lib/soundcloud/models/comment.rb",
|
27
27
|
"lib/soundcloud/models/event.rb",
|
28
|
+
"lib/soundcloud/models/group.rb",
|
28
29
|
"lib/soundcloud/models/playlist.rb",
|
29
30
|
"lib/soundcloud/models/track.rb",
|
30
31
|
"lib/soundcloud/models/user.rb",
|
@@ -34,6 +35,7 @@ Gem::Specification.new do |s|
|
|
34
35
|
"spec/fixtures/test_track.mp3",
|
35
36
|
"spec/soundcloud_comment_spec.rb",
|
36
37
|
"spec/soundcloud_event_spec.rb",
|
38
|
+
"spec/soundcloud_group_spec.rb",
|
37
39
|
"spec/soundcloud_playlist_spec.rb",
|
38
40
|
"spec/soundcloud_spec.rb",
|
39
41
|
"spec/soundcloud_track_spec.rb",
|
@@ -48,6 +50,7 @@ Gem::Specification.new do |s|
|
|
48
50
|
s.test_files = [
|
49
51
|
"spec/soundcloud_comment_spec.rb",
|
50
52
|
"spec/soundcloud_event_spec.rb",
|
53
|
+
"spec/soundcloud_group_spec.rb",
|
51
54
|
"spec/soundcloud_playlist_spec.rb",
|
52
55
|
"spec/soundcloud_spec.rb",
|
53
56
|
"spec/soundcloud_track_spec.rb",
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Soundcloud::Models::Group" do
|
4
|
+
before(:all) do
|
5
|
+
@sc = Soundcloud.register({:access_token=> valid_oauth_access_token, :site => soundcloud_site})
|
6
|
+
|
7
|
+
@api_test_1 = @sc.User.find('api-test-1')
|
8
|
+
@api_test_2 = @sc.User.find('api-test-2')
|
9
|
+
@api_test_3 = @sc.User.find('api-test-3')
|
10
|
+
end
|
11
|
+
|
12
|
+
# static-test-group id = 2937
|
13
|
+
# api_test_1 - creator
|
14
|
+
# api_test_3 - member
|
15
|
+
# api_test_2 track1 should be contributied
|
16
|
+
|
17
|
+
it 'should find all (50) groups' do
|
18
|
+
@sc.Group.find(:all)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should get the fixture group' do
|
22
|
+
group = @sc.Group.find(2937)
|
23
|
+
group.name.should == "static-test-group"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
describe 'users' do
|
28
|
+
before do
|
29
|
+
@group = @sc.Group.find(2937)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have the right creatotr api_test_1' do
|
33
|
+
@group.creator.uri.should == @api_test_1.uri
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have api_test_3 has a member' do
|
37
|
+
@group.members.should include(@api_test_3)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should have api_test_2 as a contributor' do
|
41
|
+
@group.contributors.should include(@api_test_2)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should have a contributed track' do
|
45
|
+
@group.tracks.map(&:uri).should include('http://api.sandbox-soundcloud.com/tracks/875948')
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/spec/soundcloud_spec.rb
CHANGED
@@ -38,6 +38,5 @@ describe "Soundcloud" do
|
|
38
38
|
sc = Soundcloud.register({:access_token=> valid_oauth_access_token, :site => soundcloud_site})
|
39
39
|
sc.to_s.should match(/Soundcloud::.+/)
|
40
40
|
lambda{ sc.User.find(:one, :from => "/me")}.should_not raise_error ActiveResource::UnauthorizedAccess
|
41
|
-
end
|
42
|
-
|
41
|
+
end
|
43
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Wagener
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-21 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/soundcloud/models/base.rb
|
55
55
|
- lib/soundcloud/models/comment.rb
|
56
56
|
- lib/soundcloud/models/event.rb
|
57
|
+
- lib/soundcloud/models/group.rb
|
57
58
|
- lib/soundcloud/models/playlist.rb
|
58
59
|
- lib/soundcloud/models/track.rb
|
59
60
|
- lib/soundcloud/models/user.rb
|
@@ -63,6 +64,7 @@ files:
|
|
63
64
|
- spec/fixtures/test_track.mp3
|
64
65
|
- spec/soundcloud_comment_spec.rb
|
65
66
|
- spec/soundcloud_event_spec.rb
|
67
|
+
- spec/soundcloud_group_spec.rb
|
66
68
|
- spec/soundcloud_playlist_spec.rb
|
67
69
|
- spec/soundcloud_spec.rb
|
68
70
|
- spec/soundcloud_track_spec.rb
|
@@ -99,6 +101,7 @@ summary: A ruby wrapper for the SoundCloud API
|
|
99
101
|
test_files:
|
100
102
|
- spec/soundcloud_comment_spec.rb
|
101
103
|
- spec/soundcloud_event_spec.rb
|
104
|
+
- spec/soundcloud_group_spec.rb
|
102
105
|
- spec/soundcloud_playlist_spec.rb
|
103
106
|
- spec/soundcloud_spec.rb
|
104
107
|
- spec/soundcloud_track_spec.rb
|