Initial small fixes
- Skip blank lines in watchlist - Initialize Livecheck#version as nil - Simplify livecheck_version logic - Make test a bit more understandable
This commit is contained in:
parent
bf03893227
commit
4b87da4da9
@ -67,7 +67,9 @@ module Homebrew
|
|||||||
args.named.to_formulae_and_casks
|
args.named.to_formulae_and_casks
|
||||||
elsif File.exist?(WATCHLIST_PATH)
|
elsif File.exist?(WATCHLIST_PATH)
|
||||||
begin
|
begin
|
||||||
names = Pathname.new(WATCHLIST_PATH).read.lines.reject { |line| line.start_with?("#") }.map(&:strip)
|
names = Pathname.new(WATCHLIST_PATH).read.lines
|
||||||
|
.reject { |line| line.start_with?("#") || line.blank? }
|
||||||
|
.map(&:strip)
|
||||||
CLI::NamedArgs.new(*names).to_formulae_and_casks
|
CLI::NamedArgs.new(*names).to_formulae_and_casks
|
||||||
rescue Errno::ENOENT => e
|
rescue Errno::ENOENT => e
|
||||||
onoe e
|
onoe e
|
||||||
|
|||||||
@ -20,6 +20,7 @@ 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
|
||||||
@ -88,10 +89,10 @@ class Livecheck
|
|||||||
@url = case val
|
@url = case val
|
||||||
when nil
|
when nil
|
||||||
return @url
|
return @url
|
||||||
when :cask_url
|
|
||||||
@formula_or_cask.url.to_s
|
|
||||||
when :appcast
|
when :appcast
|
||||||
@formula_or_cask.appcast.to_s
|
@formula_or_cask.appcast.to_s
|
||||||
|
when :cask_url
|
||||||
|
@formula_or_cask.url.to_s
|
||||||
when :head, :stable
|
when :head, :stable
|
||||||
@formula_or_cask.send(val).url
|
@formula_or_cask.send(val).url
|
||||||
when :homepage
|
when :homepage
|
||||||
|
|||||||
@ -115,9 +115,11 @@ module Homebrew
|
|||||||
# comparison.
|
# comparison.
|
||||||
livecheck_version = formula_or_cask.livecheck.version
|
livecheck_version = formula_or_cask.livecheck.version
|
||||||
current = if livecheck_version.is_a?(String)
|
current = if livecheck_version.is_a?(String)
|
||||||
livecheck_version
|
Version.new(livecheck_version)
|
||||||
else
|
elsif livecheck_version.is_a?(Array)
|
||||||
version = if formula
|
separator, method = livecheck_version
|
||||||
|
Version.new(formula_or_cask.version.to_s.split(separator, 2).try(method))
|
||||||
|
elsif formula
|
||||||
if formula.head_only?
|
if formula.head_only?
|
||||||
formula.any_installed_version.version.commit
|
formula.any_installed_version.version.commit
|
||||||
else
|
else
|
||||||
@ -125,13 +127,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
Version.new(formula_or_cask.version)
|
Version.new(formula_or_cask.version)
|
||||||
end
|
|
||||||
if livecheck_version.is_a?(Array)
|
|
||||||
separator, method = livecheck_version
|
|
||||||
Version.new(version.to_s.split(separator, 2).try(method))
|
|
||||||
else
|
|
||||||
version
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
latest = if formula&.stable? || cask
|
latest = if formula&.stable? || cask
|
||||||
|
|||||||
@ -113,8 +113,8 @@ describe Livecheck do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns value if set" do
|
it "returns value if set" do
|
||||||
livecheckable.version("foo")
|
livecheckable.version("1.2.3")
|
||||||
expect(livecheckable.version).to eq("foo")
|
expect(livecheckable.version).to eq("1.2.3")
|
||||||
|
|
||||||
livecheckable.version(:before_comma)
|
livecheckable.version(:before_comma)
|
||||||
expect(livecheckable.version).to eq([",", :first])
|
expect(livecheckable.version).to eq([",", :first])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user