From 488149242bc8d1fd0997195fd7dc85cd4e3247de Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 9 Jun 2018 11:18:40 +0200 Subject: [PATCH] Remove `Hbc.init`. --- Library/Homebrew/cask/lib/hbc.rb | 6 ------ Library/Homebrew/cask/lib/hbc/caskroom.rb | 2 ++ Library/Homebrew/cask/lib/hbc/cli.rb | 5 ----- Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb | 4 ---- Library/Homebrew/cask/lib/hbc/cli/audit.rb | 4 ---- Library/Homebrew/cask/lib/hbc/cli/install.rb | 4 ---- .../cask/lib/hbc/cli/internal_appcast_checkpoint.rb | 4 ---- .../cask/lib/hbc/cli/internal_audit_modified_casks.rb | 4 ---- Library/Homebrew/cask/lib/hbc/cli/list.rb | 4 ---- Library/Homebrew/cask/lib/hbc/cli/upgrade.rb | 4 ---- Library/Homebrew/cask/lib/hbc/installer.rb | 2 ++ 11 files changed, 4 insertions(+), 39 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb index ffed20f2f4..9c8c67f518 100644 --- a/Library/Homebrew/cask/lib/hbc.rb +++ b/Library/Homebrew/cask/lib/hbc.rb @@ -25,9 +25,3 @@ require "hbc/url" require "hbc/utils" require "hbc/verify" require "hbc/version" - -module Hbc - def self.init - Caskroom.ensure_caskroom_exists - end -end diff --git a/Library/Homebrew/cask/lib/hbc/caskroom.rb b/Library/Homebrew/cask/lib/hbc/caskroom.rb index 4ed4a2b7a5..ac6bf8e3f0 100644 --- a/Library/Homebrew/cask/lib/hbc/caskroom.rb +++ b/Library/Homebrew/cask/lib/hbc/caskroom.rb @@ -21,6 +21,8 @@ module Hbc end def casks + return [] unless path.exist? + Pathname.glob(path.join("*")).sort.select(&:directory?).map do |path| token = path.basename.to_s diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index 57cec17469..b75d5e63de 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -88,10 +88,6 @@ module Hbc @lookup.fetch(command_name, command_name) end - def self.should_init?(command) - command.is_a?(Class) && !command.abstract? && command.needs_init? - end - def self.run_command(command, *args) if command.respond_to?(:run) # usual case: built-in command verb @@ -164,7 +160,6 @@ module Hbc MacOS.full_version = ENV["MACOS_VERSION"] unless ENV["MACOS_VERSION"].nil? Tap.default_cask_tap.install unless Tap.default_cask_tap.installed? - Hbc.init if self.class.should_init?(command) self.class.run_command(command, *args) rescue CaskError, ArgumentError, OptionParser::InvalidOption => e msg = e.message diff --git a/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb b/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb index 2cfe3c467d..e6313b5fc5 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb @@ -27,10 +27,6 @@ module Hbc nil end - def self.needs_init? - false - end - def self.run(*args) new(*args).run end diff --git a/Library/Homebrew/cask/lib/hbc/cli/audit.rb b/Library/Homebrew/cask/lib/hbc/cli/audit.rb index 2b89a8d2c3..c1bb5bcd8c 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/audit.rb @@ -20,10 +20,6 @@ module Hbc odebug "Auditing Cask #{cask}" Auditor.audit(cask, audit_download: download?, check_token_conflicts: token_conflicts?) end - - def self.needs_init? - true - end end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/install.rb b/Library/Homebrew/cask/lib/hbc/cli/install.rb index d8f148b1ba..31d90f60ef 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/install.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/install.rb @@ -27,10 +27,6 @@ module Hbc def self.help "installs the given Cask" end - - def self.needs_init? - true - end end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb index a538ffd8c3..a88d1fc170 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -49,10 +49,6 @@ module Hbc def self.help "prints or calculates a given Cask's or URL's appcast checkpoint" end - - def self.needs_init? - true - end end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb index f06e2acc58..eadd8e2839 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb @@ -5,10 +5,6 @@ module Hbc option "--cleanup", :cleanup, false - def self.needs_init? - true - end - attr_accessor :commit_range private :commit_range= diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb index 788b0eede5..916860e7e2 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/list.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb @@ -57,10 +57,6 @@ module Hbc def self.help "with no args, lists installed Casks; given installed Casks, lists staged files" end - - def self.needs_init? - true - end end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/upgrade.rb b/Library/Homebrew/cask/lib/hbc/cli/upgrade.rb index 3969546712..276b180aa1 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/upgrade.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/upgrade.rb @@ -82,10 +82,6 @@ module Hbc def self.help "upgrades all outdated casks" end - - def self.needs_init? - true - end end end end diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 90e4c286d4..eb55c9c941 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -55,6 +55,8 @@ module Hbc def stage odebug "Hbc::Installer#stage" + Caskroom.ensure_caskroom_exists + extract_primary_container save_caskfile rescue StandardError => e