Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updates for sproutcore readiness

  • Loading branch information...
commit 759a104c831eace68c46b02c12924faa4f28bd3d 1 parent efefc9e
Sudara authored
3  app/controllers/assets_controller.rb
@@ -30,6 +30,9 @@ def index
30 30
             page.replace 'stash', :partial => "assets"
31 31
           end
32 32
         end
  33
+        format.json do
  34
+          render :json => '{ records : ' + @assets.to_json(:methods => [:name, :type, :length], :only => [:id,:name,:listens_count, :description,:permalink,:hotness]) + '}'
  35
+        end
33 36
       end
34 37
   end
35 38
 
2  app/controllers/users_controller.rb
@@ -31,7 +31,7 @@ def index
31 31
       # API 
32 32
       format.json do
33 33
         users = User.musicians.find(:all,:include => :pic)
34  
-        render :json => '{ records : ' + users.to_json(:methods => [:name, :type], :only => [:id,:name,:comments_count,:bio_html,:website,:login]) + '}'
  34
+        render :json => '{ records : ' + users.to_json(:methods => [:name, :type, :avatar], :only => [:id,:name,:comments_count,:bio_html,:website,:login,:tracks_count,:created_at]) + '}'
35 35
       end
36 36
      # format.fbml do
37 37
      #   @users = User.paginate(:all, :per_page => 10, :order => 'listens_count DESC', :page => params[:page])
5  app/models/asset.rb
@@ -136,6 +136,11 @@ def length
136 136
     self.class.formatted_time(self[:length])
137 137
   end
138 138
   
  139
+  # hack for sproutcore json
  140
+  def type
  141
+    'Track'
  142
+  end
  143
+  
139 144
   protected 
140 145
   
141 146
   def set_title_to_filename
2  app/models/asset/uploading.rb
@@ -40,7 +40,7 @@ class Asset
40 40
                   # Don't know why can't upload mp3 files (zip files are passed)
41 41
                   # so remove content_type for development and test environments
42 42
                   :content_type => (RAILS_ENV == 'production' ? ['audio/mpeg','application/zip'] : nil),
43  
-                  :max_size => 40.megabytes,
  43
+                  :max_size => 60.megabytes,
44 44
                   :path_prefix => File.join(ALONETONE.path_prefix, "mp3")
45 45
                     
46 46
   validates_as_attachment
10  app/models/user/profile.rb
@@ -24,11 +24,11 @@ def has_as_favorite?(asset)
24 24
 
25 25
   def dummy_pic(size)
26 26
     case size
27  
-      when :album then 'no-pic-200.png'
28  
-      when :large then 'no-pic-83.png'
29  
-      when :small then 'no-pic-50.png'
30  
-      when :tiny then 'no-pic-25.png'
31  
-      when nil then 'no-pic-200.jpg' 
  27
+      when :album then 'no-pic.png'
  28
+      when :large then 'no-pic_large.png'
  29
+      when :small then 'no-pic_small.png'
  30
+      when :tiny then 'no-pic_tiny.png'
  31
+      when nil then 'no-pic.png' 
32 32
     end
33 33
   end
34 34
   
132  lib/tasks/rspec.rake
... ...
@@ -0,0 +1,132 @@
  1
+raise "To avoid rake task loading problems: run 'rake clobber' in vendor/plugins/rspec" if File.directory?(File.join(File.dirname(__FILE__), *%w[.. .. vendor plugins rspec pkg]))
  2
+raise "To avoid rake task loading problems: run 'rake clobber' in vendor/plugins/rspec-rails" if File.directory?(File.join(File.dirname(__FILE__), *%w[.. .. vendor plugins rspec-rails pkg]))
  3
+
  4
+# In rails 1.2, plugins aren't available in the path until they're loaded.
  5
+# Check to see if the rspec plugin is installed first and require
  6
+# it if it is.  If not, use the gem version.
  7
+rspec_base = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec/lib')
  8
+$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
  9
+require 'spec/rake/spectask'
  10
+
  11
+spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
  12
+task :noop do
  13
+end
  14
+
  15
+task :default => :spec
  16
+task :stats => "spec:statsetup"
  17
+
  18
