homebrew-core/Formula/yaz.rb
2017-03-27 05:10:53 -07:00

77 lines
2.6 KiB
Ruby
Raw 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.20.3.tar.gz"
sha256 "f8b9127022d2e7fbad658a699a5eef5451c665be3e7b9325ffee987f62bfee82"
bottle do
cellar :any
sha256 "6c3bc07863cce1b5fd44bb45348d9831d3856143e21acb09ff377cdaf7bf6637" => :sierra
sha256 "9d725c5a36c86beca743664fea2edf248d0d26ddb98da4961f055fce5fd92e63" => :el_capitan
sha256 "98fab17671841b882a0ce1b9aa8e820e7ba1b03b0e8090bd685ef49bc83ed700" => :yosemite
end
head do
url "https://github.com/indexdata/yaz.git"
depends_on "automake" => :build
depends_on "autoconf" => :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.undent
<?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.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