/
saxon.rb
55 lines (49 loc) 路 1.5 KB
/
saxon.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Saxon < Formula
desc "XSLT and XQuery processor"
homepage "https://github.com/Saxonica/Saxon-HE"
url "https://github.com/Saxonica/Saxon-HE/releases/download/SaxonHE12-4/SaxonHE12-4J.zip"
version "12.4"
sha256 "44ab28ea945090983196f0b6479596a27fd57a341e8465b6db7fc2eca8c3ddce"
license all_of: ["BSD-3-Clause", "MIT", "MPL-2.0"]
livecheck do
url :stable
regex(/^SaxonHE[._-]?v?(\d+(?:[.-]\d+)+)$/i)
strategy :github_latest do |json, regex|
match = json["tag_name"]&.match(regex)
next if match.blank?
match[1]&.tr("-", ".")
end
end
bottle do
sha256 cellar: :any_skip_relocation, all: "19384b20adad8aa3c1eb7e5e6323c39898beaab96d0b905c9c24e3988c6c60a5"
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