8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/happy-commit.rb', line 8
def self.install
if File.exist?(self.hooks_path)
FileUtils.mkpath(self.sounds_path)
self.sounds.each_with_index do |sound, i|
FileUtils.cp(sound, self.sounds_path+"/#{i}.wav")
end
File.open(self.post_commit_path, "w") do |f|
f << %@#!/usr/bin/env ruby
sounds = Dir.glob(".git/sounds/*.wav")
command = %w[aplay afplay play].find { |w| `#\{w} --version 2>/dev/null`; $?.success? }
system("#\{command} #\{sounds.at(rand(sounds.size))} 2>/dev/null &")
@
end
FileUtils.chmod(0755, self.post_commit_path)
end
end
|