soundcloud-ruby-api-wrapper 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/soundcloud/models/track.rb +24 -12
  3. data/lib/soundcloud.rb +1 -2
  4. data/ruby-api-wrapper.gemspec +2 -33
  5. data/spec/soundcloud_comment_spec.rb +1 -1
  6. data/spec/soundcloud_event_spec.rb +1 -1
  7. data/spec/soundcloud_playlist_spec.rb +1 -2
  8. data/spec/soundcloud_spec.rb +1 -1
  9. data/spec/soundcloud_track_spec.rb +19 -4
  10. data/spec/soundcloud_user_spec.rb +1 -1
  11. metadata +2 -33
  12. data/doc/classes/Soundcloud/Models/Comment.html +0 -197
  13. data/doc/classes/Soundcloud/Models/Comment.src/M000007.html +0 -22
  14. data/doc/classes/Soundcloud/Models/Event.html +0 -190
  15. data/doc/classes/Soundcloud/Models/Event.src/M000009.html +0 -18
  16. data/doc/classes/Soundcloud/Models/Playlist.html +0 -220
  17. data/doc/classes/Soundcloud/Models/Playlist.src/M000009.html +0 -20
  18. data/doc/classes/Soundcloud/Models/Playlist.src/M000010.html +0 -20
  19. data/doc/classes/Soundcloud/Models/Track.html +0 -348
  20. data/doc/classes/Soundcloud/Models/Track.src/M000003.html +0 -29
  21. data/doc/classes/Soundcloud/Models/Track.src/M000004.html +0 -18
  22. data/doc/classes/Soundcloud/Models/Track.src/M000005.html +0 -22
  23. data/doc/classes/Soundcloud/Models/Track.src/M000006.html +0 -28
  24. data/doc/classes/Soundcloud/Models/User.html +0 -284
  25. data/doc/classes/Soundcloud/Models/User.src/M000008.html +0 -18
  26. data/doc/classes/Soundcloud/Models.html +0 -135
  27. data/doc/classes/Soundcloud.html +0 -213
  28. data/doc/classes/Soundcloud.src/M000001.html +0 -24
  29. data/doc/classes/Soundcloud.src/M000002.html +0 -19
  30. data/doc/created.rid +0 -1
  31. data/doc/files/lib/soundcloud/models/base_rb.html +0 -101
  32. data/doc/files/lib/soundcloud/models/comment_rb.html +0 -101
  33. data/doc/files/lib/soundcloud/models/event_rb.html +0 -101
  34. data/doc/files/lib/soundcloud/models/playlist_rb.html +0 -101
  35. data/doc/files/lib/soundcloud/models/track_rb.html +0 -101
  36. data/doc/files/lib/soundcloud/models/user_rb.html +0 -101
  37. data/doc/files/lib/soundcloud_rb.html +0 -127
  38. data/doc/fr_class_index.html +0 -33
  39. data/doc/fr_file_index.html +0 -33
  40. data/doc/fr_method_index.html +0 -36
  41. data/doc/index.html +0 -24
  42. data/doc/rdoc-style.css +0 -208
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 2
3
+ :minor: 3
4
4
  :patch: 1
@@ -87,7 +87,6 @@ module Soundcloud
87
87
  can_be_a_single_changeable :favorite
88
88
 
89
89
  cattr_accessor :element_name
90
- attr_accessor :asset_data
91
90
  self.element_name = 'track'
92
91
 
93
92
  def download_url
@@ -106,14 +105,13 @@ module Soundcloud
106
105
  end
107
106
 
108
107
  # multipart stuff, to upload a soundfile
109
-
110
- @asset_data = nil
108
+
111
109
  def set_asset_data(file)
112
- @asset_data = file
110
+ self.asset_data = file
113
111
  end
114
112
 
115
113
  def update
116
- if not @asset_data.nil?
114
+ if not self.asset_data.nil?
117
115
  raise 'Multipart update is NotImplemented'
118
116
  self.class.send_multipart_request(:put,'/tracks/#{self.id}','replacement[asset_data]',@asset_data)
