diff options
| author | Markus Reiter | 2016-09-20 15:11:33 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-09-23 15:30:05 +0200 |
| commit | 59212445da7048233ef32705433e548783fcf84b (patch) | |
| tree | d1ff519490652760f5c37aa55032d82482ebbda1 | |
| parent | b957a1b7e6c1305617cff429f16f73f0c8ec604c (diff) | |
| download | brew-59212445da7048233ef32705433e548783fcf84b.tar.bz2 | |
Run `rubocop —auto-correct`.
29 files changed, 158 insertions, 134 deletions
diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml index 2677748ad..7ba758a90 100644 --- a/Library/Homebrew/cask/.rubocop.yml +++ b/Library/Homebrew/cask/.rubocop.yml @@ -31,9 +31,6 @@ Metrics/ModuleLength: Metrics/PerceivedComplexity: Enabled: false -Performance/StringReplacement: - Enabled: false - Style/AlignHash: EnforcedHashRocketStyle: table EnforcedColonStyle: table @@ -129,6 +126,8 @@ Style/RegexpLiteral: Style/StringLiterals: EnforcedStyle: double_quotes +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes + Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: comma - diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb index fcf98d7ad..c879fc2be 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb @@ -10,7 +10,7 @@ class Hbc::Artifact::AbstractFlightBlock < Hbc::Artifact::Base end 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 def self.me?(cask) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb index 8565ab836..8f41e9fd5 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb @@ -64,9 +64,9 @@ class Hbc::Artifact::Moved < Hbc::Artifact::Relocated def delete ohai "Removing #{self.class.artifact_english_name}: '#{target}'" - if MacOS.undeletable?(target) - raise Hbc::CaskError, "Cannot remove undeletable #{self.class.artifact_english_name}" - elsif force + raise Hbc::CaskError, "Cannot remove undeletable #{self.class.artifact_english_name}" if MacOS.undeletable?(target) + + if force Hbc::Utils.gain_permissions_remove(target, command: @command) else target.rmtree diff --git a/Library/Homebrew/cask/lib/hbc/cache.rb b/Library/Homebrew/cask/lib/hbc/cache.rb index 9fc5fe0f3..7ae5fcc8c 100644 --- a/Library/Homebrew/cask/lib/hbc/cache.rb +++ b/Library/Homebrew/cask/lib/hbc/cache.rb @@ -3,32 +3,32 @@ module Hbc::Cache def ensure_cache_exists return if Hbc.cache.exist? + odebug "Creating Cache at #{Hbc.cache}" Hbc.cache.mkpath end def migrate_legacy_cache - if Hbc.legacy_cache.exist? - ohai "Migrating cached files to #{Hbc.cache}..." - - Hbc.legacy_cache.children.select(&:symlink?).each do |symlink| - file = symlink.readlink + return unless Hbc.legacy_cache.exist? - new_name = file.basename - .sub(%r{\-((?:(\d|#{Hbc::DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$}x, - '--\1') + ohai "Migrating cached files to #{Hbc.cache}..." + Hbc.legacy_cache.children.select(&:symlink?).each do |symlink| + file = symlink.readlink - renamed_file = Hbc.cache.join(new_name) + new_name = file.basename + .sub(%r{\-((?:(\d|#{Hbc::DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$}x, + '--\1') - if file.exist? - puts "#{file} -> #{renamed_file}" - FileUtils.mv(file, renamed_file) - end + renamed_file = Hbc.cache.join(new_name) - FileUtils.rm(symlink) + if file.exist? + puts "#{file} -> #{renamed_file}" + FileUtils.mv(file, renamed_file) end - FileUtils.remove_entry_secure(Hbc.legacy_cache) + FileUtils.rm(symlink) end + + FileUtils.remove_entry_secure(Hbc.legacy_cache) end end diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb index fd13a6fe7..f19e5b81f 100644 --- a/Library/Homebrew/cask/lib/hbc/cask.rb +++ b/Library/Homebrew/cask/lib/hbc/cask.rb @@ -87,28 +87,29 @@ class Hbc::Cask end def dumpcask - if Hbc.respond_to?(:debug) && Hbc.debug - odebug "Cask instance dumps in YAML:" - odebug "Cask instance toplevel:", to_yaml - [ - :name, - :homepage, - :url, - :appcast, - :version, - :license, - :sha256, - :artifacts, - :caveats, - :depends_on, - :conflicts_with, - :container, - :gpg, - :accessibility_access, - :auto_updates, - ].each do |method| - odebug "Cask instance method '#{method}':", send(method).to_yaml - end + return unless Hbc.respond_to?(:debug) + return unless Hbc.debug + + odebug "Cask instance dumps in YAML:" + odebug "Cask instance toplevel:", to_yaml + [ + :name, + :homepage, + :url, + :appcast, + :version, + :license, + :sha256, + :artifacts, + :caveats, + :depends_on, + :conflicts_with, + :container, + :gpg, + :accessibility_access, + :auto_updates, + ].each do |method| + odebug "Cask instance method '#{method}':", send(method).to_yaml end end end diff --git a/Library/Homebrew/cask/lib/hbc/caskroom.rb b/Library/Homebrew/cask/lib/hbc/caskroom.rb index 7dcb35d41..5d26ac222 100644 --- a/Library/Homebrew/cask/lib/hbc/caskroom.rb +++ b/Library/Homebrew/cask/lib/hbc/caskroom.rb @@ -3,39 +3,39 @@ module Hbc::Caskroom def migrate_caskroom_from_repo_to_prefix repo_caskroom = Hbc.homebrew_repository.join("Caskroom") - if !Hbc.caskroom.exist? && repo_caskroom.directory? - ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX" + return if Hbc.caskroom.exist? + return unless repo_caskroom.directory? - if Hbc.caskroom.parent.writable? - FileUtils.mv repo_caskroom, Hbc.caskroom - else - 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 + ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX" + + if Hbc.caskroom.parent.writable? + FileUtils.mv repo_caskroom, Hbc.caskroom + else + 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 def ensure_caskroom_exists - unless Hbc.caskroom.exist? - ohai "Creating Caskroom at #{Hbc.caskroom}" + return if Hbc.caskroom.exist? - if Hbc.caskroom.parent.writable? - Hbc.caskroom.mkpath - else - ohai "We'll set permissions properly so we won't need sudo in the future" - toplevel_dir = Hbc.caskroom - toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root? - unless toplevel_dir.directory? - # If a toplevel dir such as '/opt' must be created, enforce standard permissions. - # sudo in system is rude. - system "/usr/bin/sudo", "--", "/bin/mkdir", "--", toplevel_dir - system "/usr/bin/sudo", "--", "/bin/chmod", "--", "0775", toplevel_dir - end + ohai "Creating Caskroom at #{Hbc.caskroom}" + if Hbc.caskroom.parent.writable? + Hbc.caskroom.mkpath + else + ohai "We'll set permissions properly so we won't need sudo in the future" + toplevel_dir = Hbc.caskroom + toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root? + unless toplevel_dir.directory? + # If a toplevel dir such as '/opt' must be created, enforce standard permissions. # 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 + system "/usr/bin/sudo", "--", "/bin/mkdir", "--", toplevel_dir + system "/usr/bin/sudo", "--", "/bin/chmod", "--", "0775", toplevel_dir + 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 diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index 1378176da..7b3b886b9 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -117,11 +117,11 @@ class Hbc::CLI rescue NameError nil end + if klass.respond_to?(:run) # invoke "run" on a Ruby library which follows our coding conventions - klass.run(*rest) - else # other Ruby libraries must do everything via "require" + klass.run(*rest) end elsif Hbc::Utils.which "brewcask-#{command}" # arbitrary external executable on PATH, Homebrew-style diff --git a/Library/Homebrew/cask/lib/hbc/cli/audit.rb b/Library/Homebrew/cask/lib/hbc/cli/audit.rb index 289547b44..14f3d8254 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/audit.rb @@ -6,7 +6,7 @@ class Hbc::CLI::Audit < Hbc::CLI::Base def self.run(*args) failed_casks = new(args, Hbc::Auditor).run 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 def initialize(args, auditor) diff --git a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb index 4115d26fc..39a90e702 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb @@ -65,7 +65,7 @@ class Hbc::CLI::Cleanup < Hbc::CLI::Base def remove_cache_files(*tokens) 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 ohai message diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index 2632bcaef..7cfccd8b9 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -54,7 +54,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base if homebrew_origin !~ %r{\S} homebrew_origin = "#{none_string} #{error_string}" 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 rescue StandardError homebrew_origin = error_string "Not Found - Error running git" @@ -106,7 +106,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base end 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 notfound_string end @@ -143,7 +143,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base if dir.nil? || dir.to_s.empty? none_string 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 dir.to_s end @@ -175,9 +175,9 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base def self.render_staging_location(path) path = Pathname.new(path) if !path.exist? - "#{path} #{error_string 'error: path does not exist'}}" + "#{path} #{error_string "error: path does not exist"}}" elsif !path.writable? - "#{path} #{error_string 'error: not writable by current user'}" + "#{path} #{error_string "error: not writable by current user"}" else path end diff --git a/Library/Homebrew/cask/lib/hbc/cli/install.rb b/Library/Homebrew/cask/lib/hbc/cli/install.rb index 43eab9f3d..16e3b8121 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/install.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/install.rb @@ -36,7 +36,7 @@ class Hbc::CLI::Install < Hbc::CLI::Base count += 1 end end - count == 0 ? nil : count == cask_tokens.length + count.zero? ? nil : count == cask_tokens.length end def self.warn_unavailable_with_suggestion(cask_token, e) 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 f05dbe803..2cee09eef 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 @@ -62,7 +62,7 @@ class Hbc::CLI::InternalAuditModifiedCasks < Hbc::CLI::InternalUseBase end def git_root - @git_root ||= git(*%w[rev-parse --show-toplevel]) + @git_root ||= git("rev-parse", "--show-toplevel") end 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) } if @modified_casks.any? num_modified = @modified_casks.size - ohai "#{num_modified} modified #{pluralize('cask', num_modified)}: " \ - "#{@modified_casks.join(' ')}" + ohai "#{num_modified} modified #{pluralize("cask", num_modified)}: " \ + "#{@modified_casks.join(" ")}" end @modified_casks end @@ -122,7 +122,7 @@ class Hbc::CLI::InternalAuditModifiedCasks < Hbc::CLI::InternalUseBase num_failed = failed_casks.size cask_pluralized = pluralize("cask", num_failed) odie "audit failed for #{num_failed} #{cask_pluralized}: " \ - "#{failed_casks.join(' ')}" + "#{failed_casks.join(" ")}" end def pluralize(str, num) diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb index d1cfe8d63..1bccf610d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb @@ -21,7 +21,7 @@ class Hbc::CLI::InternalDump < Hbc::CLI::InternalUseBase opoo "#{cask_token} was not found or would not load: #{e}" end end - count == 0 ? nil : count == cask_tokens.length + count.zero? ? nil : count == cask_tokens.length end def self.help diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index 651a9ae37..0fb99cc72 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -118,7 +118,7 @@ class Hbc::CLI::InternalStanza < Hbc::CLI::InternalUseBase count += 1 end - count == 0 ? nil : count == cask_tokens.length + count.zero? ? nil : count == cask_tokens.length end def self.help diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb index 88907a797..8b9c67105 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/list.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb @@ -48,7 +48,7 @@ class Hbc::CLI::List < Hbc::CLI::Base end end - count == 0 ? nil : count == cask_tokens.length + count.zero? ? nil : count == cask_tokens.length end def self.list_artifacts(cask) diff --git a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb index ae15414b7..2ce9b7d4d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb @@ -28,8 +28,8 @@ class Hbc::CLI::Uninstall < Hbc::CLI::Base single = versions.count == 1 puts <<-EOS.undent - #{cask_token} #{versions.join(', ')} #{single ? 'is' : 'are'} still installed. - Remove #{single ? 'it' : 'them all'} with `brew cask uninstall --force #{cask_token}`. + #{cask_token} #{versions.join(", ")} #{single ? "is" : "are"} still installed. + Remove #{single ? "it" : "them all"} with `brew cask uninstall --force #{cask_token}`. EOS end end diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb index f39012542..b947741ea 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl.rb @@ -269,8 +269,16 @@ class Hbc::DSL end def method_missing(method, *) - Hbc::Utils.method_missing_message(method, token) - nil + if method + Hbc::Utils.method_missing_message(method, token) + nil + else + super + end + end + + def respond_to_missing?(*) + true end def appdir diff --git a/Library/Homebrew/cask/lib/hbc/dsl/base.rb b/Library/Homebrew/cask/lib/hbc/dsl/base.rb index 4bf62014e..f47f3aab7 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/base.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/base.rb @@ -13,9 +13,17 @@ class Hbc::DSL::Base end def method_missing(method, *) - underscored_class = self.class.name.gsub(%r{([[:lower:]])([[:upper:]][[:lower:]])}, '\1_\2').downcase - section = underscored_class.downcase.split("::").last - Hbc::Utils.method_missing_message(method, @cask.to_s, section) - nil + if method + underscored_class = self.class.name.gsub(%r{([[:lower:]])([[:upper:]][[:lower:]])}, '\1_\2').downcase + section = underscored_class.downcase.split("::").last + Hbc::Utils.method_missing_message(method, @cask.to_s, section) + nil + else + super + end + end + + def respond_to_missing?(*) + true end end diff --git a/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb b/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb index 02c76fb27..218178faa 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb @@ -25,13 +25,21 @@ class Hbc::DSL::StanzaProxy coder["resolved"] = @resolver.call end - def respond_to?(symbol, include_private = false) - return true if %i{encode_with proxy? to_s type}.include?(symbol) - return false if symbol == :to_ary - @resolver.call.respond_to?(symbol, include_private) + def method_missing(method, *args) + if method != :to_ary + @resolver.call.send(method, *args) + else + super + end end - def method_missing(symbol, *args) - @resolver.call.send(symbol, *args) + def respond_to?(method, include_private = false) + 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 diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 72a9b3077..fad79644e 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -139,15 +139,15 @@ class Hbc::Installer # dependencies should also apply for "brew cask stage" # override dependencies with --force or perhaps --force-deps def satisfy_dependencies - if @cask.depends_on - ohai "Satisfying dependencies" - macos_dependencies - arch_dependencies - x11_dependencies - formula_dependencies - cask_dependencies unless skip_cask_deps - puts "complete" - end + return unless @cask.depends_on + + ohai "Satisfying dependencies" + macos_dependencies + arch_dependencies + x11_dependencies + formula_dependencies + cask_dependencies unless skip_cask_deps + puts "complete" end def macos_dependencies @@ -159,7 +159,7 @@ class Hbc::Installer end elsif @cask.depends_on.macos.length > 1 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 else unless MacOS.version == @cask.depends_on.macos.first @@ -175,7 +175,7 @@ class Hbc::Installer arch[:type] == @current_arch[:type] && 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 def x11_dependencies @@ -203,7 +203,7 @@ class Hbc::Installer def cask_dependencies 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.sorted.each do |dep_token| puts "#{dep_token} ..." diff --git a/Library/Homebrew/cask/lib/hbc/source/tapped_qualified.rb b/Library/Homebrew/cask/lib/hbc/source/tapped_qualified.rb index 1da013db2..97a35defe 100644 --- a/Library/Homebrew/cask/lib/hbc/source/tapped_qualified.rb +++ b/Library/Homebrew/cask/lib/hbc/source/tapped_qualified.rb @@ -11,7 +11,7 @@ class Hbc::Source::TappedQualified < Hbc::Source::Tapped qualified_token = Hbc::QualifiedToken.parse(query) return if qualified_token.nil? - user, repo, token = qualified_token + user, repo = qualified_token[0..1] Tap.fetch(user, repo) end diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb index bb8d91504..9ffe9da38 100644 --- a/Library/Homebrew/cask/lib/hbc/system_command.rb +++ b/Library/Homebrew/cask/lib/hbc/system_command.rb @@ -123,7 +123,7 @@ class Hbc::SystemCommand::Result end def success? - @exit_status == 0 + @exit_status.zero? end def merged_output diff --git a/Library/Homebrew/cask/lib/hbc/url_checker.rb b/Library/Homebrew/cask/lib/hbc/url_checker.rb index 8737903df..327306b2b 100644 --- a/Library/Homebrew/cask/lib/hbc/url_checker.rb +++ b/Library/Homebrew/cask/lib/hbc/url_checker.rb @@ -36,7 +36,7 @@ class Hbc::UrlChecker def _check_response_status ok = OK_RESPONSES[cask.url.scheme] 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 def _get_data_from_request diff --git a/Library/Homebrew/cask/lib/hbc/utils.rb b/Library/Homebrew/cask/lib/hbc/utils.rb index 599127523..1b80f6ae2 100644 --- a/Library/Homebrew/cask/lib/hbc/utils.rb +++ b/Library/Homebrew/cask/lib/hbc/utils.rb @@ -32,14 +32,15 @@ end # global methods def odebug(title, *sput) - if Hbc.respond_to?(:debug) && Hbc.debug - width = Tty.width * 4 - 6 - if $stdout.tty? && title.to_s.length > width - title = title.to_s[0, width - 3] + "..." - end - puts "#{Tty.magenta}==>#{Tty.reset} #{Tty.white}#{title}#{Tty.reset}" - puts sput unless sput.empty? + return unless Hbc.respond_to?(:debug) + return unless Hbc.debug + + width = Tty.width * 4 - 6 + if $stdout.tty? && title.to_s.length > width + title = title.to_s[0, width - 3] + "..." end + puts "#{Tty.magenta}==>#{Tty.reset} #{Tty.white}#{title}#{Tty.reset}" + puts sput unless sput.empty? end module Hbc::Utils diff --git a/Library/Homebrew/cask/spec/cask/cli/cleanup_spec.rb b/Library/Homebrew/cask/spec/cask/cli/cleanup_spec.rb index ab2cd55cc..fe8bb2d4d 100644 --- a/Library/Homebrew/cask/spec/cask/cli/cleanup_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/cleanup_spec.rb @@ -12,7 +12,7 @@ describe Hbc::CLI::Cleanup do describe "cleanup" do it "removes cached downloads of given casks" do - cleaned_up_cached_download = 'caffeine' + cleaned_up_cached_download = "caffeine" cached_downloads = [ cache_location.join("#{cleaned_up_cached_download}--latest.zip"), diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index bfd4407e0..5a26884ac 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -9,7 +9,7 @@ end project_root = Pathname.new(File.expand_path("../..", __FILE__)) # 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" diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb index afa4a61aa..47408ab9f 100644 --- a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb @@ -60,7 +60,6 @@ describe Hbc::Artifact::App do File.exist?(cask.staged_path.join("Caffeine Deluxe.app")).must_equal true end - describe "avoids clobbering an existing app" do let(:cask) { local_two_apps_caffeine } @@ -70,8 +69,8 @@ describe Hbc::Artifact::App do TestHelper.must_output(self, lambda { Hbc::Artifact::App.new(cask).install_phase }, <<-EOS.undent.chomp) - ==> 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')}' + ==> 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")}' EOS source_path = cask.staged_path.join("Caffeine Mini.app") @@ -85,8 +84,8 @@ describe Hbc::Artifact::App do TestHelper.must_output(self, lambda { Hbc::Artifact::App.new(cask).install_phase }, <<-EOS.undent.chomp) - ==> 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. + ==> 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. EOS source_path = cask.staged_path.join("Caffeine Pro.app") diff --git a/Library/Homebrew/cask/test/cask/cli/list_test.rb b/Library/Homebrew/cask/test/cask/cli/list_test.rb index 2189498d4..6831bf0a4 100644 --- a/Library/Homebrew/cask/test/cask/cli/list_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/list_test.rb @@ -79,9 +79,9 @@ describe Hbc::CLI::List do Hbc::CLI::List.run("local-transmission", "local-caffeine") }.must_output <<-EOS.undent ==> Apps - #{Hbc.appdir.join('Transmission.app')} (#{Hbc.appdir.join('Transmission.app').abv}) + #{Hbc.appdir.join("Transmission.app")} (#{Hbc.appdir.join("Transmission.app").abv}) ==> Apps - Missing App: #{Hbc.appdir.join('Caffeine.app')} + Missing App: #{Hbc.appdir.join("Caffeine.app")} EOS end end diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index 3599b43be..4d795bffe 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -10,7 +10,7 @@ project_root = Pathname.new(File.expand_path("../..", __FILE__)) tap_root = Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask") # 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" |
