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.19.0.tar.gz" sha256 "68e5b31517f09c6f6b548d24e70b72b5faeb9dd9b2e47b1ef13e32bf15b2ff18" revision 1 bottle do cellar :any sha256 "c0226b7ae16105e624687d1528ba4fc94432e0c4ca30ede9737d39cddcd244a9" => :sierra sha256 "11e056188cc94e9fa1dbf991d56352a7323778156e33ccc01487e6fc13bda015" => :el_capitan sha256 "e9b6f12b73f546c0d4ad88de3783f4b82e20c30a25368f19704af41d5b488ea2" => :yosemite end head do url "https://github.com/indexdata/yaz.git" depends_on "automake" => :build depends_on "autoconf" => :build depends_on "libtool" => :build end option :universal depends_on "pkg-config" => :build depends_on "icu4c" => :recommended def install ENV.universal_binary if build.universal? 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.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 = shell_output("#{bin}/yaz-icu -c #{configurationfile} #{inputfile}") assert_equal expectedresult, result end end end