Related tags
Ruby on Rails git pre-commit hook
git provides a few hooks so you can control the workflow of your source code commits. These hooks are placed inside your .git/hooks directory, and a inside there are a few samples to look at.
For my Ruby on Rails applications, I use the git pre-commit hook, to ensure that my Ruby code syntax is correct, and that it passes all my RSpec tests.
In your application directory, create a file in the git directory: .git/hooks/pre-commit
#!/usr/bin/env ruby
# vim: set syntax=ruby
flag = false
Dir["{app,config,lib,runners}/**/*/*.rb"].each do |file|
result = `ruby -c #{file}`
if $? != 0
puts result
flag = true
end
end
Dir["public/javascripts/**/*.js"].each do |file|
result = `grep -n console #{file}`
if $? == 0
puts file
puts result
flag = true
end
end
exit 1 if flag
exec "rake spec"
Don't forget to make it executable:
chmod u+x .git/hooks/pre-commit
Now you are ready to go.
Malaysia.rb March 2008 Meetup
Spammed on several places:
We have two presentations lined up for the night:
1. Gavin will provide a survey of different methods of handling missing references in various programming languages with emphasis on Scala. This stuff has been popping up a lot on Reddit. For a good backgrounder (in Ruby), see http://blog.thoughtfolder.com/2008-03-16-navigating-nil-method-chaining-in-ruby.html
2. Aizat will live build a Jabber bot that integrates with Twitter, provides system monitoring and makes coffee in the morning. Expect lots of BDD love with Autotest and RSpec.
Also, I have one last FREE PeepCode Episode Coupons to give away!
When: Thursday, March 27th 2008, 7:30PM
Agenda:
7:30 - 8:00pm Socializing
8:00 - 8:15pm Opening by the Organizer
8:15 - 8:45pm "Survey of different methods of handling missing Preferences" by Gavin Bong
8:45 - 9:15pm "Developing a Jabber bot ... LIVE!" by Aizat Faiz
9:15 - 9:30pm PeepCode Episode Coupon Lucky Draw and CloseCost:
Free. No registration required, just come right in, have a seat, and join the crowd. Invite your friends.Contact:
kamal.fariz@gmail.com
+60123099143
aizat.faiz@gmail.com
+60176908783Where:
Open University Malaysia Angkasa Raya
Floor Tingkat 3, Bangunan Angkasa Raya,
Jalan Ampang
Kuala LumpurLocated near Kuala Lumpur City Centre (KLCC)
15 minute walk from the KLCC LRT station.
Praying facilities are available on the campus.
