84 lines
3.6 KiB
Ruby
84 lines
3.6 KiB
Ruby
class Remarshal < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Convert between TOML, YAML and JSON"
|
|
homepage "https://github.com/dbohdan/remarshal"
|
|
url "https://files.pythonhosted.org/packages/24/37/1f167687b2d9f3bac3e7e73508f86c7e6c1bf26a37ca5443182c8f596625/remarshal-0.14.0.tar.gz"
|
|
sha256 "16425aa1575a271dd3705d812b06276eeedc3ac557e7fd28e06822ad14cd0667"
|
|
license "MIT"
|
|
revision 3
|
|
head "https://github.com/dbohdan/remarshal.git", branch: "master"
|
|
|
|
bottle do
|
|
rebuild 1
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "c537c470d33b0e448c03a34754f95fcf6738bebab5a8484eae74448a5a0df737"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "72b85ac20f3ab3d3a8172294dd1af9830c2337da5e3a8b90a95cc33e67213a6b"
|
|
sha256 cellar: :any_skip_relocation, monterey: "87c3e6cc0bd24eba5749faae9deafdcd7691759c65d2f0a8a2f985b54c060815"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "63043b6846a31a0f5f65dde4564a9c58f00b58c51daa2125fd616408815959be"
|
|
sha256 cellar: :any_skip_relocation, catalina: "e9bb6247fc4e693b99f3d0075e04e315d54c996d8cafd7a2193c074f7e0b770e"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "4eb6f74d4dbd9fb9614adde6170a05faef95cacbd91e991fc5c403914b62b49a"
|
|
end
|
|
|
|
depends_on "poetry" => :build
|
|
depends_on "python@3.10"
|
|
depends_on "pyyaml"
|
|
depends_on "six"
|
|
|
|
conflicts_with "msgpack-tools", because: "both install 'json2msgpack' binary"
|
|
|
|
resource "cbor2" do
|
|
url "https://files.pythonhosted.org/packages/9e/25/9dd432c051010faea6a702cb85d0b53dc9d5414513866b6a73b3ac954092/cbor2-5.4.1.tar.gz"
|
|
sha256 "a8bf432f6cb595f50aeb8fed2a4aa3b3f7caa7f135fb57e4378eaa39242feac9"
|
|
end
|
|
|
|
resource "python-dateutil" do
|
|
url "https://files.pythonhosted.org/packages/4c/c4/13b4776ea2d76c115c1d1b84579f3764ee6d57204f6be27119f13a61d0a9/python-dateutil-2.8.2.tar.gz"
|
|
sha256 "0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"
|
|
end
|
|
|
|
resource "tomlkit" do
|
|
url "https://files.pythonhosted.org/packages/65/ed/7b7216101bc48627b630693b03392f33827901b81d4e1360a76515e3abc4/tomlkit-0.7.2.tar.gz"
|
|
sha256 "d7a454f319a7e9bd2e249f239168729327e4dd2d27b17dc68be264ad1ce36754"
|
|
end
|
|
|
|
resource "u-msgpack-python" do
|
|
url "https://files.pythonhosted.org/packages/62/94/a4f485b628310534d377b3e7cb6f85b8066dc823dbff0e4421fb4227fb7e/u-msgpack-python-2.7.1.tar.gz"
|
|
sha256 "b7e7d433cab77171a4c752875d91836f3040306bab5063fb6dbe11f64ea69551"
|
|
end
|
|
|
|
def install
|
|
venv = virtualenv_create(libexec, "python3.10")
|
|
venv.pip_install resources
|
|
system Formula["poetry"].opt_bin/"poetry", "build", "--format", "wheel", "--verbose", "--no-interaction"
|
|
venv.pip_install_and_link Dir["dist/remarshal-*.whl"].first
|
|
|
|
%w[toml yaml json msgpack].permutation(2).each do |informat, outformat|
|
|
bin.install_symlink "remarshal" => "#{informat}2#{outformat}"
|
|
end
|
|
end
|
|
|
|
test do
|
|
json = <<~EOS.chomp
|
|
{"foo.bar":"baz","qux":1}
|
|
EOS
|
|
yaml = <<~EOS.chomp
|
|
foo.bar: baz
|
|
qux: 1
|
|
|
|
EOS
|
|
toml = <<~EOS.chomp
|
|
"foo.bar" = "baz"
|
|
qux = 1
|
|
|
|
EOS
|
|
assert_equal yaml, pipe_output("#{bin}/remarshal -if=json -of=yaml", json)
|
|
assert_equal yaml, pipe_output("#{bin}/json2yaml", json)
|
|
assert_equal toml, pipe_output("#{bin}/remarshal -if=yaml -of=toml", yaml)
|
|
assert_equal toml, pipe_output("#{bin}/yaml2toml", yaml)
|
|
assert_equal json, pipe_output("#{bin}/remarshal -if=toml -of=json", toml).chomp
|
|
assert_equal json, pipe_output("#{bin}/toml2json", toml).chomp
|
|
assert_equal pipe_output("#{bin}/remarshal -if=yaml -of=msgpack", yaml),
|
|
pipe_output("#{bin}/remarshal -if=json -of=msgpack", json)
|
|
end
|
|
end
|