public
Description: A Rails plugin / Git hook that optimises PNGs upon adding or updating.
Homepage:
Clone URL: git://github.com/shift/git_png_optimise.git
git_png_optimise / install.rb
100644 15 lines (12 sloc) 0.535 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Install hook code here
require 'fileutils'
 
if File.exists? '.git/hooks/pre-commit'
  require 'readline'
  puts "A .git/hooks/pre-commit already exists, awnser no to backup your pre-commit hook"
  responce = Readline::readline 'Overwrite [y/n]: '
  Readline::HISTORY.push(responce)
  File.rename('.git/hooks/pre-commit', '.git/hooks/pre-commit.backup') if responce =~ /^n.*/
end
 
FileUtils.copy('vendor/plugins/git_png_optimise/examples/pre-commit', '.git/hooks/pre-commit')
hook = File.open('.git/hooks/pre-commit')
hook.chmod 0755