201 lines
7.6 KiB
Ruby
201 lines
7.6 KiB
Ruby
class Jrnl < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Command-line note taker"
|
|
homepage "https://jrnl.sh/"
|
|
url "https://files.pythonhosted.org/packages/eb/29/0a133d2a95e68fc7b8964ce65ab37eb1ae922387c743d52bfc51d1a47a8f/jrnl-2.8.2.tar.gz"
|
|
sha256 "102e1f559fe4e791cd1a456efd4c5b2c5893703285a881c54a8f55e437e95eff"
|
|
license "GPL-3.0-only"
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_big_sur: "34070aef3a5f5c0d5fbda198040bbdc9e55be888bb4839ede138c9654e7da224"
|
|
sha256 cellar: :any, big_sur: "e8b1bc3d530ee445010c3c06b6e28918ccb4e163632a4cb396199a3c66d8fc94"
|
|
sha256 cellar: :any, catalina: "495fa86f26e9b548a526e9c80822a40fd74addcfcdefcb0217796b025ce1fe37"
|
|
sha256 cellar: :any, mojave: "eb0616878a7bd05560ad6dea5aa53c2ba7d7f486ba61411a977c55ef027a4c81"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "19e725b1a5b25f3eb854bb14476a8631a8f03d0316568ca323cafb1f5c13cbcd"
|
|
end
|
|
|
|
depends_on "rust" => :build
|
|
depends_on "python@3.9"
|
|
|
|
uses_from_macos "expect" => :test
|
|
|
|
on_linux do
|
|
depends_on "pkg-config" => :build
|
|
end
|
|
|
|
resource "ansiwrap" do
|
|
url "https://files.pythonhosted.org/packages/7c/45/2616341cfcace37d4619d5106a85fcc24f2170d1a161bc5f7fdb81772fbc/ansiwrap-0.8.4.zip"
|
|
sha256 "ca0c740734cde59bf919f8ff2c386f74f9a369818cdc60efe94893d01ea8d9b7"
|
|
end
|
|
|
|
resource "asteval" do
|
|
url "https://files.pythonhosted.org/packages/f0/81/c1385350267c5c02be74acba7167fd6608083324a51421c6b8a57240eb35/asteval-0.9.25.tar.gz"
|
|
sha256 "bea22b7d8fa16bcba95ebc72052ae5d8ca97114c9959bb47f8b8eebf30e4342f"
|
|
end
|
|
|
|
resource "cffi" do
|
|
url "https://files.pythonhosted.org/packages/2e/92/87bb61538d7e60da8a7ec247dc048f7671afe17016cd0008b3b710012804/cffi-1.14.6.tar.gz"
|
|
sha256 "c9a875ce9d7fe32887784274dd533c57909b7b1dcadcc128a2ac21331a9765dd"
|
|
end
|
|
|
|
resource "colorama" do
|
|
url "https://files.pythonhosted.org/packages/1f/bb/5d3246097ab77fa083a61bd8d3d527b7ae063c7d8e8671b1cf8c4ec10cbe/colorama-0.4.4.tar.gz"
|
|
sha256 "5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"
|
|
end
|
|
|
|
resource "cryptography" do
|
|
url "https://files.pythonhosted.org/packages/9b/77/461087a514d2e8ece1c975d8216bc03f7048e6090c5166bc34115afdaa53/cryptography-3.4.7.tar.gz"
|
|
sha256 "3d10de8116d25649631977cb37da6cbdd2d6fa0e0281d014a5b7d337255ca713"
|
|
end
|
|
|
|
resource "importlib-metadata" do
|
|
url "https://files.pythonhosted.org/packages/58/f1/9b77b8aa38482b7c284b8f8eda8b99d3b1103a280f107bab362a1c518c92/importlib_metadata-4.6.3.tar.gz"
|
|
sha256 "0645585859e9a6689c523927a5032f2ba5919f1f7d0e84bd4533312320de1ff9"
|
|
end
|
|
|
|
resource "keyring" do
|
|
url "https://files.pythonhosted.org/packages/b0/b5/b27458e1d2adf2a11c6e95c67ac63f828e96fe7e166132e5dacbe03e88c0/keyring-23.0.1.tar.gz"
|
|
sha256 "045703609dd3fccfcdb27da201684278823b72af515aedec1a8515719a038cb8"
|
|
end
|
|
|
|
resource "parsedatetime" do
|
|
url "https://files.pythonhosted.org/packages/a8/20/cb587f6672dbe585d101f590c3871d16e7aec5a576a1694997a3777312ac/parsedatetime-2.6.tar.gz"
|
|
sha256 "4cb368fbb18a0b7231f4d76119165451c8d2e35951455dfee97c62a87b04d455"
|
|
end
|
|
|
|
resource "pycparser" do
|
|
url "https://files.pythonhosted.org/packages/0f/86/e19659527668d70be91d0369aeaa055b4eb396b0f387a4f92293a20035bd/pycparser-2.20.tar.gz"
|
|
sha256 "2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"
|
|
end
|
|
|
|
resource "python-dateutil" do
|
|
url "https://files.pythonhosted.org/packages/4c/c4/13b4776ea2d76c115c1d1b84579f3764ee6d57204f6be27119f13a61d0a9/python-dateutil-2.8.2.tar.gz"
|
|
sha256 "0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"
|
|
end
|
|
|
|
resource "pytz" do
|
|
url "https://files.pythonhosted.org/packages/b0/61/eddc6eb2c682ea6fd97a7e1018a6294be80dba08fa28e7a3570148b4612d/pytz-2021.1.tar.gz"
|
|
sha256 "83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da"
|
|
end
|
|
|
|
resource "pyxdg" do
|
|
url "https://files.pythonhosted.org/packages/6f/2e/2251b5ae2f003d865beef79c8fcd517e907ed6a69f58c32403cec3eba9b2/pyxdg-0.27.tar.gz"
|
|
sha256 "80bd93aae5ed82435f20462ea0208fb198d8eec262e831ee06ce9ddb6b91c5a5"
|
|
end
|
|
|
|
resource "PyYAML" do
|
|
url "https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz"
|
|
sha256 "607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/71/39/171f1c67cd00715f190ba0b100d606d440a28c93c7714febeca8b79af85e/six-1.16.0.tar.gz"
|
|
sha256 "1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"
|
|
end
|
|
|
|
resource "textwrap3" do
|
|
url "https://files.pythonhosted.org/packages/4d/02/cef645d4558411b51700e3f56cefd88f05f05ec1b8fa39a3142963f5fcd2/textwrap3-0.9.2.zip"
|
|
sha256 "5008eeebdb236f6303dcd68f18b856d355f6197511d952ba74bc75e40e0c3414"
|
|
end
|
|
|
|
resource "tzlocal" do
|
|
url "https://files.pythonhosted.org/packages/ce/73/99e4cc30db6b21cba6c3b3b80cffc472cc5a0feaf79c290f01f1ac460710/tzlocal-2.1.tar.gz"
|
|
sha256 "643c97c5294aedc737780a49d9df30889321cbe1204eac2c2ec6134035a92e44"
|
|
end
|
|
|
|
resource "zipp" do
|
|
url "https://files.pythonhosted.org/packages/3a/9f/1d4b62cbe8d222539a84089eeab603d8e45ee1f897803a0ae0860400d6e7/zipp-3.5.0.tar.gz"
|
|
sha256 "f5812b1e007e48cff63449a5e9f4e7ebea716b4111f9c4f9a645f91d579bf0c4"
|
|
end
|
|
|
|
resource "asn1crypto" do
|
|
on_linux do
|
|
url "https://files.pythonhosted.org/packages/9f/3d/8beae739ed8c1c8f00ceac0ab6b0e97299b42da869e24cf82851b27a9123/asn1crypto-1.3.0.tar.gz"
|
|
sha256 "5a215cb8dc12f892244e3a113fe05397ee23c5c4ca7a69cd6e69811755efc42d"
|
|
end
|
|
end
|
|
|
|
resource "jeepney" do
|
|
on_linux do
|
|
url "https://files.pythonhosted.org/packages/74/24/9b720cc6b2a73c908896a0ed64cb49780dcfbf4964e23a725aa6323f4452/jeepney-0.4.3.tar.gz"
|
|
sha256 "3479b861cc2b6407de5188695fa1a8d57e5072d7059322469b62628869b8e36e"
|
|
end
|
|
end
|
|
|
|
resource "secretstorage" do
|
|
on_linux do
|
|
url "https://files.pythonhosted.org/packages/fd/9f/36197c75d9a09b1ab63f56cb985af6cd858ca3fc41fd9cd890ce69bae5b9/SecretStorage-3.1.2.tar.gz"
|
|
sha256 "15da8a989b65498e29be338b3b279965f1b8f09b9668bd8010da183024c8bff6"
|
|
end
|
|
end
|
|
|
|
def install
|
|
virtualenv_install_with_resources
|
|
end
|
|
|
|
test do
|
|
(testpath/"tests.sh").write <<~EOS
|
|
#!/usr/bin/env expect
|
|
|
|
set timeout 3
|
|
match_max 100000
|
|
|
|
# Write the journal
|
|
spawn "#{bin}/jrnl" "This is the fanciest test in the world."
|
|
|
|
expect {
|
|
"/.local/share/jrnl/journal.txt" { send -- "#{testpath}/test.txt\r" }
|
|
timeout { exit 1 }
|
|
}
|
|
|
|
expect {
|
|
"You can always change this later" { send -- "n\r" }
|
|
timeout { exit 1 }
|
|
}
|
|
|
|
expect {
|
|
eof { exit }
|
|
timeout { exit 1 }
|
|
}
|
|
|
|
# Read the journal
|
|
spawn "#{bin}/jrnl" -1
|
|
|
|
expect {
|
|
"This is the fanciest test in the world." { exit }
|
|
timeout { exit 1 }
|
|
eof { exit 1 }
|
|
}
|
|
|
|
# Encrypt the journal
|
|
spawn "#{bin}/jrnl" --encrypt
|
|
|
|
expect {
|
|
-exact "Enter password for new journal: " { send -- "homebrew\r" }
|
|
timeout { exit 1 }
|
|
}
|
|
|
|
expect {
|
|
-exact "Enter password again: " { send -- "homebrew\r" }
|
|
timeout { exit 1 }
|
|
}
|
|
|
|
expect {
|
|
-exact "Do you want to store the password in your keychain? \[Y/n\] " { send -- "n\r" }
|
|
timeout { exit 1 }
|
|
}
|
|
|
|
expect {
|
|
-re "Journal encrypted to .*/test.txt." { exit }
|
|
timeout { exit 1 }
|
|
eof { exit 1 }
|
|
}
|
|
EOS
|
|
|
|
system "expect", "./tests.sh"
|
|
assert_predicate testpath/".config/jrnl/jrnl.yaml", :exist?
|
|
assert_predicate testpath/"test.txt", :exist?
|
|
end
|
|
end
|