Remove version
from Livecheck
.
This commit is contained in:
parent
fa64a17ae9
commit
3bde9d34a9
@ -20,7 +20,6 @@ class Livecheck
|
||||
@skip_msg = nil
|
||||
@strategy = nil
|
||||
@url = nil
|
||||
@version = nil
|
||||
end
|
||||
|
||||
# Sets the `@regex` instance variable to the provided `Regexp` or returns the
|
||||
@ -104,16 +103,6 @@ class Livecheck
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: documentation
|
||||
def version(val = nil)
|
||||
return @version if val.nil?
|
||||
unless val.is_a?(String) || (val.is_a?(Symbol) && Cask::DSL::Version.method_defined?(val))
|
||||
raise TypeError, "Livecheck#version expects a String or valid Symbol"
|
||||
end
|
||||
|
||||
@version = val
|
||||
end
|
||||
|
||||
# Returns a `Hash` of all instance variable values.
|
||||
# @return [Hash]
|
||||
def to_hash
|
||||
@ -123,7 +112,6 @@ class Livecheck
|
||||
"skip_msg" => @skip_msg,
|
||||
"strategy" => @strategy,
|
||||
"url" => @url,
|
||||
"version" => @version,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -113,17 +113,12 @@ module Homebrew
|
||||
# head-only formulae. A formula with `stable` and `head` that's
|
||||
# installed using `--head` will still use the `stable` version for
|
||||
# comparison.
|
||||
livecheck_version = formula_or_cask.livecheck.version
|
||||
current = if livecheck_version.is_a?(String)
|
||||
Version.new(livecheck_version)
|
||||
elsif formula
|
||||
current = if formula
|
||||
if formula.head_only?
|
||||
formula.any_installed_version.version.commit
|
||||
else
|
||||
formula.stable.version
|
||||
end
|
||||
elsif livecheck_version.is_a?(Symbol)
|
||||
Version.new(Cask::DSL::Version.new(formula_or_cask.version).try(livecheck_version))
|
||||
else
|
||||
Version.new(formula_or_cask.version)
|
||||
end
|
||||
|
@ -85,7 +85,6 @@ describe Homebrew::Livecheck do
|
||||
|
||||
livecheck do
|
||||
url "https://formulae.brew.sh/api/formula/ruby.json"
|
||||
version :before_comma
|
||||
regex(/"stable":"(\d+(?:\.\d+)+)"/i)
|
||||
end
|
||||
end
|
||||
|
@ -107,26 +107,6 @@ describe Livecheck do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#version" do
|
||||
it "returns nil if not set" do
|
||||
expect(livecheckable.version).to be nil
|
||||
end
|
||||
|
||||
it "returns value if set" do
|
||||
livecheckable.version("1.2.3")
|
||||
expect(livecheckable.version).to eq("1.2.3")
|
||||
|
||||
livecheckable.version(:before_comma)
|
||||
expect(livecheckable.version).to eq(:before_comma)
|
||||
end
|
||||
|
||||
it "raises a TypeError if the argument isn't a String or Symbol" do
|
||||
expect {
|
||||
livecheckable.version(/foo/)
|
||||
}.to raise_error(TypeError, "Livecheck#version expects a String or valid Symbol")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#to_hash" do
|
||||
it "returns a Hash of all instance variables" do
|
||||
expect(livecheckable.to_hash).to eq(
|
||||
@ -136,7 +116,6 @@ describe Livecheck do
|
||||
"skip_msg" => nil,
|
||||
"strategy" => nil,
|
||||
"url" => nil,
|
||||
"version" => nil,
|
||||
},
|
||||
)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user