119
117
  end
@@ -121,16 +119,30 @@ module Soundcloud
121
119
  end
122
120
 
123
121
  def create
124
- if @asset_data.nil?
122
+ if self.asset_data.nil?
125
123
  super
126
124
  else
127
- #post asset_data
128
- params = {'track[title]' => self.title,'track[sharing]' => self.sharing}
129
- response = connection.handle_response(self.class.send_multipart_request(:post,'/tracks','track[asset_data]',@asset_data,params))
125
+ #post asset_data
126
+
127
+ # default to private
128
+ if self.sharing?.nil?
129
+ self.sharing = 'private'
130
+ end
131
+
132
+ params = ActiveSupport::OrderedHash.new
133
+ self.attributes.reject { |k,v| k.to_s == 'asset_data'}.each { |k,v|
134
+ params["track[#{k}]".to_sym] = v
135
+ }
136
+
137
+ # ignore is added because the multipart gem is adding an extra new line
138
+ # to the last parameter which will break parsing of track[sharing]
139
+ params[:ignore] = 'multipart bug'
140
+
141
+ response = connection.handle_response(self.class.send_multipart_request(:post,'/tracks','track[asset_data]',self.asset_data,params))
142
+
130
143
  self.id = id_from_response(response)
131
- @asset_data = nil
132
- # second, 'normal' update request
133
- update
144
+ load_attributes_from_response(response)
145
+ self.asset_data = nil
134
146
  end
135
147
  end
136
148
  end
data/lib/soundcloud.rb CHANGED
@@ -23,8 +23,7 @@ module Soundcloud
23
23
  :site => site,
24
24
  :request_token_path => "/oauth/request_token",
25
25
  :access_token_path => "/oauth/access_token",
26
- :authorize_path => "/oauth/authorize",
27
- :scheme => :query_string
26
+ :authorize_path => "/oauth/authorize"
28
27
  })
29
28
  end
30
29
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ruby-api-wrapper}
5
- s.version = "0.2.1"
5
+ s.version = "0.3.1"
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-07-03}
9
+ s.date = %q{2009-07-10}
10
10
  s.email = %q{johannes@wagener.cc}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -21,37 +21,6 @@ Gem::Specification.new do |s|
21
21
  "README.rdoc",
22
22
  "Rakefile",
23
23
  "VERSION.yml",
24
- "doc/classes/Soundcloud.html",
25
- "doc/classes/Soundcloud.src/M000001.html",
26
- "doc/classes/Soundcloud.src/M000002.html",
27
- "doc/classes/Soundcloud/Models.html",
28
- "doc/classes/Soundcloud/Models/Comment.html",
29
- "doc/classes/Soundcloud/Models/Comment.src/M000007.html",
30
- "doc/classes/Soundcloud/Models/Event.html",
31
- "doc/classes/Soundcloud/Models/Event.src/M000009.html",
32
- "doc/classes/Soundcloud/Models/Playlist.html",
33
- "doc/classes/Soundcloud/Models/Playlist.src/M000009.html",
34
- "doc/classes/Soundcloud/Models/Playlist.src/M000010.html",
35
- "doc/classes/Soundcloud/Models/Track.html",
36
- "doc/classes/Soundcloud/Models/Track.src/M000003.html",
37
- "doc/classes/Soundcloud/Models/Track.src/M000004.html",
38
- "doc/classes/Soundcloud/Models/Track.src/M000005.html",
39
- "doc/classes/Soundcloud/Models/Track.src/M000006.html",
40
- "doc/classes/Soundcloud/Models/User.html",
41
- "doc/classes/Soundcloud/Models/User.src/M000008.html",
42
- "doc/created.rid",
43
- "doc/files/lib/soundcloud/models/base_rb.html",
44
- "doc/files/lib/soundcloud/models/comment_rb.html",
45
- "doc/files/lib/soundcloud/models/event_rb.html",
46
- "doc/files/lib/soundcloud/models/playlist_rb.html",
47
- "doc/files/lib/soundcloud/models/track_rb.html",
48
- "doc/files/lib/soundcloud/models/user_rb.html",
49
- "doc/files/lib/soundcloud_rb.html",
50
- "doc/fr_class_index.html",
51
- "doc/fr_file_index.html",
52
- "doc/fr_method_index.html",
53
- "doc/index.html",
54
- "doc/rdoc-style.css",
55
24
  "lib/soundcloud.rb",
