2019-02-04 04:33:06 +00:00
|
|
|
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"
|
|
|
|
|
2019-02-05 21:39:33 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any_skip_relocation
|
|
|
|
sha256 "34211b3c0dd4cd265c4f48fff89af75ebeeb2c8e8af6fb0d1b7efda1dd3d5a21" => :mojave
|
|
|
|
sha256 "e9df149e4f974b5a54d6591332d205bc706a2115601691ae7fa6d358e7e74291" => :high_sierra
|
|
|
|
sha256 "cbd8c8763e194f661b58550e2d3602d21f70e8957a338d5f29982b312acbfe25" => :sierra
|
|
|
|
end
|
|
|
|
|
2019-02-04 04:33:06 +00:00
|
|
|
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
|