play 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/play.rb +1 -1
- data/lib/play/album.rb +9 -0
- data/lib/play/app/api.rb +19 -0
- data/play.gemspec +3 -2
- data/test/test_album.rb +18 -0
- metadata +6 -4
data/lib/play.rb
CHANGED
data/lib/play/album.rb
CHANGED
@@ -2,5 +2,14 @@ module Play
|
|
2
2
|
class Album < ActiveRecord::Base
|
3
3
|
has_many :songs
|
4
4
|
belongs_to :artist
|
5
|
+
|
6
|
+
# Queue up an entire ALBUM!
|
7
|
+
#
|
8
|
+
# user - the User who is requesting the album to be queued
|
9
|
+
#
|
10
|
+
# Returns nothing.
|
11
|
+
def enqueue!(user)
|
12
|
+
songs.each{ |song| song.enqueue!(user) }
|
13
|
+
end
|
5
14
|
end
|
6
15
|
end
|
data/lib/play/app/api.rb
CHANGED
@@ -50,6 +50,25 @@ module Play
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
post "/api/add_album" do
|
54
|
+
api_authenticate
|
55
|
+
artist = Play::Artist.find_by_name(params[:artist_name])
|
56
|
+
if artist
|
57
|
+
album = artist.albums.find_by_name(params[:album_name])
|
58
|
+
if album
|
59
|
+
album.enqueue!(api_user)
|
60
|
+
{
|
61
|
+
'artist_name' => artist.name,
|
62
|
+
'album_name' => album.name
|
63
|
+
}.to_json
|
64
|
+
else
|
65
|
+
error("Sorry, but we couldn't find that album.")
|
66
|
+
end
|
67
|
+
else
|
68
|
+
error("Sorry, but we couldn't find that artist.")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
53
72
|
post "/api/remove" do
|
54
73
|
error "This hasn't been implemented yet. Whoops."
|
55
74
|
end
|
data/play.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'play'
|
16
|
-
s.version = '0.0.
|
17
|
-
s.date = '2011-05-
|
16
|
+
s.version = '0.0.2'
|
17
|
+
s.date = '2011-05-06'
|
18
18
|
s.rubyforge_project = 'play'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -111,6 +111,7 @@ Gem::Specification.new do |s|
|
|
111
111
|
public/css/base.css
|
112
112
|
test/helper.rb
|
113
113
|
test/spec/mini.rb
|
114
|
+
test/test_album.rb
|
114
115
|
test/test_api.rb
|
115
116
|
test/test_app.rb
|
116
117
|
test/test_artist.rb
|
data/test/test_album.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
context "Album" do
|
4
|
+
fixtures do
|
5
|
+
@artist = Play::Artist.create(:name => "Justice")
|
6
|
+
@album = Album.create(:name => 'Cross', :artist => @artist)
|
7
|
+
@song = Play::Song.create(:title => "Stress",
|
8
|
+
:artist => @artist,
|
9
|
+
:album => @album)
|
10
|
+
@user = User.create
|
11
|
+
end
|
12
|
+
|
13
|
+
test "enqueueing songs" do
|
14
|
+
Song.any_instance.expects(:enqueue!).with(@user).times(1)
|
15
|
+
@album.enqueue!(@user)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: play
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zach Holman
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-06 00:00:00 -07:00
|
19
19
|
default_executable: play
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- public/css/base.css
|
245
245
|
- test/helper.rb
|
246
246
|
- test/spec/mini.rb
|
247
|
+
- test/test_album.rb
|
247
248
|
- test/test_api.rb
|
248
249
|
- test/test_app.rb
|
249
250
|
- test/test_artist.rb
|
@@ -288,6 +289,7 @@ signing_key:
|
|
288
289
|
specification_version: 2
|
289
290
|
summary: "Your company's dj. \xE2\x96\xBA"
|
290
291
|
test_files:
|
292
|
+
- test/test_album.rb
|
291
293
|
- test/test_api.rb
|
292
294
|
- test/test_app.rb
|
293
295
|
- test/test_artist.rb
|