homebrew-core/Formula/statik.rb
2020-01-11 10:59:33 +01:00

67 lines
2.3 KiB
Ruby

class Statik < Formula
include Language::Python::Virtualenv
desc "Python-based, generic static web site generator aimed at developers"
homepage "https://getstatik.com"
url "https://github.com/thanethomson/statik/archive/v0.22.2.tar.gz"
sha256 "27aeda86c40ba2a489d2d8e85b7b38200e8f5763310003294c135ab2cf09975b"
revision 3
head "https://github.com/thanethomson/statik.git"
bottle do
cellar :any
sha256 "42b9ce47cd1adf076f99b06ee1af089870a2da0c4abc2f86fd98a94761a1eb27" => :catalina
sha256 "0291dbdf49901a3141f97a466ecda416ab8ee1c11c30f04bab8c5f4208a95a1c" => :mojave
sha256 "9d898d64f57db338a4ece54d14d6cdda03a47eb8131fbb6b39067c9213ec838c" => :high_sierra
end
depends_on "python@3.8"
conflicts_with "go-statik", :because => "both install `statik` binaries"
def install
venv = virtualenv_create(libexec, "python3")
system libexec/"bin/pip", "install", "-v", "--no-binary", ":all:",
"--ignore-installed", buildpath
system libexec/"bin/pip", "uninstall", "-y", "statik"
venv.pip_install_and_link buildpath
end
test do
(testpath/"config.yml").write <<~EOS
project-name: Homebrew Test
base-path: /
EOS
(testpath/"models/Post.yml").write("title: String")
(testpath/"data/Post/test-post1.yml").write("title: Test post 1")
(testpath/"data/Post/test-post2.yml").write("title: Test post 2")
(testpath/"views/posts.yml").write <<~EOS
path:
template: /{{ post.pk }}/
for-each:
post: session.query(Post).all()
template: post
EOS
(testpath/"views/home.yml").write <<~EOS
path: /
template: home
EOS
(testpath/"templates/home.html").write <<~EOS
<html>
<head><title>Home</title></head>
<body>Hello world!</body>
</html>
EOS
(testpath/"templates/post.html").write <<~EOS
<html>
<head><title>Post</title></head>
<body>{{ post.title }}</body>
</html>
EOS
system bin/"statik"
assert_predicate testpath/"public/index.html", :exist?, "home view was not correctly generated!"
assert_predicate testpath/"public/test-post1/index.html", :exist?, "test-post1 was not correctly generated!"
assert_predicate testpath/"public/test-post2/index.html", :exist?, "test-post2 was not correctly generated!"
end
end