Sha256: b6772d1c7ed1d888b1646275c257339c2bbb610c0f85755c82a7deaff5230be5

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 Bytes

Contents

require 'fileutils'
require 'happy-commit/on_commit'

module HappyCommit
  include HappyCommit::OnCommit

  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 << File.read(File.expand_path("../happy-commit/hook.rb", __FILE__))
      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

1 entries across 1 versions & 1 rubygems

Version Path
happy-commit-0.1.0 lib/happy-commit.rb