56
25
  "lib/soundcloud/models/base.rb",
57
26
  "lib/soundcloud/models/comment.rb",
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe 'Soundcloud::Models::Comment' do
4
4
  before(:all) do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe 'Soundcloud::Models::Event' do
4
4
  before(:all) do
@@ -1,5 +1,4 @@
1
- require 'spec_helper'
2
-
1
+ require File.dirname(__FILE__) + '/spec_helper'
3
2
 
4
3
  describe 'Soundcloud::Models::Playlist' do
5
4
  before(:all) do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  # this spec tests against api.sandbox-soundcloud.com
4
4
  # it makes the follwing assumptions
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe "Soundcloud::Models::Track" do
4
4
  before(:all) do
@@ -25,13 +25,28 @@ describe "Soundcloud::Models::Track" do
25
25
 
26
26
  end
27
27
 
28
+ it "should be able to create a new track and default to sharing=private" do
29
+ test_track_file = File.new( File.dirname(__FILE__) + '/fixtures/test_track.mp3')
30
+ track = @sc.Track.create({:title => "test", :asset_data => test_track_file})
31
+ track.sharing.should == 'private'
32
+ track.permalink.should_not == nil
33
+ track.destroy
34
+ end
35
+
36
+ it "should be able to create a new public track and sharing should stay public" do
37
+ test_track_file = File.new( File.dirname(__FILE__) + '/fixtures/test_track.mp3')
38
+ track = @sc.Track.create({:title => "test", :sharing => 'public', :asset_data => test_track_file})
39
+ track.sharing.should == 'public'
40
+ track.permalink.should_not == nil
41
+ track.destroy
42
+ end
43
+
28
44
  it 'should be able to create a new track and remove it' do
29
- test_track_file = File.new('spec/fixtures/test_track.mp3')
45
+ test_track_file = File.new(File.dirname(__FILE__) + '/fixtures/test_track.mp3')
30
46
 
31
47
  track = @sc.Track.new
32
48
  track.title = 'API Test 1'
33
- track.sharing = 'private'
34
- # track.set_asset_data(test_track_file)
49
+ track.sharing = 'private'
35
50
  track.asset_data = test_track_file
36
51
  track.save
37
52
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe "Soundcloud::Models::User" do
4
4
  before(:all) do
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.2.1
4
+ version: 0.3.1
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-07-03 00:00:00 -07:00
12
+ date: 2009-07-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,37 +50,6 @@ files:
50
50
  - README.rdoc
51
51
  - Rakefile
52
52
  - VERSION.yml
53
- - doc/classes/Soundcloud.html
54
- - doc/classes/Soundcloud.src/M000001.html
55
- - doc/classes/Soundcloud.src/M000002.html
56
- - doc/classes/Soundcloud/Models.html
57
- - doc/classes/Soundcloud/Models/Comment.html
58
- - doc/classes/Soundcloud/Models/Comment.src/M000007.html
59
- - doc/classes/Soundcloud/Models/Event.html
60
- - doc/classes/Soundcloud/Models/Event.src/M000009.html
61
- - doc/classes/Soundcloud/Models/Playlist.html
62
- - doc/classes/Soundcloud/Models/Playlist.src/M000009.html
63
- - doc/classes/Soundcloud/Models/Playlist.src/M000010.html
64
- - doc/classes/Soundcloud/Models/Track.html
65
- - doc/classes/Soundcloud/Models/Track.src/M000003.html
66
- - doc/classes/Soundcloud/Models/Track.src/M000004.html
67
- - doc/classes/Soundcloud/Models/Track.src/M000005.html
68
- - doc/classes/Soundcloud/Models/Track.src/M000006.html
69
- - doc/classes/Soundcloud/Models/User.html
70
- - doc/classes/Soundcloud/Models/User.src/M000008.html
71
- - doc/created.rid
72
- - doc/files/lib/soundcloud/models/base_rb.html
73
- - doc/files/lib/soundcloud/models/comment_rb.html
74
- - doc/files/lib/soundcloud/models/event_rb.html
75
- - doc/files/lib/soundcloud/models/playlist_rb.html
76
- - doc/files/lib/soundcloud/models/track_rb.html
77
- - doc/files/lib/soundcloud/models/user_rb.html
78
- - doc/files/lib/soundcloud_rb.html
79
- - doc/fr_class_index.html
80
- - doc/fr_file_index.html
81
- - doc/fr_method_index.html
82
- - doc/index.html
83
- - doc/rdoc-style.css
84
53
  - lib/soundcloud.rb
