class Assets::PrecompileLocalGenerator

Public Instance Methods

copy_initializer_file() click to toggle source
# File lib/generators/assets/precompile_local/precompile_local_generator.rb, line 6
    def copy_initializer_file
      append_file 'config/deploy/production' do
        <<-RUBY


namespace :deploy do
  task :restart, :roles => :app, :except => { :no_release => true } do
      run "cd #{current_path} && touch tmp/restart.txt"
  end
  namespace :assets do
    task :precompile, :roles => :web do
      from = source.next_revision(current_revision)
      run_locally("RAILS_ENV=production rake assets:clean && RAILS_ENV=production rake assets:precompile")
      run_locally "cd public && tar -jcf assets.tar.bz2 assets"
      top.upload "public/assets.tar.bz2", "#{shared_path}", :via => :scp
      run "rm -rf #{shared_path}/assets"
      run "cd #{shared_path} && tar -jxf assets.tar.bz2 && rm assets.tar.bz2"
      run_locally "rm public/assets.tar.bz2"
      run_locally("RAILS_ENV=production rake assets:clean")
      run_locally "rm -rf public/assets"
      run_locally "rm -rf tmp/cache/assets"
    end

    task :symlink, roles: :web do
      run ("rm -rf #{latest_release}/public/assets &&
            mkdir -p #{latest_release}/public &&
            mkdir -p #{shared_path}/assets &&
            ln -s #{shared_path}/assets #{latest_release}/public/assets")
    end
  end
end

        RUBY
      end
    end