ADDED various models: playlist, track, artist, youtube_rating
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
source 'http://rubygems.org'
|
||||
|
||||
gem 'rake', '0.8.7'
|
||||
gem 'rake' #, '0.8.7'
|
||||
|
||||
gem 'rails', '3.0.5'
|
||||
gem 'jquery-rails', '>= 0.2.6'
|
||||
|
||||
+3
-7
@@ -33,7 +33,6 @@ GEM
|
||||
bcrypt-ruby (2.1.4)
|
||||
bcrypt-ruby (2.1.4-x86-mingw32)
|
||||
builder (2.1.2)
|
||||
crack (0.1.8)
|
||||
daemons (1.0.10)
|
||||
devise (1.3.4)
|
||||
bcrypt-ruby (~> 2.1.2)
|
||||
@@ -53,8 +52,6 @@ GEM
|
||||
haml (~> 3.0)
|
||||
railties (~> 3.0)
|
||||
hashie (1.0.0)
|
||||
httparty (0.7.7)
|
||||
crack (= 0.1.8)
|
||||
i18n (0.6.0)
|
||||
jquery-rails (1.0.9)
|
||||
railties (~> 3.0)
|
||||
@@ -116,7 +113,7 @@ GEM
|
||||
activesupport (= 3.0.5)
|
||||
rake (>= 0.8.7)
|
||||
thor (~> 0.14.4)
|
||||
rake (0.8.7)
|
||||
rake (0.9.2)
|
||||
ruby-openid (2.1.8)
|
||||
ruby-openid-apps-discovery (1.2.0)
|
||||
ruby-openid (>= 2.1.7)
|
||||
@@ -148,15 +145,14 @@ DEPENDENCIES
|
||||
devise
|
||||
haml-rails
|
||||
hashie
|
||||
httparty
|
||||
jquery-rails (>= 0.2.6)
|
||||
json
|
||||
mongrel (= 1.2.0.pre2)
|
||||
oa-oauth
|
||||
oa-openid
|
||||
paperclip (~> 2.3)
|
||||
json
|
||||
rails (= 3.0.5)
|
||||
rake (= 0.8.7)
|
||||
rake
|
||||
ruby_parser
|
||||
sqlite3
|
||||
sqlite3-ruby
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
class Artist < ActiveRecord::Base
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
class Playlist < ActiveRecord::Base
|
||||
has_many :tracks, :through => :playlists_tracks
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
class PlaylistsTracks < ActiveRecord::Base
|
||||
belongs_to :playlist
|
||||
belongs_to :track
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
class Track < ActiveRecord::Base
|
||||
belongs_to :artist
|
||||
has_many :playlists, :through => :playlists_tracks
|
||||
end
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class User < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
has_and_belongs_to_many :artists
|
||||
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable, :omniauthable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
class YoutubeVideoRating < ActiveRecord::Base
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class CreatePlaylists < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :playlists do |t|
|
||||
t.string :name
|
||||
t.references :user
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :playlists
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class CreateTracks < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :tracks do |t|
|
||||
t.string :title
|
||||
t.references :artist
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :tracks
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
class CreatePlaylistsTracks < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :playlists_tracks do |t|
|
||||
t.references :playlist
|
||||
t.references :track
|
||||
t.string :youtube_id
|
||||
t.integer :position
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :playlists_tracks
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
class CreateArtists < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :artists do |t|
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :artists_users do |t|
|
||||
t.references :user
|
||||
t.references :artist
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :artists
|
||||
drop_table :artists_users
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class CreateYoutubeVideoRatings < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :youtube_video_ratings do |t|
|
||||
t.string :search_query
|
||||
t.string :video_id
|
||||
t.integer :rating, :default => 0
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :youtube_video_ratings
|
||||
end
|
||||
end
|
||||
+43
-1
@@ -10,7 +10,41 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20110530191034) do
|
||||
ActiveRecord::Schema.define(:version => 20110606000240) do
|
||||
|
||||
create_table "artists", :force => true do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "artists_users", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "artist_id"
|
||||
end
|
||||
|
||||
create_table "playlists", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "playlists_tracks", :force => true do |t|
|
||||
t.integer "playlist_id"
|
||||
t.integer "track_id"
|
||||
t.string "youtube_id"
|
||||
t.integer "position"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "tracks", :force => true do |t|
|
||||
t.string "title"
|
||||
t.integer "artist_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "username"
|
||||
@@ -37,4 +71,12 @@ ActiveRecord::Schema.define(:version => 20110530191034) do
|
||||
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
||||
add_index "users", ["username"], :name => "index_users_on_username", :unique => true
|
||||
|
||||
create_table "youtube_video_ratings", :force => true do |t|
|
||||
t.string "search_query"
|
||||
t.string "video_id"
|
||||
t.integer "rating", :default => 0
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -79,7 +79,6 @@ module LastFM
|
||||
puts "<< ---- '#{current_class_name}.#{method.to_s}' -- TIME: #{response.time.to_s} ----"
|
||||
|
||||
hash = Hashie::Mash.new(JSON.parse(response.body))
|
||||
puts hash
|
||||
hash = method.to_s == "search" ? hash.results.send(node.to_sym) : hash.send(node.to_sym)
|
||||
|
||||
update_results "#{current_class_name}_#{method}", hash unless hash.blank?
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
owner:
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
owner:
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
playlist:
|
||||
track:
|
||||
youtube_id: MyString
|
||||
position: 1
|
||||
|
||||
two:
|
||||
playlist:
|
||||
track:
|
||||
youtube_id: MyString
|
||||
position: 1
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
title: MyString
|
||||
artist:
|
||||
|
||||
two:
|
||||
title: MyString
|
||||
artist:
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
search_query: MyString
|
||||
video_id: MyString
|
||||
rating: 1
|
||||
|
||||
two:
|
||||
search_query: MyString
|
||||
video_id: MyString
|
||||
rating: 1
|
||||
@@ -1,14 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ArtistControllerTest < ActionController::TestCase
|
||||
test "should get show" do
|
||||
get :show
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
class HomeControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SearchControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TracksControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ArtistTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PlaylistTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TrackInfoTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TrackTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
require 'test_helper'
|
||||
|
||||
class YoutubeVideoRatingTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user