/
jinja2-cli.rb
91 lines (81 loc) 路 3.78 KB
/
jinja2-cli.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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/a4/22/c922839761b311b72ccc95c2ca2239311a3e80916458878962626f96922a/jinja2-cli-0.8.2.tar.gz"
sha256 "a16bb1454111128e206f568c95938cdef5b5a139929378f72bb8cf6179e18e50"
license "BSD-2-Clause"
bottle do
rebuild 6
sha256 cellar: :any, arm64_sonoma: "5e6317bf512472455c25ed47d55f79b34d06cfdb948cfeb578d9aba399a49716"
sha256 cellar: :any, arm64_ventura: "c80c6d8eba05a57503305aa937c16f63a7cb4be55c5c11fa154ff637758407a1"
sha256 cellar: :any, arm64_monterey: "61f5f30d260e9700923c66fc1e973208dcf6d7816daeaa8a0b559518e679e85b"
sha256 cellar: :any, sonoma: "45f6bf3e5b569a6884a8c1ee8746389bed3e9ffcb9b7505c2207d0cc5f53ed8a"
sha256 cellar: :any, ventura: "04bc49119ca858e3e1f455ae6da0c1d2dbda14987879bfbb31d71855b1a91afc"
sha256 cellar: :any, monterey: "9018172309d4bbd3a4d3fa15b75e96dda5c8d814d74feb86edda40ac2cd25f28"
sha256 cellar: :any_skip_relocation, x86_64_linux: "ffef8d2b244034ea71cf97254df437ad3e78dbb9cb7c4589d40181a0cdd71719"
end
depends_on "libyaml"
depends_on "python@3.12"
resource "jinja2" do
url "https://files.pythonhosted.org/packages/b2/5e/3a21abf3cd467d7876045335e681d276ac32492febe6d98ad89562d1a7e1/Jinja2-3.1.3.tar.gz"
sha256 "ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"
end
resource "markupsafe" do
url "https://files.pythonhosted.org/packages/87/5b/aae44c6655f3801e81aa3eef09dbbf012431987ba564d7231722f68df02d/MarkupSafe-2.1.5.tar.gz"
sha256 "d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b"
end
resource "pyyaml" do
url "https://files.pythonhosted.org/packages/cd/e5/af35f7ea75cf72f2cd079c95ee16797de7cd71f29ea7c68ae5ce7be1eda0/PyYAML-6.0.1.tar.gz"
sha256 "bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"
end
resource "toml" do
url "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c/toml-0.10.2.tar.gz"
sha256 "b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
end
resource "xmltodict" do
url "https://files.pythonhosted.org/packages/39/0d/40df5be1e684bbaecdb9d1e0e40d5d482465de6b00cbb92b84ee5d243c7f/xmltodict-0.13.0.tar.gz"
sha256 "341595a488e3e01a85a9d8911d8912fd922ede5fecc4dce437eb4b6c8d037e56"
end
def install
virtualenv_install_with_resources
end
test do
output = if OS.mac?
shell_output("script -q /dev/null #{bin}/jinja2 --version")
else
shell_output("script -q /dev/null -e -c \"#{bin}/jinja2 --version\"")
end
assert_match version.to_s, output
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