85
54
  - lib/soundcloud/models/base.rb
86
55
  - lib/soundcloud/models/comment.rb
@@ -1,197 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Soundcloud::Models::Comment</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Soundcloud::Models::Comment</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../../files/lib/soundcloud/models/comment_rb.html">
59
- lib/soundcloud/models/comment.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Base
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
- <div id="description">
82
- <p>
83
- SC API Attributes (as of 26/05/09):
84
- </p>
85
- <ul>
86
- <li>body
87
-
88
- </li>
89
- <li>timestamp
90
-
91
- </li>
92
- <li>id
93
-
94
- </li>
95
- <li>track_id
96
-
97
- </li>
98
- <li>user_id
99
-
100
- </li>
101
- <li>uri
102
-
103
- </li>
104
- </ul>
105
- <p>
106
- Custom Wrapper Attributes/Methods:
107
- </p>
108
- <ul>
109
- <li>user
110
-
111
- </li>
112
- <li>track
113
-
114
- </li>
115
- </ul>
116
- <p>
117
- Look up the resource attributes and filtering usage here:
118
- </p>
119
- <p>
120
- <a
121
- href="http://wiki.github.com/soundcloud/api/documentation#comment">wiki.github.com/soundcloud/api/documentation#comment</a>
122
- </p>
123
- <p>
124
- Examples:
125
- </p>
126
- <pre>
127
- # add a comment to a track
128
- some_track = sc_client.Track.find('some-track')
129
- sc_client.Comment.create({:track =&gt; some_track, :body =&gt; 'Nice Track!'})
130
-
131
- # optionally you can add a timestamp (in milliseconds)
132
- sc_client.Comment.create({:track =&gt; some_track, :body =&gt; 'nice drums @ the 5th second!', :timestamp =&gt; 5000})
133
-
134
- # display all comments of some track
135
- some_track.comments.each do |comment|
136
- p &quot;#{comment.user.full_name} wrote: #{comment.body}&quot;
137
- end
138
- </pre>
139
-
140
- </div>
141
-
142
-
143
- </div>
144
-
145
- <div id="method-list">
146
- <h3 class="section-bar">Methods</h3>
147
-
148
- <div class="name-list">
149
- <a href="#M000007">new</a>&nbsp;&nbsp;
150
- </div>
151
- </div>
152
-
153
- </div>
154
-
155
-
156
- <!-- if includes -->
157
-
158
- <div id="section">
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
- <!-- if method_list -->
168
- <div id="methods">
169
- <h3 class="section-bar">Public Class methods</h3>
170
-
171
- <div id="method-M000007" class="method-detail">
172
- <a name="M000007"></a>
173
-
174
- <div class="method-heading">
175
- <a href="Comment.src/M000007.html" target="Code" class="method-signature"
176
- onclick="popupCode('Comment.src/M000007.html');return false;">
177
- <span class="method-name">new</span><span class="method-args">(options)</span>
178
- </a>
179
- </div>
180
-
181
- <div class="method-description">
182
- </div>
183
- </div>
184
-
185
-
186
- </div>
187
-
188
-
189
- </div>
190
-
191
-
192
- <div id="validator-badges">
193
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
194
- </div>
195
-
196
- </body>
197
- </html>