From 57abdba4eb1a3549b963105b7030906bdabd8ff3 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 27 Jul 2020 10:39:13 +0100 Subject: [PATCH] developer/bin/list_running_app_ids: fix RuboCop style. See https://github.com/Homebrew/brew/pull/7867. --- developer/bin/list_running_app_ids | 36 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/developer/bin/list_running_app_ids b/developer/bin/list_running_app_ids index 71afe8f6e8..1225c3c261 100755 --- a/developer/bin/list_running_app_ids +++ b/developer/bin/list_running_app_ids @@ -30,30 +30,30 @@ def check_ruby end def usage - <<-EOS -list_running_app_ids [ -t ] + <<~EOS + list_running_app_ids [ -t ] -Print a list of currently running Applications and associated -Bundle IDs, which may be useful in a Cask uninstall stanza, eg + Print a list of currently running Applications and associated + Bundle IDs, which may be useful in a Cask uninstall stanza, eg - uninstall quit: 'bundle.id.goes.here' + uninstall quit: 'bundle.id.goes.here' -Applications attributed to Apple are excluded from the output. + Applications attributed to Apple are excluded from the output. -With optional "-t ", silently test if a given app -is running, exiting with an error code if not. + With optional "-t ", silently test if a given app + is running, exiting with an error code if not. -See CONTRIBUTING.md for more information. + See CONTRIBUTING.md for more information. -EOS + EOS end def process_args until ARGV.empty? - if ARGV.first =~ %r{^-+t(?:est)?$} && ARGV.length > 1 + if ARGV.first =~ /^-+t(?:est)?$/ && ARGV.length > 1 ARGV.shift $opt_test = ARGV.shift - elsif ARGV.first =~ %r{^-+h(?:elp)?$} + elsif /^-+h(?:elp)?$/.match?(ARGV.first) puts usage exit 0 else @@ -64,8 +64,9 @@ def process_args end def load_apps - out, err, status = Open3.capture3("/usr/bin/osascript", "-e", 'tell application "System Events" to get (name, bundle identifier, unix id) of every process') - if status.exitstatus > 0 + out, err, status = Open3.capture3("/usr/bin/osascript", "-e", + 'tell application "System Events" to get (name, bundle identifier, unix id) of every process') + if status.exitstatus.positive? puts err exit status.exitstatus end @@ -81,11 +82,11 @@ def test_app(bundle) end def excluded_bundle_id(bundle_id) - %r{^com\.apple\.}.match(bundle_id) + /^com\.apple\./.match(bundle_id) end def excluded_app_name(app_name) - %r{^osascript$}.match(app_name) # this script itself + /^osascript$/.match(app_name) # this script itself end def report_apps @@ -93,7 +94,8 @@ def report_apps @app_names.zip(@bundle_ids, @unix_ids).each do |app_name, bundle_id, _unix_id| next if excluded_bundle_id bundle_id next if excluded_app_name app_name - bundle_id.gsub!(%r{^(missing value)$}, '<\1>') + + bundle_id.gsub!(/^(missing value)$/, '<\1>') running.add "#{bundle_id.ljust($COLUMNS / 2)}\t#{app_name}" end