Skip to content

Commit 1cc20f9

Browse files
alex-scSMillerDev
andcommitted
metanorma 1.12.8 (new formula)
Co-Authored-By: Sean Molenaar <[email protected]>
1 parent 5f7d594 commit 1cc20f9

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

Formula/m/metanorma.rb

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
class Metanorma < Formula
2+
desc "Toolchain for publishing metanorma documentation"
3+
homepage "https://www.metanorma.com"
4+
url "https://github.com/metanorma/metanorma-cli/archive/refs/tags/v1.12.8.tar.gz"
5+
sha256 "92f5b0f0675d260cdebc29685e205af912116b0fa18f4a3dbf203df23f82c528"
6+
license "BSD-2-Clause"
7+
8+
depends_on "pkgconf" => :build
9+
depends_on "gflags"
10+
depends_on "graphviz"
11+
depends_on "openjdk"
12+
depends_on "plantuml"
13+
depends_on "readline"
14+
depends_on "[email protected]" # default ruby 2.6 is not supported
15+
depends_on "xml2rfc"
16+
17+
uses_from_macos "sqlite"
18+
uses_from_macos "zlib"
19+
20+
on_linux do
21+
depends_on "libxslt"
22+
end
23+
24+
resource "gemfile-lock" do
25+
url "https://github.com/metanorma/metanorma-cli/releases/download/v1.12.8/Gemfile.lock"
26+
sha256 "d5abc46cdde32a1707736f76db4a2a5da4727ea78dcef59003f514ccd1ba5240"
27+
end
28+
29+
resource "gemfile" do
30+
url "https://rubygems.org/downloads/metanorma-cli-1.12.8.gem"
31+
sha256 "b746637b00a051ca409ccf98fc82c12c443d27183c3d4bdd3535ad47eb015573"
32+
end
33+
34+
def install
35+
ENV["BUNDLE_VERSION"] = "system" # Avoid installing Bundler into the keg
36+
ENV["GEM_HOME"] = libexec
37+
38+
# Ensure Ruby 3.4 is used
39+
ENV.prepend_path "PATH", Formula["[email protected]"].opt_bin
40+
41+
# Unpack the gemfile-lock and gemfile (to be shipped with the source code in future releases)
42+
resources.each do |r|
43+
r.stage do
44+
cp_r ".", buildpath
45+
end
46+
end
47+
# Remove the metanorma GitHub source block
48+
regex = %r{
49+
source\s+"https://rubygems\.pkg\.github\.com/metanorma"\s+do\s+
50+
gem\s+"metanorma-nist"\s+
51+
end\n?
52+
}mx
53+
inreplace "Gemfile", regex, ""
54+
55+
# Configure sqlite3 to use brew's libsqlite3
56+
sqlite = Formula["sqlite"]
57+
system "bundle", "config", "build.sqlite3",
58+
"--enable-system-libraries",
59+
"--with-sqlite3-include=#{sqlite.opt_include}",
60+
"--with-sqlite3-lib=#{sqlite.opt_include}"
61+
62+
if OS.linux?
63+
# Configure pngcheck to use brew's zlib (libz.so.1)
64+
zlib = Formula["zlib"]
65+
ENV.append "CFLAGS", "-I#{zlib.opt_include}"
66+
ENV.append "LDFLAGS", "-L#{zlib.opt_lib} -Wl,-rpath,#{zlib.opt_lib}"
67+
ENV.append "PKG_CONFIG_PATH", "#{zlib.opt_lib}/pkgconfig"
68+
end
69+
70+
system "bundle", "config", "set", "without", "development", "test"
71+
system "bundle", "install"
72+
system "gem", "build", "metanorma-cli.gemspec"
73+
system "gem", "install", "metanorma-cli-#{version}.gem"
74+
75+
bin.install libexec/"bin/#{name}"
76+
bin.env_script_all_files(
77+
libexec/"bin",
78+
PATH: "#{Formula["[email protected]"].opt_bin}:$PATH",
79+
GEM_HOME: ENV["GEM_HOME"],
80+
JAVA_HOME: Language::Java.overridable_java_home_env[:JAVA_HOME],
81+
)
82+
end
83+
84+
def caveats
85+
<<~EOS
86+
inkscape >= 1.0 is required to generate Word output using SVG images.
87+
Install it by running `brew cask install inkscape` or
88+
directly download from https://inkscape.org/release/inkscape-1.0/
89+
EOS
90+
end
91+
92+
test do
93+
test_doc = <<~ADOC
94+
= Document title
95+
Author
96+
:docfile: test.adoc
97+
:nodoc:
98+
:novalid:
99+
:no-isobib:
100+
ADOC
101+
102+
(testpath / "test-iso.adoc").write(test_doc)
103+
system bin/"metanorma", "--type", "iso", testpath / "test-iso.adoc",
104+
"--agree-to-terms"
105+
assert_path_exists testpath / "test-iso.xml"
106+
assert_path_exists testpath / "test-iso.html"
107+
108+
(testpath / "test-csa.adoc").write(test_doc)
109+
system bin/"metanorma", "--type", "csa", testpath / "test-csa.adoc",
110+
"--agree-to-terms"
111+
assert_path_exists testpath / "test-csa.pdf"
112+
assert_path_exists testpath / "test-csa.html"
113+
end
114+
end

0 commit comments

Comments
 (0)