homebrew-cask/Casks/postgres-unofficial.rb

47 lines
1.7 KiB
Ruby

cask "postgres-unofficial" do
version "2.6,11-12-13-14-15"
sha256 "2e9a7dace621f290184c736e003a06d982486731f56c14755ba8d4d164b485d9"
url "https://github.com/PostgresApp/PostgresApp/releases/download/v#{version.csv.first}/Postgres-#{version.csv.first}-#{version.csv.second}.dmg",
verified: "github.com/PostgresApp/PostgresApp/"
name "Postgres"
desc "App wrapper for Postgres"
homepage "https://postgresapp.com/"
livecheck do
url "https://github.com/PostgresApp/PostgresApp/releases/latest"
regex(/href=.*?Postgres[._-]v?(\d+(?:\.\d+)+)[._-](\d+(?:-\d+)+)\.dmg/i)
strategy :header_match do |headers, regex|
next if headers["location"].blank?
# Identify the latest tag from the response's `location` header
latest_tag = File.basename(headers["location"])
next if latest_tag.blank?
# Fetch the assets list HTML for the latest tag and match within it
assets_page = Homebrew::Livecheck::Strategy.page_content(
@url.sub(%r{/releases/?.+}, "/releases/expanded_assets/#{latest_tag}"),
)
assets_page[:content]&.scan(regex)&.map { |match| "#{match[0]},#{match[1]}" }
end
end
auto_updates true
depends_on macos: ">= :sierra"
app "Postgres.app"
uninstall launchctl: "com.postgresapp.Postgres#{version.major}LoginHelper",
quit: [
"com.postgresapp.Postgres#{version.major}",
"com.postgresapp.Postgres#{version.major}MenuHelper",
]
zap trash: [
"~/Library/Application Support/Postgres",
"~/Library/Caches/com.postgresapp.Postgres#{version.major}",
"~/Library/Cookies/com.postgresapp.Postgres#{version.major}.binarycookies",
"~/Library/Preferences/com.postgresapp.Postgres#{version.major}.plist",
]
end