157 lines
6 KiB
Ruby
157 lines
6 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/v3.9.tar.gz"
|
|
sha256 "eb756901634f08dc294e511c69021e3c8bc24b34d16209e46e5cd3f6007d42be"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "c456ad1c4a94d84a9f3027cdf2bd24c27f3d190194f0708e6f77017cae4aba89" => :mojave
|
|
sha256 "767a54fc3724058bc84d0ae7c2d53065c8b1ddb50a1dc8b58d94395e28c715de" => :high_sierra
|
|
sha256 "2a509cf47639dab303f1c84943c322062285ba3ea94a0f2061d8e9c46f6e6632" => :sierra
|
|
sha256 "19c526c4af8d3893fb3a6b1dbcbb6d4aacb0caaba4157284f17581fd1b1eb482" => :el_capitan
|
|
end
|
|
|
|
depends_on "openssl"
|
|
depends_on "python"
|
|
|
|
resource "asn1crypto" do
|
|
url "https://files.pythonhosted.org/packages/fc/f1/8db7daa71f414ddabfa056c4ef792e1461ff655c2ae2928a2b675bfed6b4/asn1crypto-0.24.0.tar.gz"
|
|
sha256 "9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49"
|
|
end
|
|
|
|
resource "beautifulsoup4" do
|
|
url "https://files.pythonhosted.org/packages/88/df/86bffad6309f74f3ff85ea69344a078fc30003270c8df6894fca7a3c72ff/beautifulsoup4-4.6.3.tar.gz"
|
|
sha256 "90f8e61121d6ae58362ce3bed8cd997efb00c914eae0ff3d363c32f9a9822d10"
|
|
end
|
|
|
|
resource "certifi" do
|
|
url "https://files.pythonhosted.org/packages/e1/0f/f8d5e939184547b3bdc6128551b831a62832713aa98c2ccdf8c47ecc7f17/certifi-2018.8.24.tar.gz"
|
|
sha256 "376690d6f16d32f9d1fe8932551d80b23e9d393a8578c5633a2ed39a64861638"
|
|
end
|
|
|
|
resource "cffi" do
|
|
url "https://files.pythonhosted.org/packages/e7/a7/4cd50e57cc6f436f1cc3a7e8fa700ff9b8b4d471620629074913e3735fb2/cffi-1.11.5.tar.gz"
|
|
sha256 "e90f17980e6ab0f3c2f3730e56d1fe9bcba1891eeea58966e89d352492cc74f4"
|
|
end
|
|
|
|
resource "cryptography" do
|
|
url "https://files.pythonhosted.org/packages/22/21/233e38f74188db94e8451ef6385754a98f3cad9b59bedf3a8e8b14988be4/cryptography-2.3.1.tar.gz"
|
|
sha256 "8d10113ca826a4c29d5b85b2c4e045ffa8bad74fb525ee0eceb1d38d4c70dfd6"
|
|
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/65/c4/80f97e9c9628f3cac9b98bfca0402ede54e0563b56482e3e6e45c43c4935/idna-2.7.tar.gz"
|
|
sha256 "684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16"
|
|
end
|
|
|
|
resource "pycparser" do
|
|
url "https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz"
|
|
sha256 "99a8ca03e29851d96616ad0404b4aad7d9ee16f25c9f9708a11faf2810f7b226"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz"
|
|
sha256 "70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"
|
|
end
|
|
|
|
resource "urllib3" do
|
|
url "https://files.pythonhosted.org/packages/3c/d2/dc5471622bd200db1cd9319e02e71bc655e9ea27b8e0ce65fc69de0dac15/urllib3-1.23.tar.gz"
|
|
sha256 "a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf"
|
|
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.py", "#!/usr/bin/env python3", "#!#{libexec}/bin/python"
|
|
|
|
bin.install "buku.py" => "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
|