class Yaz < Formula desc "Toolkit for Z39.50/SRW/SRU clients/servers" homepage "https://www.indexdata.com/yaz" url "http://ftp.indexdata.dk/pub/yaz/yaz-5.27.2.tar.gz" sha256 "09fdebc78ef169194f3d275ede5ef39087484c1395bf518484051bba81cb154e" bottle do cellar :any sha256 "dec79484e11ffb10ac51d1d902ac9860036af7bea924a0c3022b40d9f6df8c2f" => :catalina sha256 "765a114f35202bf28fd7a05011d7c8e388929a2c10a6c03f4b5a1348684296ea" => :mojave sha256 "047af6554ea6d94e46ca01d8c146a0ea8414fc5e2c0956e90e7a33cce8a133dc" => :high_sierra end head do url "https://github.com/indexdata/yaz.git" depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build end depends_on "pkg-config" => :build depends_on "icu4c" def install system "./buildconf.sh" if build.head? 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 = shell_output("#{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 by running yaz-icu with the example icu_chain # from its man page. configfile = testpath/"icu-chain.xml" configfile.write <<~EOS EOS inputfile = testpath/"icu-test.txt" inputfile.write "yaz-ICU xy!" expectedresult = <<~EOS 1 1 'yaz' 'yaz' 2 1 '' '' 3 1 'icuz' 'ICUz' 4 1 '' '' EOS result = shell_output("#{bin}/yaz-icu -c #{configfile} #{inputfile}") assert_equal expectedresult, result end end