class Yaz < Formula desc "Toolkit for Z39.50/SRW/SRU clients/servers" homepage "http://www.indexdata.com/yaz" url "http://ftp.indexdata.dk/pub/yaz/yaz-5.14.4.tar.gz" sha256 "0238e2fd09a5060880c3447528c68adeb56c4444d67078033c0f3e3cdeda573b" bottle do cellar :any sha256 "d873eec6aae920b48c3f6c86ffb0e6bb1b8b24f23241107cfc194deef76f5fe7" => :yosemite sha256 "4c5e7d13920ea1ce514f8ff2920936dff9aab883fe962056a204086d09f9c7aa" => :mavericks sha256 "cff5a0ffe4c60545203c6b4f7b7642a58c787552ef35baced12cdf73d5fa6df6" => :mountain_lion end depends_on "pkg-config" => :build depends_on "icu4c" => :recommended depends_on "gnutls" => :optional depends_on "libgcrypt" if build.with? "gnutls" def install system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}", "--with-xml2" system "make", "install" end test do # This test converts between MARC8, an obscure mostly-obsolete library # text encoding supported by yaz-iconv, and UTF8. marc8file = testpath/"marc8.txt" marc8file.write "$1!0-!L,i$3i$si$Ki$Ai$O!+=(B" result = `#{bin}/yaz-iconv -f marc8 -t utf8 #{marc8file}` result.force_encoding(Encoding::UTF_8) if result.respond_to?(:force_encoding) assert_equal "世界こんにちは!", result # Test ICU support if building with ICU by running yaz-icu # with the example icu_chain from its man page. if build.with? "icu4c" # The input string should be transformed to be: # * without control characters (tab) # * split into tokens at word boundaries (including -) # * without whitespace and Punctuation # * xy transformed to z # * lowercase configurationfile = testpath/"icu-chain.xml" configurationfile.write <<-EOS.undent EOS inputfile = testpath/"icu-test.txt" inputfile.write "yaz-ICU xy!" expectedresult = <<-EOS.undent 1 1 'yaz' 'yaz' 2 1 '' '' 3 1 'icuz' 'ICUz' 4 1 '' '' EOS result = `#{bin}/yaz-icu -c #{configurationfile} #{inputfile}` assert_equal expectedresult, result end end end