# typed: strict # frozen_string_literal: true require "livecheck/strategic" module Homebrew module Livecheck module Strategy # The {Launchpad} strategy identifies versions of software at # launchpad.net by checking the main page for a project. # # Launchpad URLs take a variety of formats but all the current formats # contain the project name as the first part of the URL path: # # * `https://launchpad.net/example/1.2/1.2.3/+download/example-1.2.3.tar.gz` # * `https://launchpad.net/example/trunk/1.2.3/+download/example-1.2.3.tar.gz` # * `https://code.launchpad.net/example/1.2/1.2.3/+download/example-1.2.3.tar.gz` # # The default regex identifies the latest version within an HTML element # found on the main page for a project: # #
# Latest version is 1.2.3 #
# # @api public class Launchpad extend Strategic # The `Regexp` used to determine if the strategy applies to the URL. URL_MATCH_REGEX = %r{ ^https?://(?:[^/]+?\.)*launchpad\.net /(?[^/]+) # The Launchpad project name }ix # The default regex used to identify the latest version when a regex # isn't provided. DEFAULT_REGEX = %r{class="[^"]*version[^"]*"[^>]*>\s*Latest version is (.+)\s*