70 lines
2.5 KiB
Ruby
70 lines
2.5 KiB
Ruby
class Remarshal < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Convert between TOML, YAML and JSON"
|
|
homepage "https://github.com/dbohdan/remarshal"
|
|
url "https://github.com/dbohdan/remarshal/archive/v0.8.0.tar.gz"
|
|
sha256 "ab2ab978aaf20e97719680f8f242ea3407090b562d747205486a02cdbf14d17f"
|
|
revision 1
|
|
head "https://github.com/dbohdan/remarshal.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
rebuild 1
|
|
sha256 "b712854f25a498770ff04dab6f675279763ee0b7b1d354407135e80368d8e418" => :mojave
|
|
sha256 "44582cb5294bd6f84f5488b9ed3872656b732c81504b6063b104d1244614ab08" => :high_sierra
|
|
sha256 "f5006481444b6658f07ecbb7106a99291671690ffe45e6d54ad40372a4c92c20" => :sierra
|
|
end
|
|
|
|
depends_on "python"
|
|
|
|
resource "PyYAML" do
|
|
url "https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz"
|
|
sha256 "3ef3092145e9b70e3ddd2c7ad59bdd0252a94dfe3949721633e41344de00a6bf"
|
|
end
|
|
|
|
resource "pytoml" do
|
|
url "https://files.pythonhosted.org/packages/6d/2a/c5a0eb781cff59df8613a531f07f9d82bb47ea595aa91c6f114f1621a94a/pytoml-0.1.14.tar.gz"
|
|
sha256 "aff69147d436c3ba8c7f3bc1b3f4aa3d7e47d305a495f2631872e6429694aabf"
|
|
end
|
|
|
|
resource "python-dateutil" do
|
|
url "https://files.pythonhosted.org/packages/c5/39/4da7c2dbc4f023fba5fb2325febcadf0d0ce0efdc8bd12083a0f65d20653/python-dateutil-2.7.2.tar.gz"
|
|
sha256 "9d8074be4c993fbe4947878ce593052f71dac82932a677d49194d8ce9778002e"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz"
|
|
sha256 "70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"
|
|
end
|
|
|
|
def install
|
|
virtualenv_install_with_resources
|
|
|
|
["toml", "yaml", "json"].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
|
|
end
|
|
end
|