73 lines
2.5 KiB
Ruby
73 lines
2.5 KiB
Ruby
# encoding: UTF-8
|
||
class Yaz < Formula
|
||
desc "Toolkit for Z39.50/SRW/SRU clients/servers"
|
||
homepage "http://www.indexdata.com/yaz"
|
||
url "http://ftp.indexdata.dk/pub/yaz/yaz-5.11.0.tar.gz"
|
||
sha1 "29dff79332979d1fa5e4e6c2cebb099200b10413"
|
||
revision 1
|
||
|
||
bottle do
|
||
cellar :any
|
||
sha256 "0390addce108b35a87873f12f6e719d50b3bd9fc6691ca97e7804994eacff0f1" => :yosemite
|
||
sha256 "fff6d21688f1851216a043a5aa2c6120c11b18b0074c27a2fd4973ddedc46547" => :mavericks
|
||
sha256 "0b2244a11ee8f1b0815d4097ab5b3c243c6e45ef26110484eeaa46fcc733e731" => :mountain_lion
|
||
end
|
||
|
||
depends_on "pkg-config" => :build
|
||
depends_on "icu4c" => :recommended
|
||
depends_on "gnutls" => :optional
|
||
depends_on "libgcrypt" if build.with? "gnutls"
|
||
|
||
def install
|
||
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 = `#{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 = `#{bin}/yaz-icu -c #{configurationfile} #{inputfile}`
|
||
assert_equal expectedresult, result
|
||
end
|
||
end
|
||
end
|