Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-7 of 7 total  RSS 

rake task to rename views to rails 2.0 format

// This task will rename your files to the rails 2.0 format, using git mv. Add it to /lib/tasks/rails.rake

   1  
   2  namespace 'views' do
   3    desc 'Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder, and .haml to .html.haml'
   4    task 'rename' do
   5      Dir.glob('app/views/**/[^_]*.rhtml').each do |file|
   6        puts `git mv #{file} #{file.gsub(/\.rhtml$/, '.html.erb')}`
   7      end
   8  
   9      Dir.glob('app/views/**/[^_]*.rxml').each do |file|
  10        puts `git mv #{file} #{file.gsub(/\.rxml$/, '.xml.builder')}`
  11      end
  12  
  13      Dir.glob('app/views/**/[^_]*.rjs').each do |file|
  14        puts `git mv #{file} #{file.gsub(/\.rjs$/, '.js.rjs')}`
  15      end
  16      Dir.glob('app/views/**/[^_]*.haml').each do |file|
  17        puts `git mv #{file} #{file.gsub(/\.haml$/, '.html.haml')}`
  18      end
  19    end
  20  end

.autotest file

   1  
   2  require 'autotest/redgreen'
   3  require 'autotest/timestamp'
   4  #require 'autotest/growl'
   5  
   6  #require 'autotest/html_report'
   7  #require 'autotest/kdenotify'
   8  #require 'autotest/menu'
   9  #require 'autotest/pretty'
  10  #require 'autotest/snarl'
  11  
  12  # Sort-of from http://blog.labratz.net/articles/2006/09/13/growl-autotest-rails-with-zentest-3-4-0
  13  def growl(title, msg, pri=0, stick="", image="")
  14    image_arg = (!image.empty?) ? "--image #{image}" : ""
  15    system "growlnotify -n autotest #{image_arg} -p #{pri} -m #{msg.inspect} #{title} #{stick}" 
  16  end
  17  
  18  Autotest.add_hook :red do |at|
  19    growl("Tests Failed", "#{at.files_to_test.size} tests failed", 2, "", "/Applications/Mail.app/Contents/Resources/Caution.tiff")
  20  end
  21  
  22  Autotest.add_hook :green do |at|
  23    growl("Tests Passed", "All tests passed", -2, "", "/Applications/Mail.app/Contents/Resources/certificate.tiff") #if at.tainted
  24  end  

rails related svn configurator

   1  
   2  #!/bin/sh
   3  svn remove log/*
   4  svn commit -m"removing log files" 
   5  svn propset svn:ignore "*.log" log/
   6  svn update log/
   7  svn commit -m 'Ignoring all files in /log/ ending in .log'
   8  svn move config/database.yml config/database.example
   9  svn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code'
  10  svn propset svn:ignore "database.yml" config/
  11  svn update config/
  12  svn commit -m 'Ignoring database.yml'
  13  svn remove tmp/*
  14  svn propset svn:ignore "*" tmp/
  15  svn update tmp/
  16  svn commit -m "ignore tmp/ content from now" 
  17  svn propset svn:ignore ".htaccess" config/
  18  svn update config/
  19  svn commit -m 'Ignoring .htaccess'
  20  svn propset svn:ignore "dispatch.fcgi" config/
  21  svn update config/
  22  svn commit -m 'Ignoring dispatch.fcgi'

exception_logger route

   1  
   2  map.exceptions '/logged_exceptions/:action/:id', :controller => 'logged_exceptions', :action => 'index', :id => nil 

fix darwin ports shebang on rails

   1  ruby -i -pe 'gsub!("#!/opt/local/bin/ruby", "#!/usr/bin/env ruby")' public/dispatch.* script/*

correct use of priority_countries

   1  <%= form.country_select :billing_country, ["United States"] %>

rails svn:externals for plugins and rails edge

export SVN_EDITOR=/usr/bin/vim
svn propedit svn:externals vendor
--[sample file]--
rails http://dev.rubyonrails.org/svn/rails/trunk/
plugins/acts_authenticated http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated
plugins/exception_logger http://svn.techno-weenie.net/projects/plugins/exception_logger
--[end of sample file] --

svn ci -m "added plugins and rails source to svn externals"
svn --ignore-externals stat
« Newer Snippets
Older Snippets »
Showing 1-7 of 7 total  RSS