Sha256: 7039021e0bb130dac16c2b833e7067ec16eccd72d748937ae9246386fcb0db7c
Contents?: true
Size: 887 Bytes
Versions: 3
Compression:
Stored size: 887 Bytes
Contents
require 'fileutils' module HappyCommit def self.sounds @sounds ||= Dir.glob(File.dirname(__FILE__)+"/../sounds/*.wav") end 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 protected def self.sounds_path ".git/sounds" end def self.hooks_path ".git/hooks" end def self.post_commit_path "#{self.hooks_path}/post-commit" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
happy-commit-0.0.4 | lib/happy-commit.rb |
happy-commit-0.0.3 | lib/happy-commit.rb |
happy-commit-0.0.2 | lib/happy-commit.rb |