diff --git a/Library/Homebrew/livecheck.rb b/Library/Homebrew/livecheck.rb index 1022c4059c..86364ec08c 100644 --- a/Library/Homebrew/livecheck.rb +++ b/Library/Homebrew/livecheck.rb @@ -25,11 +25,11 @@ class Livecheck @referenced_cask_name = nil @referenced_formula_name = nil @regex = nil - @throttle = nil @skip = false @skip_msg = nil @strategy = nil @strategy_block = nil + @throttle = nil @url = nil end @@ -88,23 +88,6 @@ class Livecheck end end - # Sets the `@throttle` instance variable to the provided `Integer` or returns - # the `@throttle` instance variable when no argument is provided. - sig { - params( - # Throttle rate of version patch number to use for bumpable versions. - rate: T.nilable(Integer), - ).returns(T.nilable(Integer)) - } - def throttle(rate = T.unsafe(nil)) - case rate - when nil - @throttle - when Integer - @throttle = rate - end - end - # Sets the `@skip` instance variable to `true` and sets the `@skip_msg` # instance variable if a `String` is provided. `@skip` is used to indicate # that the formula/cask/resource should be skipped and the `skip_msg` very @@ -153,6 +136,23 @@ class Livecheck sig { returns(T.nilable(Proc)) } attr_reader :strategy_block + # Sets the `@throttle` instance variable to the provided `Integer` or returns + # the `@throttle` instance variable when no argument is provided. + sig { + params( + # Throttle rate of version patch number to use for bumpable versions. + rate: T.nilable(Integer), + ).returns(T.nilable(Integer)) + } + def throttle(rate = T.unsafe(nil)) + case rate + when nil + @throttle + when Integer + @throttle = rate + end + end + # Sets the `@url` instance variable to the provided argument or returns the # `@url` instance variable when no argument is provided. The argument can be # a `String` (a URL) or a supported `Symbol` corresponding to a URL in the @@ -186,10 +186,10 @@ class Livecheck "cask" => @referenced_cask_name, "formula" => @referenced_formula_name, "regex" => @regex, - "throttle" => @throttle, "skip" => @skip, "skip_msg" => @skip_msg, "strategy" => @strategy, + "throttle" => @throttle, "url" => @url, } end diff --git a/Library/Homebrew/test/livecheck_spec.rb b/Library/Homebrew/test/livecheck_spec.rb index 2540eb7da3..f0136ca886 100644 --- a/Library/Homebrew/test/livecheck_spec.rb +++ b/Library/Homebrew/test/livecheck_spec.rb @@ -66,17 +66,6 @@ RSpec.describe Livecheck do end end - describe "#throttle" do - it "returns nil if not set" do - expect(livecheckable_f.throttle).to be_nil - end - - it "returns the Integer if set" do - livecheckable_f.throttle(10) - expect(livecheckable_f.throttle).to eq(10) - end - end - describe "#skip" do it "sets @skip to true when no argument is provided" do expect(livecheckable_f.skip).to be true @@ -111,6 +100,17 @@ RSpec.describe Livecheck do end end + describe "#throttle" do + it "returns nil if not set" do + expect(livecheckable_f.throttle).to be_nil + end + + it "returns the Integer if set" do + livecheckable_f.throttle(10) + expect(livecheckable_f.throttle).to eq(10) + end + end + describe "#url" do let(:url_string) { "https://brew.sh" } @@ -151,10 +151,10 @@ RSpec.describe Livecheck do "cask" => nil, "formula" => nil, "regex" => nil, - "throttle" => nil, "skip" => false, "skip_msg" => nil, "strategy" => nil, + "throttle" => nil, "url" => nil, }, )