class Minitest::Sound::Player
Public Class Methods
new(success: nil, failure: nil, during_test: nil)
click to toggle source
# File lib/minitest/sound/player.rb, line 4 def initialize(success: nil, failure: nil, during_test: nil) @success_sound = success @failure_sound = failure @during_test_sound = during_test @during_test_pid = nil end
Public Instance Methods
message()
click to toggle source
# File lib/minitest/sound/player.rb, line 38 def message 'warning: minitest-sound use "mpg123". Please install "mpg123".' end
play(file: nil, sync: true)
click to toggle source
# File lib/minitest/sound/player.rb, line 11 def play(file: nil, sync: true) return if file.nil? || file.empty? pid = spawn("mpg123 #{file}", err: '/dev/null') Process.waitpid(pid) if sync pid rescue Errno::ENOENT $stderr.puts message end
play_during_test_sound(sync = false)
click to toggle source
# File lib/minitest/sound/player.rb, line 29 def play_during_test_sound(sync = false) @during_test_pid = play(file: during_test_sound, sync: sync) end
play_failure_sound(sync = true)
click to toggle source
# File lib/minitest/sound/player.rb, line 25 def play_failure_sound(sync = true) play(file: failure_sound, sync: sync) end
play_success_sound(sync = true)
click to toggle source
# File lib/minitest/sound/player.rb, line 21 def play_success_sound(sync = true) play(file: success_sound, sync: sync) end
stop_during_test_sound()
click to toggle source
# File lib/minitest/sound/player.rb, line 33 def stop_during_test_sound return unless @during_test_pid Process.kill('SIGINT', @during_test_pid) end
Private Instance Methods
during_test_sound()
click to toggle source
# File lib/minitest/sound/player.rb, line 52 def during_test_sound @during_test_sound || Minitest::Sound.during_test end
failure_sound()
click to toggle source
# File lib/minitest/sound/player.rb, line 48 def failure_sound @failure_sound || Minitest::Sound.failure end
success_sound()
click to toggle source
# File lib/minitest/sound/player.rb, line 44 def success_sound @success_sound || Minitest::Sound.success end