namespace :shattered do namespace :freeze do desc "Lock this application to the current gems (by unpacking them into vendor/Shattered)" task :gems do require 'rubygems' Gem.manage_gems version = ENV['VERSION'] || Gem.cache.search('shattered').sort_by { |g| g.version }[-1].version gems = Gem.cache.search('shattered', "= #{version}") if gems.length == 0 puts "No shattered gem #{version} is installed. Do 'gem list shattered' to see what you have available." exit end puts "Freezing to the gems for shattered #{gems[0].version}" rm_rf "vendor/shattered" mkdir_p "vendor/shattered" chdir("vendor/shattered") do gems.reverse.each do |g| puts g.name Gem::GemRunner.new.run(["unpack", "-v", "#{g.version}", "#{g.name}"]) mv(Dir.glob("#{g.name}*").first, g.name) end mv(Dir.glob("shattered_ruby").first, "shatter") end end desc "Lock to latest Shattered Edge or a specific revision with REVISION=X (ex: REVISION=4021) or a tag with TAG=Y (ex: TAG=rel_1-1-0)" task :edge do $verbose = false `svn --version` rescue nil unless !$?.nil? && $?.success? $stderr.puts "ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Shattered" exit 1 end rm_rf "vendor/shattered" mkdir_p "vendor/shattered" svn_root = "http://svn.shatteredruby.com/" if ENV['TAG'] shattered_svn = "#{svn_root}/tags/#{ENV['TAG']}" touch "vendor/shattered/TAG_#{ENV['TAG']}" else shattered_svn = "#{svn_root}/trunk" if ENV['REVISION'].nil? ENV['REVISION'] = /^r(\d+)/.match(%x{svn -qr HEAD log #{svn_root}})[1] puts "REVISION not set. Using HEAD, which is revision #{ENV['REVISION']}." end touch "vendor/shattered/REVISION_#{ENV['REVISION']}" end for framework in %w( shatter shattered_pack shattered_support shattered_ogrerb ) system "svn export #{shattered_svn}/trunk/#{framework} vendor/shattered/#{framework}" + (ENV['REVISION'] ? " -r #{ENV['REVISION']}" : "") end end end desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems" task :unfreeze do rm_rf "vendor/shattered" end desc "Update both configs, scripts and public/javascripts from shattered" task :update => [ "update:scripts", "update:javascripts", "update:configs" ] namespace :update do desc "Update boot/config.rb from your current Shattered install" task :configs do require 'railties_path' FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', SHATTERED_ROOT + '/config/boot.rb') end end end