packaging/homebrew/sbm.rb (2802 bytes)
1 class Sbm < Formula 2 desc "Bookmark manager made of POSIX sh scripts, driven by dmenu or fzf" 3 homepage "https://github.com/equwal/sbm" 4 url "https://github.com/equwal/sbm/archive/refs/tags/v0.3.tar.gz" 5 sha256 "SBM_SHA256_TBD" 6 # No licence has been chosen upstream yet and the repository carries no 7 # LICENSE file. Replace SBM_LICENSE_TBD with the SPDX identifier. 8 # `brew audit --strict` rejects this token, which is intended. 9 license "SBM_LICENSE_TBD" 10 head "https://github.com/equwal/sbm.git", branch: "master" 11 12 # A menu is required: dmenu or fzf. Homebrew has no dmenu formula, and dmenu 13 # needs X11 on macOS, so fzf is the only practical menu here and is a hard 14 # dependency. See caveats. 15 depends_on "fzf" 16 17 # Optional runtime helpers are deliberately not dependencies: 18 # curl ships with macOS (bm-title, bm-check) 19 # git ships with the CLT (bm-commit) 20 # jq only for Chromium JSON bookmark files (bm-import) 21 # Homebrew dropped :optional and :recommended, so these are named in caveats. 22 23 def install 24 system "make", "install", "PREFIX=#{prefix}" 25 doc.install "README", "TODO" 26 (pkgshare/"examples").install "usertags", "engines" 27 end 28 29 def caveats 30 <<~EOS 31 sbm expects a menu, a clipboard command and an opener. On macOS: 32 33 * The menu is fzf. dmenu is an X11 program; if you run XQuartz and 34 build dmenu yourself, set SBM_MENU=dmenu. 35 * bm does not auto-detect pbcopy/pbpaste/open, so set these yourself: 36 37 export SBM_COPY=pbcopy 38 export SBM_PASTE=pbpaste 39 export SBM_OPEN=open 40 41 Example tag and search-engine files are installed in 42 43 #{pkgshare}/examples 44 45 Copy them if you want them: 46 47 mkdir -p ~/.local/share/sbm 48 cp #{pkgshare}/examples/usertags #{pkgshare}/examples/engines ~/.local/share/sbm/ 49 50 Optional programs: jq (bm-import of Chromium bookmark files). 51 curl and git come with macOS and the Command Line Tools. 52 EOS 53 end 54 55 test do 56 ENV["BOOKMARKS"] = testpath/"bookmarks" 57 ENV["USERTAGS"] = testpath/"usertags" 58 ENV["SBM_GIT"] = "0" 59 ENV["SBM_FETCH"] = "0" 60 61 # --list and --merge are the two actions that never open a menu. 62 merged = pipe_output("#{bin}/bm --merge", 63 "https://equwal.com\tSpenser Truex's website\tusers\n") 64 assert_match "added 1", merged 65 66 # Merging the same URL again must be a no-op. 67 again = pipe_output("#{bin}/bm --merge", 68 "https://equwal.com/\tsame bookmark, trailing slash\tusers\n") 69 assert_match "skipped 1", again 70 71 assert_equal "https://equwal.com\tSpenser Truex's website\tusers", 72 shell_output("#{bin}/bm --list").strip 73 74 assert_match "<li>", shell_output("#{bin}/bm-html") 75 end 76 end