Module: DeploySounds

Defined in:
lib/deploy_sounds.rb

Overview

Constant Summary collapse

AUDIO_PLAY_COMMANDS =
%w(afplay play)

Class Method Summary collapse

Class Method Details

.playObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/deploy_sounds.rb', line 5

def self.play
  AUDIO_PLAY_COMMANDS.each do |command|
    random_file = Dir.glob("#{ENV['HOME']}/.deploy_sounds/*").sample

    unless random_file
      puts "[deploy_sounds] You don't have a ~/.deploy_sounds or it's empty."
      break
    end

    if system("which #{command}")
      `#{command} #{random_file} &`
      break
    end
  end
end