class Pius < Formula
  include Language::Python::Virtualenv

  desc "PGP individual UID signer"
  homepage "https://www.phildev.net/pius/"
  url "https://github.com/jaymzh/pius/archive/v2.2.7.tar.gz"
  sha256 "1a806299bce6faa8d7f97a8fef9a0ed4cca1b68e7dff311981103cf512903d46"
  head "https://github.com/jaymzh/pius.git"

  bottle do
    cellar :any_skip_relocation
    sha256 "c6a89759b45a3eb4872c9d2b5ee6b2a8cffd7d9d2d7de68832886f2f291e0a87" => :mojave
    sha256 "7b46acad45cbc2559c2b167e5060842fea50256ddd375ba9bb6147cfd4ba286b" => :high_sierra
    sha256 "018c43d5e6de8bf924ea090937758dfc04aec4d3abbe543227fd352064f75556" => :sierra
  end

  depends_on "gnupg"
  depends_on "python"

  resource "six" do
    url "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz"
    sha256 "70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"
  end

  def install
    # Replace hardcoded gpg path (WONTFIX)
    inreplace "libpius/constants.py", %r{/usr/bin/gpg2?}, "/usr/bin/env gpg"
    virtualenv_install_with_resources
  end

  def caveats; <<~EOS
    The path to gpg is hardcoded in pius as `/usr/bin/env gpg`.
    You can specify a different path by editing ~/.pius:
      gpg-path=/path/to/gpg
  EOS
  end

  test do
    system bin/"pius", "-T"
  end
end