+desc "Run all specs in spec directory (excluding plugin specs)"
  19
+Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
  20
+  t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
  21
+  t.spec_files = FileList['spec/**/*_spec.rb']
  22
+end
  23
+
  24
+namespace :spec do
  25
+  desc "Run all specs in spec directory with RCov (excluding plugin specs)"
  26
+  Spec::Rake::SpecTask.new(:rcov) do |t|
  27
+    t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
  28
+    t.spec_files = FileList['spec/**/*_spec.rb']
  29
+    t.rcov = true
  30
+    t.rcov_opts = lambda do
  31
+      IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
  32
+    end
  33
+  end
  34
+  
  35
+  desc "Print Specdoc for all specs (excluding plugin specs)"
  36
+  Spec::Rake::SpecTask.new(:doc) do |t|
  37
+    t.spec_opts = ["--format", "specdoc", "--dry-run"]
  38
+    t.spec_files = FileList['spec/**/*_spec.rb']
  39
+  end
  40
+
  41
+  desc "Print Specdoc for all plugin specs"
  42
+  Spec::Rake::SpecTask.new(:plugin_doc) do |t|
  43
+    t.spec_opts = ["--format", "specdoc", "--dry-run"]
  44
+    t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
  45
+  end
  46
+
  47
+  [:models, :controllers, :views, :helpers, :lib].each do |sub|
  48
+    desc "Run the specs under spec/#{sub}"
  49
+    Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
  50
+      t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
  51
+      t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
  52
+    end
  53
+  end
  54
+  
  55
+  desc "Run the specs under vendor/plugins (except RSpec's own)"
  56
+  Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
  57
+    t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
  58
+    t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
  59
+  end
  60
+  
  61
+  namespace :plugins do
  62
+    desc "Runs the examples for rspec_on_rails"
  63
+    Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
  64
+      t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
  65
+      t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
  66
+    end
  67
+  end
  68
+
  69
+  # Setup specs for stats
  70
+  task :statsetup do
  71
+    require 'code_statistics'
  72
+    ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
  73
+    ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
  74
+    ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
  75
+    ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
  76
+    ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
  77
+    ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
  78
+    ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
  79
+    ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
  80
+    ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
  81
+    ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
  82
+    ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
  83
+  end
  84
+
  85
+  namespace :db do
  86
+    namespace :fixtures do
  87
+      desc "Load fixtures (from spec/fixtures) into the current environment's database.  Load specific fixtures using FIXTURES=x,y"
  88
+      task :load => :environment do
  89
+        require 'active_record/fixtures'
  90
+        ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
  91
+        (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
  92
+          Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
  93
+        end
  94
+      end
  95
+    end
  96
+  end
  97
+
  98
+  namespace :server do
  99
+    daemonized_server_pid = File.expand_path("spec_server.pid", RAILS_ROOT + "/tmp")
  100
+
  101
+    desc "start spec_server."
  102
+    task :start do
  103
+      if File.exist?(daemonized_server_pid)
  104
+        $stderr.puts "spec_server is already running."
  105
+      else
  106
+        $stderr.puts "Starting up spec server."
  107
+        system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
  108
+      end
  109
+    end
  110
+
  111
+    desc "stop spec_server."
  112
+    task :stop do
  113
+      unless File.exist?(daemonized_server_pid)
  114
+        $stderr.puts "No server running."
  115
+      else
  116
+        $stderr.puts "Shutting down spec_server."
  117
+        system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) && 
  118
+        File.delete(daemonized_server_pid)
  119
+      end
  120
+    end
  121
+
  122
+    desc "reload spec_server."
  123
+    task :restart do
  124
+      unless File.exist?(daemonized_server_pid)
  125
+        $stderr.puts "No server running."
  126
+      else
  127
+        $stderr.puts "Reloading down spec_server."
  128
+        system("kill", "-s", "USR2", File.read(daemonized_server_pid).strip)
  129
+      end
  130
+    end
  131
+  end
  132
+end
BIN  public/images/no-pic.png
BIN  public/images/no-pic_large.png
BIN  public/images/no-pic_small.png
BIN  public/images/no-pic_tiny.png

0 notes on commit 759a104

Please sign in to comment.
Something went wrong with that request. Please try again.