diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index 303197f1ce..69df9b23f3 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -43,7 +43,7 @@ Style/Documentation: - livecheck/strategy/extract_plist.rb - livecheck/strategy/git.rb - livecheck/strategy/github_latest.rb - - livecheck/strategy/github_release.rb + - livecheck/strategy/github_releases.rb - livecheck/strategy/gnome.rb - livecheck/strategy/gnu.rb - livecheck/strategy/hackage.rb diff --git a/Library/Homebrew/livecheck/strategy.rb b/Library/Homebrew/livecheck/strategy.rb index 17bbcb27cc..6710700dcf 100644 --- a/Library/Homebrew/livecheck/strategy.rb +++ b/Library/Homebrew/livecheck/strategy.rb @@ -270,7 +270,7 @@ require_relative "strategy/electron_builder" require_relative "strategy/extract_plist" require_relative "strategy/git" require_relative "strategy/github_latest" -require_relative "strategy/github_release" +require_relative "strategy/github_releases" require_relative "strategy/gnome" require_relative "strategy/gnu" require_relative "strategy/hackage" diff --git a/Library/Homebrew/livecheck/strategy/github_latest.rb b/Library/Homebrew/livecheck/strategy/github_latest.rb index bd743645a6..9207c60cc6 100644 --- a/Library/Homebrew/livecheck/strategy/github_latest.rb +++ b/Library/Homebrew/livecheck/strategy/github_latest.rb @@ -41,7 +41,7 @@ module Homebrew # @return [Boolean] sig { params(url: String).returns(T::Boolean) } def self.match?(url) - GitHubReleases.match?(url) + GithubReleases.match?(url) end # Extracts information from a provided URL and uses it to generate @@ -55,7 +55,7 @@ module Homebrew def self.generate_input_values(url) values = {} - match = url.delete_suffix(".git").match(GitHubReleases::URL_MATCH_REGEX) + match = url.delete_suffix(".git").match(GithubReleases::URL_MATCH_REGEX) return values if match.blank? values[:url] = "https://api.github.com/repos/#{match[:username]}/#{match[:repository]}/releases/latest" @@ -79,7 +79,7 @@ module Homebrew block: T.nilable(Proc), ).returns(T::Hash[Symbol, T.untyped]) } - def self.find_versions(url:, regex: GitHubReleases::DEFAULT_REGEX, **_unused, &block) + def self.find_versions(url:, regex: GithubReleases::DEFAULT_REGEX, **_unused, &block) match_data = { matches: {}, regex: regex, url: url } generated = generate_input_values(url) @@ -88,7 +88,7 @@ module Homebrew match_data[:url] = generated[:url] release = GitHub.get_latest_release(generated[:username], generated[:repository]) - GitHubReleases.versions_from_content(release, regex, &block).each do |match_text| + GithubReleases.versions_from_content(release, regex, &block).each do |match_text| match_data[:matches][match_text] = Version.new(match_text) end diff --git a/Library/Homebrew/livecheck/strategy/github_release.rb b/Library/Homebrew/livecheck/strategy/github_releases.rb similarity index 98% rename from Library/Homebrew/livecheck/strategy/github_release.rb rename to Library/Homebrew/livecheck/strategy/github_releases.rb index 2c69209680..eb18bdbe0f 100644 --- a/Library/Homebrew/livecheck/strategy/github_release.rb +++ b/Library/Homebrew/livecheck/strategy/github_releases.rb @@ -18,7 +18,7 @@ module Homebrew # releases for suitable versions and the strategy is necessary or # appropriate (e.g. the formula/cask uses a release asset and the # {GithubLatest} strategy isn't sufficient to identify the newest version. - # The strategy can only be applied by using `strategy :github_release` + # The strategy can only be applied by using `strategy :github_releases` # in a `livecheck` block. # # The default regex identifies versions like `1.2.3`/`v1.2.3` in each @@ -33,7 +33,7 @@ module Homebrew # A priority of zero causes livecheck to skip the strategy. We do this # for {GithubReleases} so we can selectively apply the strategy using - # `strategy :github_release` in a `livecheck` block. + # `strategy :github_releases` in a `livecheck` block. PRIORITY = 0 # The `Regexp` used to determine if the strategy applies to the URL. diff --git a/Library/Homebrew/test/livecheck/strategy/github_latest_spec.rb b/Library/Homebrew/test/livecheck/strategy/github_latest_spec.rb index 1fc402d17c..f118e11407 100644 --- a/Library/Homebrew/test/livecheck/strategy/github_latest_spec.rb +++ b/Library/Homebrew/test/livecheck/strategy/github_latest_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "livecheck/strategy/github_release" +require "livecheck/strategy/github_releases" require "livecheck/strategy/github_latest" describe Homebrew::Livecheck::Strategy::GithubLatest do diff --git a/Library/Homebrew/test/livecheck/strategy/github_release_spec.rb b/Library/Homebrew/test/livecheck/strategy/github_releases_spec.rb similarity index 72% rename from Library/Homebrew/test/livecheck/strategy/github_release_spec.rb rename to Library/Homebrew/test/livecheck/strategy/github_releases_spec.rb index 0f6895b588..597472509f 100644 --- a/Library/Homebrew/test/livecheck/strategy/github_release_spec.rb +++ b/Library/Homebrew/test/livecheck/strategy/github_releases_spec.rb @@ -2,8 +2,8 @@ require "livecheck/strategy" -describe Homebrew::Livecheck::Strategy::GitHubReleases do - subject(:github_release) { described_class } +describe Homebrew::Livecheck::Strategy::GithubReleases do + subject(:github_releases) { described_class } let(:github_urls) do { @@ -14,7 +14,7 @@ describe Homebrew::Livecheck::Strategy::GitHubReleases do end let(:non_github_url) { "https://brew.sh/test" } - let(:regex) { github_release::DEFAULT_REGEX } + let(:regex) { github_releases::DEFAULT_REGEX } let(:generated) do { @@ -85,55 +85,55 @@ describe Homebrew::Livecheck::Strategy::GitHubReleases do describe "::match?" do it "returns true for a GitHub release artifact URL" do - expect(github_release.match?(github_urls[:release_artifact])).to be true + expect(github_releases.match?(github_urls[:release_artifact])).to be true end it "returns true for a GitHub tag archive URL" do - expect(github_release.match?(github_urls[:tag_archive])).to be true + expect(github_releases.match?(github_urls[:tag_archive])).to be true end it "returns true for a GitHub repository upload URL" do - expect(github_release.match?(github_urls[:repository_upload])).to be true + expect(github_releases.match?(github_urls[:repository_upload])).to be true end it "returns false for a non-GitHub URL" do - expect(github_release.match?(non_github_url)).to be false + expect(github_releases.match?(non_github_url)).to be false end end describe "::generate_input_values" do it "returns a hash containing a url and regex for a GitHub release artifact URL" do - expect(github_release.generate_input_values(github_urls[:release_artifact])).to eq(generated) + expect(github_releases.generate_input_values(github_urls[:release_artifact])).to eq(generated) end it "returns a hash containing a url and regex for a GitHub tag archive URL" do - expect(github_release.generate_input_values(github_urls[:tag_archive])).to eq(generated) + expect(github_releases.generate_input_values(github_urls[:tag_archive])).to eq(generated) end it "returns a hash containing a url and regex for a GitHub repository upload URL" do - expect(github_release.generate_input_values(github_urls[:repository_upload])).to eq(generated) + expect(github_releases.generate_input_values(github_urls[:repository_upload])).to eq(generated) end it "returns an empty hash for a non-Github URL" do - expect(github_release.generate_input_values(non_github_url)).to eq({}) + expect(github_releases.generate_input_values(non_github_url)).to eq({}) end end describe "::versions_from_content" do it "returns an empty array if content is blank" do - expect(github_release.versions_from_content({}, regex)).to eq([]) + expect(github_releases.versions_from_content({}, regex)).to eq([]) end it "returns an array of version strings when given content" do - expect(github_release.versions_from_content(json, regex)).to eq(matches) + expect(github_releases.versions_from_content(json, regex)).to eq(matches) end it "returns an array of version strings when given content and a block" do # Returning a string from block - expect(github_release.versions_from_content(json, regex) { "1.2.3" }).to eq(["1.2.3"]) + expect(github_releases.versions_from_content(json, regex) { "1.2.3" }).to eq(["1.2.3"]) # Returning an array of strings from block - expect(github_release.versions_from_content(json, regex) do |json, regex| + expect(github_releases.versions_from_content(json, regex) do |json, regex| json.map do |release| next if release["draft"] || release["prerelease"] @@ -146,11 +146,11 @@ describe Homebrew::Livecheck::Strategy::GitHubReleases do end it "allows a nil return from a block" do - expect(github_release.versions_from_content(json, regex) { next }).to eq([]) + expect(github_releases.versions_from_content(json, regex) { next }).to eq([]) end it "errors on an invalid return type from a block" do - expect { github_release.versions_from_content(json, regex) { 123 } } + expect { github_releases.versions_from_content(json, regex) { 123 } } .to raise_error(TypeError, Homebrew::Livecheck::Strategy::INVALID_BLOCK_RETURN_VALUE_MSG) end end