homebrew-core/Formula/saxon.rb

52 lines
1.5 KiB
Ruby

class Saxon < Formula
desc "XSLT and XQuery processor"
homepage "https://saxon.sourceforge.io"
url "https://downloads.sourceforge.net/project/saxon/Saxon-HE/11/Java/SaxonHE11-3J.zip"
version "11.3"
sha256 "c462e29994e1622d1cdc50514469fd4c9eb13cb7658abe129667b2be8df35fb4"
license all_of: ["BSD-3-Clause", "MIT", "MPL-2.0"]
livecheck do
url :stable
regex(%r{url=.*?/SaxonHE(\d+(?:[.-]\d+)+)J?\.(?:t|zip)}i)
strategy :sourceforge do |page, regex|
page.scan(regex).map { |match| match&.first&.gsub("-", ".") }
end
end
bottle do
sha256 cellar: :any_skip_relocation, all: "02139e73950876f495a8cacd3b177e94f9a12b49748550a921b98f6c4a3a89e2"
end
depends_on "openjdk"
def install
libexec.install Dir["*.jar", "doc", "lib", "notices"]
bin.write_jar_script libexec/"saxon-he-#{version.major_minor}.jar", "saxon"
end
test do
(testpath/"test.xml").write <<~EOS
<test>It works!</test>
EOS
(testpath/"test.xsl").write <<~EOS
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html>
<body>
<p><xsl:value-of select="test"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
EOS
assert_equal <<~EOS.chop, shell_output("#{bin}/saxon test.xml test.xsl")
<!DOCTYPE HTML><html>
<body>
<p>It works!</p>
</body>
</html>
EOS
end
end