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.26.1.tar.gz" sha256 "ceb4367e3098bce8e09734f09c0410bd679fdc3f9423bb28d70cc15cc95b66cc" bottle do cellar :any sha256 "6026b5cbda9ca4de95407d26c9b1a93558c09311fde3b12f68eed3b49a34c7de" => :mojave sha256 "6a201f0b28d3edeb44242b9dd2c3f9f42798eb842707c467d58a96cf07c265d5" => :high_sierra sha256 "27d62ad053bc8ca774446fe354be660c7b94d1dd8dbca130b5893cf3ef597c95" => :sierra sha256 "76d2f57ed98d1dacc0ebe0cd9d873e1072cec1a3d061d769c3f99f4fc57c902a" => :el_capitan 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" => :recommended 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 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 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 #{configurationfile} #{inputfile}") assert_equal expectedresult, result end end end