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

namespace 'views' do
  desc 'Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder, and .haml to .html.haml'
  task 'rename' do
    Dir.glob('app/views/**/[^_]*.rhtml').each do |file|
      puts `git mv #{file} #{file.gsub(/\.rhtml$/, '.html.erb')}`
    end

    Dir.glob('app/views/**/[^_]*.rxml').each do |file|
      puts `git mv #{file} #{file.gsub(/\.rxml$/, '.xml.builder')}`
    end

    Dir.glob('app/views/**/[^_]*.rjs').each do |file|
      puts `git mv #{file} #{file.gsub(/\.rjs$/, '.js.rjs')}`
    end
    Dir.glob('app/views/**/[^_]*.haml').each do |file|
      puts `git mv #{file} #{file.gsub(/\.haml$/, '.html.haml')}`
    end
  end
end

.autotest file

require 'autotest/redgreen'
require 'autotest/timestamp'
#require 'autotest/growl'

#require 'autotest/html_report'
#require 'autotest/kdenotify'
#require 'autotest/menu'
#require 'autotest/pretty'
#require 'autotest/snarl'

# Sort-of from http://blog.labratz.net/articles/2006/09/13/growl-autotest-rails-with-zentest-3-4-0
def growl(title, msg, pri=0, stick="", image="")
  image_arg = (!image.empty?) ? "--image #{image}" : ""
  system "growlnotify -n autotest #{image_arg} -p #{pri} -m #{msg.inspect} #{title} #{stick}" 
end

Autotest.add_hook :red do |at|
  growl("Tests Failed", "#{at.files_to_test.size} tests failed", 2, "", "/Applications/Mail.app/Contents/Resources/Caution.tiff")
end

Autotest.add_hook :green do |at|
  growl("Tests Passed", "All tests passed", -2, "", "/Applications/Mail.app/Contents/Resources/certificate.tiff") #if at.tainted
end  

rails related svn configurator

#!/bin/sh
svn remove log/*
svn commit -m"removing log files" 
svn propset svn:ignore "*.log" log/
svn update log/
svn commit -m 'Ignoring all files in /log/ ending in .log'
svn move config/database.yml config/database.example
svn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code'
svn propset svn:ignore "database.yml" config/
svn update config/
svn commit -m 'Ignoring database.yml'
svn remove tmp/*
svn propset svn:ignore "*" tmp/
svn update tmp/
svn commit -m "ignore tmp/ content from now" 
svn propset svn:ignore ".htaccess" config/
svn update config/
svn commit -m 'Ignoring .htaccess'
svn propset svn:ignore "dispatch.fcgi" config/
svn update config/
svn commit -m 'Ignoring dispatch.fcgi'

exception_logger route

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

fix darwin ports shebang on rails

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

correct use of priority_countries

<%= 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