This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$(".session li.file").each(function() { | |
elem = $(this).children(".file-info"); | |
$(this).click(function() { | |
if($(this).hasClass("file-active")) | |
{ | |
$(this).removeClass("file-active") | |
} else { | |
$(this).addClass("file-active") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$(".session li.file").each(function() { | |
$(this).click(function() { | |
$(this).toggleClass("file-active"); | |
$(this).children(".file-info").toggleClass("hidden"); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Song < ActiveRecord::Base | |
belongs_to :session | |
validates :file_name, :presence => true | |
validate :file_name_has_to_be_audio | |
def file_name_has_to_be_audio | |
unless ['mp3', 'MP3', 'flac', 'FLAC', 'wav', 'WAV'].include? file_name.split(".").last | |
errors.add(:file_name, "has to be mp3/flac/wav file") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.2-p290 :021 > def f_in_d(dir) | |
ruby-1.9.2-p290 :022?> d = Dir.new(dir) | |
ruby-1.9.2-p290 :023?> audio_files = Array.new | |
ruby-1.9.2-p290 :024?> d.entries.each do |f| | |
ruby-1.9.2-p290 :025 > if File.directory?(f) && f != "." && f != ".." | |
ruby-1.9.2-p290 :026?> audio_files.push(Dir.glob("#{dir}/#{f}/*.{mp3,flac,wav}")) | |
ruby-1.9.2-p290 :027?> end | |
ruby-1.9.2-p290 :028?> end | |
ruby-1.9.2-p290 :029?> return audio_files | |
ruby-1.9.2-p290 :030?> end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.2-p290 :001 > dir = "/media/james/howling_vibes/aufnahmen/" | |
=> "/media/james/howling_vibes/aufnahmen/" | |
ruby-1.9.2-p290 :002 > d = Dir.new(dir) | |
=> #<Dir:/media/james/howling_vibes/aufnahmen/> | |
ruby-1.9.2-p290 :003 > audio_files = [] | |
=> [] | |
ruby-1.9.2-p290 :004 > d.entries.each do |f| | |
ruby-1.9.2-p290 :005 > if File.directory?(f) && f != "." && f != ".." | |
ruby-1.9.2-p290 :006?> audio_files.push(Dir.glob("#{dir}/#{f}/*.{mp3,flac,wav}")) | |
ruby-1.9.2-p290 :007?> end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Failures: | |
1) Archive::ArchiveDirectory should initalize | |
Failure/Error: ArchiveDirectory.new(dir).directory.should == dir | |
NameError: | |
uninitialized constant ArchiveDirectory | |
# ./spec/lib/archive_spec.rb:6:in `block (2 levels) in <top (required)>' | |
Finished in 0.31153 seconds | |
1 example, 1 failure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Archive | |
class Directory | |
attr_accessor :directory | |
def initialize(dir) | |
@directory = dir | |
@sessions = [] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## sessions_controller.rb ## | |
def new | |
@title = "Add session" | |
archive = Archive::Directory.new(Rails.root.join("spec/fixtures/archive")) | |
@new_files = files_in_archive_not_in_db(archive) | |
end | |
private |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe SessionsController do | |
render_views | |
# | |
# | |
# | |
describe "GET 'new'" do | |
it "should be successful" do | |
get :new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#session_spec.rb | |
it "should show songs in the right order" do | |
song1 = @session.songs.create(:file_name => "03.testing.mp3") | |
song2 = @session.songs.create(:file_name => "01.testing.mp3") | |
@session.songs.should == [song2, song1] | |
end | |
#session.rb |
OlderNewer