162 lines
6.1 KiB
Ruby
162 lines
6.1 KiB
Ruby
class Buku < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Powerful command-line bookmark manager"
|
|
homepage "https://github.com/jarun/Buku"
|
|
url "https://github.com/jarun/Buku/archive/v4.3.tar.gz"
|
|
sha256 "4c91cb0ac83164153c65705f46af29aaede78a2ed48d836cd2269b0fc71fed7a"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "2868e1d9ac7aa0bb4a92e6711aef4a1a3ef2cf3d52ea282e8a742da411de5df4" => :catalina
|
|
sha256 "65a2d74c738738f2a5aecb8d6c408356eb8cbfacc51d65919d6dae1140987cae" => :mojave
|
|
sha256 "5ba4a32e24d3dc000b4b9076e1afd0ee5ab009882969e29ad5241cd68d4582b4" => :high_sierra
|
|
end
|
|
|
|
depends_on "openssl@1.1"
|
|
depends_on "python"
|
|
|
|
resource "asn1crypto" do
|
|
url "https://files.pythonhosted.org/packages/9f/3d/8beae739ed8c1c8f00ceac0ab6b0e97299b42da869e24cf82851b27a9123/asn1crypto-1.3.0.tar.gz"
|
|
sha256 "5a215cb8dc12f892244e3a113fe05397ee23c5c4ca7a69cd6e69811755efc42d"
|
|
end
|
|
|
|
resource "beautifulsoup4" do
|
|
url "https://files.pythonhosted.org/packages/52/ba/0e121661f529e7f456e903bf5c4d255b8051d8ce2b5e629c5212efe4c3f1/beautifulsoup4-4.8.2.tar.gz"
|
|
sha256 "05fd825eb01c290877657a56df4c6e4c311b3965bda790c613a3d6fb01a5462a"
|
|
end
|
|
|
|
resource "certifi" do
|
|
url "https://files.pythonhosted.org/packages/41/bf/9d214a5af07debc6acf7f3f257265618f1db242a3f8e49a9b516f24523a6/certifi-2019.11.28.tar.gz"
|
|
sha256 "25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"
|
|
end
|
|
|
|
resource "cffi" do
|
|
url "https://files.pythonhosted.org/packages/2d/bf/960e5a422db3ac1a5e612cb35ca436c3fc985ed4b7ed13a1b4879006f450/cffi-1.13.2.tar.gz"
|
|
sha256 "599a1e8ff057ac530c9ad1778293c665cb81a791421f46922d80a86473c13346"
|
|
end
|
|
|
|
resource "cryptography" do
|
|
url "https://files.pythonhosted.org/packages/be/60/da377e1bed002716fb2d5d1d1cab720f298cb33ecff7bf7adea72788e4e4/cryptography-2.8.tar.gz"
|
|
sha256 "3cda1f0ed8747339bbdf71b9f38ca74c7b592f24f65cdb3ab3765e4b02871651"
|
|
end
|
|
|
|
resource "html5lib" do
|
|
url "https://files.pythonhosted.org/packages/85/3e/cf449cf1b5004e87510b9368e7a5f1acd8831c2d6691edd3c62a0823f98f/html5lib-1.0.1.tar.gz"
|
|
sha256 "66cb0dcfdbbc4f9c3ba1a63fdb511ffdbd4f513b2b6d81b80cd26ce6b3fb3736"
|
|
end
|
|
|
|
resource "idna" do
|
|
url "https://files.pythonhosted.org/packages/ad/13/eb56951b6f7950cadb579ca166e448ba77f9d24efc03edd7e55fa57d04b7/idna-2.8.tar.gz"
|
|
sha256 "c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407"
|
|
end
|
|
|
|
resource "pycparser" do
|
|
url "https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz"
|
|
sha256 "a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/21/9f/b251f7f8a76dec1d6651be194dfba8fb8d7781d10ab3987190de8391d08e/six-1.14.0.tar.gz"
|
|
sha256 "236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"
|
|
end
|
|
|
|
resource "soupsieve" do
|
|
url "https://files.pythonhosted.org/packages/92/cf/57dfed8a00f4ba33af3a6615d693bb65a19a11e26ab13293f62359216417/soupsieve-1.9.5.tar.gz"
|
|
sha256 "e2c1c5dee4a1c36bcb790e0fabd5492d874b8ebd4617622c4f6a731701060dda"
|
|
end
|
|
|
|
resource "urllib3" do
|
|
url "https://files.pythonhosted.org/packages/09/06/3bc5b100fe7e878d3dee8f807a4febff1a40c213d2783e3246edde1f3419/urllib3-1.25.8.tar.gz"
|
|
sha256 "87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc"
|
|
end
|
|
|
|
resource "webencodings" do
|
|
url "https://files.pythonhosted.org/packages/0b/02/ae6ceac1baeda530866a85075641cec12989bd8d31af6d5ab4a3e8c92f47/webencodings-0.5.1.tar.gz"
|
|
sha256 "b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"
|
|
end
|
|
|
|
def install
|
|
venv = virtualenv_create(libexec, "python3")
|
|
venv.pip_install resources
|
|
|
|
# Replace shebang with virtualenv python
|
|
inreplace "buku", "#!/usr/bin/env python3", "#!#{libexec}/bin/python"
|
|
|
|
bin.install "buku"
|
|
man1.install "buku.1"
|
|
bash_completion.install "auto-completion/bash/buku-completion.bash"
|
|
fish_completion.install "auto-completion/fish/buku.fish"
|
|
zsh_completion.install "auto-completion/zsh/_buku"
|
|
end
|
|
|
|
test do
|
|
ENV["LC_ALL"] = "en_US.UTF-8"
|
|
ENV["XDG_DATA_HOME"] = "#{testpath}/.local/share"
|
|
|
|
# Firefox exported bookmarks file
|
|
(testpath/"bookmarks.html").write <<~EOS
|
|
<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
|
<TITLE>Bookmarks</TITLE>
|
|
<H1>Bookmarks Menu</H1>
|
|
|
|
<DL><p>
|
|
<HR> <DT><H3 ADD_DATE="1464091987" LAST_MODIFIED="1477369518" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks Toolbar</H3>
|
|
<DD>Add bookmarks to this folder to see them displayed on the Bookmarks Toolbar
|
|
<DL><p>
|
|
<DT><A HREF="https://github.com/Homebrew/brew" ADD_DATE="1477369518" LAST_MODIFIED="1477369529">Title unknown</A>
|
|
</DL><p>
|
|
</DL>
|
|
EOS
|
|
|
|
(testpath/"import").write <<~EOS
|
|
spawn #{bin}/buku --nc --import bookmarks.html
|
|
expect -re "DB file is being created at .*"
|
|
expect "You should encrypt it."
|
|
expect "Append tags when bookmark exist? (y/n): "
|
|
send "y\r"
|
|
expect "Add parent folder names as tags? (y/n): "
|
|
send "y\r"
|
|
expect {
|
|
-re ".*ERROR.*" { exit 1 }
|
|
"1. Title unknown"
|
|
}
|
|
spawn sleep 5
|
|
EOS
|
|
system "/usr/bin/expect", "-f", "import"
|
|
|
|
# Test online components -- fetch titles
|
|
system bin/"buku", "--update"
|
|
|
|
# Test crypto functionality
|
|
(testpath/"crypto-test").write <<~EOS
|
|
# Lock bookmark database
|
|
spawn #{bin}/buku --lock
|
|
expect "Password: "
|
|
send "password\r"
|
|
expect "Password: "
|
|
send "password\r"
|
|
expect {
|
|
-re ".*ERROR.*" { exit 1 }
|
|
"File encrypted"
|
|
}
|
|
|
|
# Unlock bookmark database
|
|
spawn #{bin}/buku --unlock
|
|
expect "Password: "
|
|
send "password\r"
|
|
expect {
|
|
-re ".*ERROR.*" { exit 1 }
|
|
"File decrypted"
|
|
}
|
|
EOS
|
|
system "/usr/bin/expect", "-f", "crypto-test"
|
|
|
|
# Test database content and search
|
|
result = shell_output("#{bin}/buku --np --sany Homebrew")
|
|
assert_match "https://github.com/Homebrew/brew", result
|
|
assert_match "The missing package manager for macOS", result
|
|
end
|
|
end
|