181 lines
6.5 KiB
Ruby
181 lines
6.5 KiB
Ruby
class Jrnl < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Command-line note taker"
|
|
homepage "https://jrnl.sh/"
|
|
url "https://files.pythonhosted.org/packages/f5/e9/286e27e7d1f1136f7487ef42345b8841320442c031f535a2f224f49200df/jrnl-2.4.4.tar.gz"
|
|
sha256 "ec0d15cbfe3f003bfdf6e0829cf04006a23c830da3a304506b727e880f81cd62"
|
|
license "GPL-3.0"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "e1ad8309f6e5a7d6efaf5ac4acd8f319910d3c7dd788e13719526e0177dff7d5" => :catalina
|
|
sha256 "b288379f31e5ebf4868a82702d73f4a5fbc8df0a2a280088db4d9be75276a960" => :mojave
|
|
sha256 "71e27f6d7488d3a1c237fc9056b776685cf019cc1d274a0f6fc3b2fee9edfbd1" => :high_sierra
|
|
end
|
|
|
|
depends_on "python@3.8"
|
|
|
|
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/e4/3b/8aaee90977588fa3e88d7a495af306d6f4a1c1c01c8f0fe0de1fc43d0908/asteval-0.9.18.tar.gz"
|
|
sha256 "5d64e18b8a72c2c7ae8f9b70d1f80b68bbcaa98c1c0d7047c35489d03209bc86"
|
|
end
|
|
|
|
resource "cffi" do
|
|
url "https://files.pythonhosted.org/packages/05/54/3324b0c46340c31b909fcec598696aaec7ddc8c18a63f2db352562d3354c/cffi-1.14.0.tar.gz"
|
|
sha256 "2d384f4a127a15ba701207f7639d94106693b6cd64173d6c8988e2c25f3ac2b6"
|
|
end
|
|
|
|
resource "colorama" do
|
|
url "https://files.pythonhosted.org/packages/82/75/f2a4c0c94c85e2693c229142eb448840fba0f9230111faa889d1f541d12d/colorama-0.4.3.tar.gz"
|
|
sha256 "e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"
|
|
end
|
|
|
|
resource "cryptography" do
|
|
url "https://files.pythonhosted.org/packages/56/3b/78c6816918fdf2405d62c98e48589112669f36711e50158a0c15d804c30d/cryptography-2.9.2.tar.gz"
|
|
sha256 "a0c30272fb4ddda5f5ffc1089d7405b7a71b0b0f51993cb4e5dbb4590b2fc229"
|
|
end
|
|
|
|
resource "keyring" do
|
|
url "https://files.pythonhosted.org/packages/a6/52/eb8a0e13b54ec9240c7dd68fcd0951c52f62033d438af372831af770f7cc/keyring-21.2.1.tar.gz"
|
|
sha256 "c53e0e5ccde3ad34284a40ce7976b5b3a3d6de70344c3f8ee44364cc340976ec"
|
|
end
|
|
|
|
resource "packaging" do
|
|
url "https://files.pythonhosted.org/packages/65/37/83e3f492eb52d771e2820e88105f605335553fe10422cba9d256faeb1702/packaging-20.3.tar.gz"
|
|
sha256 "3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3"
|
|
end
|
|
|
|
resource "parsedatetime" do
|
|
url "https://files.pythonhosted.org/packages/a8/20/cb587f6672dbe585d101f590c3871d16e7aec5a576a1694997a3777312ac/parsedatetime-2.6.tar.gz"
|
|
sha256 "4cb368fbb18a0b7231f4d76119165451c8d2e35951455dfee97c62a87b04d455"
|
|
end
|
|
|
|
resource "passlib" do
|
|
url "https://files.pythonhosted.org/packages/6d/6b/4bfca0c13506535289b58f9c9761d20f56ed89439bfe6b8e07416ce58ee1/passlib-1.7.2.tar.gz"
|
|
sha256 "8d666cef936198bc2ab47ee9b0410c94adf2ba798e5a84bf220be079ae7ab6a8"
|
|
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/be/ed/5bbc91f03fa4c839c4c7360375da77f9659af5f7086b7a7bdda65771c8e0/python-dateutil-2.8.1.tar.gz"
|
|
sha256 "73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"
|
|
end
|
|
|
|
resource "pytz" do
|
|
url "https://files.pythonhosted.org/packages/f4/f6/94fee50f4d54f58637d4b9987a1b862aeb6cd969e73623e02c5c00755577/pytz-2020.1.tar.gz"
|
|
sha256 "c35965d010ce31b23eeb663ed3cc8c906275d6be1a34393a1d73a41febf4a048"
|
|
end
|
|
|
|
resource "pyxdg" do
|
|
url "https://files.pythonhosted.org/packages/47/6e/311d5f22e2b76381719b5d0c6e9dc39cd33999adae67db71d7279a6d70f4/pyxdg-0.26.tar.gz"
|
|
sha256 "fe2928d3f532ed32b39c32a482b54136fe766d19936afc96c8f00645f9da1a06"
|
|
end
|
|
|
|
resource "PyYAML" do
|
|
url "https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz"
|
|
sha256 "b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/6b/34/415834bfdafca3c5f451532e8a8d9ba89a21c9743a0c59fbd0205c7f9426/six-1.15.0.tar.gz"
|
|
sha256 "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"
|
|
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
|
|
|
|
def install
|
|
# Avoid error "ModuleNotFoundError: No module named 'clikit'", which is only used in Poetry build process
|
|
rm_f "pyproject.toml"
|
|
|
|
virtualenv_install_with_resources
|
|
end
|
|
|
|
test do
|
|
(testpath/"tests.sh").write <<~EOS
|
|
#!/usr/bin/expect -f
|
|
|
|
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
|