class KaitaiStructCompiler < Formula desc "Compiler for generating binary data parsers" homepage "https://kaitai.io/" # Move to packages.kaitai.io when available. url "https://github.com/kaitai-io/kaitai_struct_compiler/releases/download/0.11/kaitai-struct-compiler-0.11.zip" sha256 "ff89389d9dc9e770d78a24af328763cb1f8e7b31ce7766c9edf10669a060f2a2" license "GPL-3.0-or-later" livecheck do url :homepage regex(/href=.*?kaitai-struct-compiler[._-]v?(\d+(?:\.\d+)+)\.zip/i) end bottle do sha256 cellar: :any_skip_relocation, all: "66821f7ac017603678d4c0d615f1421a9a68996d5a7592421e72dbea54f829b8" end depends_on "openjdk" def install libexec.install Dir["*"] (bin/"kaitai-struct-compiler").write_env_script libexec/"bin/kaitai-struct-compiler", JAVA_HOME: Formula["openjdk"].opt_prefix end test do (testpath/"Test.ksy").write <<~EOS meta: id: test endian: le file-extension: test seq: - id: header type: u4 EOS system bin/"kaitai-struct-compiler", "Test.ksy", "-t", "java", "--outdir", testpath assert_path_exists testpath/"Test.java" end end