homebrew-core/Formula/buku.rb

156 lines
5.7 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.4.tar.gz"
sha256 "c7d755569117ceb85fdda734dcca657e01f6d5252d7d3b9f757faeedfdcac741"
license "GPL-3.0"
bottle do
cellar :any
sha256 "eddbed7b65e27d075deac0c14aaad86714085e02fa8e565a9f34524049c9a9b9" => :catalina
sha256 "211a2ba97cba060b7820a7def2d2956224ea21ae56ac9c2a97ee233f055ec4ec" => :mojave
sha256 "663b219a77e3005f067e4030633ed9ffbdf9d89213b66b8d1d07ab54df23c078" => :high_sierra
end
depends_on "openssl@1.1"
depends_on "python@3.8"
uses_from_macos "expect" => :test
uses_from_macos "libffi"
on_linux do
depends_on "pkg-config" => :build
end
resource "beautifulsoup4" do
url "https://files.pythonhosted.org/packages/c6/62/8a2bef01214eeaa5a4489eca7104e152968729512ee33cb5fbbc37a896b7/beautifulsoup4-4.9.1.tar.gz"
sha256 "73cc4d115b96f79c7d77c1c7f7a0a8d4c57860d1041df407dd1aae7f07a77fd7"
end
resource "certifi" do
url "https://files.pythonhosted.org/packages/b4/19/53433f37a31543364c8676f30b291d128cdf4cd5b31b755b7890f8e89ac8/certifi-2020.4.5.2.tar.gz"
sha256 "5ad7e9a056d25ffa5082862e36f119f7f7cec6457fa07ee2f8c339814b80c9b1"
end
resource "cffi" do
url "https://files.pythonhosted.org/packages/05/54/3324b0c46340c31b909fcec598696aaec7ddc8c18a63f2db352562d3354c/cffi-1.14.0.tar.gz"
sha256 "2d384f4a127a15ba701207f7639d94106693b6cd64173d6c8988e2c25f3ac2b6"
end
resource "cryptography" do
url "https://files.pythonhosted.org/packages/56/3b/78c6816918fdf2405d62c98e48589112669f36711e50158a0c15d804c30d/cryptography-2.9.2.tar.gz"
sha256 "a0c30272fb4ddda5f5ffc1089d7405b7a71b0b0f51993cb4e5dbb4590b2fc229"
end
resource "html5lib" do
url "https://files.pythonhosted.org/packages/85/3e/cf449cf1b5004e87510b9368e7a5f1acd8831c2d6691edd3c62a0823f98f/html5lib-1.0.1.tar.gz"
sha256 "66cb0dcfdbbc4f9c3ba1a63fdb511ffdbd4f513b2b6d81b80cd26ce6b3fb3736"
end
resource "pycparser" do
url "https://files.pythonhosted.org/packages/0f/86/e19659527668d70be91d0369aeaa055b4eb396b0f387a4f92293a20035bd/pycparser-2.20.tar.gz"
sha256 "2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"
end
resource "six" do
url "https://files.pythonhosted.org/packages/6b/34/415834bfdafca3c5f451532e8a8d9ba89a21c9743a0c59fbd0205c7f9426/six-1.15.0.tar.gz"
sha256 "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"
end
resource "soupsieve" do
url "https://files.pythonhosted.org/packages/3e/db/5ba900920642414333bdc3cb397075381d63eafc7e75c2373bbc560a9fa1/soupsieve-2.0.1.tar.gz"
sha256 "a59dc181727e95d25f781f0eb4fd1825ff45590ec8ff49eadfd7f1a537cc0232"
end
resource "urllib3" do
url "https://files.pythonhosted.org/packages/05/8c/40cd6949373e23081b3ea20d5594ae523e681b6f472e600fbc95ed046a36/urllib3-1.25.9.tar.gz"
sha256 "3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527"
end
resource "webencodings" do
url "https://files.pythonhosted.org/packages/0b/02/ae6ceac1baeda530866a85075641cec12989bd8d31af6d5ab4a3e8c92f47/webencodings-0.5.1.tar.gz"
sha256 "b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"
end
def install
virtualenv_install_with_resources
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 "Generate auto-tag (YYYYMonDD)? (y/n): "
send "y\r"
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