Skip to content
Snippets Groups Projects
Unverified Commit 3bde9d34 authored by Markus Reiter's avatar Markus Reiter Committed by Sam Ford
Browse files

Remove `version` from `Livecheck`.

parent fa64a17a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment