-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
y2j 1.1.1 (new formula) #10927
y2j 1.1.1 (new formula) #10927
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
class Y2j < Formula | ||
include Language::Python::Virtualenv | ||
desc "command-line tool for converting between YAML and JSON and vice versa." | ||
homepage "https://github.com/wildducktheories/y2j" | ||
url "https://github.com/wildducktheories/y2j/archive/v1.1.1.tar.gz" | ||
sha256 "e11ac6886937b3c9784f61d3c77d00d9b4dbf3fa10ec6ddc6f847b68196d9f5d" | ||
head "https://github.com/wildducktheories/y2j.git" | ||
|
||
depends_on "jq" => :run | ||
depends_on "base64" => :run | ||
depends_on :python => :run | ||
depends_on "docker" => :optional | ||
|
||
resource "PyYAML" do | ||
url "https://files.pythonhosted.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz" | ||
sha256 "592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab" | ||
end | ||
|
||
def install | ||
py_version = Language::Python.major_minor_version "python" | ||
venv_site_packages_path = libexec/"lib/python#{py_version}/site-packages" | ||
ENV["PYTHONPATH"] = venv_site_packages_path | ||
venv = virtualenv_create(libexec, "python") | ||
|
||
python_resources = resources.map(&:name).to_set | ||
python_resources.each do |r| | ||
venv.pip_install resource(r) | ||
end | ||
|
||
# Force our venv python for use with y2j | ||
inreplace buildpath/"y2j.sh", /^#!.*bash/, | ||
"#!/usr/bin/env bash\nexport PYTHONPATH=#{venv_site_packages_path}:$PYTHONPATH" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can do so in the formula: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't this only affect the runtime of the |
||
|
||
install_script = `./y2j.sh installer #{prefix.to_s}` | ||
|
||
File.open("install_y2j.sh", "w") do |f| | ||
f.write(install_script) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
chmod 0755, "./install_y2j.sh" | ||
system "./install_y2j.sh" | ||
|
||
bin.install "y2j.sh", "y2j", "j2y", "yq" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I understand what you mean on this one. It looked like The problem here was that " It was my understanding that the usage of |
||
end | ||
|
||
test do | ||
yaml_test_input = <<-EOS.undent | ||
--- | ||
foo: bar | ||
EOS | ||
|
||
expected_output = "{\n \"foo\": \"bar\"\n}" | ||
|
||
require "open3" | ||
Open3.popen3("#{bin}/y2j") do |stdin, stdout, _| | ||
stdin.write(yaml_test_input) | ||
stdin.close | ||
assert_equal expected_output, stdout.read | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use assert_equal "{\n \"foo\": \"bar\"\n}", pipe_output("#{bin}/y2j", yaml_test_input) |
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can
venv.pip_install resources
instead.