lib/taunt.rb in taunt-0.1.1 vs lib/taunt.rb in taunt-0.2.0

- old
+ new

@@ -5,32 +5,30 @@ @taunts = Dir.glob("#{taunt_home}/.taunt/**/*.{#{supported_formats.join(',')}}") end def taunt! taunt = @taunts[rand(@taunts.length)] - unless darwin? - puts "only do OS X so far sorry :(" - exit 1 - end - unless taunt puts "you need to put some taunt sounds in #{@taunt_home}" exit 1 end process = fork do - `afplay #{taunt} &` + Process.daemon + `#{play_command} #{taunt} &` end Process.detach(process) end private - def darwin? - RUBY_PLATFORM =~ /darwin/ + def play_command + %w{afplay aplay}.each {|command| + return command if system("which #{command}") + } end def supported_formats # afplay supports everything Quicktime does. # Quicktime supported formats from http://support.apple.com/kb/HT3775 %w{m4a m4b m4p mp3 caf aiff au sd2 wav snd amr} end -end \ No newline at end of file +end