From 90d47ed6bb02e9022a0f31a0a3de2c0a64644e28 Mon Sep 17 00:00:00 2001 From: Christopher D'Cunha Date: Sun, 3 Feb 2019 23:33:06 -0500 Subject: [PATCH] jinja2-cli 0.6.0 (new formula) Closes #36691. Signed-off-by: FX Coudert --- Formula/jinja2-cli.rb | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Formula/jinja2-cli.rb diff --git a/Formula/jinja2-cli.rb b/Formula/jinja2-cli.rb new file mode 100644 index 0000000000..ab0afef24b --- /dev/null +++ b/Formula/jinja2-cli.rb @@ -0,0 +1,58 @@ +class Jinja2Cli < Formula + include Language::Python::Virtualenv + + desc "CLI for the Jinja2 templating language" + homepage "https://github.com/mattrobenolt/jinja2-cli" + url "https://files.pythonhosted.org/packages/50/24/a774867a93c19d21f132154b509ad014ab22106e1927d0241b556cf8c836/jinja2-cli-0.6.0.tar.gz" + sha256 "4b1be17ce8a8f133df02205c3f0d3ebfc3a68e795d26987f846a2316636427b7" + + depends_on "python" + + resource "jinja2" do + url "https://files.pythonhosted.org/packages/56/e6/332789f295cf22308386cf5bbd1f4e00ed11484299c5d7383378cf48ba47/Jinja2-2.10.tar.gz" + sha256 "f84be1bb0040caca4cea721fcbbbbd61f9be9464ca236387158b0feea01914a4" + end + + resource "MarkupSafe" do + url "https://files.pythonhosted.org/packages/ac/7e/1b4c2e05809a4414ebce0892fe1e32c14ace86ca7d50c70f00979ca9b3a3/MarkupSafe-1.1.0.tar.gz" + sha256 "4e97332c9ce444b0c2c38dd22ddc61c743eb208d916e4265a2a3b575bdccb1d3" + end + + def install + virtualenv_install_with_resources + end + + test do + assert_match version.to_s, shell_output("script -q /dev/null #{bin}/jinja2 --version") + expected_result = <<~EOS + The Beatles: + - Ringo Starr + - George Harrison + - Paul McCartney + - John Lennon + EOS + template_file = testpath/"my-template.tmpl" + template_file.write <<~EOS + {{ band.name }}: + {% for member in band.members -%} + - {{ member.first_name }} {{ member.last_name }} + {% endfor -%} + EOS + template_variables_file = testpath/"my-template-variables.json" + template_variables_file.write <<~EOS + { + "band": { + "name": "The Beatles", + "members": [ + {"first_name": "Ringo", "last_name": "Starr"}, + {"first_name": "George", "last_name": "Harrison"}, + {"first_name": "Paul", "last_name": "McCartney"}, + {"first_name": "John", "last_name": "Lennon"} + ] + } + } + EOS + output = shell_output("#{bin}/jinja2 #{template_file} #{template_variables_file}") + assert_equal output, expected_result + end +end