aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/audiofile.rb
blob: 22fd3fb8ccd9f3dc96d9ffe9ab75a186288d2895 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require 'formula'

class Audiofile < Formula
  url 'https://github.com/downloads/mpruett/audiofile/audiofile-0.3.2.tar.gz'
  sha1 'fb55a3c9153475daa8932d3626797e033d149c1d'
  homepage 'http://www.68k.org/~michael/audiofile/'

  depends_on 'lcov' if ARGV.include? '--with-lcov'

  def options
    [
      ['--with-lcov', 'Enable Code Coverage support using lcov.'],
      ['--with-check', 'Run the test suite during install ~30sec']
    ]
  end

  def install
    args = ["--prefix=#{prefix}", "--disable-dependency-tracking"]
    args << '--enable-coverage' if ARGV.include? '--with-lcov'
    system "./configure", *args
    system "make"
    system "make check" if ARGV.include? '--with-check'
    system "make install"
  end

  def test
    inn  = '/System/Library/Sounds/Glass.aiff'
    out  = 'Glass.wav'
    hear_bin = '/usr/bin/qlmanage'
    conv_bin = "#{bin}/sfconvert"
    info_bin = "#{bin}/sfinfo"

    unless File.exist?(conv_bin) and File.exist?(inn) and
          File.exist?(hear_bin) and File.exist?(info_bin)
      opoo <<-EOS.undent
        The test program couldn't locate one of these files that normally exist:
           #{inn}
           #{conv_bin}
           #{info_bin}
           #{hear_bin}
        We are sorry for the mistake.  Another test you can run on this software
        will occur during install if you add --with-check like this:

      EOS
      oh1 '    brew rm audiofile'
      oh1 '    brew -v install audiofile --with-check'
      return
    end

    mktemp do
      system "#{conv_bin} #{inn} #{out} format wave"
      system "#{info_bin} --short --reporterror #{out}"
      system "#{hear_bin} -p #{out}" if ARGV.verbose?
      puts
      oh1 <<-EOS.undent
        Cheers mate. You converted a system sound from the Audio
        Interchange File Format \"aiff\" to the MS RIFF Wave format.
      EOS
    end
  end
end