homebrew-core/Formula/yaz.rb
2019-12-28 16:17:42 +01:00

70 lines
2.3 KiB
Ruby
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.28.0.tar.gz"
sha256 "194b09b3212b9c0626c729e8f1e13cbfbe55141434c0627860aa1469433892c4"
bottle do
cellar :any
sha256 "2d006deb88e7bda75b7405ef4b9cc2bd2d247a648b01eee201c65543d5a41db4" => :catalina
sha256 "0a3d8ad8dc5f00dab4a4f84cace3f101644c1a699d32b98c474f20ba91c42719" => :mojave
sha256 "d1ed60bd207a7d775e696a832e424e423e00a3d5a46be6fe26f04b456f69a504" => :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"
uses_from_macos "libxml2"
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
<?xml version="1.0" encoding="UTF-8"?>
<icu_chain locale="en">
<transform rule="[:Control:] Any-Remove"/>
<tokenize rule="w"/>
<transform rule="[[:WhiteSpace:][:Punctuation:]] Remove"/>
<transliterate rule="xy > z;"/>
<display/>
<casemap rule="l"/>
</icu_chain>
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