diff options
| author | Markus Reiter | 2016-10-14 20:03:34 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-10-23 14:32:03 +0200 |
| commit | 1a0f8b8a02cfe8795e2128fb294e97bb67fb03f0 (patch) | |
| tree | d877104219e739733aacf73bd6f040f48bb2ff66 /Library/Homebrew/cask/lib/hbc/cli | |
| parent | 40b7e36746f679c41f97e627f2af0e898963925b (diff) | |
| download | brew-1a0f8b8a02cfe8795e2128fb294e97bb67fb03f0.tar.bz2 | |
Use slash-delimited regular expressions.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/base.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/cat.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/create.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/edit.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/internal_use_base.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/search.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/style.rb | 2 |
9 files changed, 17 insertions, 17 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/base.rb b/Library/Homebrew/cask/lib/hbc/cli/base.rb index 6c706d537..e218a47dd 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 75f6c1e91..464e23a5e 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 84537cdc1..3e2b9c191 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 e36999200..873ca47fd 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 3090cf196..a6ff34234 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 47258a7b2..feb5a830a 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 96b6eeaa8..b1f9c5631 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 147e6d194..8e8f8fd75 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 0dd4bc474..fcb59230e 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 |
