68 lines
2.5 KiB
Ruby
68 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.10.0.tar.gz"
|
|
sha256 "7566a6426859785dd3b9fd276d281a67ecc8b09088b0affc1b128fe8c58302c2"
|
|
head "https://github.com/dbohdan/remarshal.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "2d89cb1474b2d8275c839dd1a217ded6b6490916f88b982ef0b795917fbad8c2" => :mojave
|
|
sha256 "fee3008d49e74c91d7d9bdbb3facd129a1b1b723cf6796e0d3a97c85e848b0ef" => :high_sierra
|
|
sha256 "d9c441f5965a000215be453be7c810ef7f471517629cbfaa92eecc8d3a28ce05" => :sierra
|
|
end
|
|
|
|
depends_on "python"
|
|
|
|
resource "PyYAML" do
|
|
url "https://files.pythonhosted.org/packages/a3/65/837fefac7475963d1eccf4aa684c23b95aa6c1d033a2c5965ccb11e22623/PyYAML-5.1.1.tar.gz"
|
|
sha256 "b4bb4d3f5e232425e25dda21c070ce05168a786ac9eda43768ab7f3ac2770955"
|
|
end
|
|
|
|
resource "pytoml" do
|
|
url "https://files.pythonhosted.org/packages/35/35/da1123673c54b6d701453fcd20f751d6a1fae43339b3993ae458875576e4/pytoml-0.1.20.tar.gz"
|
|
sha256 "ca2d0cb127c938b8b76a9a0d0f855cf930c1d50cc3a0af6d3595b566519a1013"
|
|
end
|
|
|
|
resource "python-dateutil" do
|
|
url "https://files.pythonhosted.org/packages/ad/99/5b2e99737edeb28c71bcbec5b5dda19d0d9ef3ca3e92e3e925e7c0bb364c/python-dateutil-2.8.0.tar.gz"
|
|
sha256 "c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/dd/bf/4138e7bfb757de47d1f4b6994648ec67a51efe58fa907c1e11e350cddfca/six-1.12.0.tar.gz"
|
|
sha256 "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
|
|
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
|