-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
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"
revision 1
bottle do
sha256 cellar: :any, arm64_sonoma: "5a422900be3d065fb5cd68129cd7d702e5399c564759cf21f9bc169223c69cb6"
sha256 cellar: :any, arm64_ventura: "80dfa76703902486f622b6de9c24e4f28fd1da701c966c2e4034b8b4ed41b7f8"
sha256 cellar: :any, arm64_monterey: "3e5e4715c5c4e8309d65131567f0288cc1e7c3fd9fcda4a290dea8afa00c6ae3"
sha256 cellar: :any, sonoma: "8722e2649db6798374bfcbb93ad6043fcc53efda58085220ef8293e853762ca9"
sha256 cellar: :any, ventura: "81cba3a13cd26ab9acb08dd1172ba78486b5c7f9f343f5814305f90f28afa4b3"
sha256 cellar: :any, monterey: "1bd54d03fb909d3c75370d74fd2cdc5b76c0372b76b1ca5bb02c15d50ac2eed8"
sha256 cellar: :any_skip_relocation, x86_64_linux: "f536e019bb6ba1d365c2ce7f2e3ac84c1d2f22065e690fdbd1e8da68387de246"
end
depends_on "libyaml"
depends_on "python@3.12"
resource "jinja2" do
url "https://files.pythonhosted.org/packages/ed/55/39036716d19cab0747a5020fc7e907f362fbf48c984b14e62127f7e68e5d/jinja2-3.1.4.tar.gz"
sha256 "4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369"
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