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