64 lines
2.2 KiB
Ruby
64 lines
2.2 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.18.1.tar.gz"
|
|
sha256 "4ff70a257cd6a0ccbcdddfd0a2dc4f954fcb371447a8494252dc1165145c126a"
|
|
head "https://github.com/thanethomson/statik.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "9e765c6e9d659702090f47534dc1584606ba0d6d888ce6c63e4533caa33b6e1b" => :high_sierra
|
|
sha256 "7176159aba59db64ee1506531461af5f8b22f5fdcebc8d07e3825dfef5139b9c" => :sierra
|
|
sha256 "4a317114436918be9e1bf0b6758b5a61aa2188345d3fe0b2139491d6a0834f1b" => :el_capitan
|
|
end
|
|
|
|
depends_on :python if MacOS.version <= :snow_leopard
|
|
|
|
def install
|
|
venv = virtualenv_create(libexec)
|
|
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
|