Refactor CLI::InternalAppcastCheckpoint.

This commit is contained in:
Markus Reiter 2017-05-20 02:43:45 +02:00
parent 33580c283a
commit 326c425dc6

View File

@ -2,14 +2,20 @@ module Hbc
class CLI class CLI
class InternalAppcastCheckpoint < InternalUseBase class InternalAppcastCheckpoint < InternalUseBase
def self.run(*args) def self.run(*args)
calculate = args.include? "--calculate" new(*args).run
cask_tokens = cask_tokens_from(args) end
raise CaskUnspecifiedError if cask_tokens.empty?
if cask_tokens.all? { |t| t =~ %r{^https?://} && t !~ /\.rb$/ } def initialize(*args)
appcask_checkpoint_for_url(cask_tokens) @cask_tokens = cask_tokens_from(args)
raise CaskUnspecifiedError if cask_tokens.empty?
@calculate = args.include? "--calculate"
end
def run
if @cask_tokens.all? { |t| t =~ %r{^https?://} && t !~ /\.rb$/ }
self.class.appcask_checkpoint_for_url(cask_tokens)
else else
appcask_checkpoint(cask_tokens, calculate) self.class.appcask_checkpoint(@cask_tokens, @calculate)
end end
end end