Run rubocop —auto-correct.
This commit is contained in:
parent
b957a1b7e6
commit
59212445da
@ -31,9 +31,6 @@ Metrics/ModuleLength:
|
|||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Performance/StringReplacement:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/AlignHash:
|
Style/AlignHash:
|
||||||
EnforcedHashRocketStyle: table
|
EnforcedHashRocketStyle: table
|
||||||
EnforcedColonStyle: table
|
EnforcedColonStyle: table
|
||||||
@ -129,6 +126,8 @@ Style/RegexpLiteral:
|
|||||||
Style/StringLiterals:
|
Style/StringLiterals:
|
||||||
EnforcedStyle: double_quotes
|
EnforcedStyle: double_quotes
|
||||||
|
|
||||||
|
Style/StringLiteralsInInterpolation:
|
||||||
|
EnforcedStyle: double_quotes
|
||||||
|
|
||||||
Style/TrailingCommaInLiteral:
|
Style/TrailingCommaInLiteral:
|
||||||
EnforcedStyleForMultiline: comma
|
EnforcedStyleForMultiline: comma
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class Hbc::Artifact::AbstractFlightBlock < Hbc::Artifact::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.class_for_dsl_key(dsl_key)
|
def self.class_for_dsl_key(dsl_key)
|
||||||
Object.const_get("Hbc::DSL::#{dsl_key.to_s.split('_').collect(&:capitalize).join}")
|
Object.const_get("Hbc::DSL::#{dsl_key.to_s.split("_").collect(&:capitalize).join}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.me?(cask)
|
def self.me?(cask)
|
||||||
|
|||||||
@ -64,9 +64,9 @@ class Hbc::Artifact::Moved < Hbc::Artifact::Relocated
|
|||||||
|
|
||||||
def delete
|
def delete
|
||||||
ohai "Removing #{self.class.artifact_english_name}: '#{target}'"
|
ohai "Removing #{self.class.artifact_english_name}: '#{target}'"
|
||||||
if MacOS.undeletable?(target)
|
raise Hbc::CaskError, "Cannot remove undeletable #{self.class.artifact_english_name}" if MacOS.undeletable?(target)
|
||||||
raise Hbc::CaskError, "Cannot remove undeletable #{self.class.artifact_english_name}"
|
|
||||||
elsif force
|
if force
|
||||||
Hbc::Utils.gain_permissions_remove(target, command: @command)
|
Hbc::Utils.gain_permissions_remove(target, command: @command)
|
||||||
else
|
else
|
||||||
target.rmtree
|
target.rmtree
|
||||||
|
|||||||
@ -3,32 +3,32 @@ module Hbc::Cache
|
|||||||
|
|
||||||
def ensure_cache_exists
|
def ensure_cache_exists
|
||||||
return if Hbc.cache.exist?
|
return if Hbc.cache.exist?
|
||||||
|
|
||||||
odebug "Creating Cache at #{Hbc.cache}"
|
odebug "Creating Cache at #{Hbc.cache}"
|
||||||
Hbc.cache.mkpath
|
Hbc.cache.mkpath
|
||||||
end
|
end
|
||||||
|
|
||||||
def migrate_legacy_cache
|
def migrate_legacy_cache
|
||||||
if Hbc.legacy_cache.exist?
|
return unless Hbc.legacy_cache.exist?
|
||||||
ohai "Migrating cached files to #{Hbc.cache}..."
|
|
||||||
|
|
||||||
Hbc.legacy_cache.children.select(&:symlink?).each do |symlink|
|
ohai "Migrating cached files to #{Hbc.cache}..."
|
||||||
file = symlink.readlink
|
Hbc.legacy_cache.children.select(&:symlink?).each do |symlink|
|
||||||
|
file = symlink.readlink
|
||||||
|
|
||||||
new_name = file.basename
|
new_name = file.basename
|
||||||
.sub(%r{\-((?:(\d|#{Hbc::DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$}x,
|
.sub(%r{\-((?:(\d|#{Hbc::DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$}x,
|
||||||
'--\1')
|
'--\1')
|
||||||
|
|
||||||
renamed_file = Hbc.cache.join(new_name)
|
renamed_file = Hbc.cache.join(new_name)
|
||||||
|
|
||||||
if file.exist?
|
if file.exist?
|
||||||
puts "#{file} -> #{renamed_file}"
|
puts "#{file} -> #{renamed_file}"
|
||||||
FileUtils.mv(file, renamed_file)
|
FileUtils.mv(file, renamed_file)
|
||||||
end
|
|
||||||
|
|
||||||
FileUtils.rm(symlink)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
FileUtils.remove_entry_secure(Hbc.legacy_cache)
|
FileUtils.rm(symlink)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
FileUtils.remove_entry_secure(Hbc.legacy_cache)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -87,28 +87,29 @@ class Hbc::Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dumpcask
|
def dumpcask
|
||||||
if Hbc.respond_to?(:debug) && Hbc.debug
|
return unless Hbc.respond_to?(:debug)
|
||||||
odebug "Cask instance dumps in YAML:"
|
return unless Hbc.debug
|
||||||
odebug "Cask instance toplevel:", to_yaml
|
|
||||||
[
|
odebug "Cask instance dumps in YAML:"
|
||||||
:name,
|
odebug "Cask instance toplevel:", to_yaml
|
||||||
:homepage,
|
[
|
||||||
:url,
|
:name,
|
||||||
:appcast,
|
:homepage,
|
||||||
:version,
|
:url,
|
||||||
:license,
|
:appcast,
|
||||||
:sha256,
|
:version,
|
||||||
:artifacts,
|
:license,
|
||||||
:caveats,
|
:sha256,
|
||||||
:depends_on,
|
:artifacts,
|
||||||
:conflicts_with,
|
:caveats,
|
||||||
:container,
|
:depends_on,
|
||||||
:gpg,
|
:conflicts_with,
|
||||||
:accessibility_access,
|
:container,
|
||||||
:auto_updates,
|
:gpg,
|
||||||
].each do |method|
|
:accessibility_access,
|
||||||
odebug "Cask instance method '#{method}':", send(method).to_yaml
|
:auto_updates,
|
||||||
end
|
].each do |method|
|
||||||
|
odebug "Cask instance method '#{method}':", send(method).to_yaml
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,39 +3,39 @@ module Hbc::Caskroom
|
|||||||
|
|
||||||
def migrate_caskroom_from_repo_to_prefix
|
def migrate_caskroom_from_repo_to_prefix
|
||||||
repo_caskroom = Hbc.homebrew_repository.join("Caskroom")
|
repo_caskroom = Hbc.homebrew_repository.join("Caskroom")
|
||||||
if !Hbc.caskroom.exist? && repo_caskroom.directory?
|
return if Hbc.caskroom.exist?
|
||||||
ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"
|
return unless repo_caskroom.directory?
|
||||||
|
|
||||||
if Hbc.caskroom.parent.writable?
|
ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"
|
||||||
FileUtils.mv repo_caskroom, Hbc.caskroom
|
|
||||||
else
|
if Hbc.caskroom.parent.writable?
|
||||||
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
|
FileUtils.mv repo_caskroom, Hbc.caskroom
|
||||||
system "/usr/bin/sudo", "--", "/bin/mv", "--", repo_caskroom.to_s, Hbc.caskroom.parent.to_s
|
else
|
||||||
end
|
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
|
||||||
|
system "/usr/bin/sudo", "--", "/bin/mv", "--", repo_caskroom.to_s, Hbc.caskroom.parent.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_caskroom_exists
|
def ensure_caskroom_exists
|
||||||
unless Hbc.caskroom.exist?
|
return if Hbc.caskroom.exist?
|
||||||
ohai "Creating Caskroom at #{Hbc.caskroom}"
|
|
||||||
|
|
||||||
if Hbc.caskroom.parent.writable?
|
ohai "Creating Caskroom at #{Hbc.caskroom}"
|
||||||
Hbc.caskroom.mkpath
|
if Hbc.caskroom.parent.writable?
|
||||||
else
|
Hbc.caskroom.mkpath
|
||||||
ohai "We'll set permissions properly so we won't need sudo in the future"
|
else
|
||||||
toplevel_dir = Hbc.caskroom
|
ohai "We'll set permissions properly so we won't need sudo in the future"
|
||||||
toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root?
|
toplevel_dir = Hbc.caskroom
|
||||||
unless toplevel_dir.directory?
|
toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root?
|
||||||
# If a toplevel dir such as '/opt' must be created, enforce standard permissions.
|
unless toplevel_dir.directory?
|
||||||
# sudo in system is rude.
|
# If a toplevel dir such as '/opt' must be created, enforce standard permissions.
|
||||||
system "/usr/bin/sudo", "--", "/bin/mkdir", "--", toplevel_dir
|
|
||||||
system "/usr/bin/sudo", "--", "/bin/chmod", "--", "0775", toplevel_dir
|
|
||||||
end
|
|
||||||
# sudo in system is rude.
|
# sudo in system is rude.
|
||||||
system "/usr/bin/sudo", "--", "/bin/mkdir", "-p", "--", Hbc.caskroom
|
system "/usr/bin/sudo", "--", "/bin/mkdir", "--", toplevel_dir
|
||||||
unless Hbc.caskroom.parent == toplevel_dir
|
system "/usr/bin/sudo", "--", "/bin/chmod", "--", "0775", toplevel_dir
|
||||||
system "/usr/bin/sudo", "--", "/usr/sbin/chown", "-R", "--", "#{Hbc::Utils.current_user}:staff", Hbc.caskroom.parent.to_s
|
end
|
||||||
end
|
# sudo in system is rude.
|
||||||
|
system "/usr/bin/sudo", "--", "/bin/mkdir", "-p", "--", Hbc.caskroom
|
||||||
|
unless Hbc.caskroom.parent == toplevel_dir
|
||||||
|
system "/usr/bin/sudo", "--", "/usr/sbin/chown", "-R", "--", "#{Hbc::Utils.current_user}:staff", Hbc.caskroom.parent.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -117,11 +117,11 @@ class Hbc::CLI
|
|||||||
rescue NameError
|
rescue NameError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if klass.respond_to?(:run)
|
if klass.respond_to?(:run)
|
||||||
# invoke "run" on a Ruby library which follows our coding conventions
|
# invoke "run" on a Ruby library which follows our coding conventions
|
||||||
klass.run(*rest)
|
|
||||||
else
|
|
||||||
# other Ruby libraries must do everything via "require"
|
# other Ruby libraries must do everything via "require"
|
||||||
|
klass.run(*rest)
|
||||||
end
|
end
|
||||||
elsif Hbc::Utils.which "brewcask-#{command}"
|
elsif Hbc::Utils.which "brewcask-#{command}"
|
||||||
# arbitrary external executable on PATH, Homebrew-style
|
# arbitrary external executable on PATH, Homebrew-style
|
||||||
|
|||||||
@ -6,7 +6,7 @@ class Hbc::CLI::Audit < Hbc::CLI::Base
|
|||||||
def self.run(*args)
|
def self.run(*args)
|
||||||
failed_casks = new(args, Hbc::Auditor).run
|
failed_casks = new(args, Hbc::Auditor).run
|
||||||
return if failed_casks.empty?
|
return if failed_casks.empty?
|
||||||
raise Hbc::CaskError, "audit failed for casks: #{failed_casks.join(' ')}"
|
raise Hbc::CaskError, "audit failed for casks: #{failed_casks.join(" ")}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(args, auditor)
|
def initialize(args, auditor)
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class Hbc::CLI::Cleanup < Hbc::CLI::Base
|
|||||||
|
|
||||||
def remove_cache_files(*tokens)
|
def remove_cache_files(*tokens)
|
||||||
message = "Removing cached downloads"
|
message = "Removing cached downloads"
|
||||||
message.concat " for #{tokens.join(', ')}" unless tokens.empty?
|
message.concat " for #{tokens.join(", ")}" unless tokens.empty?
|
||||||
message.concat " older than #{OUTDATED_DAYS} days old" if outdated_only
|
message.concat " older than #{OUTDATED_DAYS} days old" if outdated_only
|
||||||
ohai message
|
ohai message
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
|
|||||||
if homebrew_origin !~ %r{\S}
|
if homebrew_origin !~ %r{\S}
|
||||||
homebrew_origin = "#{none_string} #{error_string}"
|
homebrew_origin = "#{none_string} #{error_string}"
|
||||||
elsif homebrew_origin !~ %r{(mxcl|Homebrew)/(home)?brew(\.git)?\Z}
|
elsif homebrew_origin !~ %r{(mxcl|Homebrew)/(home)?brew(\.git)?\Z}
|
||||||
homebrew_origin.concat " #{error_string 'warning: nonstandard origin'}"
|
homebrew_origin.concat " #{error_string "warning: nonstandard origin"}"
|
||||||
end
|
end
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
homebrew_origin = error_string "Not Found - Error running git"
|
homebrew_origin = error_string "Not Found - Error running git"
|
||||||
@ -106,7 +106,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.privileged_uid
|
def self.privileged_uid
|
||||||
Process.euid == 0 ? "Yes #{error_string 'warning: not recommended'}" : "No"
|
Process.euid.zero? ? "Yes #{error_string "warning: not recommended"}" : "No"
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
notfound_string
|
notfound_string
|
||||||
end
|
end
|
||||||
@ -143,7 +143,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
|
|||||||
if dir.nil? || dir.to_s.empty?
|
if dir.nil? || dir.to_s.empty?
|
||||||
none_string
|
none_string
|
||||||
elsif dir.to_s.match(legacy_tap_pattern)
|
elsif dir.to_s.match(legacy_tap_pattern)
|
||||||
dir.to_s.concat(" #{error_string 'Warning: legacy tap path'}")
|
dir.to_s.concat(" #{error_string "Warning: legacy tap path"}")
|
||||||
else
|
else
|
||||||
dir.to_s
|
dir.to_s
|
||||||
end
|
end
|
||||||
@ -175,9 +175,9 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
|
|||||||
def self.render_staging_location(path)
|
def self.render_staging_location(path)
|
||||||
path = Pathname.new(path)
|
path = Pathname.new(path)
|
||||||
if !path.exist?
|
if !path.exist?
|
||||||
"#{path} #{error_string 'error: path does not exist'}}"
|
"#{path} #{error_string "error: path does not exist"}}"
|
||||||
elsif !path.writable?
|
elsif !path.writable?
|
||||||
"#{path} #{error_string 'error: not writable by current user'}"
|
"#{path} #{error_string "error: not writable by current user"}"
|
||||||
else
|
else
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class Hbc::CLI::Install < Hbc::CLI::Base
|
|||||||
count += 1
|
count += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
count == 0 ? nil : count == cask_tokens.length
|
count.zero? ? nil : count == cask_tokens.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.warn_unavailable_with_suggestion(cask_token, e)
|
def self.warn_unavailable_with_suggestion(cask_token, e)
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class Hbc::CLI::InternalAuditModifiedCasks < Hbc::CLI::InternalUseBase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def git_root
|
def git_root
|
||||||
@git_root ||= git(*%w[rev-parse --show-toplevel])
|
@git_root ||= git("rev-parse", "--show-toplevel")
|
||||||
end
|
end
|
||||||
|
|
||||||
def modified_cask_files
|
def modified_cask_files
|
||||||
@ -83,8 +83,8 @@ class Hbc::CLI::InternalAuditModifiedCasks < Hbc::CLI::InternalUseBase
|
|||||||
@modified_casks = modified_cask_files.map { |f| Hbc.load(f) }
|
@modified_casks = modified_cask_files.map { |f| Hbc.load(f) }
|
||||||
if @modified_casks.any?
|
if @modified_casks.any?
|
||||||
num_modified = @modified_casks.size
|
num_modified = @modified_casks.size
|
||||||
ohai "#{num_modified} modified #{pluralize('cask', num_modified)}: " \
|
ohai "#{num_modified} modified #{pluralize("cask", num_modified)}: " \
|
||||||
"#{@modified_casks.join(' ')}"
|
"#{@modified_casks.join(" ")}"
|
||||||
end
|
end
|
||||||
@modified_casks
|
@modified_casks
|
||||||
end
|
end
|
||||||
@ -122,7 +122,7 @@ class Hbc::CLI::InternalAuditModifiedCasks < Hbc::CLI::InternalUseBase
|
|||||||
num_failed = failed_casks.size
|
num_failed = failed_casks.size
|
||||||
cask_pluralized = pluralize("cask", num_failed)
|
cask_pluralized = pluralize("cask", num_failed)
|
||||||
odie "audit failed for #{num_failed} #{cask_pluralized}: " \
|
odie "audit failed for #{num_failed} #{cask_pluralized}: " \
|
||||||
"#{failed_casks.join(' ')}"
|
"#{failed_casks.join(" ")}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def pluralize(str, num)
|
def pluralize(str, num)
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class Hbc::CLI::InternalDump < Hbc::CLI::InternalUseBase
|
|||||||
opoo "#{cask_token} was not found or would not load: #{e}"
|
opoo "#{cask_token} was not found or would not load: #{e}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
count == 0 ? nil : count == cask_tokens.length
|
count.zero? ? nil : count == cask_tokens.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.help
|
def self.help
|
||||||
|
|||||||
@ -118,7 +118,7 @@ class Hbc::CLI::InternalStanza < Hbc::CLI::InternalUseBase
|
|||||||
|
|
||||||
count += 1
|
count += 1
|
||||||
end
|
end
|
||||||
count == 0 ? nil : count == cask_tokens.length
|
count.zero? ? nil : count == cask_tokens.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.help
|
def self.help
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class Hbc::CLI::List < Hbc::CLI::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
count == 0 ? nil : count == cask_tokens.length
|
count.zero? ? nil : count == cask_tokens.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.list_artifacts(cask)
|
def self.list_artifacts(cask)
|
||||||
|
|||||||
@ -28,8 +28,8 @@ class Hbc::CLI::Uninstall < Hbc::CLI::Base
|
|||||||
single = versions.count == 1
|
single = versions.count == 1
|
||||||
|
|
||||||
puts <<-EOS.undent
|
puts <<-EOS.undent
|
||||||
#{cask_token} #{versions.join(', ')} #{single ? 'is' : 'are'} still installed.
|
#{cask_token} #{versions.join(", ")} #{single ? "is" : "are"} still installed.
|
||||||
Remove #{single ? 'it' : 'them all'} with `brew cask uninstall --force #{cask_token}`.
|
Remove #{single ? "it" : "them all"} with `brew cask uninstall --force #{cask_token}`.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -269,8 +269,16 @@ class Hbc::DSL
|
|||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(method, *)
|
def method_missing(method, *)
|
||||||
Hbc::Utils.method_missing_message(method, token)
|
if method
|
||||||
nil
|
Hbc::Utils.method_missing_message(method, token)
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def respond_to_missing?(*)
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def appdir
|
def appdir
|
||||||
|
|||||||
@ -13,9 +13,17 @@ class Hbc::DSL::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(method, *)
|
def method_missing(method, *)
|
||||||
underscored_class = self.class.name.gsub(%r{([[:lower:]])([[:upper:]][[:lower:]])}, '\1_\2').downcase
|
if method
|
||||||
section = underscored_class.downcase.split("::").last
|
underscored_class = self.class.name.gsub(%r{([[:lower:]])([[:upper:]][[:lower:]])}, '\1_\2').downcase
|
||||||
Hbc::Utils.method_missing_message(method, @cask.to_s, section)
|
section = underscored_class.downcase.split("::").last
|
||||||
nil
|
Hbc::Utils.method_missing_message(method, @cask.to_s, section)
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def respond_to_missing?(*)
|
||||||
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -25,13 +25,21 @@ class Hbc::DSL::StanzaProxy
|
|||||||
coder["resolved"] = @resolver.call
|
coder["resolved"] = @resolver.call
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to?(symbol, include_private = false)
|
def method_missing(method, *args)
|
||||||
return true if %i{encode_with proxy? to_s type}.include?(symbol)
|
if method != :to_ary
|
||||||
return false if symbol == :to_ary
|
@resolver.call.send(method, *args)
|
||||||
@resolver.call.respond_to?(symbol, include_private)
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(symbol, *args)
|
def respond_to?(method, include_private = false)
|
||||||
@resolver.call.send(symbol, *args)
|
return true if %i{encode_with proxy? to_s type}.include?(method)
|
||||||
|
return false if method == :to_ary
|
||||||
|
@resolver.call.respond_to?(method, include_private)
|
||||||
|
end
|
||||||
|
|
||||||
|
def respond_to_missing?(*)
|
||||||
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -139,15 +139,15 @@ class Hbc::Installer
|
|||||||
# dependencies should also apply for "brew cask stage"
|
# dependencies should also apply for "brew cask stage"
|
||||||
# override dependencies with --force or perhaps --force-deps
|
# override dependencies with --force or perhaps --force-deps
|
||||||
def satisfy_dependencies
|
def satisfy_dependencies
|
||||||
if @cask.depends_on
|
return unless @cask.depends_on
|
||||||
ohai "Satisfying dependencies"
|
|
||||||
macos_dependencies
|
ohai "Satisfying dependencies"
|
||||||
arch_dependencies
|
macos_dependencies
|
||||||
x11_dependencies
|
arch_dependencies
|
||||||
formula_dependencies
|
x11_dependencies
|
||||||
cask_dependencies unless skip_cask_deps
|
formula_dependencies
|
||||||
puts "complete"
|
cask_dependencies unless skip_cask_deps
|
||||||
end
|
puts "complete"
|
||||||
end
|
end
|
||||||
|
|
||||||
def macos_dependencies
|
def macos_dependencies
|
||||||
@ -159,7 +159,7 @@ class Hbc::Installer
|
|||||||
end
|
end
|
||||||
elsif @cask.depends_on.macos.length > 1
|
elsif @cask.depends_on.macos.length > 1
|
||||||
unless @cask.depends_on.macos.include?(Gem::Version.new(MacOS.version.to_s))
|
unless @cask.depends_on.macos.include?(Gem::Version.new(MacOS.version.to_s))
|
||||||
raise Hbc::CaskError, "Cask #{@cask} depends on macOS release being one of [#{@cask.depends_on.macos.map(&:to_s).join(', ')}], but you are running release #{MacOS.version}."
|
raise Hbc::CaskError, "Cask #{@cask} depends on macOS release being one of [#{@cask.depends_on.macos.map(&:to_s).join(", ")}], but you are running release #{MacOS.version}."
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
unless MacOS.version == @cask.depends_on.macos.first
|
unless MacOS.version == @cask.depends_on.macos.first
|
||||||
@ -175,7 +175,7 @@ class Hbc::Installer
|
|||||||
arch[:type] == @current_arch[:type] &&
|
arch[:type] == @current_arch[:type] &&
|
||||||
Array(arch[:bits]).include?(@current_arch[:bits])
|
Array(arch[:bits]).include?(@current_arch[:bits])
|
||||||
}
|
}
|
||||||
raise Hbc::CaskError, "Cask #{@cask} depends on hardware architecture being one of [#{@cask.depends_on.arch.map(&:to_s).join(', ')}], but you are running #{@current_arch}"
|
raise Hbc::CaskError, "Cask #{@cask} depends on hardware architecture being one of [#{@cask.depends_on.arch.map(&:to_s).join(", ")}], but you are running #{@current_arch}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def x11_dependencies
|
def x11_dependencies
|
||||||
@ -203,7 +203,7 @@ class Hbc::Installer
|
|||||||
|
|
||||||
def cask_dependencies
|
def cask_dependencies
|
||||||
return unless @cask.depends_on.cask && !@cask.depends_on.cask.empty?
|
return unless @cask.depends_on.cask && !@cask.depends_on.cask.empty?
|
||||||
ohai "Installing Cask dependencies: #{@cask.depends_on.cask.join(', ')}"
|
ohai "Installing Cask dependencies: #{@cask.depends_on.cask.join(", ")}"
|
||||||
deps = Hbc::CaskDependencies.new(@cask)
|
deps = Hbc::CaskDependencies.new(@cask)
|
||||||
deps.sorted.each do |dep_token|
|
deps.sorted.each do |dep_token|
|
||||||
puts "#{dep_token} ..."
|
puts "#{dep_token} ..."
|
||||||
|
|||||||
@ -11,7 +11,7 @@ class Hbc::Source::TappedQualified < Hbc::Source::Tapped
|
|||||||
qualified_token = Hbc::QualifiedToken.parse(query)
|
qualified_token = Hbc::QualifiedToken.parse(query)
|
||||||
return if qualified_token.nil?
|
return if qualified_token.nil?
|
||||||
|
|
||||||
user, repo, token = qualified_token
|
user, repo = qualified_token[0..1]
|
||||||
Tap.fetch(user, repo)
|
Tap.fetch(user, repo)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -123,7 +123,7 @@ class Hbc::SystemCommand::Result
|
|||||||
end
|
end
|
||||||
|
|
||||||
def success?
|
def success?
|
||||||
@exit_status == 0
|
@exit_status.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
def merged_output
|
def merged_output
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class Hbc::UrlChecker
|
|||||||
def _check_response_status
|
def _check_response_status
|
||||||
ok = OK_RESPONSES[cask.url.scheme]
|
ok = OK_RESPONSES[cask.url.scheme]
|
||||||
return if ok.include?(@response_status)
|
return if ok.include?(@response_status)
|
||||||
add_error "unexpected http response, expecting #{ok.map(&:utf8_inspect).join(' or ')}, got #{@response_status.utf8_inspect}"
|
add_error "unexpected http response, expecting #{ok.map(&:utf8_inspect).join(" or ")}, got #{@response_status.utf8_inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def _get_data_from_request
|
def _get_data_from_request
|
||||||
|
|||||||
@ -32,14 +32,15 @@ end
|
|||||||
# global methods
|
# global methods
|
||||||
|
|
||||||
def odebug(title, *sput)
|
def odebug(title, *sput)
|
||||||
if Hbc.respond_to?(:debug) && Hbc.debug
|
return unless Hbc.respond_to?(:debug)
|
||||||
width = Tty.width * 4 - 6
|
return unless Hbc.debug
|
||||||
if $stdout.tty? && title.to_s.length > width
|
|
||||||
title = title.to_s[0, width - 3] + "..."
|
width = Tty.width * 4 - 6
|
||||||
end
|
if $stdout.tty? && title.to_s.length > width
|
||||||
puts "#{Tty.magenta}==>#{Tty.reset} #{Tty.white}#{title}#{Tty.reset}"
|
title = title.to_s[0, width - 3] + "..."
|
||||||
puts sput unless sput.empty?
|
|
||||||
end
|
end
|
||||||
|
puts "#{Tty.magenta}==>#{Tty.reset} #{Tty.white}#{title}#{Tty.reset}"
|
||||||
|
puts sput unless sput.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
module Hbc::Utils
|
module Hbc::Utils
|
||||||
|
|||||||
@ -12,7 +12,7 @@ describe Hbc::CLI::Cleanup do
|
|||||||
|
|
||||||
describe "cleanup" do
|
describe "cleanup" do
|
||||||
it "removes cached downloads of given casks" do
|
it "removes cached downloads of given casks" do
|
||||||
cleaned_up_cached_download = 'caffeine'
|
cleaned_up_cached_download = "caffeine"
|
||||||
|
|
||||||
cached_downloads = [
|
cached_downloads = [
|
||||||
cache_location.join("#{cleaned_up_cached_download}--latest.zip"),
|
cache_location.join("#{cleaned_up_cached_download}--latest.zip"),
|
||||||
|
|||||||
@ -9,7 +9,7 @@ end
|
|||||||
project_root = Pathname.new(File.expand_path("../..", __FILE__))
|
project_root = Pathname.new(File.expand_path("../..", __FILE__))
|
||||||
|
|
||||||
# add Homebrew to load path
|
# add Homebrew to load path
|
||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
|
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
|
||||||
|
|
||||||
require "global"
|
require "global"
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,6 @@ describe Hbc::Artifact::App do
|
|||||||
File.exist?(cask.staged_path.join("Caffeine Deluxe.app")).must_equal true
|
File.exist?(cask.staged_path.join("Caffeine Deluxe.app")).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe "avoids clobbering an existing app" do
|
describe "avoids clobbering an existing app" do
|
||||||
let(:cask) { local_two_apps_caffeine }
|
let(:cask) { local_two_apps_caffeine }
|
||||||
|
|
||||||
@ -70,8 +69,8 @@ describe Hbc::Artifact::App do
|
|||||||
TestHelper.must_output(self, lambda {
|
TestHelper.must_output(self, lambda {
|
||||||
Hbc::Artifact::App.new(cask).install_phase
|
Hbc::Artifact::App.new(cask).install_phase
|
||||||
}, <<-EOS.undent.chomp)
|
}, <<-EOS.undent.chomp)
|
||||||
==> It seems there is already an App at '#{Hbc.appdir.join('Caffeine Mini.app')}'; not moving.
|
==> It seems there is already an App at '#{Hbc.appdir.join("Caffeine Mini.app")}'; not moving.
|
||||||
==> Moving App 'Caffeine Pro.app' to '#{Hbc.appdir.join('Caffeine Pro.app')}'
|
==> Moving App 'Caffeine Pro.app' to '#{Hbc.appdir.join("Caffeine Pro.app")}'
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
source_path = cask.staged_path.join("Caffeine Mini.app")
|
source_path = cask.staged_path.join("Caffeine Mini.app")
|
||||||
@ -85,8 +84,8 @@ describe Hbc::Artifact::App do
|
|||||||
TestHelper.must_output(self, lambda {
|
TestHelper.must_output(self, lambda {
|
||||||
Hbc::Artifact::App.new(cask).install_phase
|
Hbc::Artifact::App.new(cask).install_phase
|
||||||
}, <<-EOS.undent.chomp)
|
}, <<-EOS.undent.chomp)
|
||||||
==> Moving App 'Caffeine Mini.app' to '#{Hbc.appdir.join('Caffeine Mini.app')}'
|
==> Moving App 'Caffeine Mini.app' to '#{Hbc.appdir.join("Caffeine Mini.app")}'
|
||||||
==> It seems there is already an App at '#{Hbc.appdir.join('Caffeine Pro.app')}'; not moving.
|
==> It seems there is already an App at '#{Hbc.appdir.join("Caffeine Pro.app")}'; not moving.
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
source_path = cask.staged_path.join("Caffeine Pro.app")
|
source_path = cask.staged_path.join("Caffeine Pro.app")
|
||||||
|
|||||||
@ -79,9 +79,9 @@ describe Hbc::CLI::List do
|
|||||||
Hbc::CLI::List.run("local-transmission", "local-caffeine")
|
Hbc::CLI::List.run("local-transmission", "local-caffeine")
|
||||||
}.must_output <<-EOS.undent
|
}.must_output <<-EOS.undent
|
||||||
==> Apps
|
==> Apps
|
||||||
#{Hbc.appdir.join('Transmission.app')} (#{Hbc.appdir.join('Transmission.app').abv})
|
#{Hbc.appdir.join("Transmission.app")} (#{Hbc.appdir.join("Transmission.app").abv})
|
||||||
==> Apps
|
==> Apps
|
||||||
Missing App: #{Hbc.appdir.join('Caffeine.app')}
|
Missing App: #{Hbc.appdir.join("Caffeine.app")}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -10,7 +10,7 @@ project_root = Pathname.new(File.expand_path("../..", __FILE__))
|
|||||||
tap_root = Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask")
|
tap_root = Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask")
|
||||||
|
|
||||||
# add Homebrew to load path
|
# add Homebrew to load path
|
||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
|
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
|
||||||
|
|
||||||
require "global"
|
require "global"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user