diff --git a/Formula/statik.rb b/Formula/statik.rb new file mode 100644 index 0000000000..471b734317 --- /dev/null +++ b/Formula/statik.rb @@ -0,0 +1,119 @@ +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.10.4.tar.gz" + sha256 "a93768023b3702712271f5734266ed1223e890121363fd030a3d2a6273cd583f" + head "https://github.com/thanethomson/statik.git" + + depends_on :python if MacOS.version <= :snow_leopard + + # future requirements + resource "future" do + url "https://pypi.python.org/packages/00/2b/8d082ddfed935f3608cc61140df6dcbf0edea1bc3ab52fb6c29ae3e81e85/future-0.16.0.tar.gz" + sha256 "e39ced1ab767b5936646cedba8bcce582398233d6a627067d4c6a454c90cfedb" + end + + # Jinja2 requirements + resource "MarkupSafe" do + url "https://pypi.python.org/packages/c0/41/bae1254e0396c0cc8cf1751cb7d9afc90a602353695af5952530482c963f/MarkupSafe-0.23.tar.gz" + sha256 "a4ec1aff59b95a14b45eb2e23761a0179e98319da5a7eb76b56ea8cdc7b871c3" + end + + resource "jinja2" do + url "https://pypi.python.org/packages/5f/bd/5815d4d925a2b8cbbb4b4960f018441b0c65f24ba29f3bdcfb3c8218a307/Jinja2-2.8.1.tar.gz" + sha256 "35341f3a97b46327b3ef1eb624aadea87a535b8f50863036e085e7c426ac5891" + end + + # livereload requirements + resource "six" do + url "https://pypi.python.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz" + sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a" + end + + resource "singledispatch" do + url "https://pypi.python.org/packages/d9/e9/513ad8dc17210db12cb14f2d4d190d618fb87dd38814203ea71c87ba5b68/singledispatch-3.4.0.3.tar.gz" + sha256 "5b06af87df13818d14f08a028e42f566640aef80805c3b50c5056b086e3c2b9c" + end + + resource "certifi" do + url "https://pypi.python.org/packages/4f/75/e1bc6e363a2c76f8d7e754c27c437dbe4086414e1d6d2f6b2a3e7846f22b/certifi-2016.9.26.tar.gz" + sha256 "8275aef1bbeaf05c53715bfc5d8569bd1e04ca1e8e69608cc52bcaac2604eb19" + end + + resource "backports-abc" do + url "https://pypi.python.org/packages/68/3c/1317a9113c377d1e33711ca8de1e80afbaf4a3c950dd0edfaf61f9bfe6d8/backports_abc-0.5.tar.gz" + sha256 "033be54514a03e255df75c5aee8f9e672f663f93abb723444caec8fe43437bde" + end + + resource "tornado" do + url "https://pypi.python.org/packages/1e/7c/ea047f7bbd1ff22a7f69fe55e7561040e3e54d6f31da6267ef9748321f98/tornado-4.4.2.tar.gz" + sha256 "2898f992f898cd41eeb8d53b6df75495f2f423b6672890aadaf196ea1448edcc" + end + + resource "livereload" do + url "https://pypi.python.org/packages/ba/71/2660028c74cb3289d4b9fd06632aa277b4edbe0747b7219cd92307fa19ba/livereload-2.5.0.tar.gz" + sha256 "bc708b46e22dff243c02e709c636ffeb8a64cdd019c95a215304e6ce183c4859" + end + + # markdown requirements + resource "markdown" do + url "https://pypi.python.org/packages/d4/32/642bd580c577af37b00a1eb59b0eaa996f2d11dfe394f3dd0c7a8a2de81a/Markdown-2.6.7.tar.gz" + sha256 "daebf24846efa7ff269cfde8c41a48bb2303920c7b2c7c5e04fa82e6282d05c0" + end + + # PyYAML requirements + resource "PyYAML" do + url "https://pypi.python.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz" + sha256 "592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab" + end + + # SQLAlchemy requirements + resource "SQLAlchemy" do + url "https://pypi.python.org/packages/ca/ca/c2436fdb7bb75d772d9fa17ba60c4cfded6284eed053a7274b2beb96596a/SQLAlchemy-1.1.4.tar.gz" + sha256 "701b57d628b9fa1cfb82f10665e7214d5d2db23251ca6f23b91c5f56fcdbdeb5" + end + + def install + virtualenv_install_with_resources + end + + test do + (testpath/"config.yml").write <<-EOS.undent + 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.undent + path: + template: /{{ post.pk }}/ + for-each: + post: session.query(Post).all() + template: post + EOS + (testpath/"views/home.yml").write <<-EOS.undent + path: / + template: home + EOS + (testpath/"templates/home.html").write <<-EOS.undent + + Home + Hello world! + + EOS + (testpath/"templates/post.html").write <<-EOS.undent + + Post + {{ post.title }} + + EOS + system bin/"statik" + + assert(File.exist?(testpath/"public/index.html"), "home view was not correctly generated!") + assert(File.exist?(testpath/"public/test-post1/index.html"), "test-post1 was not correctly generated!") + assert(File.exist?(testpath/"public/test-post2/index.html"), "test-post2 was not correctly generated!") + end +end