homebrew-core/Formula/remarshal.rb
2017-10-20 14:10:54 +01:00

69 lines
2.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://github.com/dbohdan/remarshal/archive/v0.7.0.tar.gz"
sha256 "785f1928e3522671a21eb2e0ce7b6882e8589ccb195b4ee49dec2403fe3d6f4b"
head "https://github.com/dbohdan/remarshal.git"
bottle do
cellar :any_skip_relocation
sha256 "59a7c2f89d2bac4215499eb54430dc7099ee2ab396c219be17a13314a07bea52" => :high_sierra
sha256 "65c68073ccdbc44ab9c6c2228cc5b1c762ffd5d603bff557408682003fd88a92" => :sierra
sha256 "99c3c25f5d38962b7a922e4aacef296b23589856db37747f2624a62fd0d46447" => :el_capitan
sha256 "d018b3c983e5256542d1864e6908057bc942b52db07c295cd89f6c8494855405" => :yosemite
end
depends_on :python if MacOS.version <= :snow_leopard
resource "PyYAML" do
url "https://files.pythonhosted.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz"
sha256 "592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab"
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/51/fc/39a3fbde6864942e8bb24c93663734b74e281b984d1b8c4f95d64b0c21f6/python-dateutil-2.6.0.tar.gz"
sha256 "62a2f8df3d66f878373fd0072eacf4ee52194ba302e00082828e0d263b0418d2"
end
resource "six" do
url "https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"
sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a"
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