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 30709a0b5d..be3050acb7 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb @@ -4,7 +4,7 @@ module Hbc module Artifact class AbstractFlightBlock < Base def self.artifact_dsl_key - super.to_s.sub(%r{_block$}, "").to_sym + super.to_s.sub(/_block$/, "").to_sym end def self.uninstall_artifact_dsl_key diff --git a/Library/Homebrew/cask/lib/hbc/artifact/base.rb b/Library/Homebrew/cask/lib/hbc/artifact/base.rb index 141ab68810..05dbedd8fc 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/base.rb @@ -2,15 +2,15 @@ module Hbc module Artifact class Base def self.artifact_name - @artifact_name ||= name.sub(%r{^.*:}, "").gsub(%r{(.)([A-Z])}, '\1_\2').downcase + @artifact_name ||= name.sub(/^.*:/, "").gsub(/(.)([A-Z])/, '\1_\2').downcase end def self.artifact_english_name - @artifact_english_name ||= name.sub(%r{^.*:}, "").gsub(%r{(.)([A-Z])}, '\1 \2') + @artifact_english_name ||= name.sub(/^.*:/, "").gsub(/(.)([A-Z])/, '\1 \2') end def self.artifact_english_article - @artifact_english_article ||= artifact_english_name =~ %r{^[aeiou]}i ? "an" : "a" + @artifact_english_article ||= artifact_english_name =~ /^[aeiou]/i ? "an" : "a" end def self.artifact_dsl_key diff --git a/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb b/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb index 1b5a4ff474..335d7e2fcc 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb @@ -15,7 +15,7 @@ module Hbc attr_reader :source, :target def printable_target - target.to_s.sub(%r{^#{ENV['HOME']}(#{File::SEPARATOR}|$)}, "~/") + target.to_s.sub(/^#{ENV['HOME']}(#{File::SEPARATOR}|$)/, "~/") end ALT_NAME_ATTRIBUTE = "com.apple.metadata:kMDItemAlternateNames".freeze @@ -28,7 +28,7 @@ module Hbc odebug "Adding #{ALT_NAME_ATTRIBUTE} metadata" altnames = @command.run("/usr/bin/xattr", args: ["-p", ALT_NAME_ATTRIBUTE, file.to_s], - print_stderr: false).stdout.sub(%r{\A\((.*)\)\Z}, '\1') + print_stderr: false).stdout.sub(/\A\((.*)\)\Z/, '\1') odebug "Existing metadata is: '#{altnames}'" altnames.concat(", ") unless altnames.empty? altnames.concat(%Q{"#{altname}"}) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb index 63ffd18c9c..b871cbc459 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb @@ -103,7 +103,7 @@ module Hbc ohai "Removing launchctl service #{service}" [false, true].each do |with_sudo| plist_status = @command.run("/bin/launchctl", args: ["list", service], sudo: with_sudo, print_stderr: false).stdout - if plist_status =~ %r{^\{} + if plist_status =~ /^\{/ @command.run!("/bin/launchctl", args: ["remove", service], sudo: with_sudo) sleep 1 end @@ -164,8 +164,8 @@ module Hbc pid_string = @command.run!("/usr/bin/osascript", args: ["-e", %Q{tell application "System Events" to get the unix id of every process whose bundle identifier is "#{bundle_id}"}], sudo: true).stdout.chomp - return [] unless pid_string =~ %r{\A\d+(?:\s*,\s*\d+)*\Z} # sanity check - pid_string.split(%r{\s*,\s*}).map(&:strip).map(&:to_i) + return [] unless pid_string =~ /\A\d+(?:\s*,\s*\d+)*\Z/ # sanity check + pid_string.split(/\s*,\s*/).map(&:strip).map(&:to_i) end def uninstall_login_item(directives) diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index 533ede70d9..0cb4703701 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -84,7 +84,7 @@ module Hbc def check_sha256_actually_256(sha256: cask.sha256, stanza: "sha256") odebug "Verifying #{stanza} string is a legal SHA-256 digest" return unless sha256.is_a?(String) - return if sha256.length == 64 && sha256[%r{^[0-9a-f]+$}i] + return if sha256.length == 64 && sha256[/^[0-9a-f]+$/i] add_error "#{stanza} string must be of 64 hexadecimal characters" end @@ -162,7 +162,7 @@ module Hbc end def bad_sourceforge_url? - bad_url_format?(%r{sourceforge}, + bad_url_format?(/sourceforge/, [ %r{\Ahttps://sourceforge\.net/projects/[^/]+/files/latest/download\Z}, %r{\Ahttps://downloads\.sourceforge\.net/(?!(project|sourceforge)\/)}, @@ -174,7 +174,7 @@ module Hbc end def bad_osdn_url? - bad_url_format?(%r{osd}, [%r{\Ahttps?://([^/]+.)?dl\.osdn\.jp/}]) + bad_url_format?(/osd/, [%r{\Ahttps?://([^/]+.)?dl\.osdn\.jp/}]) end def check_generic_artifacts diff --git a/Library/Homebrew/cask/lib/hbc/cache.rb b/Library/Homebrew/cask/lib/hbc/cache.rb index db3ec536b9..e343da3faf 100644 --- a/Library/Homebrew/cask/lib/hbc/cache.rb +++ b/Library/Homebrew/cask/lib/hbc/cache.rb @@ -17,7 +17,7 @@ module Hbc file = symlink.readlink new_name = file.basename - .sub(%r{\-((?:(\d|#{DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$}x, + .sub(/\-((?:(\d|#{DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$/x, '--\1') renamed_file = Hbc.cache.join(new_name) diff --git a/Library/Homebrew/cask/lib/hbc/caveats.rb b/Library/Homebrew/cask/lib/hbc/caveats.rb index a854291513..983d288748 100644 --- a/Library/Homebrew/cask/lib/hbc/caveats.rb +++ b/Library/Homebrew/cask/lib/hbc/caveats.rb @@ -8,7 +8,7 @@ module Hbc dsl = DSL::Caveats.new(cask) retval = dsl.instance_eval(&@block) return if retval.nil? - puts retval.to_s.sub(%r{[\r\n \t]*\Z}, "\n\n") + puts retval.to_s.sub(/[\r\n \t]*\Z/, "\n\n") end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index 11f8cc7167..cd12ab0860 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -129,7 +129,7 @@ module Hbc exec "brewcask-#{command}", *ARGV[1..-1] elsif Pathname.new(command.to_s).executable? && command.to_s.include?("/") && - !command.to_s.match(%r{\.rb$}) + !command.to_s.match(/\.rb$/) # arbitrary external executable with literal path, useful # for development and troubleshooting exec command, *ARGV[1..-1] @@ -163,7 +163,7 @@ module Hbc cask_taps = {} cask_list.each do |c| user, repo, token = c.split "/" - repo.sub!(%r{^homebrew-}i, "") + repo.sub!(/^homebrew-/i, "") cask_taps[token] ||= [] cask_taps[token].push "#{user}/#{repo}" end diff --git a/Library/Homebrew/cask/lib/hbc/cli/base.rb b/Library/Homebrew/cask/lib/hbc/cli/base.rb index 6c706d5379..e218a47dd2 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/base.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/base.rb @@ -2,7 +2,7 @@ module Hbc class CLI class Base def self.command_name - @command_name ||= name.sub(%r{^.*:}, "").gsub(%r{(.)([A-Z])}, '\1_\2').downcase + @command_name ||= name.sub(/^.*:/, "").gsub(/(.)([A-Z])/, '\1_\2').downcase end def self.visible diff --git a/Library/Homebrew/cask/lib/hbc/cli/cat.rb b/Library/Homebrew/cask/lib/hbc/cli/cat.rb index 75f6c1e91e..464e23a5e4 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/cat.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/cat.rb @@ -5,7 +5,7 @@ module Hbc cask_tokens = cask_tokens_from(args) raise CaskUnspecifiedError if cask_tokens.empty? # only respects the first argument - cask_token = cask_tokens.first.sub(%r{\.rb$}i, "") + cask_token = cask_tokens.first.sub(/\.rb$/i, "") cask_path = Hbc.path(cask_token) raise CaskUnavailableError, cask_token.to_s unless cask_path.exist? puts File.open(cask_path, &:read) diff --git a/Library/Homebrew/cask/lib/hbc/cli/create.rb b/Library/Homebrew/cask/lib/hbc/cli/create.rb index 84537cdc13..3e2b9c1911 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/create.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/create.rb @@ -4,7 +4,7 @@ module Hbc def self.run(*args) cask_tokens = cask_tokens_from(args) raise CaskUnspecifiedError if cask_tokens.empty? - cask_token = cask_tokens.first.sub(%r{\.rb$}i, "") + cask_token = cask_tokens.first.sub(/\.rb$/i, "") cask_path = Hbc.path(cask_token) odebug "Creating Cask #{cask_token}" diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index e36999200d..873ca47fde 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -53,7 +53,7 @@ module Hbc args: %w[config --get remote.origin.url], print_stderr: false).stdout.strip end - if homebrew_origin !~ %r{\S} + if homebrew_origin !~ /\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"}" @@ -92,7 +92,7 @@ module Hbc print_stderr: false) .stdout .strip - if @homebrew_constants[name] !~ %r{\S} + if @homebrew_constants[name] !~ /\S/ @homebrew_constants[name] = "#{none_string} #{error_string}" end path = Pathname.new(@homebrew_constants[name]) @@ -104,7 +104,7 @@ module Hbc end def self.locale_variables - ENV.keys.grep(%r{^(?:LC_\S+|LANG|LANGUAGE)\Z}).collect { |v| %Q{#{v}="#{ENV[v]}"} }.sort.join("\n") + ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).collect { |v| %Q{#{v}="#{ENV[v]}"} }.sort.join("\n") end def self.privileged_uid @@ -118,7 +118,7 @@ module Hbc end def self.legacy_tap_pattern - %r{phinze} + /phinze/ end def self.notfound_string diff --git a/Library/Homebrew/cask/lib/hbc/cli/edit.rb b/Library/Homebrew/cask/lib/hbc/cli/edit.rb index 3090cf1960..a6ff342341 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/edit.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/edit.rb @@ -5,7 +5,7 @@ module Hbc cask_tokens = cask_tokens_from(args) raise CaskUnspecifiedError if cask_tokens.empty? # only respects the first argument - cask_token = cask_tokens.first.sub(%r{\.rb$}i, "") + cask_token = cask_tokens.first.sub(/\.rb$/i, "") cask_path = Hbc.path(cask_token) odebug "Opening editor for Cask #{cask_token}" unless cask_path.exist? 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 47258a7b2e..feb5a830a6 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 @@ -10,7 +10,7 @@ module Hbc def run(*args) commit_range = commit_range(args) - cleanup = args.any? { |a| a =~ %r{^-+c(leanup)?$}i } + cleanup = args.any? { |a| a =~ /^-+c(leanup)?$/i } new(commit_range, cleanup: cleanup).run end @@ -109,7 +109,7 @@ module Hbc def relevant_stanza_modified?(cask_file) out = git("diff", commit_range, "--", cask_file) - out =~ %r{^\+\s*(#{RELEVANT_STANZAS.join('|')})} + out =~ /^\+\s*(#{RELEVANT_STANZAS.join('|')})/ end def git(*args) diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_use_base.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_use_base.rb index 96b6eeaa8f..b1f9c5631f 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_use_base.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_use_base.rb @@ -2,7 +2,7 @@ module Hbc class CLI class InternalUseBase < Base def self.command_name - super.sub(%r{^internal_}i, "_") + super.sub(/^internal_/i, "_") end def self.visible diff --git a/Library/Homebrew/cask/lib/hbc/cli/search.rb b/Library/Homebrew/cask/lib/hbc/cli/search.rb index 147e6d1949..8e8f8fd750 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/search.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/search.rb @@ -21,12 +21,12 @@ module Hbc all_tokens = CLI.nice_listing(Hbc.all_tokens) if search_regexp search_term = arguments.first - partial_matches = all_tokens.grep(%r{#{search_regexp}}i) + partial_matches = all_tokens.grep(/#{search_regexp}/i) else - simplified_tokens = all_tokens.map { |t| t.sub(%r{^.*\/}, "").gsub(%r{[^a-z0-9]+}i, "") } - simplified_search_term = search_term.sub(%r{\.rb$}i, "").gsub(%r{[^a-z0-9]+}i, "") - exact_match = simplified_tokens.grep(%r{^#{simplified_search_term}$}i) { |t| all_tokens[simplified_tokens.index(t)] }.first - partial_matches = simplified_tokens.grep(%r{#{simplified_search_term}}i) { |t| all_tokens[simplified_tokens.index(t)] } + simplified_tokens = all_tokens.map { |t| t.sub(%r{^.*\/}, "").gsub(/[^a-z0-9]+/i, "") } + simplified_search_term = search_term.sub(/\.rb$/i, "").gsub(/[^a-z0-9]+/i, "") + exact_match = simplified_tokens.grep(/^#{simplified_search_term}$/i) { |t| all_tokens[simplified_tokens.index(t)] }.first + partial_matches = simplified_tokens.grep(/#{simplified_search_term}/i) { |t| all_tokens[simplified_tokens.index(t)] } partial_matches.delete(exact_match) end [exact_match, partial_matches, search_term] diff --git a/Library/Homebrew/cask/lib/hbc/cli/style.rb b/Library/Homebrew/cask/lib/hbc/cli/style.rb index 0dd4bc4742..fcb59230ef 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/style.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/style.rb @@ -67,7 +67,7 @@ module Hbc end def fix? - args.any? { |arg| arg =~ %r{--(fix|(auto-?)?correct)} } + args.any? { |arg| arg =~ /--(fix|(auto-?)?correct)/ } end end end diff --git a/Library/Homebrew/cask/lib/hbc/container/bzip2.rb b/Library/Homebrew/cask/lib/hbc/container/bzip2.rb index 81808071fe..9f2a59bb8a 100644 --- a/Library/Homebrew/cask/lib/hbc/container/bzip2.rb +++ b/Library/Homebrew/cask/lib/hbc/container/bzip2.rb @@ -6,7 +6,7 @@ module Hbc class Container class Bzip2 < Base def self.me?(criteria) - criteria.magic_number(%r{^BZh}n) + criteria.magic_number(/^BZh/n) end def extract diff --git a/Library/Homebrew/cask/lib/hbc/container/cab.rb b/Library/Homebrew/cask/lib/hbc/container/cab.rb index 7ae6b06325..52c13402ce 100644 --- a/Library/Homebrew/cask/lib/hbc/container/cab.rb +++ b/Library/Homebrew/cask/lib/hbc/container/cab.rb @@ -8,7 +8,7 @@ module Hbc def self.me?(criteria) cabextract = which("cabextract") - criteria.magic_number(%r{^MSCF}n) && + criteria.magic_number(/^MSCF/n) && !cabextract.nil? && criteria.command.run(cabextract, args: ["-t", "--", criteria.path.to_s]).stderr.empty? end diff --git a/Library/Homebrew/cask/lib/hbc/container/criteria.rb b/Library/Homebrew/cask/lib/hbc/container/criteria.rb index 207c5f3cd4..66ecb8c874 100644 --- a/Library/Homebrew/cask/lib/hbc/container/criteria.rb +++ b/Library/Homebrew/cask/lib/hbc/container/criteria.rb @@ -9,7 +9,7 @@ module Hbc end def extension(regex) - path.extname.sub(%r{^\.}, "") =~ Regexp.new(regex.source, regex.options | Regexp::IGNORECASE) + path.extname.sub(/^\./, "") =~ Regexp.new(regex.source, regex.options | Regexp::IGNORECASE) end def magic_number(regex) diff --git a/Library/Homebrew/cask/lib/hbc/container/gzip.rb b/Library/Homebrew/cask/lib/hbc/container/gzip.rb index 7e4722a7f8..d3dd7b8fd0 100644 --- a/Library/Homebrew/cask/lib/hbc/container/gzip.rb +++ b/Library/Homebrew/cask/lib/hbc/container/gzip.rb @@ -6,7 +6,7 @@ module Hbc class Container class Gzip < Base def self.me?(criteria) - criteria.magic_number(%r{^\037\213}n) + criteria.magic_number(/^\037\213/n) end def extract diff --git a/Library/Homebrew/cask/lib/hbc/container/lzma.rb b/Library/Homebrew/cask/lib/hbc/container/lzma.rb index cca4d814b7..1221acfbc0 100644 --- a/Library/Homebrew/cask/lib/hbc/container/lzma.rb +++ b/Library/Homebrew/cask/lib/hbc/container/lzma.rb @@ -6,7 +6,7 @@ module Hbc class Container class Lzma < Base def self.me?(criteria) - criteria.magic_number(%r{^\]\000\000\200\000}n) + criteria.magic_number(/^\]\000\000\200\000/n) end def extract diff --git a/Library/Homebrew/cask/lib/hbc/container/otf.rb b/Library/Homebrew/cask/lib/hbc/container/otf.rb index 66222ad8d6..823d04f74e 100644 --- a/Library/Homebrew/cask/lib/hbc/container/otf.rb +++ b/Library/Homebrew/cask/lib/hbc/container/otf.rb @@ -4,7 +4,7 @@ module Hbc class Container class Otf < Naked def self.me?(criteria) - criteria.magic_number(%r{^OTTO}n) + criteria.magic_number(/^OTTO/n) end end end diff --git a/Library/Homebrew/cask/lib/hbc/container/pkg.rb b/Library/Homebrew/cask/lib/hbc/container/pkg.rb index dfd62a8633..b5f5daad84 100644 --- a/Library/Homebrew/cask/lib/hbc/container/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/container/pkg.rb @@ -4,9 +4,9 @@ module Hbc class Container class Pkg < Naked def self.me?(criteria) - criteria.extension(%r{m?pkg$}) && + criteria.extension(/m?pkg$/) && (criteria.path.directory? || - criteria.magic_number(%r{^xar!}n)) + criteria.magic_number(/^xar!/n)) end end end diff --git a/Library/Homebrew/cask/lib/hbc/container/rar.rb b/Library/Homebrew/cask/lib/hbc/container/rar.rb index bcf225623b..81481f84bd 100644 --- a/Library/Homebrew/cask/lib/hbc/container/rar.rb +++ b/Library/Homebrew/cask/lib/hbc/container/rar.rb @@ -4,7 +4,7 @@ module Hbc class Container class Rar < GenericUnar def self.me?(criteria) - criteria.magic_number(%r{^Rar!}n) && + criteria.magic_number(/^Rar!/n) && super end end diff --git a/Library/Homebrew/cask/lib/hbc/container/seven_zip.rb b/Library/Homebrew/cask/lib/hbc/container/seven_zip.rb index 7a144d5327..d1839907cd 100644 --- a/Library/Homebrew/cask/lib/hbc/container/seven_zip.rb +++ b/Library/Homebrew/cask/lib/hbc/container/seven_zip.rb @@ -5,7 +5,7 @@ module Hbc class SevenZip < GenericUnar def self.me?(criteria) # TODO: cover self-extracting archives - criteria.magic_number(%r{^7z}n) && + criteria.magic_number(/^7z/n) && super end end diff --git a/Library/Homebrew/cask/lib/hbc/container/sit.rb b/Library/Homebrew/cask/lib/hbc/container/sit.rb index 2d88493994..c486a981c3 100644 --- a/Library/Homebrew/cask/lib/hbc/container/sit.rb +++ b/Library/Homebrew/cask/lib/hbc/container/sit.rb @@ -4,7 +4,7 @@ module Hbc class Container class Sit < GenericUnar def self.me?(criteria) - criteria.magic_number(%r{^StuffIt}n) && + criteria.magic_number(/^StuffIt/n) && super end end diff --git a/Library/Homebrew/cask/lib/hbc/container/tar.rb b/Library/Homebrew/cask/lib/hbc/container/tar.rb index df77e454d0..eb646c816f 100644 --- a/Library/Homebrew/cask/lib/hbc/container/tar.rb +++ b/Library/Homebrew/cask/lib/hbc/container/tar.rb @@ -6,7 +6,7 @@ module Hbc class Container class Tar < Base def self.me?(criteria) - criteria.magic_number(%r{^.{257}ustar}n) || + criteria.magic_number(/^.{257}ustar/n) || # or compressed tar (bzip2/gzip/lzma/xz) IO.popen(["/usr/bin/tar", "-t", "-f", criteria.path.to_s], err: "/dev/null") { |io| !io.read(1).nil? } end diff --git a/Library/Homebrew/cask/lib/hbc/container/ttf.rb b/Library/Homebrew/cask/lib/hbc/container/ttf.rb index 62ca29b223..612a804f95 100644 --- a/Library/Homebrew/cask/lib/hbc/container/ttf.rb +++ b/Library/Homebrew/cask/lib/hbc/container/ttf.rb @@ -5,9 +5,9 @@ module Hbc class Ttf < Naked def self.me?(criteria) # TrueType Font - criteria.magic_number(%r{^\000\001\000\000\000}n) || + criteria.magic_number(/^\000\001\000\000\000/n) || # Truetype Font Collection - criteria.magic_number(%r{^ttcf}n) + criteria.magic_number(/^ttcf/n) end end end diff --git a/Library/Homebrew/cask/lib/hbc/container/xar.rb b/Library/Homebrew/cask/lib/hbc/container/xar.rb index 228ab23435..a0165ca57e 100644 --- a/Library/Homebrew/cask/lib/hbc/container/xar.rb +++ b/Library/Homebrew/cask/lib/hbc/container/xar.rb @@ -6,7 +6,7 @@ module Hbc class Container class Xar < Base def self.me?(criteria) - criteria.magic_number(%r{^xar!}n) + criteria.magic_number(/^xar!/n) end def extract diff --git a/Library/Homebrew/cask/lib/hbc/container/xip.rb b/Library/Homebrew/cask/lib/hbc/container/xip.rb index 2d0f17e2e8..982402e4e6 100644 --- a/Library/Homebrew/cask/lib/hbc/container/xip.rb +++ b/Library/Homebrew/cask/lib/hbc/container/xip.rb @@ -4,8 +4,8 @@ module Hbc class Container class Xip < Base def self.me?(criteria) - criteria.magic_number(%r{^xar!}n) && - IO.popen(["/usr/bin/xar", "-t", "-f", criteria.path.to_s], err: "/dev/null") { |io| io.read =~ %r{\AContent\nMetadata\n\Z} } + criteria.magic_number(/^xar!/n) && + IO.popen(["/usr/bin/xar", "-t", "-f", criteria.path.to_s], err: "/dev/null") { |io| io.read =~ /\AContent\nMetadata\n\Z/ } end def extract diff --git a/Library/Homebrew/cask/lib/hbc/container/xz.rb b/Library/Homebrew/cask/lib/hbc/container/xz.rb index fc0ae064e8..cd9f9aee2f 100644 --- a/Library/Homebrew/cask/lib/hbc/container/xz.rb +++ b/Library/Homebrew/cask/lib/hbc/container/xz.rb @@ -6,7 +6,7 @@ module Hbc class Container class Xz < Base def self.me?(criteria) - criteria.magic_number(%r{^\xFD7zXZ\x00}n) + criteria.magic_number(/^\xFD7zXZ\x00/n) end def extract diff --git a/Library/Homebrew/cask/lib/hbc/container/zip.rb b/Library/Homebrew/cask/lib/hbc/container/zip.rb index 86e2d1bd69..8e3cf5b2dc 100644 --- a/Library/Homebrew/cask/lib/hbc/container/zip.rb +++ b/Library/Homebrew/cask/lib/hbc/container/zip.rb @@ -4,7 +4,7 @@ module Hbc class Container class Zip < Base def self.me?(criteria) - criteria.magic_number(%r{^PK(\003\004|\005\006)}n) + criteria.magic_number(/^PK(\003\004|\005\006)/n) end def extract diff --git a/Library/Homebrew/cask/lib/hbc/download_strategy.rb b/Library/Homebrew/cask/lib/hbc/download_strategy.rb index 400b9ffc87..1d22e2ed2a 100644 --- a/Library/Homebrew/cask/lib/hbc/download_strategy.rb +++ b/Library/Homebrew/cask/lib/hbc/download_strategy.rb @@ -74,7 +74,7 @@ module Hbc end def temporary_path - @temporary_path ||= tarball_path.sub(%r{$}, ".incomplete") + @temporary_path ||= tarball_path.sub(/$/, ".incomplete") end def cached_location @@ -216,7 +216,7 @@ module Hbc end def repo_url - `svn info '#{@clone}' 2>/dev/null`.strip[%r{^URL: (.+)$}, 1] + `svn info '#{@clone}' 2>/dev/null`.strip[/^URL: (.+)$/, 1] end # super does not provide checks for already-existing downloads @@ -224,7 +224,7 @@ module Hbc if tarball_path.exist? puts "Already downloaded: #{tarball_path}" else - @url = @url.sub(%r{^svn\+}, "") if @url =~ %r{^svn\+http://} + @url = @url.sub(/^svn\+/, "") if @url =~ %r{^svn\+http://} ohai "Checking out #{@url}" clear_cache unless @url.chomp("/") == repo_url || quiet_system("svn", "switch", @url, @clone) @@ -291,12 +291,12 @@ module Hbc def shell_quote(str) # Oh god escaping shell args. # See http://notetoself.vrensk.com/2008/08/escaping-single-quotes-in-ruby-harder-than-expected/ - str.gsub(%r{\\|'}) { |c| "\\#{c}" } + str.gsub(/\\|'/) { |c| "\\#{c}" } end def fetch_externals `svn propget svn:externals '#{shell_quote(@url)}'`.chomp.each_line do |line| - name, url = line.split(%r{\s+}) + name, url = line.split(/\s+/) yield name, url end end diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb index ff0db0040d..1ae9a0c4df 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl.rb @@ -252,7 +252,7 @@ module Hbc if block_given? @caveats << Hbc::Caveats.new(block) elsif string.any? - @caveats << string.map { |s| s.to_s.sub(%r{[\r\n \t]*\Z}, "\n\n") } + @caveats << string.map { |s| s.to_s.sub(/[\r\n \t]*\Z/, "\n\n") } end @caveats end diff --git a/Library/Homebrew/cask/lib/hbc/dsl/base.rb b/Library/Homebrew/cask/lib/hbc/dsl/base.rb index 20a3cec619..63df847e95 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/base.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/base.rb @@ -16,7 +16,7 @@ module Hbc def method_missing(method, *) if method - underscored_class = self.class.name.gsub(%r{([[:lower:]])([[:upper:]][[:lower:]])}, '\1_\2').downcase + underscored_class = self.class.name.gsub(/([[:lower:]])([[:upper:]][[:lower:]])/, '\1_\2').downcase section = underscored_class.downcase.split("::").last Utils.method_missing_message(method, @cask.to_s, section) nil diff --git a/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb b/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb index 0e80938b78..f402c603cc 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb @@ -62,7 +62,7 @@ module Hbc begin if arg.is_a?(Symbol) Gem::Version.new(@macos_symbols.fetch(arg)) - elsif arg =~ %r{^\s*:?([a-z]\S+)\s*$}i + elsif arg =~ /^\s*:?([a-z]\S+)\s*$/i Gem::Version.new(@macos_symbols.fetch(Regexp.last_match[1].downcase.to_sym)) elsif @inverted_macos_symbols.key?(arg) Gem::Version.new(arg) @@ -86,7 +86,7 @@ module Hbc def macos=(*arg) @macos ||= [] - macos = if arg.count == 1 && arg.first =~ %r{^\s*(<|>|[=<>]=)\s*(\S+)\s*$} + macos = if arg.count == 1 && arg.first =~ /^\s*(<|>|[=<>]=)\s*(\S+)\s*$/ raise "'depends_on macos' comparison expressions cannot be combined" unless @macos.empty? operator = Regexp.last_match[1].to_sym release = self.class.coerce_os_release(Regexp.last_match[2]) @@ -103,7 +103,7 @@ module Hbc def arch=(*arg) @arch ||= [] arches = Array(*arg).map { |elt| - elt = elt.to_s.downcase.sub(%r{^:}, "").tr("-", "_").to_sym + elt = elt.to_s.downcase.sub(/^:/, "").tr("-", "_").to_sym ARCH_SYNONYMS.key?(elt) ? ARCH_SYNONYMS[elt] : elt } invalid_arches = arches - VALID_ARCHES.keys diff --git a/Library/Homebrew/cask/lib/hbc/dsl/gpg.rb b/Library/Homebrew/cask/lib/hbc/dsl/gpg.rb index 572ede2279..c54db45247 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/gpg.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/gpg.rb @@ -28,7 +28,7 @@ module Hbc def valid_id?(id) legal_lengths = Set.new [8, 16, 40] - is_valid = id.is_a?(String) && legal_lengths.include?(id.length) && id[%r{^[0-9a-f]+$}i] + is_valid = id.is_a?(String) && legal_lengths.include?(id.length) && id[/^[0-9a-f]+$/i] raise "invalid ':key_id' value: '#{id.inspect}'" unless is_valid is_valid diff --git a/Library/Homebrew/cask/lib/hbc/dsl/version.rb b/Library/Homebrew/cask/lib/hbc/dsl/version.rb index d4697460af..63c15a02d1 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/version.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/version.rb @@ -8,9 +8,9 @@ module Hbc "/" => :slashes, }.freeze - DIVIDER_REGEX = %r{(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join('|')})} + DIVIDER_REGEX = /(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join('|')})/ - MAJOR_MINOR_PATCH_REGEX = %r{^(\d+)(?:\.(\d+)(?:\.(\d+))?)?} + MAJOR_MINOR_PATCH_REGEX = /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/ class << self private diff --git a/Library/Homebrew/cask/lib/hbc/fetcher.rb b/Library/Homebrew/cask/lib/hbc/fetcher.rb index 6f58ca0237..fb2b743fac 100644 --- a/Library/Homebrew/cask/lib/hbc/fetcher.rb +++ b/Library/Homebrew/cask/lib/hbc/fetcher.rb @@ -5,7 +5,7 @@ module Hbc TIMEOUT = 10 def self.head(url) - if url.to_s =~ %r{googlecode} + if url.to_s =~ /googlecode/ googlecode_fake_head(url) else SystemCommand.run("/usr/bin/curl", @@ -18,7 +18,7 @@ module Hbc def self.googlecode_fake_head(url) command = "curl --max-time #{TIMEOUT} --verbose --location '#{url}' | head -n 20 > /dev/null" stderr = Open3.capture3(command)[1] - stderr.split("\n").grep(%r{^< }).map { |line| line.sub(%r{^< }, "") }.join("\n") + stderr.split("\n").grep(/^< /).map { |line| line.sub(/^< /, "") }.join("\n") end end end diff --git a/Library/Homebrew/cask/lib/hbc/locations.rb b/Library/Homebrew/cask/lib/hbc/locations.rb index f1c7d138be..099caf6658 100644 --- a/Library/Homebrew/cask/lib/hbc/locations.rb +++ b/Library/Homebrew/cask/lib/hbc/locations.rb @@ -136,7 +136,7 @@ module Hbc return query_path if query_path.absolute? return query_path if query_path.exist? && query_path.extname == ".rb" - query_without_extension = query.sub(%r{\.rb$}i, "") + query_without_extension = query.sub(/\.rb$/i, "") token_with_tap = if query =~ %r{\A[^/]+/[^/]+/[^/]+\Z} query_without_extension diff --git a/Library/Homebrew/cask/lib/hbc/qualified_token.rb b/Library/Homebrew/cask/lib/hbc/qualified_token.rb index 7b2e93dcfb..8868bd65df 100644 --- a/Library/Homebrew/cask/lib/hbc/qualified_token.rb +++ b/Library/Homebrew/cask/lib/hbc/qualified_token.rb @@ -3,20 +3,20 @@ module Hbc REPO_PREFIX = "homebrew-".freeze # per https://github.com/Homebrew/homebrew/blob/4c7bc9ec3bca729c898ee347b6135ba692ee0274/Library/Homebrew/cmd/tap.rb#L121 - USER_REGEX = %r{[a-z0-9_\-]+} + USER_REGEX = /[a-z0-9_\-]+/ # per https://github.com/Homebrew/homebrew/blob/4c7bc9ec3bca729c898ee347b6135ba692ee0274/Library/Homebrew/cmd/tap.rb#L121 - REPO_REGEX = %r{(?:#{REPO_PREFIX})?\w+} + REPO_REGEX = /(?:#{REPO_PREFIX})?\w+/ # per https://github.com/caskroom/homebrew-cask/blob/master/CONTRIBUTING.md#generating-a-token-for-the-cask - TOKEN_REGEX = %r{[a-z0-9\-]+} + TOKEN_REGEX = /[a-z0-9\-]+/ TAP_REGEX = %r{#{USER_REGEX}[/\-]#{REPO_REGEX}} QUALIFIED_TOKEN_REGEX = %r{#{TAP_REGEX}/#{TOKEN_REGEX}} def self.parse(arg) - return nil unless arg.is_a?(String) && arg.downcase =~ %r{^#{QUALIFIED_TOKEN_REGEX}$} + return nil unless arg.is_a?(String) && arg.downcase =~ /^#{QUALIFIED_TOKEN_REGEX}$/ path_elements = arg.downcase.split("/") if path_elements.count == 2 # eg phinze-cask/google-chrome. @@ -31,7 +31,7 @@ module Hbc # per https://github.com/Homebrew/brew/blob/master/docs/brew-tap.md user, repo, token = path_elements end - repo.sub!(%r{^#{REPO_PREFIX}}, "") + repo.sub!(/^#{REPO_PREFIX}/, "") odebug "[user, repo, token] might be [#{user}, #{repo}, #{token}]" [user, repo, token] end diff --git a/Library/Homebrew/cask/lib/hbc/source.rb b/Library/Homebrew/cask/lib/hbc/source.rb index b4d105894d..ae1fdaf8ab 100644 --- a/Library/Homebrew/cask/lib/hbc/source.rb +++ b/Library/Homebrew/cask/lib/hbc/source.rb @@ -22,7 +22,7 @@ module Hbc def self.for_query(query) odebug "Translating '#{query}' into a valid Cask source" - raise CaskUnavailableError, query if query.to_s =~ %r{^\s*$} + raise CaskUnavailableError, query if query.to_s =~ /^\s*$/ source = sources.find { |s| odebug "Testing source class #{s}" s.me?(query) diff --git a/Library/Homebrew/cask/lib/hbc/source/path_base.rb b/Library/Homebrew/cask/lib/hbc/source/path_base.rb index 7d68e518b4..4e4bdcf158 100644 --- a/Library/Homebrew/cask/lib/hbc/source/path_base.rb +++ b/Library/Homebrew/cask/lib/hbc/source/path_base.rb @@ -7,7 +7,7 @@ module Hbc # derived classes must define method self.me? def self.path_for_query(query) - Pathname.new(query).sub(%r{(\.rb)?$}, ".rb") + Pathname.new(query).sub(/(\.rb)?$/, ".rb") end attr_reader :path diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb index aa4b9b2957..41fa924f91 100644 --- a/Library/Homebrew/cask/lib/hbc/system_command.rb +++ b/Library/Homebrew/cask/lib/hbc/system_command.rb @@ -144,7 +144,7 @@ module Hbc end def self._warn_plist_garbage(command, garbage) - return true unless garbage =~ %r{\S} + return true unless garbage =~ /\S/ external = File.basename(command.first) lines = garbage.strip.split("\n") opoo "Non-XML stdout from #{external}:" @@ -152,8 +152,8 @@ module Hbc end def self._parse_plist(command, output) - raise CaskError, "Empty plist input" unless output =~ %r{\S} - output.sub!(%r{\A(.*?)(<\?\s*xml)}m, '\2') + raise CaskError, "Empty plist input" unless output =~ /\S/ + output.sub!(/\A(.*?)(<\?\s*xml)/m, '\2') _warn_plist_garbage(command, Regexp.last_match[1]) if Hbc.debug output.sub!(%r{(<\s*/\s*plist\s*>)(.*?)\Z}m, '\1') _warn_plist_garbage(command, Regexp.last_match[2]) diff --git a/Library/Homebrew/cask/lib/hbc/url_checker.rb b/Library/Homebrew/cask/lib/hbc/url_checker.rb index 4dc1f136aa..6dfe0bebea 100644 --- a/Library/Homebrew/cask/lib/hbc/url_checker.rb +++ b/Library/Homebrew/cask/lib/hbc/url_checker.rb @@ -52,7 +52,7 @@ module Hbc case cask.url.scheme when "http", "https" then - @response_status = response_lines.grep(%r{^HTTP}).last + @response_status = response_lines.grep(/^HTTP/).last if @response_status.respond_to?(:strip) @response_status.strip! unless response_lines.index(@response_status).nil? diff --git a/Library/Homebrew/cask/lib/hbc/utils.rb b/Library/Homebrew/cask/lib/hbc/utils.rb index 38fa23463f..116cb20956 100644 --- a/Library/Homebrew/cask/lib/hbc/utils.rb +++ b/Library/Homebrew/cask/lib/hbc/utils.rb @@ -12,7 +12,7 @@ class Object def utf8_inspect return inspect unless defined?(Encoding) return map(&:utf8_inspect) if respond_to?(:map) - inspect.force_encoding("UTF-8").sub(%r{\A"(.*)"\Z}, '\1') + inspect.force_encoding("UTF-8").sub(/\A"(.*)"\Z/, '\1') end end diff --git a/Library/Homebrew/cask/spec/cask/audit_spec.rb b/Library/Homebrew/cask/spec/cask/audit_spec.rb index c5433d0a29..c12063a1d6 100644 --- a/Library/Homebrew/cask/spec/cask/audit_spec.rb +++ b/Library/Homebrew/cask/spec/cask/audit_spec.rb @@ -20,7 +20,7 @@ describe Hbc::Audit do audit.add_error "bad" end - it { is_expected.to match(%r{failed}) } + it { is_expected.to match(/failed/) } end context "when there are warnings" do @@ -28,7 +28,7 @@ describe Hbc::Audit do audit.add_warning "eh" end - it { is_expected.to match(%r{warning}) } + it { is_expected.to match(/warning/) } end context "when there are errors and warnings" do @@ -37,11 +37,11 @@ describe Hbc::Audit do audit.add_warning "eh" end - it { is_expected.to match(%r{failed}) } + it { is_expected.to match(/failed/) } end context "when there are no errors or warnings" do - it { is_expected.to match(%r{passed}) } + it { is_expected.to match(/passed/) } end end @@ -53,7 +53,7 @@ describe Hbc::Audit do %w[version sha256 url name homepage].each do |stanza| context "when missing #{stanza}" do let(:cask_token) { "missing-#{stanza}" } - it { is_expected.to fail_with(%r{#{stanza} stanza is required}) } + it { is_expected.to fail_with(/#{stanza} stanza is required/) } end end end @@ -85,36 +85,36 @@ describe Hbc::Audit do context "when sha256 is sha256 for empty string" do let(:cask_token) { "sha256-for-empty-string" } - it { is_expected.to fail_with(%r{cannot use the sha256 for an empty string}) } + it { is_expected.to fail_with(/cannot use the sha256 for an empty string/) } end end describe "appcast checks" do context "when appcast has no sha256" do let(:cask_token) { "appcast-missing-checkpoint" } - it { is_expected.to fail_with(%r{checkpoint sha256 is required for appcast}) } + it { is_expected.to fail_with(/checkpoint sha256 is required for appcast/) } end context "when appcast checkpoint is not a string of 64 hexadecimal characters" do let(:cask_token) { "appcast-invalid-checkpoint" } - it { is_expected.to fail_with(%r{string must be of 64 hexadecimal characters}) } + it { is_expected.to fail_with(/string must be of 64 hexadecimal characters/) } end context "when appcast checkpoint is sha256 for empty string" do let(:cask_token) { "appcast-checkpoint-sha256-for-empty-string" } - it { is_expected.to fail_with(%r{cannot use the sha256 for an empty string}) } + it { is_expected.to fail_with(/cannot use the sha256 for an empty string/) } end context "when appcast checkpoint is valid sha256" do let(:cask_token) { "appcast-valid-checkpoint" } - it { should_not fail_with(%r{appcast :checkpoint}) } + it { should_not fail_with(/appcast :checkpoint/) } end context "when verifying appcast HTTP code" do let(:cask_token) { "appcast-valid-checkpoint" } let(:download) { instance_double(Hbc::Download) } - let(:wrong_code_msg) { %r{unexpected HTTP response code} } - let(:curl_error_msg) { %r{error retrieving appcast} } + let(:wrong_code_msg) { /unexpected HTTP response code/ } + let(:curl_error_msg) { /error retrieving appcast/ } let(:fake_curl_result) { instance_double(Hbc::SystemCommand::Result) } before do @@ -155,8 +155,8 @@ describe Hbc::Audit do context "when verifying appcast checkpoint" do let(:cask_token) { "appcast-valid-checkpoint" } let(:download) { instance_double(Hbc::Download) } - let(:mismatch_msg) { %r{appcast checkpoint mismatch} } - let(:curl_error_msg) { %r{error retrieving appcast} } + let(:mismatch_msg) { /appcast checkpoint mismatch/ } + let(:curl_error_msg) { /error retrieving appcast/ } let(:fake_curl_result) { instance_double(Hbc::SystemCommand::Result) } let(:expected_checkpoint) { "d5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2" } @@ -203,7 +203,7 @@ describe Hbc::Audit do end describe "preferred download URL formats" do - let(:warning_msg) { %r{URL format incorrect} } + let(:warning_msg) { /URL format incorrect/ } context "with incorrect SourceForge URL format" do let(:cask_token) { "sourceforge-incorrect-url-format" } @@ -234,17 +234,17 @@ describe Hbc::Audit do describe "generic artifact checks" do context "with no target" do let(:cask_token) { "generic-artifact-no-target" } - it { is_expected.to fail_with(%r{target required for generic artifact}) } + it { is_expected.to fail_with(/target required for generic artifact/) } end context "with relative target" do let(:cask_token) { "generic-artifact-relative-target" } - it { is_expected.to fail_with(%r{target must be absolute path for generic artifact}) } + it { is_expected.to fail_with(/target must be absolute path for generic artifact/) } end context "with absolute target" do let(:cask_token) { "generic-artifact-absolute-target" } - it { should_not fail_with(%r{target required for generic artifact}) } + it { should_not fail_with(/target required for generic artifact/) } end end @@ -260,7 +260,7 @@ describe Hbc::Audit do context "when doing the audit" do it "evaluates the block" do - expect(subject).to fail_with(%r{Boom}) + expect(subject).to fail_with(/Boom/) end end end @@ -276,12 +276,12 @@ describe Hbc::Audit do context "when cask token conflicts with a core formula" do let(:formula_names) { %w[with-binary other-formula] } - it { is_expected.to warn_with(%r{possible duplicate}) } + it { is_expected.to warn_with(/possible duplicate/) } end context "when cask token does not conflict with a core formula" do let(:formula_names) { %w[other-formula] } - it { should_not warn_with(%r{possible duplicate}) } + it { should_not warn_with(/possible duplicate/) } end end @@ -298,7 +298,7 @@ describe Hbc::Audit do expect(verify).to receive(:all) end - it { should_not fail_with(%r{#{error_msg}}) } + it { should_not fail_with(/#{error_msg}/) } end context "when download fails" do @@ -306,7 +306,7 @@ describe Hbc::Audit do expect(download).to receive(:perform).and_raise(StandardError.new(error_msg)) end - it { is_expected.to fail_with(%r{#{error_msg}}) } + it { is_expected.to fail_with(/#{error_msg}/) } end context "when verification fails" do @@ -315,7 +315,7 @@ describe Hbc::Audit do expect(verify).to receive(:all).and_raise(StandardError.new(error_msg)) end - it { is_expected.to fail_with(%r{#{error_msg}}) } + it { is_expected.to fail_with(/#{error_msg}/) } end end @@ -325,7 +325,7 @@ describe Hbc::Audit do expect(cask).to receive(:version).and_raise(StandardError.new) end - it { is_expected.to fail_with(%r{exception while auditing}) } + it { is_expected.to fail_with(/exception while auditing/) } end end end diff --git a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb index b452fdb19f..38f8b50ac2 100644 --- a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb @@ -4,7 +4,7 @@ describe Hbc::CLI::Doctor do it "displays some nice info about the environment" do expect { Hbc::CLI::Doctor.run - }.to output(%r{\A==> macOS Release:}).to_stdout + }.to output(/\A==> macOS Release:/).to_stdout end it "raises an exception when arguments are given" do diff --git a/Library/Homebrew/cask/spec/cask/system_command_spec.rb b/Library/Homebrew/cask/spec/cask/system_command_spec.rb index 2af0958532..be70cb5e7e 100644 --- a/Library/Homebrew/cask/spec/cask/system_command_spec.rb +++ b/Library/Homebrew/cask/spec/cask/system_command_spec.rb @@ -84,7 +84,7 @@ describe Hbc::SystemCommand do (1..6).each do |i| expect { described_class.run(command, options) - }.to output(%r{==> #{ i }}).to_stdout + }.to output(/==> #{ i }/).to_stdout end end diff --git a/Library/Homebrew/cask/test/cask/artifact/app_test.rb b/Library/Homebrew/cask/test/cask/artifact/app_test.rb index 648146f9ab..acd5b2b633 100644 --- a/Library/Homebrew/cask/test/cask/artifact/app_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/app_test.rb @@ -243,7 +243,7 @@ describe Hbc::Artifact::App do describe "app is missing" do it "returns a warning and the supposed path to the app" do contents.size.must_equal 1 - contents[0].must_match(%r{.*Missing App.*: #{target_path}}) + contents[0].must_match(/.*Missing App.*: #{target_path}/) end end end diff --git a/Library/Homebrew/cask/test/cask/cli/install_test.rb b/Library/Homebrew/cask/test/cask/cli/install_test.rb index 57d7e0d7ee..c778d0d3c5 100644 --- a/Library/Homebrew/cask/test/cask/cli/install_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/install_test.rb @@ -29,7 +29,7 @@ describe Hbc::CLI::Install do lambda { Hbc::CLI::Install.run("local-transmission", "") - }.must_output nil, %r{Warning: A Cask for local-transmission is already installed.} + }.must_output nil, /Warning: A Cask for local-transmission is already installed./ end it "allows double install with --force" do @@ -39,7 +39,7 @@ describe Hbc::CLI::Install do lambda { Hbc::CLI::Install.run("local-transmission", "--force") - }.must_output %r{==> Success! local-transmission was successfully installed!} + }.must_output(/==> Success! local-transmission was successfully installed!/) end it "skips dependencies with --skip-cask-deps" do @@ -64,7 +64,7 @@ describe Hbc::CLI::Install do begin Hbc::CLI::Install.run("googlechrome") rescue Hbc::CaskError; end - }.must_output nil, %r{No available Cask for googlechrome\. Did you mean:\ngoogle-chrome} + }.must_output nil, /No available Cask for googlechrome\. Did you mean:\ngoogle-chrome/ end it "returns multiple suggestions for a Cask fragment" do @@ -72,7 +72,7 @@ describe Hbc::CLI::Install do begin Hbc::CLI::Install.run("google") rescue Hbc::CaskError; end - }.must_output nil, %r{No available Cask for google\. Did you mean one of:\ngoogle} + }.must_output nil, /No available Cask for google\. Did you mean one of:\ngoogle/ end describe "when no Cask is specified" do diff --git a/Library/Homebrew/cask/test/cask/cli/search_test.rb b/Library/Homebrew/cask/test/cask/cli/search_test.rb index 4b15d8eab8..6eb6badb96 100644 --- a/Library/Homebrew/cask/test/cask/cli/search_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/search_test.rb @@ -19,25 +19,25 @@ describe Hbc::CLI::Search do it "lists all available Casks with no search term" do out = capture_io { Hbc::CLI::Search.run }[0] - out.must_match(%r{google-chrome}) + out.must_match(/google-chrome/) out.length.must_be :>, 1000 end it "ignores hyphens in search terms" do out = capture_io { Hbc::CLI::Search.run("goo-gle-chrome") }[0] - out.must_match(%r{google-chrome}) + out.must_match(/google-chrome/) out.length.must_be :<, 100 end it "ignores hyphens in Cask tokens" do out = capture_io { Hbc::CLI::Search.run("googlechrome") }[0] - out.must_match(%r{google-chrome}) + out.must_match(/google-chrome/) out.length.must_be :<, 100 end it "accepts multiple arguments" do out = capture_io { Hbc::CLI::Search.run("google chrome") }[0] - out.must_match(%r{google-chrome}) + out.must_match(/google-chrome/) out.length.must_be :<, 100 end @@ -49,11 +49,11 @@ describe Hbc::CLI::Search do it "Returns both exact and partial matches" do out = capture_io { Hbc::CLI::Search.run("mnemosyne") }[0] - out.must_match(%r{^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne}) + out.must_match(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/) end it "does not search the Tap name" do out = capture_io { Hbc::CLI::Search.run("caskroom") }[0] - out.must_match(%r{^No Cask found for "caskroom"\.\n}) + out.must_match(/^No Cask found for "caskroom"\.\n/) end end diff --git a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb b/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb index 6e0ea773bc..0368ad87ce 100644 --- a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb @@ -93,7 +93,7 @@ describe Hbc::CLI::Uninstall do Hbc::CLI::Uninstall.run("versioned-cask") end - out.must_match(%r{#{token} #{first_installed_version} is still installed.}) + out.must_match(/#{token} #{first_installed_version} is still installed./) err.must_be :empty? end end diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb index 4b3f88b1fc..d062875fac 100644 --- a/Library/Homebrew/cask/test/cask/dsl_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl_test.rb @@ -250,7 +250,7 @@ describe Hbc::DSL do describe "appcast stanza" do it "allows appcasts to be specified" do cask = Hbc.load("with-appcast") - cask.appcast.to_s.must_match %r{^http} + cask.appcast.to_s.must_match(/^http/) end it "prevents defining multiple appcasts" do @@ -270,12 +270,12 @@ describe Hbc::DSL do describe "gpg stanza" do it "allows gpg stanza to be specified" do cask = Hbc.load("with-gpg") - cask.gpg.to_s.must_match %r{\S} + cask.gpg.to_s.must_match(/\S/) end it "allows gpg stanza to be specified with :key_url" do cask = Hbc.load("with-gpg-key-url") - cask.gpg.to_s.must_match %r{\S} + cask.gpg.to_s.must_match(/\S/) end it "prevents specifying gpg stanza multiple times" do diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb index 9253f40e76..f64ed8c176 100644 --- a/Library/Homebrew/cask/test/cask/installer_test.rb +++ b/Library/Homebrew/cask/test/cask/installer_test.rb @@ -239,7 +239,7 @@ describe Hbc::Installer do with_caveats = Hbc.load("with-caveats") lambda { Hbc::Installer.new(with_caveats).install - }.must_output %r{Here are some things you might want to know} + }.must_output(/Here are some things you might want to know/) with_caveats.must_be :installed? end @@ -247,7 +247,7 @@ describe Hbc::Installer do with_installer_manual = Hbc.load("with-installer-manual") lambda { Hbc::Installer.new(with_installer_manual).install - }.must_output %r{To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'} + }.must_output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/) with_installer_manual.must_be :installed? end