aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/txt2man.rb
blob: 91319e06854cfb167e85367fbae85c16c15d788a (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
class Txt2man < Formula
  homepage "http://mvertes.free.fr/"
  url "http://mvertes.free.fr/download/txt2man-1.5.6.tar.gz"
  sha1 "ef1392785333ea88f7e01f4f4c519ecfbdd498bd"

  depends_on "gawk"

  def install
    man1.install %w[bookman.1 src2man.1 txt2man.1]
    bin.install %w[bookman src2man txt2man]
  end

  test do
    # txt2man
    (testpath/"test.txt").write <<-EOS.undent
      A TITLE

      blah blah blah
    EOS

    assert_match(/\.SH A TITLE/, shell_output("#{bin}/txt2man test.txt"))

    # src2man
    (testpath/"test.c").write <<-EOS.undent
      #include <stdio.h>

      /** 3
      * main - do stuff
      **/
      int main(void) { return 0; }
    EOS

    assert_equal "main.3\n", shell_output("#{bin}/src2man test.c 2>&1")
    assert File.read("main.3").include?(%q(\fBmain \fP- do stuff))

    # bookman
    system "#{bin}/bookman", "-t", "Test", "-o", "test", Dir["#{man1}/*"]
    assert File.exist?("test")
  end
end