110 lines
4.0 KiB
Ruby
110 lines
4.0 KiB
Ruby
class Yaz < Formula
|
||
desc "Toolkit for Z39.50/SRW/SRU clients/servers"
|
||
homepage "https://www.indexdata.com/resources/software/yaz/"
|
||
license "BSD-3-Clause"
|
||
|
||
stable do
|
||
url "https://ftp.indexdata.com/pub/yaz/yaz-5.33.0.tar.gz"
|
||
sha256 "9eab77267524191a8286ad80291a2220ffe9d322b3ea0e4b1c6bdbc5db21a04f"
|
||
end
|
||
|
||
# The latest version text is currently omitted from the homepage for this
|
||
# software, so we have to check the related directory listing page.
|
||
livecheck do
|
||
url "https://ftp.indexdata.com/pub/yaz/"
|
||
regex(/href=.*?yaz[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
||
end
|
||
|
||
bottle do
|
||
sha256 cellar: :any, arm64_ventura: "aa89c290236c1f2e72f325f20e6eac52d998e78632ff1ac01294e14ab25d184f"
|
||
sha256 cellar: :any, arm64_monterey: "f7cf58ef82fe983ed07969e498a6eaee40d2e33c647326d39638a15c1d239677"
|
||
sha256 cellar: :any, arm64_big_sur: "443f77e9afd087075232dbc89414bc8d1879980c856a9dcf5a57875f6ffbabe3"
|
||
sha256 cellar: :any, ventura: "65519ae132fa21bf3f8a14d67ca552423c3fdb60d19e512493c07c28afd79c50"
|
||
sha256 cellar: :any, monterey: "e437bf9b3f249f45d1cffdee7c42030f6a53ef48a78661d3579a6e3e3a15fb26"
|
||
sha256 cellar: :any, big_sur: "9546416c957770190812a345b565ade5997e3e9667bb93b30804da55b0b29dad"
|
||
sha256 cellar: :any_skip_relocation, x86_64_linux: "318a94f7ba3f6c79fa133e538b9e80106abab906071ad57739a0926806eed0d2"
|
||
end
|
||
|
||
head do
|
||
url "https://github.com/indexdata/yaz.git", branch: "master"
|
||
|
||
depends_on "autoconf" => :build
|
||
depends_on "automake" => :build
|
||
depends_on "docbook-xsl" => :build
|
||
depends_on "libtool" => :build
|
||
|
||
uses_from_macos "bison" => :build
|
||
uses_from_macos "tcl-tk" => :build
|
||
end
|
||
|
||
depends_on "pkg-config" => :build
|
||
depends_on "gnutls"
|
||
depends_on "icu4c"
|
||
|
||
uses_from_macos "libxml2"
|
||
uses_from_macos "libxslt"
|
||
|
||
def install
|
||
if build.head?
|
||
ENV["XML_CATALOG_FILES"] = etc/"xml/catalog"
|
||
system "./buildconf.sh"
|
||
end
|
||
system "./configure", *std_configure_args,
|
||
"--with-gnutls",
|
||
"--with-xml2",
|
||
"--with-xslt"
|
||
system "make", "install"
|
||
|
||
# Replace dependencies' cellar paths, which can break build for dependents
|
||
# (like `metaproxy` and `zebra`) after a dependency is version/revision bumped
|
||
inreplace bin/"yaz-config" do |s|
|
||
s.gsub! Formula["gnutls"].prefix.realpath, Formula["gnutls"].opt_prefix
|
||
s.gsub! Formula["icu4c"].prefix.realpath, Formula["icu4c"].opt_prefix
|
||
end
|
||
unless OS.mac?
|
||
inreplace [bin/"yaz-config", lib/"pkgconfig/yaz.pc"] do |s|
|
||
s.gsub! Formula["libxml2"].prefix.realpath, Formula["libxml2"].opt_prefix
|
||
s.gsub! Formula["libxslt"].prefix.realpath, Formula["libxslt"].opt_prefix
|
||
end
|
||
end
|
||
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
|